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.

167 lines
4.8 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. RR_UNLINK = 8,
  34. RR_UNHIDE = 16,
  35. RR_NO_TRD_CHECK = 32,
  36. RR_NO_LP_CHECK = 64,
  37. RR_NO_CHECK_TABLE_SEL = 128,
  38. RR_NEW_CHARS = 256
  39. };
  40. extern BOOL IsWhiteSpace(unsigned ch);
  41. // ============================== CRchTxtPtr =====================================================
  42. // Keeps physical positions corresponding to text character position (cp)
  43. // within current text block, formatting runs, objects, unknown RTF runs,
  44. // and floating ranges.
  45. class CRchTxtPtr : public ITxNotify
  46. {
  47. public:
  48. #ifdef DEBUG
  49. BOOL Invariant( void ) const;
  50. int m_InvariantCheckInterval;
  51. LONG GetParaNumber() const;
  52. #endif // DEBUG
  53. CTxtPtr _rpTX; // rp in the plain text array
  54. CFormatRunPtr _rpCF; // rp in character format runs
  55. CFormatRunPtr _rpPF; // rp in paragraph format runs
  56. // Useful constructors
  57. CRchTxtPtr(CTxtEdit *ped);
  58. CRchTxtPtr(CTxtEdit *ped, LONG cp);
  59. CRchTxtPtr(const CRchTxtPtr& rtp);
  60. CRchTxtPtr(const CDisplay * pdp);
  61. virtual CRchTxtPtr& operator =(const CRchTxtPtr& rtp)
  62. {
  63. _rpTX._ped = rtp._rpTX._ped;
  64. SetCp(rtp.GetCp());
  65. return *this;
  66. }
  67. LONG Move(LONG cch);
  68. LONG AdvanceCRLF();
  69. LONG BackupCRLF(BOOL fDiacriticCheck = TRUE);
  70. #ifndef NOCOMPLEXSCRIPTS
  71. LONG SnapToCluster(INT iDirection = 0);
  72. #endif
  73. LONG SetCp( LONG cp);
  74. void BindToCp(LONG cp);
  75. void CheckFormatRuns();
  76. LONG GetCp() const { return _rpTX.GetCp(); }
  77. LONG GetTextLength() const { return _rpTX.GetTextLength(); }
  78. LONG GetObjectCount() const { return GetPed()->GetObjectCount(); }
  79. CTxtEdit *GetPed() const { return _rpTX._ped; }
  80. const WCHAR * GetPch(LONG &cchvalid) { return _rpTX.GetPch(cchvalid); }
  81. WCHAR GetChar() { return _rpTX.GetChar(); }
  82. WCHAR GetPrevChar() { return _rpTX.GetPrevChar(); }
  83. LONG GetPlainText(LONG cchBuff, WCHAR *pch, LONG cpMost, BOOL fTextize, BOOL fUseCRLF);
  84. void ValidateCp(LONG &cp) const;
  85. LONG GetCachFromCch(LONG cch);
  86. LONG GetCchFromCach(LONG cach);
  87. // Text manipulation methods
  88. // Range operations
  89. LONG ReplaceRange(LONG cchOld, LONG cchNew, WCHAR const *pch,
  90. IUndoBuilder *publdr, LONG iFormat,
  91. LONG *pcchMove = NULL, DWORD dwFlags = 0);
  92. BOOL ItemizeReplaceRange(LONG cchUpdate, LONG cchMove,
  93. IUndoBuilder *publdr, BOOL fUnicodeBidi = FALSE);
  94. BOOL ChangeCase(LONG cch, LONG Type, IUndoBuilder *publdr);
  95. LONG UnitCounter (LONG iUnit, LONG & cUnit, LONG cchMax, BOOL fNotAtBOL = FALSE);
  96. void ExtendFormattingCRLF();
  97. LONG ExpandRangeFormatting(LONG cchRange, LONG cchMove, LONG& cchAdvance);
  98. // Search and word-break support
  99. LONG FindText(LONG cpMax, DWORD dwFlags, WCHAR const *pch,
  100. LONG cchToFind);
  101. LONG FindWordBreak(INT action, LONG cpMost = -1);
  102. // Text-run management
  103. LONG GetIchRunCF();
  104. LONG GetIchRunPF();
  105. LONG GetCchRunCF();
  106. LONG GetCchLeftRunCF();
  107. LONG GetCchLeftRunPF();
  108. // Character & paragraph format retrieval
  109. const CCharFormat* GetCF() const;
  110. const CParaFormat* GetPF() const;
  111. LONG Get_iCF(); //@cmember Get CF index
  112. LONG Get_iPF(); //@cmember Get PF index
  113. BOOL IsCollapsed() const {return (GetPF()->_wEffects & PFE_COLLAPSED) != 0;}
  114. BOOL IsHidden() const {return (GetCF()->_dwEffects & CFE_HIDDEN) != 0;}
  115. BOOL InTable() const {return (GetPF()->_wEffects & PFE_TABLE) != 0;}
  116. BOOL IsParaRTL() const {return (GetPF()->_wEffects & PFE_RTLPARA) != 0;}
  117. // ITxNotify methods
  118. virtual void OnPreReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  119. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData ) { ; }
  120. virtual void OnPostReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  121. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData ) { ; }
  122. virtual void Zombie();
  123. BOOL Check_rpCF();
  124. BOOL Check_rpPF();
  125. protected:
  126. void InitRunPtrs();
  127. BOOL IsRich();
  128. bool fUseUIFont() const {return GetPed()->fUseUIFont();}
  129. BOOL IsInOutlineView() const {return GetPed()->IsInOutlineView();}
  130. void SetRunPtrs(LONG cp, LONG cpFrom);
  131. private:
  132. LONG ReplaceRangeFormatting(LONG cchOld, LONG cchNew, LONG iFormat,
  133. IUndoBuilder *publdr,
  134. IAntiEvent **ppaeCF, IAntiEvent **ppaePF,
  135. LONG cchMove, LONG cchPrevEOP, LONG cchNextEOP,
  136. LONG cchSaveBefore = 0, LONG cchSaveAfter = 0);
  137. };
  138. #endif