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.

299 lines
10 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _COLEOBJ.H The OLE Object management class |
  5. *
  6. * Author: alexgo 10/24/95
  7. *
  8. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  9. */
  10. #ifndef __COLEOBJ_H__
  11. #define __COLEOBJ_H__
  12. #ifndef NOINKOBJECT
  13. #include "HWXInk.h"
  14. #endif
  15. #include "_notmgr.h"
  16. #ifndef NOLINESERVICES
  17. extern "C" {
  18. #include "plsdnode.h"
  19. }
  20. #endif
  21. class CDisplay;
  22. class CDevDesc;
  23. class CTxtEdit;
  24. class IUndoBuilder;
  25. /*
  26. * COleObject
  27. *
  28. * @class This class manages an individual OLE object embedding.
  29. *
  30. */
  31. class COleObject : public IOleClientSite, public IOleInPlaceSite,
  32. public IAdviseSink, public CSafeRefCount, public ITxNotify
  33. {
  34. //@access Public methods
  35. public:
  36. //
  37. // IUnknown methods
  38. //
  39. STDMETHOD(QueryInterface)(REFIID riid, void **pv);
  40. STDMETHOD_(ULONG, AddRef)(void);
  41. STDMETHOD_(ULONG, Release)(void);
  42. //
  43. // IOleClientSite methods
  44. //
  45. STDMETHOD(SaveObject)(void);
  46. STDMETHOD(GetMoniker)(DWORD dwAssign, DWORD dwWhichMoniker,
  47. IMoniker **ppmk);
  48. STDMETHOD(GetContainer)(IOleContainer **ppContainer);
  49. STDMETHOD(ShowObject)(void);
  50. STDMETHOD(OnShowWindow)(BOOL fShow);
  51. STDMETHOD(RequestNewObjectLayout)(void);
  52. //
  53. // IOleInPlaceSite methods
  54. //
  55. STDMETHOD(GetWindow)(HWND *phwnd);
  56. STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
  57. STDMETHOD(CanInPlaceActivate)(void);
  58. STDMETHOD(OnInPlaceActivate)(void);
  59. STDMETHOD(OnUIActivate)(void);
  60. STDMETHOD(GetWindowContext)(IOleInPlaceFrame **ppFrame,
  61. IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
  62. LPRECT lprcClipRect,
  63. LPOLEINPLACEFRAMEINFO lpFrameInfo);
  64. STDMETHOD(Scroll)(SIZE scrollExtant);
  65. STDMETHOD(OnUIDeactivate)(BOOL fUndoable);
  66. STDMETHOD(OnInPlaceDeactivate)(void);
  67. STDMETHOD(DiscardUndoState)(void);
  68. STDMETHOD(DeactivateAndUndo)(void);
  69. STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect);
  70. //
  71. // IAdviseSink methods
  72. //
  73. STDMETHOD_(void, OnDataChange)(FORMATETC *pfetc, STGMEDIUM *pmedium);
  74. STDMETHOD_(void, OnViewChange)(DWORD dwAspect, LONG lindex);
  75. STDMETHOD_(void, OnRename)(IMoniker *pmk);
  76. STDMETHOD_(void, OnSave)(void);
  77. STDMETHOD_(void, OnClose)(void);
  78. //
  79. // ITxNotify methods
  80. //
  81. virtual void OnPreReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  82. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData );
  83. virtual void OnPostReplaceRange( LONG cp, LONG cchDel, LONG cchNew,
  84. LONG cpFormatMin, LONG cpFormatMax, NOTIFY_DATA *pNotifyData );
  85. virtual void Zombie();
  86. //
  87. // internal public methods
  88. //
  89. COleObject(CTxtEdit *ped); //@cmember Constructor
  90. LONG GetCp() {return _cp;} //@cmember Get cp for this object
  91. CTxtEdit *GetPed() {return _ped;} //@cmember Get ped for this object
  92. //@cmember Fill out the REOBJECT struct
  93. HRESULT GetObjectData(REOBJECT *preobj, DWORD dwFlags);
  94. BOOL IsLink(); //@cmember returns TRUE if the object
  95. // is a link object.
  96. //@cmember Initialize from the given
  97. // object data
  98. HRESULT InitFromREOBJECT(LONG cp, REOBJECT *preobj);
  99. //@cmember Measures the object (no outgoing calls)
  100. void MeasureObj(long dvpInch, long dupInch, LONG & dup, LONG & dvpAscent,
  101. LONG & dvpDescent, SHORT dvpDescentFont, TFLOW tflow);
  102. //@cmember Draws the object
  103. void DrawObj(const CDisplay *pdp, long dypInch, long dxpInch, HDC hdc, const RECTUV *prcClip,
  104. BOOL fMetafile, POINTUV *ppt, LONG yBaselineLine, LONG yDescentMaxCur, TFLOW tflow);
  105. //@cmember Handle the object being
  106. // deleted from the backing store
  107. void Delete(IUndoBuilder *publdr);
  108. void Restore(); //@cmember restore an object into
  109. // the backing store
  110. //@cmember Force a close on the
  111. // object
  112. void Close(DWORD dwSaveOption);
  113. //@cmember Zombie the object.
  114. void MakeZombie(void);
  115. //@cmember Activate the object
  116. BOOL ActivateObj(UINT uiMsg, WPARAM wParam, LPARAM lParam);
  117. HRESULT DeActivateObj(void); //@cmember Aeactivate the object
  118. //@cmember Set individual selection
  119. //state of object
  120. void GetRectuv(RECTUV &rc);
  121. void FetchObjectExtents(void);//@cmember Gets the size of the object
  122. //@cmember return REO_SELECTED state
  123. BOOL FWrapTextAround(void) const {return (_pi.dwFlags & REO_WRAPTEXTAROUND) != 0;}
  124. BOOL FAlignToRight(void) const {return (_pi.dwFlags & REO_ALIGNTORIGHT) != 0;}
  125. BOOL GetREOSELECTED(void) {return (_pi.dwFlags & REO_SELECTED);}
  126. //@cmember set REO_SELECTED state
  127. void SetREOSELECTED(BOOL fSelect);
  128. //@cmember checks for hits on frame handles
  129. WCHAR* CheckForHandleHit(const POINTUV &pt, BOOL fLogical = FALSE);
  130. //@cmember handle object resize
  131. BOOL HandleResize(const POINT &pt);
  132. //@cmember sets object size
  133. void Resize(const SIZEUV &size, BOOL fCreateAntiEvent);
  134. //@cmember update _size
  135. void ResetSize(const SIZEUV &size)
  136. {_size = size;}
  137. //@cmember called when object position changes
  138. void OnReposition();
  139. //@cmember gets objects IUnknown
  140. IUnknown * GetIUnknown(void) {return _punkobj;}
  141. //@cmember converts to the specified class
  142. HRESULT Convert(REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew);
  143. //@cmember activate as the specified class
  144. HRESULT ActivateAs(REFCLSID rclsid, REFCLSID rclsidAs);
  145. //@cmember set aspect to use
  146. void SetDvaspect(DWORD dvaspect);
  147. //@cmember get current aspect
  148. DWORD GetDvaspect()
  149. { return _pi.dvaspect; }
  150. //@cmember see IPersistStore::HandsOffStorage
  151. void HandsOffStorage(void);
  152. //@cmember see IPersistStore::SaveCompleted
  153. void SaveCompleted(LPSTORAGE lpstg);
  154. //@cmember set REO_LINKAVAILABLE flag
  155. HRESULT SetLinkAvailable(BOOL fAvailable);
  156. //@cmember Used for textize support
  157. LONG WriteTextInfoToEditStream(EDITSTREAM *pes, UINT CodePage);
  158. void SetHdata(HGLOBAL hg) {_hdata = hg;} //@cmember get the _hdata member
  159. void GetSize(SIZEUV &size) {size = _size;}
  160. //&cmember gets the _size member
  161. DWORD GetFlags() {return _pi.dwFlags;}
  162. //&cmember gets the _sizel member
  163. DWORD GetUser() {return _pi.dwUser;}
  164. //&cmember gets the _sizel member
  165. DWORD GetAspect() {return _pi.dvaspect;}
  166. //&cmember gets the _sizel member
  167. // For internal use without reentering undo system.
  168. STDMETHOD(SafeSaveObject)(void);
  169. HGLOBAL GetHdata() {return _hdata;}
  170. struct ImageInfo
  171. {
  172. LONG xScale, yScale; // @field scaling percentage along axes
  173. SHORT xExtGoal, yExtGoal; // @field desired dimensions in twips for pictures
  174. SHORT cBytesPerLine; // @field # bytes per raster line, if bitmap
  175. };
  176. //@cmember set the _pimageinfo member
  177. void SetImageInfo(struct ImageInfo *pim) {_pimageinfo = pim;}
  178. //@cmember get the _pimageinfo member
  179. ImageInfo *GetImageInfo() {return _pimageinfo;}
  180. #ifdef DEBUG
  181. void DbgDump(DWORD id);
  182. #endif
  183. BOOL GetViewChanged() {return _fViewChange;}
  184. void ResetViewChanged() {_fViewChange = FALSE;}
  185. //@access Private methods and data
  186. private:
  187. virtual ~COleObject(); //@cmember Destructor
  188. void SavePrivateState(void);//@cmember Saves private information
  189. HRESULT ConnectObject(void);//@cmember setup advises, etc.
  190. void DisconnectObject(void);//@cmember tear down advises, etc.
  191. void CleanupState(void); //@cmember cleans up our member data, etc.
  192. //@cmember draws frame around object
  193. void DrawFrame(const CDisplay *pdp, HDC hdc, RECT* prc);
  194. //@cmember helper to draw frame handles
  195. void DrawHandle(HDC hdc, int x, int y);
  196. //@cmember helper to check for hit on a handle
  197. void CreateDib(HDC hdc);
  198. //@cmember helper to create DIB for WinCE bitmaps
  199. void DrawDib(HDC hdc, RECT *prc);
  200. //@cmember helper to draw WinCE bitmaps
  201. BOOL InHandle(int up, int vp, const POINTUV &pt);
  202. //@cmember to restablish rectangle position
  203. enum { SE_NOTACTIVATING, SE_ACTIVATING }; // used by SetExtent to indicate
  204. // the context of the SetExtent call
  205. //@cmember Attempts to set object extents
  206. HRESULT SetExtent(int iActivating);
  207. CTxtEdit * _ped; //@cmember edit context for this object
  208. IUnknown * _punkobj; //@cmember pointer to the objects IUnknown.
  209. IStorage * _pstg; //@cmember storage for the object
  210. SIZEUV _size; //@cmember cached "real" size of the object
  211. LONG _cp; //@cmember position of this object
  212. DWORD _dwConn; //@cmember advise connection cookie
  213. HGLOBAL _hdata;
  214. HBITMAP _hdib;
  215. ImageInfo * _pimageinfo;
  216. struct PersistedInfo
  217. {
  218. DWORD dwFlags; //@cmember see richole.h
  219. DWORD dwUser; //@cmember user defined
  220. DWORD dvaspect; //@cmember from the DVASPECT enumeration
  221. };
  222. PersistedInfo _pi;
  223. SHORT _dxyFrame; //@cmember Object frame width
  224. WORD _fInPlaceActive:1; //@cmember inplace active?
  225. WORD _fInUndo:1; //@cmember in the undo stack?
  226. WORD _fIsWordArt2:1; //@cmember Is this object a WordArt 2.0
  227. // object? (need to do hacks for it)
  228. WORD _fIsPaintBrush:1; //@cmember Is this object a PaintBrush
  229. // object? (need to do hacks for it)
  230. WORD _fPBUseLocalSize:1;
  231. //@cmember Signals that SetExtent
  232. // for a PaintBrush object failed and that
  233. // _size is an accurate indication of object size
  234. WORD _fDraw:1; //@cmember Should object be drawn?
  235. WORD _fSetExtent:1; //@cmember Does SetExtent need to be called
  236. // when activating.
  237. WORD _fDeactivateCalled:1;//@cmember Whether deactivate has been called.
  238. WORD _fAspectChanged:1; //@cmember Forces FetchObjectExtents to call through when aspect changes
  239. WORD _fViewChange:1; //@cmember flag to indicate size of object changed
  240. WORD _fActivateCalled:1; //@member Are we in the middle of the activation sequence?
  241. WORD _fIsInkObject:1; //@member Is this object a Ink Object
  242. #ifndef NOINKOBJECT
  243. public:
  244. ILineInfo *_pILineInfo; //@member Ink object ILineInfo
  245. BOOL IsInkObject() { return _fIsInkObject; };
  246. #endif
  247. #ifndef NOLINESERVICES
  248. public:
  249. PLSDNODE _plsdnTop; //@cmember Ptr to LS display node
  250. #endif
  251. //VikramM - hacks added for E-Book
  252. private:
  253. BOOL _fIsEBookImage; //@flags this is a ebook image that needs special treatment
  254. LPARAM _EBookImageID;
  255. SIZE _sizeEBookImage;
  256. public: //E-Book functions
  257. void IsEbookImage(BOOL fIs) { _fIsEBookImage = fIs; };
  258. void SetEBookImageID(LPARAM lParam) { _EBookImageID = lParam ; };
  259. void SetEBookImageSizeDP(SIZE size) {_sizeEBookImage = size; };
  260. };
  261. #endif // __COLEOBJ_H_