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.

182 lines
4.9 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. #define NOCLIPBOARD
  5. #define NOGDICAPMASKS
  6. #define NOCTLMGR
  7. #define NOVIRTUALKEYCODES
  8. #define NOWINMESSAGES
  9. #define NOWINSTYLES
  10. #define NOSYSMETRICS
  11. #define NOMENUS
  12. #define NOKEYSTATE
  13. #define NOGDI
  14. #define NORASTEROPS
  15. #define NOSYSCOMMANDS
  16. #define NOSHOWWINDOW
  17. #define NOCOLOR
  18. #define NOATOM
  19. #define NOBITMAP
  20. #define NOICON
  21. #define NOBRUSH
  22. #define NOCREATESTRUCT
  23. #define NOMB
  24. #define NOFONT
  25. #define NOMSG
  26. #define NOOPENFILE
  27. #define NOPEN
  28. #define NOPOINT
  29. #define NOREGION
  30. #define NOSCROLL
  31. #define NOSOUND
  32. #define NOWH
  33. #define NOWINOFFSETS
  34. #define NOWNDCLASS
  35. #define NOCOMM
  36. #include <windows.h>
  37. /*#include "toolbox.h"*/
  38. #include "mw.h"
  39. #include "cmddefs.h"
  40. #include "dispdefs.h"
  41. #include "wwdefs.h"
  42. #include "docdefs.h"
  43. #include "editdefs.h"
  44. #include "filedefs.h"
  45. #include "str.h"
  46. #include "propdefs.h"
  47. #include "fkpdefs.h"
  48. #include "printdef.h" /* printdefs.h */
  49. #include "debug.h"
  50. extern int docMode;
  51. extern struct FCB (**hpfnfcb)[];
  52. int **HAllocate();
  53. #ifdef CASHMERE /* Only if we support multiple sections */
  54. AddSects(docDest, cpDest, docSrc, cpFirst, cpLim, hsetbSrc)
  55. int docDest, docSrc;
  56. typeCP cpDest, cpFirst, cpLim;
  57. struct SETB **hsetbSrc;
  58. { /* Add SED's to correspond with inserted section marks */
  59. /* Called after inserting docSrc[cpFirst:cpLim) into docDest@cpDest */
  60. struct SETB *psetbSrc, **hsetbDest, *psetbDest;
  61. struct SED *psedSrc, *psedDest;
  62. int csedDest, isedSrc, csedIns, isedDest;
  63. psedSrc = &(psetbSrc = *hsetbSrc)->rgsed[0];
  64. psedSrc += (isedSrc = IcpSearch(cpFirst + 1, psedSrc,
  65. cchSED, bcpSED, psetbSrc->csed));
  66. /* Find all section marks in inserted area. */
  67. for (csedIns = 0; psedSrc->cp <= cpLim; psedSrc++, csedIns++)
  68. ;
  69. if (csedIns != 0)
  70. { /* Insert sed's. */
  71. /* Ensure destination setb large enough */
  72. /* HEAP MOVEMENT */
  73. if (FNoHeap(hsetbDest = HsetbEnsure(docDest, csedIns)))
  74. return;
  75. psedDest = &(psetbDest = *hsetbDest)->rgsed[0];
  76. /* Find ised to insert new sed's */
  77. psedDest += (isedDest = IcpSearch(cpDest + 1, psedDest,
  78. cchSED, bcpSED, csedDest = psetbDest->csed));
  79. /* Insert new sed's */
  80. psedSrc = &(psetbSrc = *hsetbSrc)->rgsed[isedSrc];
  81. psetbDest->csed += csedIns; /* Update sed count */
  82. blt(psedDest, psedDest + csedIns,
  83. cwSED * (csedDest - isedDest)); /* Open up setb */
  84. blt(psedSrc, psedDest, cwSED * csedIns);
  85. while (csedIns--)
  86. (psedDest++)->cp = cpDest + (psedSrc++)->cp - cpFirst;
  87. }
  88. } /* end of A d d S e c t s */
  89. #endif /* CASHMERE */
  90. #ifdef CASHMERE /* Only if we support separate sections */
  91. RemoveDelSeds(doc, cpFirst, cpLim, hsetb)
  92. int doc;
  93. typeCP cpFirst, cpLim;
  94. struct SETB **hsetb;
  95. {
  96. struct SETB *psetb;
  97. struct SED *psed, *psedT;
  98. int ised, csed, csedDel;
  99. {
  100. psetb = *hsetb;
  101. psed = &psetb->rgsed[0];
  102. psed += (ised =
  103. IcpSearch(cpFirst + 1, psed, cchSED, bcpSED, csed = psetb->csed));
  104. /* Find all section marks in deleted area. */
  105. for (psedT = psed, csedDel = 0; psedT->cp <= cpLim; psedT++, csedDel++)
  106. ;
  107. Assert(ised + csedDel < csed);
  108. if (csedDel != 0)
  109. { /* Close up setb. */
  110. blt(psedT, psed, cwSED * ((csed -= csedDel) - ised));
  111. (*hsetb)->csed = csed;
  112. docMode = docNil;
  113. }
  114. }
  115. } /* end of R e m o v e D e l S e d s */
  116. #endif /* CASHMERE */
  117. #ifdef CASHMERE /* This loads a complete section table */
  118. struct SETB **HsetbCreate(fn)
  119. int fn;
  120. { /* Create a section table from a formatted file */
  121. struct SETB *psetbFile;
  122. typePN pn;
  123. int cchT;
  124. int csed, ised;
  125. struct SETB **hsetb;
  126. int *pwSetb;
  127. int cw;
  128. struct SED *psed;
  129. Assert(fn != fnNil && (**hpfnfcb)[fn].fFormatted);
  130. if ((pn = (**hpfnfcb)[fn].pnSetb) == (**hpfnfcb)[fn].pnBftb)
  131. return (struct SETB **) 0;
  132. psetbFile = (struct SETB *) PchGetPn(fn, pn, &cchT, false);
  133. if ((csed = psetbFile->csed) == 0)
  134. return (struct SETB **)0;
  135. hsetb = (struct SETB **) HAllocate(cw = cwSETBBase + csed * cwSED);
  136. if (FNoHeap(hsetb))
  137. return (struct SETB **)hOverflow;
  138. pwSetb = (int *) *hsetb;
  139. blt(psetbFile, pwSetb, min(cwSector, cw));
  140. while ((cw -= cwSector) > 0)
  141. { /* Copy the sed's to heap */
  142. blt(PchGetPn(fn, ++pn, &cchT, false), pwSetb += cwSector,
  143. min(cwSector, cw));
  144. }
  145. for (ised = 0, psed = &(**hsetb).rgsed[0]; ised < csed; ised++, psed++)
  146. psed->fn = fn;
  147. (**hsetb).csedMax = csed;
  148. return hsetb;
  149. } /* end of H s e t b C r e a t e */
  150. #endif /* CASHMERE */
  151.