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.

343 lines
9.5 KiB

  1. #include "iobj.h"
  2. #include "lsidefs.h"
  3. #include "lssetdoc.h"
  4. #include "lsc.h"
  5. #include "lstext.h"
  6. #include "prepdisp.h"
  7. #include "zqfromza.h"
  8. static LSERR SetDocForFormaters(PLSC plsc, LSDOCINF* plsdocinf);
  9. /* L S S E T D O C */
  10. /*----------------------------------------------------------------------------
  11. %%Function: LsSetDoc
  12. %%Contact: igorzv
  13. Parameters:
  14. plsc - (IN) ptr to line services context
  15. fDisplay - (IN) Intend to display?
  16. fPresEqualRef - (IN) Ref & Pres Devices are equal?
  17. pclsdevres - (IN) device resolutions
  18. Fill in a part of a Line Services context.
  19. Can be called more frequently then LsCreateContext.
  20. ----------------------------------------------------------------------------*/
  21. LSERR WINAPI LsSetDoc(PLSC plsc,
  22. BOOL fDisplay,
  23. BOOL fPresEqualRef,
  24. const LSDEVRES* pclsdevres)
  25. {
  26. LSDOCINF* plsdocinf = &(plsc->lsdocinf);
  27. LSERR lserr;
  28. if (!FIsLSC(plsc)) /* check that context is valid and not busy (for example in formating) */
  29. return lserrInvalidContext;
  30. if (FIsLSCBusy(plsc))
  31. return lserrSetDocDisabled;
  32. if (!fDisplay && !fPresEqualRef)
  33. {
  34. plsc->lsstate = LsStateNotReady;
  35. return lserrInvalidParameter;
  36. }
  37. /* if nothing is changed: return right away */
  38. if (((BYTE) fDisplay == plsdocinf->fDisplay) &&
  39. ((BYTE) fPresEqualRef == plsdocinf->fPresEqualRef ) &&
  40. (pclsdevres->dxrInch == plsdocinf->lsdevres.dxrInch) &&
  41. (pclsdevres->dyrInch == plsdocinf->lsdevres.dyrInch) &&
  42. (fPresEqualRef ||
  43. ((pclsdevres->dxpInch == plsdocinf->lsdevres.dxpInch) &&
  44. (pclsdevres->dypInch == plsdocinf->lsdevres.dypInch))))
  45. return lserrNone;
  46. /* if we have current line we must prepare it for display before changing context */
  47. if (plsc->plslineCur != NULL)
  48. {
  49. lserr = PrepareLineForDisplayProc(plsc->plslineCur);
  50. if (lserr != lserrNone)
  51. {
  52. plsc->lsstate = LsStateNotReady;
  53. return lserr;
  54. }
  55. plsc->plslineCur = NULL;
  56. }
  57. plsc->lsstate = LsStateSettingDoc; /* this assignment should be after PrepareForDisplay */
  58. plsdocinf->fDisplay = (BYTE) fDisplay;
  59. plsdocinf->fPresEqualRef = (BYTE) fPresEqualRef;
  60. plsdocinf->lsdevres = *pclsdevres;
  61. if (fPresEqualRef)
  62. {
  63. plsdocinf->lsdevres.dxpInch = plsdocinf->lsdevres.dxrInch;
  64. plsdocinf->lsdevres.dypInch = plsdocinf->lsdevres.dyrInch;
  65. }
  66. if (!FBetween(plsdocinf->lsdevres.dxpInch, 0, zqLim-1) ||
  67. !FBetween(plsdocinf->lsdevres.dypInch, 0, zqLim-1) ||
  68. !FBetween(plsdocinf->lsdevres.dxrInch, 0, zqLim-1) ||
  69. !FBetween(plsdocinf->lsdevres.dyrInch, 0, zqLim-1))
  70. {
  71. plsc->lsstate = LsStateNotReady;
  72. return lserrInvalidParameter;
  73. }
  74. lserr = SetDocForFormaters(plsc, plsdocinf);
  75. if (lserr != lserrNone)
  76. {
  77. plsc->lsstate = LsStateNotReady;
  78. return lserr;
  79. }
  80. plsc->lsstate = LsStateFree;
  81. return lserrNone;
  82. }
  83. LSERR WINAPI LsSetModWidthPairs(
  84. PLSC plsc, /* IN: ptr to line services context */
  85. DWORD clspairact, /* IN: Number of mod pairs info units*/
  86. const LSPAIRACT* rglspairact, /* IN: Mod pairs info units array */
  87. DWORD cModWidthClasses, /* IN: Number of Mod Width classes */
  88. const BYTE* rgilspairact) /* IN: Mod width information(square):
  89. indexes in the LSPAIRACT array */
  90. {
  91. LSERR lserr;
  92. DWORD iobjText;
  93. PILSOBJ pilsobjText;
  94. if (!FIsLSC(plsc)) /* check that context is valid and not busy (for example in formating) */
  95. return lserrInvalidContext;
  96. if (FIsLSCBusy(plsc))
  97. return lserrSetDocDisabled;
  98. /* if we have current line we must prepare it for display before changing context */
  99. if (plsc->plslineCur != NULL)
  100. {
  101. lserr = PrepareLineForDisplayProc(plsc->plslineCur);
  102. if (lserr != lserrNone)
  103. {
  104. plsc->lsstate = LsStateNotReady;
  105. return lserr;
  106. }
  107. plsc->plslineCur = NULL;
  108. }
  109. plsc->lsstate = LsStateSettingDoc; /* this assignment should be after PrepareForDisplay */
  110. iobjText = IobjTextFromLsc(&plsc->lsiobjcontext);
  111. pilsobjText = PilsobjFromLsc(&plsc->lsiobjcontext, iobjText);
  112. lserr = SetTextModWidthPairs(pilsobjText, clspairact,
  113. rglspairact, cModWidthClasses, rgilspairact);
  114. if (lserr != lserrNone)
  115. {
  116. plsc->lsstate = LsStateNotReady;
  117. return lserr;
  118. }
  119. plsc->lsstate = LsStateFree;
  120. return lserrNone;
  121. }
  122. LSERR WINAPI LsSetCompression(
  123. PLSC plsc, /* IN: ptr to line services context */
  124. DWORD cPriorities, /* IN: Number of compression priorities*/
  125. DWORD clspract, /* IN: Number of compression info units*/
  126. const LSPRACT* rglspract, /* IN: Compession info units array */
  127. DWORD cModWidthClasses, /* IN: Number of Mod Width classes */
  128. const BYTE* rgilspract) /* IN: Compression information:
  129. indexes in the LSPRACT array */
  130. {
  131. LSERR lserr;
  132. DWORD iobjText;
  133. PILSOBJ pilsobjText;
  134. if (!FIsLSC(plsc)) /* check that context is valid and not busy (for example in formating) */
  135. return lserrInvalidContext;
  136. if (FIsLSCBusy(plsc))
  137. return lserrSetDocDisabled;
  138. /* if we have current line we must prepare it for display before changing context */
  139. if (plsc->plslineCur != NULL)
  140. {
  141. lserr = PrepareLineForDisplayProc(plsc->plslineCur);
  142. if (lserr != lserrNone)
  143. {
  144. plsc->lsstate = LsStateNotReady;
  145. return lserr;
  146. }
  147. plsc->plslineCur = NULL;
  148. }
  149. plsc->lsstate = LsStateSettingDoc; /* this assignment should be after PrepareForDisplay */
  150. iobjText = IobjTextFromLsc(&plsc->lsiobjcontext);
  151. pilsobjText = PilsobjFromLsc(&plsc->lsiobjcontext, iobjText);
  152. lserr = SetTextCompression(pilsobjText, cPriorities, clspract,
  153. rglspract, cModWidthClasses, rgilspract);
  154. if (lserr != lserrNone)
  155. {
  156. plsc->lsstate = LsStateNotReady;
  157. return lserr;
  158. }
  159. plsc->lsstate = LsStateFree;
  160. return lserrNone;
  161. }
  162. LSERR WINAPI LsSetExpansion(
  163. PLSC plsc, /* IN: ptr to line services context */
  164. DWORD cExpansionClasses, /* IN: Number of expansion info units*/
  165. const LSEXPAN* rglsexpan, /* IN: Expansion info units array */
  166. DWORD cModWidthClasses, /* IN: Number of Mod Width classes */
  167. const BYTE* rgilsexpan) /* IN: Expansion information(square):
  168. indexes in the LSEXPAN array */
  169. {
  170. LSERR lserr;
  171. DWORD iobjText;
  172. PILSOBJ pilsobjText;
  173. if (!FIsLSC(plsc)) /* check that context is valid and not busy (for example in formating) */
  174. return lserrInvalidContext;
  175. if (FIsLSCBusy(plsc))
  176. return lserrSetDocDisabled;
  177. /* if we have current line we must prepare it for display before changing context */
  178. if (plsc->plslineCur != NULL)
  179. {
  180. lserr = PrepareLineForDisplayProc(plsc->plslineCur);
  181. if (lserr != lserrNone)
  182. {
  183. plsc->lsstate = LsStateNotReady;
  184. return lserr;
  185. }
  186. plsc->plslineCur = NULL;
  187. }
  188. plsc->lsstate = LsStateSettingDoc; /* this assignment should be after PrepareForDisplay */
  189. iobjText = IobjTextFromLsc(&plsc->lsiobjcontext);
  190. pilsobjText = PilsobjFromLsc(&plsc->lsiobjcontext, iobjText);
  191. lserr = SetTextExpansion(pilsobjText, cExpansionClasses,
  192. rglsexpan, cModWidthClasses, rgilsexpan);
  193. if (lserr != lserrNone)
  194. {
  195. plsc->lsstate = LsStateNotReady;
  196. return lserr;
  197. }
  198. plsc->lsstate = LsStateFree;
  199. return lserrNone;
  200. }
  201. LSERR WINAPI LsSetBreaking(
  202. PLSC plsc, /* IN: ptr to line services context */
  203. DWORD clsbrk, /* IN: Number of breaking info units*/
  204. const LSBRK* rglsbrk, /* IN: Breaking info units array */
  205. DWORD cBreakingClasses, /* IN: Number of breaking classes */
  206. const BYTE* rgilsbrk) /* IN: Breaking information(square):
  207. indexes in the LSBRK array */
  208. {
  209. LSERR lserr;
  210. DWORD iobjText;
  211. PILSOBJ pilsobjText;
  212. if (!FIsLSC(plsc)) /* check that context is valid and not busy (for example in formating) */
  213. return lserrInvalidContext;
  214. if (FIsLSCBusy(plsc))
  215. return lserrSetDocDisabled;
  216. /* if we have current line we must prepare it for display before changing context */
  217. if (plsc->plslineCur != NULL)
  218. {
  219. lserr = PrepareLineForDisplayProc(plsc->plslineCur);
  220. if (lserr != lserrNone)
  221. {
  222. plsc->lsstate = LsStateNotReady;
  223. return lserr;
  224. }
  225. plsc->plslineCur = NULL;
  226. }
  227. plsc->lsstate = LsStateSettingDoc; /* this assignment should be after PrepareForDisplay */
  228. iobjText = IobjTextFromLsc(&plsc->lsiobjcontext);
  229. pilsobjText = PilsobjFromLsc(&plsc->lsiobjcontext, iobjText);
  230. lserr = SetTextBreaking(pilsobjText, clsbrk,
  231. rglsbrk, cBreakingClasses, rgilsbrk);
  232. if (lserr != lserrNone)
  233. {
  234. plsc->lsstate = LsStateNotReady;
  235. return lserr;
  236. }
  237. plsc->lsstate = LsStateFree;
  238. return lserrNone;
  239. }
  240. /* S E T D O C F O R F O R M A T E R S */
  241. /*----------------------------------------------------------------------------
  242. %%Function: SetDocForFormaters
  243. %%Contact: igorzv
  244. Parameter:
  245. plsc - (IN) ptr to line services context
  246. plsdocinf - (IN) ptr to set doc input
  247. Invokes SetDoc methods for all formaters
  248. ----------------------------------------------------------------------------*/
  249. LSERR SetDocForFormaters(PLSC plsc, LSDOCINF* plsdocinf)
  250. {
  251. DWORD iobjMac;
  252. DWORD iobj;
  253. PILSOBJ pilsobj;
  254. LSERR lserr;
  255. Assert(FIsLSC(plsc));
  256. Assert(plsc->lsstate == LsStateSettingDoc);
  257. Assert(plsdocinf != NULL);
  258. iobjMac = plsc->lsiobjcontext.iobjMac;
  259. for (iobj = 0; iobj < iobjMac; iobj++)
  260. {
  261. pilsobj = plsc->lsiobjcontext.rgobj[iobj].pilsobj;
  262. lserr = plsc->lsiobjcontext.rgobj[iobj].lsim.pfnSetDoc(pilsobj,plsdocinf);
  263. if (lserr != lserrNone)
  264. return lserr;
  265. }
  266. return lserrNone;
  267. }