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.

393 lines
11 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // File: srs.hxx
  4. //
  5. // Contents: Class Definitions
  6. //
  7. // Classes: SRFactory
  8. // SRCtrl
  9. // SRInPlace
  10. // SRDV
  11. //
  12. //------------------------------------------------------------------------
  13. #ifndef __SRS_HXX
  14. #define __SRS_HXX
  15. //
  16. // Resource Identifiers:
  17. //
  18. // Our base id is 0, so our Class Descriptor resource IDs
  19. // are identical to the offsets
  20. //
  21. #define IDS_CLASSID IDOFF_CLASSID
  22. #define IDS_USERTYPEFULL IDOFF_USERTYPEFULL
  23. #define IDS_USERTYPESHORT IDOFF_USERTYPESHORT
  24. #define IDS_USERTYPEAPP IDOFF_USERTYPEAPP
  25. #define IDS_DOCFEXT IDOFF_DOCFEXT
  26. #define IDR_ICON IDOFF_ICON
  27. #define IDR_ACCELS IDOFF_ACCELS
  28. #define IDR_MENU IDOFF_MENU
  29. #define IDR_MGW IDOFF_MGW
  30. #define IDR_MISCSTATUS IDOFF_MISCSTATUS
  31. //
  32. // resource compiler not interested in the rest...
  33. //
  34. #ifndef RC_INVOKED
  35. #include "oleglue.h" // interface with soundrec C code
  36. //OLE2 clsid.
  37. DEFINE_OLEGUID(CLSID_SoundRec, 0x00020C01, 0, 0);
  38. #define CLSID_SOUNDREC CLSID_SoundRec
  39. //OLE1 clsid.
  40. DEFINE_OLEGUID(CLSID_Ole1SoundRec, 0x0003000D, 0, 0);
  41. #define CLSID_OLE1SOUNDREC CLSID_Ole1SoundRec
  42. //+---------------------------------------------------------------
  43. //
  44. // Class: SRFactory
  45. //
  46. // Purpose: Creates new objects
  47. //
  48. // Notes: This factory creates SRCtrl objects, which in turn
  49. // create the SRDV and SRInPlace subobjects.
  50. //
  51. //---------------------------------------------------------------
  52. class SRFactory: public StdClassFactory
  53. {
  54. public:
  55. STDMETHOD(CreateInstance) (LPUNKNOWN, REFIID, LPVOID FAR*);
  56. STDMETHOD(LockServer) (BOOL fLock);
  57. static BOOL Create(HINSTANCE hinst);
  58. BOOL Init(HINSTANCE hinst);
  59. ~SRFactory() { delete _pClass; }
  60. LPCLASSDESCRIPTOR _pClass;
  61. };
  62. //
  63. // forward declaration of classes
  64. //
  65. class SRCtrl;
  66. typedef SRCtrl FAR* LPSRCTRL;
  67. class SRInPlace;
  68. typedef SRInPlace FAR* LPSRINPLACE;
  69. class SRDV;
  70. typedef SRDV FAR* LPSRDV;
  71. class CXBag;
  72. typedef CXBag FAR* LPXBAG;
  73. //+---------------------------------------------------------------
  74. //
  75. // Class: SRCtrl
  76. //
  77. // Purpose: Manages the control aspect of server
  78. //
  79. // Notes: Our objects are composed of three subobjects:
  80. // a SRCtrl subobject, a SRDV subobject, and an
  81. // SRInPlace subobject. Each of these is derived from
  82. // a corresponding Srvr base class.
  83. //
  84. //---------------------------------------------------------------
  85. class SRCtrl: public SrvrCtrl
  86. {
  87. public:
  88. static BOOL ClassInit(LPCLASSDESCRIPTOR pClass);
  89. static HRESULT Create(LPUNKNOWN pUnkOuter, LPCLASSDESCRIPTOR pClass,
  90. LPUNKNOWN FAR* ppUnkCtrl, LPSRCTRL FAR* ppObj);
  91. static HRESULT DoPlay(LPVOID, LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
  92. static HRESULT DoShow(LPVOID, LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
  93. static HRESULT DoOpen(LPVOID, LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
  94. // we are an aggregatable object so we use a delegating IUnknown
  95. DECLARE_DELEGATING_IUNKNOWN(SRCtrl);
  96. STDMETHOD(GetMoniker) (DWORD dwAssign,
  97. DWORD dwWhichMoniker,
  98. LPMONIKER FAR* ppmk);
  99. STDMETHOD(IsUpToDate) (void);
  100. void GetHostNames(LPTSTR FAR* plpstrCntrApp, LPTSTR FAR* plpstrCntrObj);
  101. void Lock(void);
  102. void UnLock(void);
  103. void MarkAsLoaded(void);
  104. BOOL IsLoaded(void);
  105. //
  106. // base-class virtuals overridden to do additional,
  107. // server-specific processing
  108. //
  109. virtual HRESULT RunningToOpened();
  110. virtual HRESULT OpenedToRunning();
  111. virtual HRESULT PassiveToLoaded();
  112. virtual HRESULT LoadedToPassive();
  113. #ifdef WE_SUPPORT_INPLACE
  114. virtual HRESULT RunningToInPlace();
  115. virtual HRESULT InPlaceToRunning();
  116. virtual HRESULT UIActiveToInPlace();
  117. #endif //WE_SUPPORT_INPLACE
  118. protected:
  119. // constructors, initializers, and destructors
  120. SRCtrl(LPUNKNOWN pUnkOuter);
  121. HRESULT Init(LPCLASSDESCRIPTOR pClass);
  122. virtual ~SRCtrl(void);
  123. DECLARE_PRIVATE_IUNKNOWN(SRCtrl);
  124. LPUNKNOWN _pDVCtrlUnk; // controlling unknown for DV subobj
  125. LPUNKNOWN _pIPCtrlUnk; // controlling unknown for InPlace subobj
  126. int _cLock;
  127. BOOL _fLoaded; // loaded.
  128. };
  129. //+---------------------------------------------------------------
  130. //
  131. // Class: SRHeader
  132. //
  133. // Purpose: Document information placed at the head of the
  134. // documents contents stream
  135. //
  136. //---------------------------------------------------------------
  137. class SRHeader
  138. {
  139. public:
  140. SRHeader();
  141. HRESULT Read(LPSTREAM pStrm);
  142. HRESULT Write(LPSTREAM pStrm);
  143. SIZEL _sizel; // our size (HIMETRIC)
  144. DWORD _dwNative; // size of native data
  145. //
  146. // Our native data follows the header...
  147. //
  148. };
  149. //+---------------------------------------------------------------
  150. //
  151. // Member: SRHeader::SRHeader
  152. //
  153. // Synopsis: Constructor for SRHeader class
  154. //
  155. //----------------------------------------------------------------
  156. inline SRHeader::SRHeader()
  157. {
  158. _sizel.cx = HimetricFromHPix(GetSystemMetrics(SM_CXICON));
  159. _sizel.cy = HimetricFromVPix(GetSystemMetrics(SM_CYICON));
  160. _dwNative = 0;
  161. }
  162. //+---------------------------------------------------------------
  163. //
  164. // Member: SRHeader::Read, public
  165. //
  166. // Synopsis: Reads a self-delimited header from a stream
  167. //
  168. // Arguments: [pStrm] -- stream to read from
  169. //
  170. // Returns: SUCCESS if the item could be read from the stream
  171. //
  172. // Notes: This also checks the version number in the header
  173. // and will fail if the version number is incorrect.
  174. //
  175. //----------------------------------------------------------------
  176. inline HRESULT SRHeader::Read(LPSTREAM pStrm)
  177. {
  178. return pStrm->Read(this, sizeof(SRHeader), NULL);
  179. }
  180. //+---------------------------------------------------------------
  181. //
  182. // Member: SRHeader::Write, public
  183. //
  184. // Synopsis: Writes a self-delimited header to a stream
  185. //
  186. // Arguments: [pStrm] -- stream to write to
  187. //
  188. // Returns: SUCCESS if the item could be written to the stream
  189. //
  190. //----------------------------------------------------------------
  191. inline HRESULT SRHeader::Write(LPSTREAM pStrm)
  192. {
  193. return pStrm->Write(this, sizeof(SRHeader), NULL);
  194. }
  195. //+---------------------------------------------------------------
  196. //
  197. // Class: SRDV
  198. //
  199. // Purpose: The data/view subobject of a compound document object
  200. //
  201. //---------------------------------------------------------------
  202. class SRDV: public SrvrDV
  203. {
  204. public:
  205. static BOOL ClassInit(LPCLASSDESCRIPTOR pClass);
  206. static HRESULT Create(LPSRCTRL pCtrl,
  207. LPCLASSDESCRIPTOR pClass,
  208. LPUNKNOWN FAR* ppUnkCtrl,
  209. LPSRDV FAR* ppObj);
  210. static HRESULT GetDIB(LPSRVRDV, LPFORMATETC, LPSTGMEDIUM, BOOL);
  211. // we use standard aggregation for delegation to the control subobject
  212. DECLARE_DELEGATING_IUNKNOWN(SRDV);
  213. // base-class virtuals overridden to do additional,
  214. // server-specific processing
  215. virtual HRESULT RenderContent(DWORD dwDrawAspect,
  216. LONG lindex,
  217. void FAR* pvAspect,
  218. DVTARGETDEVICE FAR * ptd,
  219. HDC hicTargetDev,
  220. HDC hdcDraw,
  221. LPCRECTL lprectl,
  222. LPCRECTL lprcWBounds,
  223. BOOL (CALLBACK *pfnContinue) (ULONG_PTR),
  224. ULONG_PTR dwContinue);
  225. virtual HRESULT GetClipboardCopy(LPSRVRDV FAR* ppDV)
  226. {
  227. *ppDV = NULL;
  228. return E_FAIL;
  229. };
  230. STDMETHOD(Load) (LPCOLESTR lpszFileName, DWORD grfMode);
  231. protected:
  232. // base-class virtuals overridden to do additional,
  233. // server-specific processing
  234. virtual HRESULT LoadFromStorage(LPSTORAGE pStg);
  235. virtual HRESULT SaveToStorage(LPSTORAGE pStg, BOOL fSameAsLoad);
  236. // constructors, initializers, and destructors
  237. SRDV(LPUNKNOWN pUnkOuter);
  238. HRESULT Init(LPSRCTRL pCtrl, LPCLASSDESCRIPTOR pClass);
  239. virtual ~SRDV(void);
  240. DECLARE_PRIVATE_IUNKNOWN(SRDV);
  241. //
  242. // native data
  243. //
  244. SRHeader _header; // global properties for the document
  245. };
  246. //+---------------------------------------------------------------
  247. //
  248. // Class: SRInPlace
  249. //
  250. // Purpose: InPlace aspect of OLE compound document
  251. //
  252. // Notes: This class supports SrvrInPlace
  253. //
  254. //---------------------------------------------------------------
  255. class SRInPlace: public SrvrInPlace
  256. {
  257. public:
  258. static BOOL ClassInit(LPCLASSDESCRIPTOR pClass);
  259. static HRESULT Create(LPSRCTRL pSRCtrl,
  260. LPCLASSDESCRIPTOR pClass,
  261. LPUNKNOWN FAR* ppUnkCtrl,
  262. LPSRINPLACE FAR* ppObj);
  263. DECLARE_DELEGATING_IUNKNOWN(SRInPlace);
  264. protected:
  265. SRInPlace(LPUNKNOWN pUnkOuter);
  266. HRESULT Init(LPSRCTRL pSRCtrl, LPCLASSDESCRIPTOR pClass);
  267. ~SRInPlace(void);
  268. DECLARE_PRIVATE_IUNKNOWN(SRInPlace);
  269. // private helpers
  270. virtual HWND AttachWin(HWND hwndParent);
  271. };
  272. //
  273. // Data transfer object
  274. //
  275. class CXBag: public IDataObject
  276. {
  277. public:
  278. static HRESULT Create(LPXBAG *ppXBag, LPSRCTRL pHost, LPPOINT pptSelect);
  279. DECLARE_STANDARD_IUNKNOWN(CXBag);
  280. //
  281. //IDataObject
  282. //
  283. STDMETHODIMP DAdvise( FORMATETC FAR* pFormatetc,
  284. DWORD advf,
  285. LPADVISESINK pAdvSink,
  286. DWORD FAR* pdwConnection) { return OLE_E_ADVISENOTSUPPORTED; }
  287. STDMETHODIMP DUnadvise( DWORD dwConnection)
  288. { return OLE_E_ADVISENOTSUPPORTED; }
  289. STDMETHODIMP EnumDAdvise( LPENUMSTATDATA FAR* ppenumAdvise)
  290. { return OLE_E_ADVISENOTSUPPORTED; }
  291. STDMETHODIMP EnumFormatEtc( DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc);
  292. STDMETHODIMP GetCanonicalFormatEtc( LPFORMATETC pformatetc,
  293. LPFORMATETC pformatetcOut)
  294. { pformatetcOut->ptd = NULL; return E_NOTIMPL; }
  295. STDMETHODIMP GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium );
  296. STDMETHODIMP GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
  297. STDMETHODIMP QueryGetData(LPFORMATETC pformatetc );
  298. STDMETHODIMP SetData(LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium, BOOL fRelease)
  299. { return E_NOTIMPL; }
  300. //
  301. //Public Helpers
  302. //
  303. HRESULT SnapShotAndDetach(void);
  304. void Detach(void)
  305. {
  306. _pHost = NULL;
  307. };
  308. private:
  309. CXBag(LPSRCTRL pHost);
  310. ~CXBag();
  311. HRESULT BagItInStorage(LPSTGMEDIUM pmedium, BOOL fStgProvided);
  312. LPSRCTRL _pHost; // ptr back to host
  313. LPSTORAGE _pStgBag; // snapshot storage (or NULL)
  314. };
  315. #endif //!RC_INVOKED
  316. #endif //__SRS_HXX