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.

158 lines
4.6 KiB

  1. /*
  2. * _RTEXT.H
  3. *
  4. * Purpose:
  5. * Base classes for rich-text manipulation
  6. *
  7. * Authors:
  8. * Original RichEdit code: David R. Fulmer
  9. * Christian Fortini
  10. * Murray Sargent
  11. *
  12. */
  13. #ifndef _RTEXT_H
  14. #define _RTEXT_H
  15. #include "_edit.h"
  16. #include "_array.h"
  17. #include "_doc.h"
  18. #include "_text.h"
  19. #include "_runptr.h"
  20. #include "_frunptr.h"
  21. #include "_notmgr.h"
  22. //#pragma warning(disable: 4250)
  23. #define yHeightCharMost 32760
  24. class CTxtEdit;
  25. class CTxtRange;
  26. class CRchTxtPtr;
  27. // ReplaceRange's flags
  28. enum
  29. {
  30. RR_ITMZ_NOUNICODEBIDI = 0,
  31. RR_ITMZ_UNICODEBIDI = 1,
  32. RR_ITMZ_NONE = 2,
  33. //the following bits should be exclusive
  34. RR_NO_EOR_CHECK = 8 //flag indicating not to perform end-of-row check,
  35. };
  36. extern BOOL IsWhiteSpace(unsigned ch);
  37. // ============================== CRchTxtPtr =====================================================
  38. // Keeps physical positions corresponding to text character position (cp)
  39. // within current text block, formatting runs, objects, unknown RTF runs,
  40. // and floating ranges.
  41. class CRchTxtPtr : public ITxNotify
  42. {
  43. public:
  44. #ifdef DEBUG
  45. BOOL Invariant( void ) const;
  46. int m_InvariantCheckInterval;
  47. #endif // DEBUG
  48. CTxtPtr _rpTX; // rp in the plain text array
  49. CFormatRunPtr _rpCF; // rp in character format runs
  50. CFormatRunPtr _rpPF; // rp in paragraph format runs
  51. // Useful constructors
  52. CRchTxtPtr(CTxtEdit *ped);
  53. CRchTxtPtr(CTxtEdit *ped, LONG cp);
  54. CRchTxtPtr(const CRchTxtPtr& rtp);
  55. CRchTxtPtr(const CDisplay * pdp);
  56. virtual CRchTxtPtr& operator =(const CRchTxtPtr& rtp)
  57. {
  58. _rpTX._ped = rtp._rpTX._ped;
  59. SetCp(rtp.GetCp());
  60. return *this;
  61. }
  62. LONG Advance(LONG cch);
  63. LONG AdvanceCRLF();
  64. LONG BackupCRLF(BOOL fDiacriticCheck = TRUE);
  65. LONG SnapToCluster(INT iDirection = 0);
  66. LONG SetCp( LONG cp);
  67. void BindToCp(LONG cp);
  68. void CheckFormatRuns();
  69. LONG GetCp() const { return _rpTX.GetCp(); }
  70. LONG GetTextLength() const { return _rpTX.GetTextLength(); }
  71. LONG GetObjectCount() const { return GetPed()->GetObjectCount(); }
  72. CTxtEdit *GetPed() const { return _rpTX._ped; }
  73. const TCHAR * GetPch(LONG &cchvalid) { return _rpTX.GetPch(cchvalid); }
  74. TCHAR GetChar() { return _rpTX.GetChar(); }
  75. TCHAR GetPrevChar() { return _rpTX.GetPrevChar(); }
  76. void ValidateCp(LONG &cp) const;
  77. LONG GetParaNumber() const;
  78. LONG GetCachFromCch(LONG cch);
  79. LONG GetCchFromCach(LONG cach);
  80. // Text manipulation methods
  81. // Range operations
  82. LONG ReplaceRange(LONG cchOld, LONG cchNew, TCHAR const *pch,
  83. IUndoBuilder *publdr, LONG iFormat,
  84. LONG *pcchMove = NULL, DWORD dwFlags = 0);
  85. BOOL ItemizeReplaceRange(LONG cchUpdate, LONG cchMove,
  86. IUndoBuilder *publdr, BOOL fUnicodeBidi = FALSE);
  87. BOOL ChangeCase(LONG cch, LONG Type, IUndoBuilder *publdr);
  88. LONG UnitCounter (LONG iUnit, LONG & cUnit, LONG cchMax);
  89. void ExtendFormattingCRLF();
  90. LONG ExpandRangeFormatting(LONG cchRange, LONG cchMove, LONG& cchAdvance);
  91. // Search and word-break support
  92. LONG FindText(LONG cpMax, DWORD dwFlags, TCHAR const *pch,
  93. LONG cchToFind);
  94. LONG FindWordBreak(INT action, LONG cpMost = -1);
  95. // Text-run management
  96. LONG GetIchRunCF();
  97. LONG GetIchRunPF();
  98. LONG GetCchRunCF();
  99. LONG GetCchLeftRunCF();
  100. LONG GetCchLeftRunPF();
  101. // Character & paragraph format retrieval
  102. const CCharFormat* GetCF() const;
  103. const CParaFormat* GetPF() const;
  104. BOOL IsCollapsed() const {return (GetPF()->_wEffects & PFE_COLLAPSED) != 0;}
  105. BOOL IsHidden() const {return (GetCF()->_dwEffects & CFE_HIDDEN) != 0;}
  106. BOOL InTable() const {return (GetPF()->_wEffects & PFE_TABLE) != 0;}
  107. BOOL IsParaRTL() const {return (GetPF()->_wEffects & PFE_RTLPARA) != 0;}
  108. // ITxNotify methods
  109. virtual void OnPreReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  110. LONG cpFormatMin, LONG cpFormatMax) { ; }
  111. virtual void OnPostReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  112. LONG cpFormatMin, LONG cpFormatMax) { ; }
  113. virtual void Zombie();
  114. BOOL Check_rpCF();
  115. BOOL Check_rpPF();
  116. protected:
  117. BOOL AdvanceRunPtrs(LONG cp);
  118. void InitRunPtrs();
  119. BOOL IsRich();
  120. bool fUseUIFont() const {return GetPed()->fUseUIFont();}
  121. BOOL IsInOutlineView() const {return GetPed()->IsInOutlineView();}
  122. void SetRunPtrs(LONG cp, LONG cpFrom);
  123. private:
  124. LONG ReplaceRangeFormatting(LONG cchOld, LONG cchNew, LONG iFormat,
  125. IUndoBuilder *publdr,
  126. IAntiEvent **ppaeCF, IAntiEvent **ppaePF,
  127. LONG cchMove, LONG cchPrevEOP, LONG cchNextEOP,
  128. LONG cchSaveBefore = 0, LONG cchSaveAfter = 0);
  129. };
  130. #endif