Source code of Windows XP (NT5)
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.

472 lines
12 KiB

  1. #include "lsmem.h"
  2. #include "limits.h"
  3. #include "hih.h"
  4. #include "objhelp.h"
  5. #include "lscbk.h"
  6. #include "lsdevres.h"
  7. #include "pdobj.h"
  8. #include "objdim.h"
  9. #include "plssubl.h"
  10. #include "plsdnode.h"
  11. #include "pilsobj.h"
  12. #include "lscrsubl.h"
  13. #include "lssubset.h"
  14. #include "lsdnset.h"
  15. #include "zqfromza.h"
  16. #include "lsdocinf.h"
  17. #include "fmti.h"
  18. #include "posichnk.h"
  19. #include "locchnk.h"
  20. #include "lsdnfin.h"
  21. #include "brko.h"
  22. #include "lspap.h"
  23. #include "plspap.h"
  24. #include "lsqsubl.h"
  25. #include "dispi.h"
  26. #include "lsdssubl.h"
  27. #include "lsems.h"
  28. #include "dispmisc.h"
  29. #include "sobjhelp.h"
  30. #define HIH_ESC_CNT 1
  31. struct ilsobj
  32. {
  33. POLS pols;
  34. LSCBK lscbk;
  35. PLSC plsc;
  36. PFNHIHENUM pfnEnum;
  37. LSESC lsescHih;
  38. };
  39. struct dobj
  40. {
  41. SOBJHELP sobjhelp; /* common area for simple objects */
  42. PILSOBJ pilsobj; /* ILS object */
  43. LSCP cpStart; /* Starting LS cp for object */
  44. PLSSUBL plssubl; /* Handle to second line */
  45. };
  46. /* H I H F R E E D O B J */
  47. /*----------------------------------------------------------------------------
  48. %%Function: HihFreeDobj
  49. %%Contact: antons
  50. Free all resources associated with Hih dobj.
  51. ----------------------------------------------------------------------------*/
  52. static LSERR HihFreeDobj (PDOBJ pdobj)
  53. {
  54. LSERR lserr = lserrNone;
  55. PILSOBJ pilsobj = pdobj->pilsobj;
  56. if (pdobj->plssubl != NULL)
  57. {
  58. lserr = LsDestroySubline(pdobj->plssubl);
  59. }
  60. pilsobj->lscbk.pfnDisposePtr(pilsobj->pols, pdobj);
  61. return lserr;
  62. }
  63. /* H I H C R E A T E I L S O B J */
  64. /*----------------------------------------------------------------------------
  65. %%Function: HihCreateILSObj
  66. %%Contact: ricksa
  67. CreateILSObj
  68. Create the ILS object for all Hih objects.
  69. ----------------------------------------------------------------------------*/
  70. LSERR WINAPI HihCreateILSObj(
  71. POLS pols, /* (IN): client application context */
  72. PLSC plsc, /* (IN): LS context */
  73. PCLSCBK pclscbk, /* (IN): callbacks to client application */
  74. DWORD idObj, /* (IN): id of the object */
  75. PILSOBJ *ppilsobj) /* (OUT): object ilsobj */
  76. {
  77. PILSOBJ pilsobj;
  78. LSERR lserr;
  79. HIHINIT hihinit;
  80. hihinit.dwVersion = HIH_VERSION;
  81. /* Get initialization data */
  82. lserr = pclscbk->pfnGetObjectHandlerInfo(pols, idObj, &hihinit);
  83. if (lserr != lserrNone)
  84. {
  85. return lserr;
  86. }
  87. pilsobj = pclscbk->pfnNewPtr(pols, sizeof(*pilsobj));
  88. if (NULL == pilsobj)
  89. {
  90. return lserrOutOfMemory;
  91. }
  92. pilsobj->pols = pols;
  93. pilsobj->lscbk = *pclscbk;
  94. pilsobj->plsc = plsc;
  95. pilsobj->lsescHih.wchFirst = hihinit.wchEndHih;
  96. pilsobj->lsescHih.wchLast = hihinit.wchEndHih;
  97. pilsobj->pfnEnum = hihinit.pfnEnum;
  98. *ppilsobj = pilsobj;
  99. return lserrNone;
  100. }
  101. /* H I H D E S T R O Y I L S O B J */
  102. /*----------------------------------------------------------------------------
  103. %%Function: HihDestroyILSObj
  104. %%Contact: ricksa
  105. DestroyILSObj
  106. Free all resources assocaiated with Hih ILS object.
  107. ----------------------------------------------------------------------------*/
  108. LSERR WINAPI HihDestroyILSObj(
  109. PILSOBJ pilsobj) /* (IN): object ilsobj */
  110. {
  111. pilsobj->lscbk.pfnDisposePtr(pilsobj->pols, pilsobj);
  112. return lserrNone;
  113. }
  114. /* H I H S E T D O C */
  115. /*----------------------------------------------------------------------------
  116. %%Function: HihSetDoc
  117. %%Contact: ricksa
  118. SetDoc
  119. Keep track of device information for scaling purposes.
  120. ----------------------------------------------------------------------------*/
  121. LSERR WINAPI HihSetDoc(
  122. PILSOBJ pilsobj, /* (IN): object ilsobj */
  123. PCLSDOCINF pclsdocinf) /* (IN): initialization data of the document level */
  124. {
  125. Unreferenced(pilsobj);
  126. Unreferenced(pclsdocinf);
  127. return lserrNone;
  128. }
  129. /* H I H C R E A T E L N O B J */
  130. /*----------------------------------------------------------------------------
  131. %%Function: HihCreateLNObj
  132. %%Contact: ricksa
  133. CreateLNObj
  134. Create the Line Object for the Hih. No real need for a line
  135. object so don't allocated it.
  136. ----------------------------------------------------------------------------*/
  137. LSERR WINAPI HihCreateLNObj(
  138. PCILSOBJ pcilsobj, /* (IN): object ilsobj */
  139. PLNOBJ *pplnobj) /* (OUT): object lnobj */
  140. {
  141. *pplnobj = (PLNOBJ) pcilsobj;
  142. return lserrNone;
  143. }
  144. /* H I H D E S T R O Y L N O B J */
  145. /*----------------------------------------------------------------------------
  146. %%Function: HihDestroyLNObj
  147. %%Contact: ricksa
  148. DestroyLNObj
  149. Frees resources associated with the Hih line object. Since
  150. there isn't any this is a no-op.
  151. ----------------------------------------------------------------------------*/
  152. LSERR WINAPI HihDestroyLNObj(
  153. PLNOBJ plnobj) /* (OUT): object lnobj */
  154. {
  155. Unreferenced(plnobj);
  156. return lserrNone;
  157. }
  158. /* H I H F M T */
  159. /*----------------------------------------------------------------------------
  160. %%Function: HihFmt
  161. %%Contact: ricksa
  162. Fmt
  163. Format the Hih object.
  164. ----------------------------------------------------------------------------*/
  165. LSERR WINAPI HihFmt(
  166. PLNOBJ plnobj, /* (IN): object lnobj */
  167. PCFMTIN pcfmtin, /* (IN): formatting input */
  168. FMTRES *pfmtres) /* (OUT): formatting result */
  169. {
  170. PDOBJ pdobj;
  171. LSERR lserr;
  172. PILSOBJ pilsobj = (PILSOBJ) plnobj;
  173. POLS pols = pilsobj->pols;
  174. LSCP cpStartMain = pcfmtin->lsfgi.cpFirst + 1;
  175. LSCP cpOut;
  176. FMTRES fmtres;
  177. FMTRES fmtr = fmtrCompletedRun;
  178. /*
  179. * Allocate the DOBJ
  180. */
  181. pdobj = pilsobj->lscbk.pfnNewPtr(pols, sizeof(*pdobj));
  182. if (NULL == pdobj)
  183. {
  184. return lserrOutOfMemory;
  185. }
  186. ZeroMemory(pdobj, sizeof(*pdobj));
  187. pdobj->pilsobj = pilsobj;
  188. pdobj->cpStart = pcfmtin->lsfgi.cpFirst;
  189. /*
  190. * Build main line of text
  191. */
  192. lserr = FormatLine(pilsobj->plsc, cpStartMain, LONG_MAX, pcfmtin->lsfgi.lstflow,
  193. &pdobj->plssubl, HIH_ESC_CNT, &pilsobj->lsescHih,
  194. &pdobj->sobjhelp.objdimAll, &cpOut, NULL, NULL, &fmtres);
  195. if (lserr != lserrNone)
  196. {
  197. HihFreeDobj(pdobj); /* do not need to check return error code */
  198. return lserr;
  199. }
  200. /*
  201. * Note: the + 2 in the following is because cpStartMain is + 1 from the
  202. * actual start of the object (it is the cpStartMain of the Hih
  203. * data) and additional + 1 for the escape character at the end of the
  204. * tatenakayoko.
  205. */
  206. Assert (fmtres != fmtrExceededMargin);
  207. pdobj->sobjhelp.dcp = cpOut - cpStartMain + 2;
  208. lserr = LsdnFinishRegular(pilsobj->plsc, pdobj->sobjhelp.dcp,
  209. pcfmtin->lsfrun.plsrun, pcfmtin->lsfrun.plschp, pdobj,
  210. &pdobj->sobjhelp.objdimAll);
  211. if (lserr != lserrNone)
  212. {
  213. HihFreeDobj(pdobj); /* do not need to check return error code */
  214. return lserr;
  215. }
  216. if (pcfmtin->lsfgi.urPen + pdobj->sobjhelp.objdimAll.dur > pcfmtin->lsfgi.urColumnMax)
  217. {
  218. fmtr = fmtrExceededMargin;
  219. }
  220. *pfmtres = fmtr;
  221. return lserrNone;
  222. }
  223. /* H I H G E T S P E C I A L E F F E C T S I N S I D E */
  224. /*----------------------------------------------------------------------------
  225. %%Function: HihGetSpecialEffectsInside
  226. %%Contact: ricksa
  227. GetSpecialEffectsInside
  228. .
  229. ----------------------------------------------------------------------------*/
  230. LSERR WINAPI HihGetSpecialEffectsInside(
  231. PDOBJ pdobj, /* (IN): dobj */
  232. UINT *pEffectsFlags) /* (OUT): Special effects for this object */
  233. {
  234. return LsGetSpecialEffectsSubline(pdobj->plssubl, pEffectsFlags);
  235. }
  236. /* H I H C A L C P R E S E N T A T I O N */
  237. /*----------------------------------------------------------------------------
  238. %%Function: HihCalcPresentation
  239. %%Contact: ricksa
  240. CalcPresentation
  241. This has three jobs. First it distributes space to the shorter string
  242. if so requested. Next it prepares each line for presentation. Finally,
  243. it calculates the positions of the lines in output device coordinates.
  244. ----------------------------------------------------------------------------*/
  245. LSERR WINAPI HihCalcPresentation(
  246. PDOBJ pdobj, /* (IN): dobj */
  247. long dup, /* (IN): dup of dobj */
  248. LSKJUST lskjust, /* (IN): Justification type */
  249. BOOL fLastVisibleOnLine ) /* (IN): Is this object last visible on line? */
  250. {
  251. Unreferenced (fLastVisibleOnLine);
  252. Unreferenced(dup);
  253. Unreferenced (lskjust);
  254. return LsMatchPresSubline(pdobj->plssubl);
  255. }
  256. /* H I H Q U E R Y P O I N T P C P */
  257. /*----------------------------------------------------------------------------
  258. %%Function: HihQueryPointPcp
  259. %%Contact: ricksa
  260. Map dup to dcp
  261. Just call through to Query result helper.
  262. ----------------------------------------------------------------------------*/
  263. LSERR WINAPI HihQueryPointPcp(
  264. PDOBJ pdobj, /*(IN): dobj to query */
  265. PCPOINTUV ppointuvQuery, /*(IN): query point (uQuery,vQuery) */
  266. PCLSQIN plsqin, /*(IN): query input */
  267. PLSQOUT plsqout) /*(OUT): query output */
  268. {
  269. Unreferenced(ppointuvQuery);
  270. return CreateQueryResult(pdobj->plssubl, 0, 0, plsqin, plsqout);
  271. }
  272. /* H I H Q U E R Y C P P P O I N T */
  273. /*----------------------------------------------------------------------------
  274. %%Function: HihQueryCpPpoint
  275. %%Contact: ricksa
  276. Map dcp to dup
  277. Just call through to Query result helper.
  278. ----------------------------------------------------------------------------*/
  279. LSERR WINAPI HihQueryCpPpoint(
  280. PDOBJ pdobj, /*(IN): dobj to query, */
  281. LSDCP dcp, /*(IN): dcp for the query */
  282. PCLSQIN plsqin, /*(IN): query input */
  283. PLSQOUT plsqout) /*(OUT): query output */
  284. {
  285. Unreferenced(dcp);
  286. return CreateQueryResult(pdobj->plssubl, 0, 0, plsqin, plsqout);
  287. }
  288. /* H I H D I S P L A Y */
  289. /*----------------------------------------------------------------------------
  290. %%Function: HihDisplay
  291. %%Contact: ricksa
  292. Display
  293. This calculates the positions of the various lines for the
  294. display and then displays them.
  295. ----------------------------------------------------------------------------*/
  296. LSERR WINAPI HihDisplay(
  297. PDOBJ pdobj, /*(IN): dobj to display */
  298. PCDISPIN pcdispin) /*(IN): info for display */
  299. {
  300. /* display the Hih line */
  301. return LsDisplaySubline(pdobj->plssubl, &pcdispin->ptPen, pcdispin->kDispMode,
  302. pcdispin->prcClip);
  303. }
  304. /* H I H D E S T R O Y D O B J */
  305. /*----------------------------------------------------------------------------
  306. %%Function: HihDestroyDobj
  307. %%Contact: ricksa
  308. DestroyDobj
  309. Free all resources connected with the input dobj.
  310. ----------------------------------------------------------------------------*/
  311. LSERR WINAPI HihDestroyDobj(
  312. PDOBJ pdobj) /*(IN): dobj to destroy */
  313. {
  314. return HihFreeDobj(pdobj);
  315. }
  316. /* H I H E N U M */
  317. /*----------------------------------------------------------------------------
  318. %%Function: HihEnum
  319. %%Contact: ricksa
  320. Enumeration callback - passed to client.
  321. ----------------------------------------------------------------------------*/
  322. LSERR WINAPI HihEnum(
  323. PDOBJ pdobj, /*(IN): dobj to enumerate */
  324. PLSRUN plsrun, /*(IN): from DNODE */
  325. PCLSCHP plschp, /*(IN): from DNODE */
  326. LSCP cp, /*(IN): from DNODE */
  327. LSDCP dcp, /*(IN): from DNODE */
  328. LSTFLOW lstflow, /*(IN): text flow*/
  329. BOOL fReverse, /*(IN): enumerate in reverse order */
  330. BOOL fGeometryNeeded, /*(IN): */
  331. const POINT* pt, /*(IN): starting position (top left), iff fGeometryNeeded */
  332. PCHEIGHTS pcheights, /*(IN): from DNODE, relevant iff fGeometryNeeded */
  333. long dupRun) /*(IN): from DNODE, relevant iff fGeometryNeeded */
  334. {
  335. return pdobj->pilsobj->pfnEnum(pdobj->pilsobj->pols, plsrun, plschp, cp,
  336. dcp, lstflow, fReverse, fGeometryNeeded, pt, pcheights, dupRun,
  337. pdobj->plssubl);
  338. }
  339. /* H I H H A N D L E R I N I T */
  340. /*----------------------------------------------------------------------------
  341. %%Function: HihHandlerInit
  342. %%Contact: ricksa
  343. Initialize global Hih data and return LSIMETHODS.
  344. ----------------------------------------------------------------------------*/
  345. LSERR WINAPI LsGetHihLsimethods(
  346. LSIMETHODS *plsim)
  347. {
  348. plsim->pfnCreateILSObj = HihCreateILSObj;
  349. plsim->pfnDestroyILSObj = HihDestroyILSObj;
  350. plsim->pfnSetDoc = HihSetDoc;
  351. plsim->pfnCreateLNObj = HihCreateLNObj;
  352. plsim->pfnDestroyLNObj = HihDestroyLNObj;
  353. plsim->pfnFmt = HihFmt;
  354. plsim->pfnFmtResume = ObjHelpFmtResume;
  355. plsim->pfnGetModWidthPrecedingChar = ObjHelpGetModWidthChar;
  356. plsim->pfnGetModWidthFollowingChar = ObjHelpGetModWidthChar;
  357. plsim->pfnTruncateChunk = SobjTruncateChunk;
  358. plsim->pfnFindPrevBreakChunk = SobjFindPrevBreakChunk;
  359. plsim->pfnFindNextBreakChunk = SobjFindNextBreakChunk;
  360. plsim->pfnForceBreakChunk = SobjForceBreakChunk;
  361. plsim->pfnSetBreak = ObjHelpSetBreak;
  362. plsim->pfnGetSpecialEffectsInside = HihGetSpecialEffectsInside;
  363. plsim->pfnFExpandWithPrecedingChar = ObjHelpFExpandWithPrecedingChar;
  364. plsim->pfnFExpandWithFollowingChar = ObjHelpFExpandWithFollowingChar;
  365. plsim->pfnCalcPresentation = HihCalcPresentation;
  366. plsim->pfnQueryPointPcp = HihQueryPointPcp;
  367. plsim->pfnQueryCpPpoint = HihQueryCpPpoint;
  368. plsim->pfnDisplay = HihDisplay;
  369. plsim->pfnDestroyDObj = HihDestroyDobj;
  370. plsim->pfnEnum = HihEnum;
  371. return lserrNone;
  372. }