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.

448 lines
9.8 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module OLSOLE.CPP -- OlsOle LineServices object class
  5. *
  6. * Author:
  7. * Murray Sargent (with lots of help from RickSa's ols code)
  8. *
  9. * Copyright (c) 1997-1998 Microsoft Corporation. All rights reserved.
  10. */
  11. #include "_common.h"
  12. #include "_font.h"
  13. #include "_edit.h"
  14. #include "_disp.h"
  15. #include "_ols.h"
  16. #include "_render.h"
  17. extern "C" {
  18. #include "objdim.h"
  19. #include "pobjdim.h"
  20. #include "plsdnode.h"
  21. #include "dispi.h"
  22. #include "pdispi.h"
  23. #include "fmti.h"
  24. #include "lsdnset.h"
  25. #include "lsdnfin.h"
  26. #include "brko.h"
  27. #include "pbrko.h"
  28. #include "locchnk.h"
  29. #include "lsqout.h"
  30. #include "lsqin.h"
  31. #include "lsimeth.h"
  32. }
  33. #ifdef LINESERVICES
  34. /*
  35. * OlsOleCreateILSObj(pols, plsc, pclscbk, dword, ppilsobj)
  36. *
  37. * @func
  38. * Create LS Ole object handler. We don't have any need for
  39. * this, so just set it to 0.
  40. *
  41. * @rdesc
  42. * LSERR
  43. */
  44. LSERR WINAPI OlsOleCreateILSObj(
  45. POLS pols, //[IN]: COls *
  46. PLSC plsc, //[IN]: LineServices context
  47. PCLSCBK,
  48. DWORD,
  49. PILSOBJ *ppilsobj) //[OUT]: ptr to ilsobj
  50. {
  51. *ppilsobj = 0;
  52. return lserrNone;
  53. }
  54. /*
  55. * OlsOleDestroyILSObj(pilsobj)
  56. *
  57. * @func
  58. * Destroy LS Ole handler object. Nothing to do, since we don't
  59. * use the ILSObj.
  60. *
  61. * @rdesc
  62. * LSERR
  63. */
  64. LSERR WINAPI OlsOleDestroyILSObj(
  65. PILSOBJ pilsobj)
  66. {
  67. return lserrNone;
  68. }
  69. /*
  70. * OlsOleSetDoc(pilsobj, pclsdocinf)
  71. *
  72. * @func
  73. * Set doc info. Nothing to do for Ole objects
  74. *
  75. * @rdesc
  76. * LSERR
  77. */
  78. LSERR WINAPI OlsOleSetDoc(
  79. PILSOBJ,
  80. PCLSDOCINF)
  81. {
  82. // Ole objects don't care about this
  83. return lserrNone;
  84. }
  85. /*
  86. * OlsOleCreateLNObj(pilsobj, pplnobj)
  87. *
  88. * @func
  89. * Create the line object. Nothing needed in addition to the ped,
  90. * so just return the ped as the LN object.
  91. *
  92. * @rdesc
  93. * LSERR
  94. */
  95. LSERR WINAPI OlsOleCreateLNObj(
  96. PCILSOBJ pilsobj,
  97. PLNOBJ * pplnobj)
  98. {
  99. *pplnobj = (PLNOBJ)g_pols->_pme->GetPed(); // Just the ped
  100. return lserrNone;
  101. }
  102. /*
  103. * OlsOleDestroyLNObj(plnobj)
  104. *
  105. * @func
  106. * Destroy LN object. Nothing to do, since ped is destroyed
  107. * elsewhere
  108. *
  109. * @rdesc
  110. * LSERR
  111. */
  112. LSERR WINAPI OlsOleDestroyLNObj(
  113. PLNOBJ plnobj)
  114. {
  115. return lserrNone;
  116. }
  117. /*
  118. * OlsOleFmt(plnobj, pcfmtin, pfmres)
  119. *
  120. * @func
  121. * Compute dimensions of a particular Ole object
  122. *
  123. * @rdesc
  124. * LSERR
  125. */
  126. LSERR WINAPI OlsOleFmt(
  127. PLNOBJ plnobj,
  128. PCFMTIN pcfmtin,
  129. FMTRES *pfmres)
  130. {
  131. const LONG cp = pcfmtin->lsfrun.plsrun->_cp; //Cannot trust LS cps
  132. LONG dup = 0;
  133. LSERR lserr;
  134. OBJDIM objdim;
  135. CTxtEdit * ped = (CTxtEdit *)plnobj;
  136. COleObject * pobj = ped->GetObjectMgr()->GetObjectFromCp(cp);
  137. Assert(pobj);
  138. ZeroMemory(&objdim, sizeof(objdim));
  139. pobj->MeasureObj(g_pols->_pme->GetDyrInch(), g_pols->_pme->GetDxrInch(),
  140. objdim.dur, objdim.heightsRef.dvAscent,
  141. objdim.heightsRef.dvDescent, pcfmtin->lstxmRef.dvDescent);
  142. pobj->MeasureObj(g_pols->_pme->GetDypInch(), g_pols->_pme->GetDxpInch(),
  143. dup, objdim.heightsPres.dvAscent,
  144. objdim.heightsPres.dvDescent, pcfmtin->lstxmPres.dvDescent);
  145. pobj->_plsdnTop = pcfmtin->plsdnTop;
  146. lserr = g_plsc->dnFinishRegular(1, pcfmtin->lsfrun.plsrun, pcfmtin->lsfrun.plschp, (PDOBJ)pobj, &objdim);
  147. if(lserrNone == lserr)
  148. {
  149. lserr = g_plsc->dnSetRigidDup(pcfmtin->plsdnTop, dup);
  150. if(lserrNone == lserr)
  151. {
  152. *pfmres = fmtrCompletedRun;
  153. if (pcfmtin->lsfgi.urPen + objdim.dur > pcfmtin->lsfgi.urColumnMax
  154. && !pcfmtin->lsfgi.fFirstOnLine)
  155. {
  156. *pfmres = fmtrExceededMargin;
  157. }
  158. }
  159. }
  160. return lserr;
  161. }
  162. /*
  163. * OlsOleTruncateChunk(plocchnk, posichnk)
  164. *
  165. * @func
  166. * Truncate chunk plocchnk at the point posichnk
  167. *
  168. * @rdesc
  169. * LSERR
  170. */
  171. LSERR WINAPI OlsOleTruncateChunk(
  172. PCLOCCHNK plocchnk, // (IN): locchnk to truncate
  173. PPOSICHNK posichnk) // (OUT): truncation point
  174. {
  175. LSERR lserr;
  176. OBJDIM objdim;
  177. PLSCHNK plschnk = plocchnk->plschnk;
  178. COleObject * pobj;
  179. long ur = plocchnk->lsfgi.urPen;
  180. long urColumnMax = plocchnk->lsfgi.urColumnMax;
  181. for(DWORD i = 0; ur <= urColumnMax; i++)
  182. {
  183. AssertSz(i < plocchnk->clschnk, "OlsOleTruncateChunk: exceeded group of chunks");
  184. pobj = (COleObject *)plschnk[i].pdobj;
  185. Assert(pobj);
  186. lserr = g_plsc->dnQueryObjDimRange(pobj->_plsdnTop, pobj->_plsdnTop, &objdim);
  187. if(lserr != lserrNone)
  188. return lserr;
  189. ur += objdim.dur;
  190. }
  191. posichnk->ichnk = i - 1;
  192. posichnk->dcp = 1;
  193. return lserrNone;
  194. }
  195. /*
  196. * OlsOleFindPrevBreakChunk(plocchnk, pposichnk, brkcond, pbrkout)
  197. *
  198. * @func
  199. * Find previous break in chunk
  200. *
  201. * @rdesc
  202. * LSERR
  203. */
  204. LSERR WINAPI OlsOleFindPrevBreakChunk(
  205. PCLOCCHNK plocchnk,
  206. PCPOSICHNK pposichnk,
  207. BRKCOND brkcond, //(IN): recommendation about break after chunk
  208. PBRKOUT pbrkout)
  209. {
  210. ZeroMemory(pbrkout, sizeof(*pbrkout));
  211. if (pposichnk->ichnk == ichnkOutside && (brkcond == brkcondPlease || brkcond == brkcondCan))
  212. {
  213. pbrkout->fSuccessful = fTrue;
  214. pbrkout->posichnk.ichnk = plocchnk->clschnk - 1;
  215. pbrkout->posichnk.dcp = plocchnk->plschnk[plocchnk->clschnk - 1].dcp;
  216. COleObject *pobj = (COleObject *)plocchnk->plschnk[plocchnk->clschnk - 1].pdobj;
  217. Assert(pobj);
  218. g_plsc->dnQueryObjDimRange(pobj->_plsdnTop, pobj->_plsdnTop, &pbrkout->objdim);
  219. }
  220. else
  221. pbrkout->brkcond = brkcondPlease;
  222. return lserrNone;
  223. }
  224. /*
  225. * OlsOleForceBreakChunk(plocchnk, pposichnk, pbrkout)
  226. *
  227. * @func
  228. * Called when forced to break a line.
  229. *
  230. * @rdesc
  231. * LSERR
  232. */
  233. LSERR WINAPI OlsOleForceBreakChunk(
  234. PCLOCCHNK plocchnk,
  235. PCPOSICHNK pposichnk,
  236. PBRKOUT pbrkout)
  237. {
  238. ZeroMemory(pbrkout, sizeof(*pbrkout));
  239. pbrkout->fSuccessful = fTrue;
  240. if (plocchnk->lsfgi.fFirstOnLine && pposichnk->ichnk == 0 || pposichnk->ichnk == ichnkOutside)
  241. {
  242. pbrkout->posichnk.dcp = 1;
  243. COleObject *pobj = (COleObject *)plocchnk->plschnk[0].pdobj;
  244. Assert(pobj);
  245. g_plsc->dnQueryObjDimRange(pobj->_plsdnTop, pobj->_plsdnTop, &pbrkout->objdim);
  246. }
  247. else
  248. {
  249. pbrkout->posichnk.ichnk = pposichnk->ichnk;
  250. pbrkout->posichnk.dcp = 0;
  251. }
  252. return lserrNone;
  253. }
  254. /*
  255. * OlsOleSetBreak(pdobj, brkkind, nBreakRecord, rgBreakRecord, nActualBreakRecord)
  256. *
  257. * @func
  258. * Set break
  259. *
  260. * @rdesc
  261. * LSERR
  262. */
  263. LSERR WINAPI OlsOleSetBreak(
  264. PDOBJ pdobj, // (IN): dobj which is broken
  265. BRKKIND brkkind, // (IN): Previous/Next/Force/Imposed was chosen
  266. DWORD nBreakRecord, // (IN): size of array
  267. BREAKREC* rgBreakRecord, // (OUT): array of break records
  268. DWORD* nActualBreakRecord) // (OUT): actual number of used elements in array
  269. {
  270. return lserrNone;
  271. }
  272. LSERR WINAPI OlsOleGetSpecialEffectsInside(
  273. PDOBJ pdobj, // (IN): dobj
  274. UINT *pEffectsFlags) // (OUT): Special effects for this object
  275. {
  276. *pEffectsFlags = 0;
  277. return lserrNone;
  278. }
  279. LSERR WINAPI OlsOleCalcPresentation(
  280. PDOBJ, // (IN): dobj
  281. long, // (IN): dup of dobj
  282. LSKJUST, // (IN): LSKJUST
  283. BOOL fLastVisibleOnLine)// (IN): this object is last visible object on line
  284. {
  285. return lserrNone;
  286. }
  287. /*
  288. * OlsOleQueryPointPcp(pdobj, ppointuvQuery, plsqin, plsqout)
  289. *
  290. * @func
  291. * Query Ole object PointFromCp.
  292. *
  293. * @rdesc
  294. * LSERR
  295. */
  296. LSERR WINAPI OlsOleQueryPointPcp(
  297. PDOBJ pdobj, //(IN): dobj to query
  298. PCPOINTUV ppointuvQuery, //(IN): query point (uQuery,vQuery)
  299. PCLSQIN plsqin, //(IN): query input
  300. PLSQOUT plsqout) //(OUT): query output
  301. {
  302. ZeroMemory(plsqout, sizeof(LSQOUT));
  303. plsqout->heightsPresObj = plsqin->heightsPresRun;
  304. plsqout->dupObj = plsqin->dupRun;
  305. return lserrNone;
  306. }
  307. /*
  308. * OlsOleQueryCpPpoint(pdobj, dcp, plsqin, plsqout)
  309. *
  310. * @func
  311. * Query Ole object CpFromPoint.
  312. *
  313. * @rdesc
  314. * LSERR
  315. */
  316. LSERR WINAPI OlsOleQueryCpPpoint(
  317. PDOBJ pdobj, //(IN): dobj to query
  318. LSDCP dcp, //(IN): dcp for query
  319. PCLSQIN plsqin, //(IN): query input
  320. PLSQOUT plsqout) //(OUT): query output
  321. {
  322. ZeroMemory(plsqout, sizeof(LSQOUT));
  323. plsqout->heightsPresObj = plsqin->heightsPresRun;
  324. plsqout->dupObj = plsqin->dupRun;
  325. return lserrNone;
  326. }
  327. /*
  328. * OlsOleDisplay(pdobj, pcdispin)
  329. *
  330. * @func
  331. * Display object
  332. *
  333. * @rdesc
  334. * LSERR
  335. */
  336. LSERR WINAPI OlsOleDisplay(
  337. PDOBJ pdobj, //(IN): dobj to query
  338. PCDISPIN pcdispin) //(IN): display info
  339. {
  340. POINT pt, ptCur;
  341. COleObject *pobj = (COleObject *)pdobj;
  342. Assert(pobj);
  343. CRenderer *pre = g_pols->GetRenderer();
  344. const CDisplay *pdp = pre->GetPdp();
  345. ptCur = pre->GetCurPoint();
  346. pt.x = pcdispin->ptPen.x;
  347. pt.y = ptCur.y;
  348. if (pcdispin->lstflow == lstflowWS)
  349. pt.x -= pcdispin->dup - 1;
  350. pre->SetCurPoint(pt);
  351. pre->SetClipLeftRight(pcdispin->dup);
  352. RECT rc = pre->GetClipRect();
  353. pre->SetSelected(pcdispin->plsrun->IsSelected());
  354. pre->Check_pccs();
  355. pre->SetFontAndColor(pcdispin->plsrun->_pCF);
  356. // Draw it!
  357. HDC hdc = pre->GetDC();
  358. pobj->DrawObj(pdp, pre->GetDypInch(), pre->GetDxpInch(), hdc, pdp->IsMetafile(), &pt, &rc, pcdispin->ptPen.y - pt.y, pre->GetLine()._yDescent);
  359. return lserrNone;
  360. }
  361. /*
  362. * OlsOleDistroyDObj(pdobj)
  363. *
  364. * @func
  365. * Destroy object: nothing to do since object is destroyed elsewhere
  366. *
  367. * @rdesc
  368. * LSERR
  369. */
  370. LSERR WINAPI OlsOleDestroyDObj(
  371. PDOBJ pdobj)
  372. {
  373. return lserrNone;
  374. }
  375. extern const LSIMETHODS vlsimethodsOle =
  376. {
  377. OlsOleCreateILSObj,
  378. OlsOleDestroyILSObj,
  379. OlsOleSetDoc,
  380. OlsOleCreateLNObj,
  381. OlsOleDestroyLNObj,
  382. OlsOleFmt,
  383. 0,//OlsOleFmtResume
  384. 0,//OlsOleGetModWidthPrecedingChar
  385. 0,//OlsOleGetModWidthFollowingChar
  386. OlsOleTruncateChunk,
  387. OlsOleFindPrevBreakChunk,
  388. 0,//OlsOleFindNextBreakChunk
  389. OlsOleForceBreakChunk,
  390. OlsOleSetBreak,
  391. OlsOleGetSpecialEffectsInside,
  392. 0,//OlsOleFExpandWithPrecedingChar
  393. 0,//OlsOleFExpandWithFollowingChar
  394. OlsOleCalcPresentation,
  395. OlsOleQueryPointPcp,
  396. OlsOleQueryCpPpoint,
  397. 0,//pfnEnum
  398. OlsOleDisplay,
  399. OlsOleDestroyDObj
  400. };
  401. #endif // LINESERVICES