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.

240 lines
7.9 KiB

  1. /*
  2. * @doc
  3. *
  4. * @module _tomfmt.h -- CTxtFont and CTxtPara Classes |
  5. *
  6. * This class implements the TOM ITextFont and ITextPara interfaces
  7. *
  8. * Author: <nl>
  9. * Murray Sargent
  10. *
  11. * Copyright (c) 1995-1998, Microsoft Corporation. All rights reserved.
  12. */
  13. #ifndef _tomformat_H
  14. #define _tomformat_H
  15. #include "_range.h"
  16. extern const BYTE g_rgREtoTOMAlign[];
  17. // CTxtFormat: base class for CTxtFont and CTxtPara
  18. class CTxtFormat
  19. {
  20. protected:
  21. CTxtFormat(CTxtRange *prg);
  22. ~CTxtFormat();
  23. long _cRefs;
  24. CTxtRange * _prg;
  25. HRESULT CanChange(long *pBool, BOOL fPara);
  26. HRESULT GetParameter (long *pParm, DWORD dwMask, long Type, long *pValue);
  27. HRESULT SetParameter (long *pParm, long Type, long Value);
  28. HRESULT IsTrue (BOOL f, long *pB);
  29. BOOL IsZombie() {return _prg && _prg->IsZombie();}
  30. };
  31. class CTxtFont : public ITextFont, CTxtFormat
  32. {
  33. friend CTxtRange;
  34. CCharFormat _CF;
  35. DWORD _dwMask; // CHARFORMAT2 mask
  36. union
  37. {
  38. DWORD _dwFlags; // All together now
  39. struct
  40. {
  41. DWORD _fApplyLater : 1; // Delay call to _prg->CharFormatSetter()
  42. DWORD _fCacheParms : 1; // Update _CF now but not on GetXs
  43. };
  44. };
  45. public:
  46. CTxtFont(CTxtRange *prg);
  47. // IUnknown methods
  48. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  49. STDMETHOD_(ULONG, AddRef)();
  50. STDMETHOD_(ULONG, Release)();
  51. // IDispatch methods
  52. STDMETHODIMP GetTypeInfoCount(UINT * pctinfo);
  53. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo ** pptinfo);
  54. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR ** rgszNames, UINT cNames,
  55. LCID lcid, DISPID * rgdispid) ;
  56. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
  57. DISPPARAMS * pdispparams, VARIANT * pvarResult,
  58. EXCEPINFO * pexcepinfo, UINT * puArgErr) ;
  59. // ITextFont methods
  60. STDMETHODIMP GetDuplicate(ITextFont **ppFont);
  61. STDMETHODIMP SetDuplicate(ITextFont *pFont);
  62. STDMETHODIMP CanChange(long *pB);
  63. STDMETHODIMP IsEqual(ITextFont *pFont, long *pB);
  64. STDMETHODIMP Reset(long Value);
  65. STDMETHODIMP GetStyle(long *pValue);
  66. STDMETHODIMP SetStyle(long Value);
  67. STDMETHODIMP GetAllCaps(long *pValue);
  68. STDMETHODIMP SetAllCaps(long Value);
  69. STDMETHODIMP GetAnimation(long *pValue);
  70. STDMETHODIMP SetAnimation(long Value);
  71. STDMETHODIMP GetBackColor(long *pValue);
  72. STDMETHODIMP SetBackColor(long Value);
  73. STDMETHODIMP GetBold(long *pValue);
  74. STDMETHODIMP SetBold(long Value);
  75. STDMETHODIMP GetEmboss(long *pValue);
  76. STDMETHODIMP SetEmboss(long Value);
  77. STDMETHODIMP GetForeColor(long *pValue);
  78. STDMETHODIMP SetForeColor(long Value);
  79. STDMETHODIMP GetHidden(long *pValue);
  80. STDMETHODIMP SetHidden(long Value);
  81. STDMETHODIMP GetEngrave(long *pValue);
  82. STDMETHODIMP SetEngrave(long Value);
  83. STDMETHODIMP GetItalic(long *pValue);
  84. STDMETHODIMP SetItalic(long Value);
  85. STDMETHODIMP GetKerning(float *pValue);
  86. STDMETHODIMP SetKerning(float Value);
  87. STDMETHODIMP GetLanguageID(long *pValue);
  88. STDMETHODIMP SetLanguageID(long Value);
  89. STDMETHODIMP GetName(BSTR *pbstr);
  90. STDMETHODIMP SetName(BSTR bstr);
  91. STDMETHODIMP GetOutline(long *pValue);
  92. STDMETHODIMP SetOutline(long Value);
  93. STDMETHODIMP GetPosition(float *pValue);
  94. STDMETHODIMP SetPosition(float Value);
  95. STDMETHODIMP GetProtected(long *pValue);
  96. STDMETHODIMP SetProtected(long Value);
  97. STDMETHODIMP GetShadow(long *pValue);
  98. STDMETHODIMP SetShadow(long Value);
  99. STDMETHODIMP GetSize(float *pValue);
  100. STDMETHODIMP SetSize(float Value);
  101. STDMETHODIMP GetSmallCaps(long *pValue);
  102. STDMETHODIMP SetSmallCaps(long Value);
  103. STDMETHODIMP GetSpacing(float *pValue);
  104. STDMETHODIMP SetSpacing(float Value);
  105. STDMETHODIMP GetStrikeThrough(long *pValue);
  106. STDMETHODIMP SetStrikeThrough(long Value);
  107. STDMETHODIMP GetSubscript(long *pValue);
  108. STDMETHODIMP SetSubscript(long Value);
  109. STDMETHODIMP GetSuperscript(long *pValue);
  110. STDMETHODIMP SetSuperscript(long Value);
  111. STDMETHODIMP GetUnderline(long *pValue);
  112. STDMETHODIMP SetUnderline(long Value);
  113. STDMETHODIMP GetWeight(long *pValue);
  114. STDMETHODIMP SetWeight(long Value);
  115. //@access Private ITextFont helper methods
  116. private:
  117. HRESULT GetParameter (long *pParm, DWORD dwMask, long Type, long *pValue);
  118. HRESULT SetParameter (long *pParm, DWORD dwMask, long Type, long Value);
  119. HRESULT EffectGetter (long *ptomBool, DWORD dwMask);
  120. HRESULT EffectSetter (long Value, DWORD dwMask, DWORD dwEffect);
  121. HRESULT FormatSetter (DWORD dwMask);
  122. HRESULT UpdateFormat ();
  123. };
  124. class CTxtPara : public ITextPara, CTxtFormat
  125. {
  126. friend CTxtRange;
  127. CParaFormat _PF;
  128. DWORD _dwMask; // PARAFORMAT2 mask
  129. union
  130. {
  131. DWORD _dwFlags; // All together now
  132. struct
  133. {
  134. DWORD _fApplyLater : 1; // Delay call to _prg->ParaFormatSetter()
  135. DWORD _fCacheParms : 1; // Update _PF now but not on GetXs
  136. };
  137. };
  138. LONG _rgxTabs[MAX_TAB_STOPS];// Place to store tabs till committed
  139. public:
  140. CTxtPara(CTxtRange *prg);
  141. ~CTxtPara();
  142. // IUnknown methods
  143. STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  144. STDMETHOD_(ULONG, AddRef)();
  145. STDMETHOD_(ULONG, Release)();
  146. // IDispatch methods
  147. STDMETHODIMP GetTypeInfoCount(UINT * pctinfo);
  148. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo ** pptinfo);
  149. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR ** rgszNames, UINT cNames,
  150. LCID lcid, DISPID * rgdispid) ;
  151. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
  152. DISPPARAMS * pdispparams, VARIANT * pvarResult,
  153. EXCEPINFO * pexcepinfo, UINT * puArgErr) ;
  154. // ITextPara methods
  155. STDMETHODIMP GetDuplicate(ITextPara **ppPara);
  156. STDMETHODIMP SetDuplicate(ITextPara *pPara);
  157. STDMETHODIMP CanChange(long *pB);
  158. STDMETHODIMP IsEqual(ITextPara *pPara, long *pB);
  159. STDMETHODIMP Reset(long Value);
  160. STDMETHODIMP GetStyle(long *pValue);
  161. STDMETHODIMP SetStyle(long Value);
  162. STDMETHODIMP GetAlignment(long *pValue);
  163. STDMETHODIMP SetAlignment(long Value);
  164. STDMETHODIMP GetHyphenation(long *pValue);
  165. STDMETHODIMP SetHyphenation(long Value);
  166. STDMETHODIMP GetFirstLineIndent(float *pValue);
  167. STDMETHODIMP GetKeepTogether(long *pValue);
  168. STDMETHODIMP SetKeepTogether(long Value);
  169. STDMETHODIMP GetKeepWithNext(long *pValue);
  170. STDMETHODIMP SetKeepWithNext(long Value);
  171. STDMETHODIMP GetLeftIndent(float *pValue);
  172. STDMETHODIMP GetLineSpacing(float *pValue);
  173. STDMETHODIMP GetLineSpacingRule(long *pValue);
  174. STDMETHODIMP GetListAlignment(long * pValue);
  175. STDMETHODIMP SetListAlignment(long Value);
  176. STDMETHODIMP GetListLevelIndex(long * pValue);
  177. STDMETHODIMP SetListLevelIndex(long Value);
  178. STDMETHODIMP GetListStart(long * pValue);
  179. STDMETHODIMP SetListStart(long Value);
  180. STDMETHODIMP GetListTab(float * pValue);
  181. STDMETHODIMP SetListTab(float Value);
  182. STDMETHODIMP GetListType(long *pValue);
  183. STDMETHODIMP SetListType(long Value);
  184. STDMETHODIMP GetNoLineNumber(long *pValue);
  185. STDMETHODIMP SetNoLineNumber(long Value);
  186. STDMETHODIMP GetPageBreakBefore(long *pValue);
  187. STDMETHODIMP SetPageBreakBefore(long Value);
  188. STDMETHODIMP GetRightIndent(float *pValue);
  189. STDMETHODIMP SetRightIndent(float Value);
  190. STDMETHODIMP SetIndents(float StartIndent, float LeftIndent, float RightIndent);
  191. STDMETHODIMP SetLineSpacing(long LineSpacingRule, float LineSpacing);
  192. STDMETHODIMP GetSpaceAfter(float *pValue);
  193. STDMETHODIMP SetSpaceAfter(float Value);
  194. STDMETHODIMP GetSpaceBefore(float *pValue);
  195. STDMETHODIMP SetSpaceBefore(float Value);
  196. STDMETHODIMP GetWidowControl(long *pValue);
  197. STDMETHODIMP SetWidowControl(long Value);
  198. STDMETHODIMP GetTabCount(long *pValue);
  199. STDMETHODIMP AddTab(float tpPos, long tbAlign, long tbLeader);
  200. STDMETHODIMP ClearAllTabs();
  201. STDMETHODIMP DeleteTab(float tbPos);
  202. STDMETHODIMP GetTab(long iTab, float *ptbPos, long *ptbAlign, long *ptbLeader);
  203. HRESULT FormatSetter (DWORD dwMask);
  204. //@access Private ITextPara helper methods
  205. private:
  206. HRESULT GetParameter (long *pParm, DWORD dwMask, long Type, long *pValue);
  207. HRESULT SetParameter (long *pParm, DWORD dwMask, long Type, long Value);
  208. HRESULT EffectGetter (long * ptomBool, DWORD dwMask);
  209. HRESULT EffectSetter (long Value, DWORD dwMask);
  210. HRESULT UpdateFormat ();
  211. void CheckTabsAddRef();
  212. };
  213. #endif