Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.6 KiB

  1. /*************************************************************************
  2. **
  3. ** OLE 2 Sample Code
  4. **
  5. ** outlname.c
  6. **
  7. ** This file contains OutlineName functions.
  8. **
  9. ** (c) Copyright Microsoft Corp. 1992 - 1993 All Rights Reserved
  10. **
  11. *************************************************************************/
  12. #include "outline.h"
  13. OLEDBGDATA
  14. /* OutlineName_SetName
  15. * -------------------
  16. *
  17. * Change the string of a name.
  18. */
  19. void OutlineName_SetName(LPOUTLINENAME lpOutlineName, LPSTR lpszName)
  20. {
  21. lstrcpy(lpOutlineName->m_szName, lpszName);
  22. }
  23. /* OutlineName_SetSel
  24. * ------------------
  25. *
  26. * Change the line range of a name.
  27. */
  28. void OutlineName_SetSel(LPOUTLINENAME lpOutlineName, LPLINERANGE lplrSel, BOOL fRangeModified)
  29. {
  30. #if defined( OLE_SERVER )
  31. // Call OLE server specific function instead
  32. ServerName_SetSel((LPSERVERNAME)lpOutlineName, lplrSel, fRangeModified);
  33. #else
  34. lpOutlineName->m_nStartLine = lplrSel->m_nStartLine;
  35. lpOutlineName->m_nEndLine = lplrSel->m_nEndLine;
  36. #endif
  37. }
  38. /* OutlineName_GetSel
  39. * ------------------
  40. *
  41. * Retrieve the line range of a name.
  42. */
  43. void OutlineName_GetSel(LPOUTLINENAME lpOutlineName, LPLINERANGE lplrSel)
  44. {
  45. lplrSel->m_nStartLine = lpOutlineName->m_nStartLine;
  46. lplrSel->m_nEndLine = lpOutlineName->m_nEndLine;
  47. }
  48. /* OutlineName_SaveToStg
  49. * ---------------------
  50. *
  51. * Save a name into a storage
  52. */
  53. BOOL OutlineName_SaveToStg(LPOUTLINENAME lpOutlineName, LPLINERANGE lplrSel, UINT uFormat, LPSTREAM lpNTStm, BOOL FAR* lpfNameSaved)
  54. {
  55. HRESULT hrErr = NOERROR;
  56. ULONG nWritten;
  57. *lpfNameSaved = FALSE;
  58. /* if no range given or if the name is completely within the range,
  59. ** write it out.
  60. */
  61. if (!lplrSel ||
  62. ((lplrSel->m_nStartLine <= lpOutlineName->m_nStartLine) &&
  63. (lplrSel->m_nEndLine >= lpOutlineName->m_nEndLine))) {
  64. hrErr = lpNTStm->lpVtbl->Write(
  65. lpNTStm,
  66. lpOutlineName,
  67. sizeof(OUTLINENAME),
  68. &nWritten
  69. );
  70. *lpfNameSaved = TRUE;
  71. }
  72. return ((hrErr == NOERROR) ? TRUE : FALSE);
  73. }
  74. /* OutlineName_LoadFromStg
  75. * -----------------------
  76. *
  77. * Load names from an open stream of a storage. if the name already
  78. * exits in the OutlineNameTable, it is NOT modified.
  79. *
  80. * Returns TRUE is all ok, else FALSE.
  81. */
  82. BOOL OutlineName_LoadFromStg(LPOUTLINENAME lpOutlineName, LPSTREAM lpNTStm)
  83. {
  84. HRESULT hrErr = NOERROR;
  85. ULONG nRead;
  86. hrErr = lpNTStm->lpVtbl->Read(
  87. lpNTStm,
  88. lpOutlineName,
  89. sizeof(OUTLINENAME),
  90. &nRead
  91. );
  92. return ((hrErr == NOERROR) ? TRUE : FALSE);
  93. }