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.

354 lines
10 KiB

  1. #include "lsidefs.h"
  2. #include "lsmem.h"
  3. #include "limits.h"
  4. #include "objhelp.h"
  5. #include "lscrsubl.h"
  6. #include "lssubset.h"
  7. #include "lsdnset.h"
  8. #include "lstfset.h"
  9. #include "lsdocinf.h"
  10. #include "fmti.h"
  11. #include "lsqout.h"
  12. #include "lsqin.h"
  13. #include "mwcls.h"
  14. #include "brkkind.h"
  15. #include "brko.h"
  16. /* G E T B R E A K R E C O R D I N D E X */
  17. /*----------------------------------------------------------------------------
  18. %%Function: GetBreakRecordIndex
  19. %%Contact: antons
  20. Index of the break record from brkkind. Assert if
  21. brrkkind = brkkindImposedAfter.
  22. ----------------------------------------------------------------------------*/
  23. DWORD GetBreakRecordIndex (BRKKIND brkkind)
  24. {
  25. DWORD result = 0;
  26. Assert (brkkind != brkkindImposedAfter);
  27. Assert (NBreaksToSave == 3);
  28. switch (brkkind)
  29. {
  30. case brkkindPrev: result = 0; break;
  31. case brkkindNext: result = 1; break;
  32. case brkkindForce: result = 2; break;
  33. case brkkindImposedAfter: break;
  34. default: AssertSz (FALSE, "Unknown brkkind");
  35. };
  36. Assert (result < NBreaksToSave);
  37. return result;
  38. }
  39. /* F O R M A T L I N E */
  40. /*----------------------------------------------------------------------------
  41. %%Function: FormatLine
  42. %%Contact: antons
  43. Formats a line of text with the given escape characters ignoring
  44. all tabs, eops, etc.
  45. ----------------------------------------------------------------------------*/
  46. LSERR FormatLine(
  47. PLSC plsc,
  48. LSCP cpStart,
  49. long durColMax,
  50. LSTFLOW lstflow,
  51. PLSSUBL *pplssubl,
  52. DWORD cdwlsesc,
  53. const LSESC *plsesc,
  54. OBJDIM *pobjdim,
  55. LSCP *pcpOut,
  56. PLSDNODE *pplsdnStart,
  57. PLSDNODE *pplsdnEnd,
  58. FMTRES *pfmtres)
  59. {
  60. return FormatResumedLine ( plsc,
  61. cpStart,
  62. durColMax,
  63. lstflow,
  64. pplssubl,
  65. cdwlsesc,
  66. plsesc,
  67. pobjdim,
  68. pcpOut,
  69. pplsdnStart,
  70. pplsdnEnd,
  71. pfmtres,
  72. NULL, /* Array of break records */
  73. 0 ); /* Number of break record */
  74. }
  75. /* F O R M A T R E S U M E D L I N E */
  76. /*----------------------------------------------------------------------------
  77. %%Function: FormatResumedLine
  78. %%Contact: ricksa
  79. Formats a line that contains broken objects at its beginning.
  80. ----------------------------------------------------------------------------*/
  81. LSERR FormatResumedLine(
  82. PLSC plsc,
  83. LSCP cpStart,
  84. long durColMax,
  85. LSTFLOW lstflow,
  86. PLSSUBL *pplssubl,
  87. DWORD cdwlsesc,
  88. const LSESC *plsesc,
  89. POBJDIM pobjdim,
  90. LSCP *pcpOut,
  91. PLSDNODE *pplsdnStart,
  92. PLSDNODE *pplsdnEnd,
  93. FMTRES *pfmtres,
  94. const BREAKREC *pbreakrec,
  95. DWORD cbreakrec)
  96. {
  97. LSERR lserr;
  98. PLSDNODE plsdnStart;
  99. PLSDNODE plsdnEnd;
  100. LSCP cpOut;
  101. FMTRES fmtres;
  102. PLSSUBL plssubl = NULL;
  103. BOOL fSuccessful = FALSE;
  104. LSTFLOW lstflowUnused;
  105. *pplssubl = NULL; /* In case of lserr */
  106. while (! fSuccessful)
  107. {
  108. lserr = LsCreateSubline(plsc, cpStart, durColMax, lstflow, FALSE);
  109. if (lserr != lserrNone) return lserr;
  110. lserr = LsFetchAppendToCurrentSublineResume(plsc, pbreakrec, cbreakrec,
  111. 0, plsesc, cdwlsesc, &fSuccessful, &fmtres, &cpOut, &plsdnStart, &plsdnEnd);
  112. if (lserr != lserrNone) return lserr;
  113. /* REVIEW (antons): fmtrStopped is not handled */
  114. Assert (fmtres == fmtrCompletedRun || fmtres == fmtrExceededMargin || fmtres == fmtrTab);
  115. if (pplsdnStart != NULL) *pplsdnStart = plsdnStart;
  116. while (fSuccessful && (fmtres == fmtrTab))
  117. {
  118. /* Format as much as we can - note we move max to maximum postive value. */
  119. lserr = LsFetchAppendToCurrentSubline(plsc, 0, plsesc, cdwlsesc,
  120. &fSuccessful, &fmtres, &cpOut, &plsdnStart, &plsdnEnd);
  121. if (lserr != lserrNone) return lserr;
  122. /* REVIEW (antons): fmtrStopped is not handled */
  123. Assert (fmtres == fmtrCompletedRun || fmtres == fmtrExceededMargin || fmtres == fmtrTab);
  124. }
  125. if (! fSuccessful)
  126. {
  127. /* FetchAppend UnSuccessful => Finish and Destroy subline, then repeat */
  128. lserr = LsFinishCurrentSubline(plsc, &plssubl);
  129. if (lserr != lserrNone) return lserr;
  130. lserr = LsDestroySubline(plssubl);
  131. if (lserr != lserrNone) return lserr;
  132. }
  133. else
  134. {
  135. if (pplsdnEnd != NULL) *pplsdnEnd = plsdnEnd;
  136. *pcpOut = cpOut;
  137. *pfmtres = fmtres;
  138. };
  139. }; /* while (! fSuccessful) */
  140. lserr = LsFinishCurrentSubline(plsc, &plssubl);
  141. if (lserrNone != lserr) return lserr;
  142. lserr = LssbGetObjDimSubline(plssubl, &lstflowUnused, pobjdim);
  143. if (lserr != lserrNone)
  144. {
  145. LsDestroySubline(plssubl);
  146. return lserr;
  147. }
  148. *pplssubl = plssubl;
  149. return lserrNone;
  150. }
  151. /* C R E A T E Q U E R Y R E S U L T */
  152. /*----------------------------------------------------------------------------
  153. %%Function: CreateQueryResult
  154. %%Contact: ricksa
  155. Common routine to fill in query output record for Query methods.
  156. .
  157. ----------------------------------------------------------------------------*/
  158. LSERR CreateQueryResult(
  159. PLSSUBL plssubl, /*(IN): subline of ruby */
  160. long dupAdj, /*(IN): u offset of start of subline */
  161. long dvpAdj, /*(IN): v offset of start of subline */
  162. PCLSQIN plsqin, /*(IN): query input */
  163. PLSQOUT plsqout) /*(OUT): query output */
  164. {
  165. ZeroMemory(plsqout, sizeof(LSQOUT));
  166. plsqout->heightsPresObj = plsqin->heightsPresRun;
  167. plsqout->dupObj = plsqin->dupRun;
  168. ZeroMemory(&plsqout->lstextcell, sizeof(plsqout->lstextcell));
  169. plsqout->plssubl = plssubl;
  170. plsqout->pointUvStartSubline.u += dupAdj;
  171. plsqout->pointUvStartSubline.v += dvpAdj;
  172. return lserrNone;
  173. }
  174. /* O B J H E L P F M T R E S U M E */
  175. /*----------------------------------------------------------------------------
  176. %%Function: ObjHelpFmtResume
  177. %%Contact: ricksa
  178. This is a helper that is used by objects that don't support
  179. the resuming of formatting.
  180. ----------------------------------------------------------------------------*/
  181. LSERR WINAPI ObjHelpFmtResume(
  182. PLNOBJ plnobj, /* (IN): object lnobj */
  183. const BREAKREC *rgBreakRecord, /* (IN): array of break records */
  184. DWORD nBreakRecord, /* (IN): size of the break records array */
  185. PCFMTIN pcfmtin, /* (IN): formatting input */
  186. FMTRES *pfmtres) /* (OUT): formatting result */
  187. {
  188. Unreferenced(plnobj);
  189. Unreferenced(rgBreakRecord);
  190. Unreferenced(nBreakRecord);
  191. Unreferenced(pcfmtin);
  192. Unreferenced(pfmtres);
  193. return lserrInvalidBreakRecord;
  194. }
  195. /* O B J H E L P G E T M O D W I D T H C H A R */
  196. /*----------------------------------------------------------------------------
  197. %%Function: ObjHelpGetModWidthChar
  198. %%Contact: ricksa
  199. Implementation of LSIMETHOD for objects that do nothing for mod width.
  200. Tatenakayoko and Hih are examples of this kind of object.
  201. ----------------------------------------------------------------------------*/
  202. LSERR WINAPI ObjHelpGetModWidthChar(
  203. PDOBJ pdobj, /* (IN): dobj */
  204. PLSRUN plsrun, /* (IN): plsrun of the object */
  205. PLSRUN plsrunText, /* (IN): plsrun of the preceding char */
  206. PCHEIGHTS pcheightsRef, /* (IN): height info about character */
  207. WCHAR wchar, /* (IN): preceding character */
  208. MWCLS mwcls, /* (IN): ModWidth class of preceding character */
  209. long *pdurChange) /* (OUT): amount by which width of the preceding char is to be changed */
  210. {
  211. Unreferenced(pdobj);
  212. Unreferenced(plsrun);
  213. Unreferenced(plsrunText);
  214. Unreferenced(pcheightsRef);
  215. Unreferenced(wchar);
  216. Unreferenced(mwcls);
  217. *pdurChange = 0;
  218. return lserrNone;
  219. }
  220. /* O B J H E L P S E T B R E A K */
  221. /*----------------------------------------------------------------------------
  222. %%Function: ObjHelpSetBreak
  223. %%Contact: ricksa
  224. SetBreak
  225. Implementation of LSIMETHOD for objects that do nothing for SetBreak.
  226. Tatenakayoko and Hih are examples of this kind of object.
  227. ----------------------------------------------------------------------------*/
  228. LSERR WINAPI ObjHelpSetBreak(
  229. PDOBJ pdobj, /* (IN): dobj which is broken */
  230. BRKKIND brkkind, /* (IN): Previous / Next / Force / Imposed was chosen */
  231. DWORD cBreakRecord, /* (IN): size of array */
  232. BREAKREC *rgBreakRecord, /* (IN): array of break records */
  233. DWORD *pcActualBreakRecord) /* (IN): actual number of used elements in array */
  234. {
  235. Unreferenced(pdobj);
  236. Unreferenced(brkkind);
  237. Unreferenced(rgBreakRecord);
  238. Unreferenced(cBreakRecord);
  239. *pcActualBreakRecord = 0;
  240. return lserrNone;
  241. }
  242. /* ObjHelpFExpandWithPrecedingChar */
  243. /*----------------------------------------------------------------------------
  244. %%Function: ObjHelpFExpandWithPrecedingChar
  245. %%Contact: ricksa
  246. Default implementation of LSIMETHOD for objects that do not
  247. allow expanding the previous character.
  248. ----------------------------------------------------------------------------*/
  249. LSERR WINAPI ObjHelpFExpandWithPrecedingChar(
  250. PDOBJ pdobj, /* (IN): dobj */
  251. PLSRUN plsrun, /* (IN): plsrun of the object */
  252. PLSRUN plsrunText, /* (IN): plsrun of the preceding char */
  253. WCHAR wchar, /* (IN): preceding character */
  254. MWCLS mwcls, /* (IN): ModWidth class of preceding character*/
  255. BOOL *pfExpand) /* (OUT): (OUT): expand preceding character? */
  256. {
  257. Unreferenced(pdobj);
  258. Unreferenced(plsrun);
  259. Unreferenced(plsrunText);
  260. Unreferenced(wchar);
  261. Unreferenced(mwcls);
  262. *pfExpand = fTrue;
  263. return lserrNone;
  264. }
  265. /* ObjHelpFExpandWithFollowingChar */
  266. /*----------------------------------------------------------------------------
  267. %%Function: ObjHelpFExpandWithFollowingChar
  268. %%Contact: ricksa
  269. Default implementation of LSIMETHOD for objects that do not
  270. allow expanding themselves.
  271. ----------------------------------------------------------------------------*/
  272. LSERR WINAPI ObjHelpFExpandWithFollowingChar(
  273. PDOBJ pdobj, /* (IN): dobj */
  274. PLSRUN plsrun, /* (IN): plsrun of the object */
  275. PLSRUN plsrunText, /* (IN): plsrun of the following char */
  276. WCHAR wchar, /* (IN): following character */
  277. MWCLS mwcls, /* (IN): ModWidth class of following character*/
  278. BOOL *pfExpand) /* (OUT): expand object? */
  279. {
  280. Unreferenced(pdobj);
  281. Unreferenced(plsrun);
  282. Unreferenced(plsrunText);
  283. Unreferenced(wchar);
  284. Unreferenced(mwcls);
  285. *pfExpand = fTrue;
  286. return lserrNone;
  287. }