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.

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