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.

285 lines
11 KiB

  1. #ifndef CHNUTILS_DEFINED
  2. #define CHNUTILS_DEFINED
  3. /* Chunk & group chunk utilities */
  4. #include "lsidefs.h"
  5. #include "plsdnode.h"
  6. #include "lsgrchnk.h"
  7. #include "plocchnk.h"
  8. #include "pposichn.h"
  9. #include "dninfo.h"
  10. #include "plschcon.h"
  11. #include "lstflow.h"
  12. #include "lschcon.h"
  13. #include "lscbk.h"
  14. #include "port.h"
  15. #include "posichnk.h"
  16. /* MACROS -----------------------------------------------------------------*/
  17. #define FlushSublineChunkContext(plschnkcontext) \
  18. (plschnkcontext)->FLocationValid = fFalse;\
  19. (plschnkcontext)->FChunkValid = fFalse;\
  20. (plschnkcontext)->FGroupChunk = fFalse;\
  21. (plschnkcontext)->FBorderInside = fFalse;\
  22. (plschnkcontext)->grpfTnti = 0;\
  23. (plschnkcontext)->fNTIAppliedToLastChunk = fFalse;\
  24. (plschnkcontext)->locchnkCurrent.clschnk = 0;\
  25. #define InitSublineChunkContext(plschnkcontext, urFirst, vrFirst) \
  26. FlushSublineChunkContext(plschnkcontext); \
  27. (plschnkcontext)->urFirstChunk = (urFirst); \
  28. (plschnkcontext)->vrFirstChunk = (vrFirst);
  29. #define IdObjFromChnk(plocchnk) (Assert((plocchnk)->clschnk > 0), \
  30. ((plocchnk)->plschnk[0].plschp->idObj))
  31. #define InvalidateChunk(plschnkcontext) \
  32. (plschnkcontext)->FChunkValid = fFalse;
  33. #define InvalidateChunkLocation(plschnkcontext) \
  34. (plschnkcontext)->FLocationValid = fFalse;
  35. #define SetNTIAppliedToLastChunk(plschnkcontext) \
  36. (plschnkcontext)->fNTIAppliedToLastChunk = fTrue;
  37. #define FlushNTIAppliedToLastChunk(plschnkcontext) \
  38. (plschnkcontext)->fNTIAppliedToLastChunk = fFalse;
  39. #define FNTIAppliedToLastChunk(plschnkcontext) \
  40. (plschnkcontext)->fNTIAppliedToLastChunk
  41. #define FIsChunkBoundary(plsdn, idObjChnk, cpBase) \
  42. (((plsdn) == NULL) || \
  43. (FIsDnodeBorder(plsdn) ? fFalse : \
  44. ((FIsDnodePen(plsdn)) \
  45. || ((plsdn)->fTab) \
  46. || ((idObjChnk) != IdObjFromDnode(plsdn)) \
  47. || (((cpBase) >= 0) ? ((plsdn)->cpFirst < 0) : ((plsdn)->cpFirst >= 0)))))
  48. /* last check verifies that we are not crossing boundaries of autonumber */
  49. #define SetUrColumnMaxForChunks(plschnkcontext, Ur) \
  50. (plschnkcontext)->locchnkCurrent.lsfgi.urColumnMax = Ur;
  51. #define GetUrColumnMaxForChunks(plschnkcontext) \
  52. (plschnkcontext)->locchnkCurrent.lsfgi.urColumnMax
  53. #define GetChunkArray(plschnkcontext) (plschnkcontext)->locchnkCurrent.plschnk
  54. #define GetChunkSize(plschnkcontext) (plschnkcontext)->locchnkCurrent.clschnk
  55. #define FlushNominalToIdealState(plschnkcontext) \
  56. (plschnkcontext)->grpfTnti = 0;
  57. #define SetNominalToIdealFlags(plschnkcontext, plschp) \
  58. AddNominalToIdealFlags(((plschnkcontext)->grpfTnti), plschp);
  59. #define DnodeFromChunk(plschunkcontext, ichnk) \
  60. (Assert(((DWORD) ichnk) < (plschunkcontext)->locchnkCurrent.clschnk), \
  61. (plschunkcontext)->pplsdnChunk[ichnk])
  62. #define LastDnodeFromChunk(plschunkcontext) \
  63. DnodeFromChunk(plschunkcontext, (plschunkcontext)->locchnkCurrent.clschnk - 1)
  64. /* L O C D N O D E F R O M C H U N K */
  65. /*----------------------------------------------------------------------------
  66. %%Function: LocDnodeFromChunk
  67. %%Contact: igorzv
  68. Parameters:
  69. plschuncontext - (IN) LineServices context
  70. ichnk - (IN) index in chunk
  71. pplsdn - (OUT) dnode to fill in
  72. ppoint (OUT) position of dnode
  73. ----------------------------------------------------------------------------*/
  74. #define LocDnodeFromChunk(plschunkcontext, ichnk, pplsdn, ppoint) \
  75. Assert((DWORD)(ichnk) < (plschunkcontext)->locchnkCurrent.clschnk); \
  76. Assert((ichnk) != ichnkOutside); \
  77. (ppoint)->u = (plschunkcontext)->locchnkCurrent.ppointUvLoc[ichnk].u; \
  78. (ppoint)->v = (plschunkcontext)->locchnkCurrent.ppointUvLoc[ichnk].v; \
  79. *(pplsdn) = (plschunkcontext)->pplsdnChunk[ichnk];
  80. #define ApplyFFirstSublineToChunk(plschunkcontext, fFirstSubline) \
  81. (plschunkcontext)->locchnkCurrent.lsfgi.fFirstOnLine = \
  82. FIsFirstOnLine(plschunkcontext->pplsdnChunk[0]) \
  83. && fFirstSubline ;
  84. #define GetFFirstOnLineChunk(plocchnk) \
  85. (plocchnk)->lsfgi.fFirstOnLine
  86. #define NumberOfDnodesInChunk(plocchnk) \
  87. (plocchnk)->clschnk
  88. #define GetPointChunkStart(plocchnk, point) \
  89. point.u = plocchnk->lsfgi.urPen; \
  90. point.v = plocchnk->lsfgi.vrPen;
  91. #define PosInChunkAfterChunk(plocchnk, posichnk) \
  92. posichnk.ichnk = plocchnk->clschnk - 1; \
  93. posichnk.dcp = plocchnk->plschnk[plocchnk->clschnk - 1].dcp;
  94. /* ROUTINES ----------------------------------------------------------------------*/
  95. LSERR FillChunkArray(PLSCHUNKCONTEXT plschunkcontext , /* IN: LS chunk context */
  96. PLSDNODE plsdn); /* IN: last dnode in a chunk */
  97. LSERR CollectChunkAround(PLSCHUNKCONTEXT plschnukcontext, /* IN: LS chunk context */
  98. PLSDNODE plsdn, /* IN: dnode to collect chunk arround */
  99. LSTFLOW lstflow, /* IN: text flow */
  100. POINTUV* ppoint); /* IN: position of dnode */
  101. LSERR CollectPreviousChunk(PLSCHUNKCONTEXT plschunkcontext,/* IN: LS chunk context */
  102. BOOL* pfSuccessful); /* fSuccessful does previous chunk exist */
  103. LSERR CollectNextChunk(PLSCHUNKCONTEXT plschunkcontext, /* IN: LS chunk context */
  104. BOOL* pfSuccessful); /* fSuccessful does next chunk exist */
  105. LSERR GetUrPenAtBeginingOfLastChunk(PLSCHUNKCONTEXT plschunkcontext, /* IN: LS chunk context */
  106. PLSDNODE plsdnFirst, /* IN: First dnode in a chunk (used for checks */
  107. PLSDNODE plsdnLast, /* IN: last dnode in a chunk */
  108. POINTUV* ppoint, /* IN: point after lst dnode */
  109. long* purPen); /* OUT: ur before chunk */
  110. void SetPosInChunk(PLSCHUNKCONTEXT plschunkcontext, /* IN: LS chunk context */
  111. PLSDNODE plsdn, /* IN: position to convert to position in a current chunk */
  112. LSDCP dcp, /* IN: dcp in the dnode */
  113. PPOSICHNK pposinchnk); /* OUT: position in a current chunk */
  114. enum CollectSublines
  115. {
  116. CollectSublinesNone,
  117. CollectSublinesForJustification,
  118. CollectSublinesForCompression,
  119. CollectSublinesForDisplay,
  120. CollectSublinesForDecimalTab,
  121. CollectSublinesForTrailingArea,
  122. };
  123. typedef enum CollectSublines COLLECTSUBLINES;
  124. typedef struct grchunkext
  125. {
  126. PLSCHUNKCONTEXT plschunkcontext;/* Chunk context */
  127. DWORD iobjText; /* idobj of text */
  128. enum COLLECTSUBLINES Purpose; /* for what purpose we are collecting group chunk */
  129. LSGRCHNK lsgrchnk; /* group chunk */
  130. PLSDNODE plsdnFirst; /* group chunk was collected between plsdnFirst */
  131. PLSDNODE plsdnNext; /* and plsdnNext */
  132. /*(both plsdnFirst and plsdnNext are in a main subline)*/
  133. PLSDNODE plsdnLastUsed; /* last dnode that participates in calculation of above fields*/
  134. /* can be on the second level */
  135. long durTotal; /* durTotal of all dnodes between First and Last */
  136. long durTextTotal; /* durTextTotal of all text dnodes between First and Last */
  137. long dupNonTextTotal; /* dupNonTextTotal of all non text dnodes between First and Last (including pens) */
  138. DWORD cNonTextObjects; /* number of non text objects (excliding pens) */
  139. PLSDNODE* pplsdnNonText; /* array of non text objects */
  140. BOOL* pfNonTextExpandAfter; /* array of flags for non text objects */
  141. DWORD cNonTextObjectsExpand; /* number of non text objects that can be expanded */
  142. /* fields below are valid only for group chunk collected for compression or justification */
  143. POSICHNK posichnkBeforeTrailing;/* information about last text cp before trailing area */
  144. PLSDNODE plsdnStartTrailing; /* dnode where trailing area starts */
  145. long durTrailing; /* dur of trailing area in group chunk */
  146. LSDCP dcpTrailing; /* amount of characters in trailing are */
  147. BOOL fClosingBorderStartsTrailing;/* closing border located just before trailing area */
  148. } GRCHUNKEXT;
  149. #define FFirstOnLineGroupChunk(pgrchunkext, plsc) \
  150. (Assert(FIsLSDNODE((pgrchunkext)->plsdnFirst)), \
  151. ((pgrchunkext)->plsdnFirst->plsdnPrev == NULL && \
  152. (IdObjFromDnode((pgrchunkext)->plsdnFirst) == IobjTextFromLsc(&(plsc)->lsiobjcontext))))
  153. void InitGroupChunkExt(PLSCHUNKCONTEXT plschnkcontext, /* Chunk context */
  154. DWORD iobjText, /* text iobj */
  155. GRCHUNKEXT* pgrchunkext); /* OUT: structure to initialize */
  156. LSERR CollectTextGroupChunk(
  157. PLSDNODE plsdnFirst, /* IN: First Dnode */
  158. LSCP cpLim, /* IN: cpLim(boundary) for collecting,
  159. group chunk can stop before this boundary but can't go beyond */
  160. COLLECTSUBLINES Purpose, /* IN: what sublines to take from complex object */
  161. GRCHUNKEXT* pgrchunkext); /* OUT: extended group chunk */
  162. LSERR CollectPreviousTextGroupChunk(
  163. PLSDNODE plsdnEnd, /* IN: last dnode of a chunk */
  164. COLLECTSUBLINES Purpose, /* IN: what sublines to take from complex object */
  165. BOOL fAllSimpleText, /* IN: we have only simple text in this line */
  166. GRCHUNKEXT* pgrchunkext); /* OUT: extended group chunk */
  167. /* G E T T R A I L I N G I N F O F O R T E X T G R O U P C H U N K */
  168. /*----------------------------------------------------------------------------
  169. %%Function: GetTrailingInfoForTextGroupChunk
  170. %%Contact: igorzv
  171. Parameters:
  172. plsdnLastDnode - (IN) dnode where to start calculation of trailing area
  173. dcpLastDnode (IN) dcp in this dnode
  174. iobjText - (IN) iobj of text
  175. pdurTrailing - (OUT) dur of trailing area in group chunk
  176. pdcpTrailing - (OUT) dcp of trailing area in chunk
  177. pplsdnStartTrailingText - (OUT) dnode where trailing area starts
  178. pdcpStartTrailingText- (OUT) with pcDnodesTrailing defines last character in text before
  179. trailing area, doesn't valid if pcDnodesTrailing == 0
  180. pcDnodesTrailing - (OUT) number of dnodes in trailing area
  181. pplsdnStartTrailingObject -(OUT) dnode on the upper level where trailing are starts
  182. pdcpStartTrailingText -(OUT) dcp in such dnode
  183. pfClosingBorderStartsTrailing - (OUT) closing border located just before trailing area
  184. ----------------------------------------------------------------------------*/
  185. LSERR GetTrailingInfoForTextGroupChunk
  186. (PLSDNODE plsdnLast, LSDCP dcpLastDnode, DWORD iobjText,
  187. long* pdurTrailing, LSDCP* pdcpTrailing,
  188. PLSDNODE* pplsdnStartTrailingText, LSDCP* pdcpStartTrailingText,
  189. int* pcDnodesTrailing, PLSDNODE* pplsdnStartTrailingObject,
  190. LSDCP* pdcpStartTrailingObject, BOOL* pfClosingBorderStartsTrailing);
  191. LSERR AllocChunkArrays(PLSCHUNKCONTEXT plschunkcontext, LSCBK* plscbk, POLS pols,
  192. PLSIOBJCONTEXT plsiobjcontext);
  193. void DisposeChunkArrays(PLSCHUNKCONTEXT plschunkcontext);
  194. LSERR DuplicateChunkContext(PLSCHUNKCONTEXT plschunkcontextOld,
  195. PLSCHUNKCONTEXT* pplschunkcontextNew);
  196. void DestroyChunkContext(PLSCHUNKCONTEXT plschunkcontext);
  197. void FindPointOffset(
  198. PLSDNODE plsdnFirst, /* IN: dnode from the boundaries of which
  199. to calculate offset */
  200. enum lsdevice lsdev, /* IN: presentation or reference device */
  201. LSTFLOW lstflow, /* IN: text flow to use for calculation */
  202. COLLECTSUBLINES Purpose, /* IN: what sublines to take from a complex object */
  203. PLSDNODE plsdnContainsPoint, /* IN: dnode contains point */
  204. long duInDnode, /* IN: offset in the dnode */
  205. long* pduOffset); /* OUT: offset from the starting point */
  206. #endif /* CHNUTILS_DEFINED */