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.

190 lines
5.5 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _FRUNPTR.H -- CFormatRunPtr class declaration |
  5. *
  6. * Original Authors: <nl>
  7. * Original RichEdit code: David R. Fulmer <nl>
  8. * Christian Fortini <nl>
  9. * Murray Sargent <nl>
  10. *
  11. * History: <nl>
  12. * 06-25-95 alexgo cleanup and commenting
  13. *
  14. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  15. */
  16. #ifndef _FRUNPTR_H
  17. #define _FRUNPTR_H
  18. #include "_array.h"
  19. #include "_text.h"
  20. #include "_runptr.h"
  21. #include "_format.h"
  22. #define CharFormat 0
  23. #define ParaFormat 1
  24. typedef enum {
  25. IGNORE_CURRENT_FONT = 0,
  26. MATCH_CURRENT_CHARSET = 1,
  27. MATCH_FONT_SIG = 2,
  28. MATCH_ASCII = 4,
  29. GET_HEIGHT_ONLY = 8,
  30. } FONT_MATCHING;
  31. /*
  32. * CFormatRunPtr
  33. *
  34. * @class A Run pointer over an array of CFormatRun structures.
  35. * This pointer understands how to add remove character/paragraph
  36. * formatting
  37. *
  38. * @base public | CRunPtr<lt>CFormatRun<gt>
  39. *
  40. * @devnote The format run pointer has one extra interesting state
  41. * transistion beyond the normal CRunPtrBase transistions.
  42. *
  43. * If this run pointer is in the NULL state, then InitRuns may
  44. * be used to create or fetch the correct run array for the
  45. * run pointer. Note that if a run array is already allocated
  46. * it will be simply be fetched and used. This allows us to
  47. * treat unitialized run pointers the same as run pointers to
  48. * an uninitialized document.
  49. * @xref See also <mf CFormatRunPtr::InitRuns>
  50. */
  51. class CFormatRunPtr : public CRunPtr<CFormatRun>
  52. {
  53. friend class CRchTxtPtr;
  54. friend class CTxtRange;
  55. friend class CReplaceFormattingAE;
  56. friend class CUniscribe;
  57. //@access Public Methods
  58. public:
  59. #ifdef DEBUG
  60. BOOL Invariant(void) const; //@cmember Invariant tests
  61. #endif
  62. CFormatRunPtr(const CFormatRunPtr &rp) //@cmember Copy Constructor
  63. : CRunPtr<CFormatRun>((CRunPtrBase&)rp) {}
  64. CFormatRunPtr(CFormatRuns *pfr) //@cmember Constructor
  65. : CRunPtr<CFormatRun>((CRunArray *)pfr) {}
  66. short GetFormat() const; //@cmember Get current format index
  67. void SetLevel (CBiDiLevel& level); //@cmember Set run's embedding level
  68. BYTE GetLevel (CBiDiLevel* pLevel = NULL);//@cmember Get run's embedding level
  69. BOOL SameLevel (CFormatRunPtr* prp)
  70. {
  71. return !(IsValid() && GetRun(0)->_level._value != prp->GetRun(0)->_level._value);
  72. }
  73. BOOL SameLevel (BYTE bLevel)
  74. {
  75. return !(IsValid() && GetRun(0)->_level._value != bLevel);
  76. }
  77. //@access Private Methods
  78. private:
  79. //@cmember Format Run Array management
  80. BOOL InitRuns(LONG ich, LONG cch, CFormatRuns **ppfrs);
  81. //@cmember Formatting replacement
  82. void Delete(LONG cch, IFormatCache *pf, LONG cchMove);
  83. //@cmember Formatting insertion
  84. LONG InsertFormat(LONG cch, LONG iformat, IFormatCache *pf);
  85. //@cmember Merge two adjacent formatting runs
  86. void MergeRuns(LONG iRun, IFormatCache *pf);
  87. //@cmember Split run
  88. void SplitFormat(IFormatCache *pf);
  89. //@cmember Sets the format for the current run
  90. LONG SetFormat(LONG ifmt, LONG cch, IFormatCache *pf, CBiDiLevel* pLevel = NULL);
  91. //@cmember Extends formatting from previous run
  92. void AdjustFormatting(LONG cch, IFormatCache *pf);
  93. //@cmember Remove <p cRun>
  94. void Remove (LONG cRun, IFormatCache *pf);
  95. };
  96. enum MASKOP
  97. {
  98. MO_OR = 0,
  99. MO_AND,
  100. MO_EXACT
  101. };
  102. class CTxtEdit;
  103. class CCFRunPtr : public CFormatRunPtr
  104. {
  105. friend class CRchTxtPtr;
  106. friend class CTxtRange;
  107. public:
  108. CTxtEdit *_ped;
  109. CCFRunPtr(const CRchTxtPtr &rtp); //@cmember Copy Constructor
  110. CCFRunPtr(const CFormatRunPtr &rp, CTxtEdit *ped);
  111. LONG CountAttributes(LONG cUnit, LONG cchMax, LONG cp, LONG cchText, LONG Unit)
  112. {return 0;}
  113. BOOL IsHidden() {return IsMask(CFE_HIDDEN);}
  114. BOOL IsLinkProtected() {return IsMask(CFE_LINKPROTECTED);}
  115. BOOL IsMask(DWORD dwMask, MASKOP mo = MO_OR);
  116. BOOL IsInHidden(); //@cmember True if in hidden text
  117. LONG FindUnhidden(); //@cmember Find nearest unhidden CF
  118. LONG FindUnhiddenBackward(); //@cmember Find previous unhidden CF
  119. LONG FindUnhiddenForward(); //@cmember Find previous unhidden CF
  120. const CCharFormat * GetCF()
  121. {return _ped->GetCharFormat(GetFormat());}
  122. DWORD GetEffects()
  123. {return GetCF()->_dwEffects;}
  124. int MatchFormatSignature(const CCharFormat* pCF, int iCharRep, int fMatchCurrent, QWORD* pqwFontSig = NULL);
  125. //@member Get font info for code page
  126. bool GetPreferredFontInfo(
  127. BYTE iCharRep,
  128. BYTE & iCharRepRet,
  129. SHORT & iFont,
  130. SHORT & yHeight,
  131. BYTE & bPitchAndFamily,
  132. int iFormat,
  133. int iMatchCurrent = MATCH_FONT_SIG,
  134. int *piFormat = NULL
  135. );
  136. };
  137. class CPFRunPtr : public CFormatRunPtr
  138. {
  139. friend class CRchTxtPtr;
  140. friend class CTxtRange;
  141. public:
  142. CTxtEdit *_ped;
  143. CPFRunPtr(const CRchTxtPtr &rtp); //@cmember Copy Constructor
  144. //@cmember Find Heading before cpMost
  145. LONG FindHeading(LONG cch, LONG& lHeading);
  146. BOOL FindRowEnd(LONG TableLevel);//@cmember Move past row end
  147. BOOL InTable(); //@cmember True if paraformat is in table
  148. BOOL IsCollapsed(); //@cmember True if paraformat is collapsed
  149. BOOL IsTableRowDelimiter();//@cmember True if paraformat is TableRowDelimeter
  150. LONG FindExpanded(); //@cmember Find nearest expanded PF
  151. LONG FindExpandedBackward();//@cmember Find previous expanded PF
  152. LONG FindExpandedForward();//@cmember Find next expanded PF
  153. const CParaFormat * GetPF()
  154. {return _ped->GetParaFormat(GetFormat());}
  155. LONG GetOutlineLevel(); //@cmember Get outline level
  156. LONG GetStyle(); //@cmember Get style
  157. LONG GetMinTableLevel(LONG cch);//@cmember Get min tbl lvl in cch chars
  158. LONG GetTableLevel(); //@cmember Get table level at this ptr
  159. BOOL ResolveRowStartPF();//@cmember Resolve table row start PF
  160. };
  161. #endif