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.

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