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.

168 lines
3.9 KiB

  1. #include "enumcore.h"
  2. #include "lsc.h"
  3. #include "lssubl.h"
  4. #include "heights.h"
  5. #include "lsdnode.h"
  6. #include "dninfo.h"
  7. #include "lstfset.h"
  8. static LSERR EnumerateDnode(PLSC plsc, PLSDNODE pdn, POINTUV pt, BOOL fReverse,
  9. BOOL fGeometry, const POINT* pptOrg);
  10. // %%Function: EnumSublineCore
  11. // %%Contact: victork
  12. //
  13. /*
  14. * Enumerates subline calling enumeration callback for pens, methods for objects.
  15. * Provides geometry information if needed (Prepdisp should be done already in this case.)
  16. * Notice that auto-decimal tab is enumerated as a tab before Prepdisp and as a pen after.
  17. */
  18. LSERR EnumSublineCore(PLSSUBL plssubl, BOOL fReverse, BOOL fGeometry,
  19. const POINT* pptOrg, long upLeftIndent)
  20. {
  21. LSERR lserr;
  22. LSCP cpLim = plssubl->cpLimDisplay;
  23. PLSC plsc = plssubl->plsc;
  24. PLSDNODE pdn;
  25. POINTUV pt = {0,0}; // init'ed to get rid of assert.
  26. if (plssubl->plsdnFirst == NULL)
  27. {
  28. return lserrNone; // early exit for empty sublines
  29. }
  30. Assert(!fGeometry || plssubl->fDupInvalid == fFalse);
  31. if (fReverse)
  32. {
  33. pdn = plssubl->plsdnFirst;
  34. if (fGeometry)
  35. {
  36. pt.u = upLeftIndent;
  37. pt.v = 0;
  38. while (FDnodeBeforeCpLim(pdn, cpLim))
  39. {
  40. if (pdn->klsdn == klsdnReal)
  41. {
  42. pt.u += pdn->u.real.dup;
  43. }
  44. else
  45. {
  46. pt.u += pdn->u.pen.dup;
  47. pt.v += pdn->u.pen.dvp;
  48. }
  49. pdn = pdn->plsdnNext;
  50. }
  51. }
  52. pdn = plssubl->plsdnLastDisplay;
  53. while (pdn != NULL)
  54. {
  55. if (fGeometry)
  56. {
  57. // pt is now after pdn, downdate it to point before
  58. if (pdn->klsdn == klsdnReal)
  59. {
  60. pt.u -= pdn->u.real.dup;
  61. }
  62. else
  63. {
  64. pt.u -= pdn->u.pen.dup;
  65. pt.v -= pdn->u.pen.dvp;
  66. }
  67. }
  68. lserr = EnumerateDnode(plsc, pdn, pt, fReverse, fGeometry, pptOrg);
  69. if (lserr != lserrNone) return lserr;
  70. pdn = pdn->plsdnPrev;
  71. }
  72. }
  73. else
  74. {
  75. pdn = plssubl->plsdnFirst;
  76. pt.u = upLeftIndent;
  77. pt.v = 0;
  78. while (FDnodeBeforeCpLim(pdn, cpLim))
  79. {
  80. lserr = EnumerateDnode(plsc, pdn, pt, fReverse, fGeometry, pptOrg);
  81. if (lserr != lserrNone) return lserr;
  82. if (fGeometry)
  83. {
  84. if (pdn->klsdn == klsdnReal)
  85. {
  86. pt.u += pdn->u.real.dup;
  87. }
  88. else
  89. {
  90. pt.u += pdn->u.pen.dup;
  91. pt.v += pdn->u.pen.dvp;
  92. }
  93. }
  94. pdn = pdn->plsdnNext;
  95. }
  96. }
  97. return lserrNone;
  98. }
  99. // %%Function: EnumerateDnode
  100. // %%Contact: victork
  101. //
  102. static LSERR EnumerateDnode(PLSC plsc, PLSDNODE pdn, POINTUV pt, BOOL fReverse,
  103. BOOL fGeometry, const POINT* pptOrg)
  104. {
  105. POINTUV ptRaised;
  106. POINT ptXY;
  107. LSTFLOW lstflow = pdn->plssubl->lstflow;
  108. if (pdn->klsdn == klsdnReal)
  109. {
  110. if (pdn->u.real.pdobj == NULL)
  111. {
  112. // How could it happen:
  113. // we substitute autodecimal tab by a pen at PrepareLineForDisplay time.
  114. // Pens don't require plsrun, so we are fine at display.
  115. // If Client doesn't ask for geometry, the substitution might not happen
  116. Assert (!fGeometry);
  117. Assert (pdn->fTab);
  118. Assert(pdn->cpFirst < 0);
  119. Assert(plsc->lsadjustcontext.fAutodecimalTabPresent);
  120. return plsc->lscbk.pfnEnumPen(plsc->pols, fFalse, lstflow,
  121. fReverse, fFalse, &ptXY, 0, 0);
  122. }
  123. else
  124. {
  125. if (fGeometry)
  126. {
  127. ptRaised = pt;
  128. ptRaised.v += pdn->u.real.lschp.dvpPos;
  129. LsPointXYFromPointUV(pptOrg, lstflow, &ptRaised, &(ptXY));
  130. }
  131. return (*plsc->lsiobjcontext.rgobj[pdn->u.real.lschp.idObj].lsim.pfnEnum)
  132. (pdn->u.real.pdobj, pdn->u.real.plsrun, &(pdn->u.real.lschp), pdn->cpFirst, pdn->dcp,
  133. lstflow, fReverse, fGeometry, &ptXY, &pdn->u.real.objdim.heightsPres, pdn->u.real.dup);
  134. }
  135. }
  136. else
  137. {
  138. return plsc->lscbk.pfnEnumPen(plsc->pols, pdn->fBorderNode, lstflow,
  139. fReverse, fGeometry, &ptXY, pdn->u.pen.dup, pdn->u.pen.dvp);
  140. }
  141. }