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.

275 lines
12 KiB

  1. #ifndef pack2cpp_h__
  2. #define pack2cpp_h__
  3. #include <priv.h>
  4. #ifdef __cplusplus
  5. #undef DebugMsg
  6. #define DebugMsg TraceMsg
  7. ////////////////////////////////
  8. // CPackage Definition
  9. //
  10. class CPackage : public IEnumOLEVERB,
  11. public IOleCommandTarget,
  12. public IOleObject,
  13. public IViewObject2,
  14. public IDataObject,
  15. public IPersistStorage,
  16. public IAdviseSink,
  17. public IRunnableObject,
  18. public IPersistFile,
  19. public IOleCache,
  20. public IExternalConnection
  21. // cleanup -- inherit interfaces
  22. {
  23. public:
  24. CPackage(); // constructor
  25. ~CPackage(); // destructor
  26. HRESULT Init(); // used to initialze fields that could fail
  27. BOOL RunWizard();
  28. // IUnknown methods...
  29. STDMETHODIMP QueryInterface(REFIID,void **);
  30. STDMETHODIMP_(ULONG) AddRef(void);
  31. STDMETHODIMP_(ULONG) Release(void);
  32. // IEnumOLEVERB methods...
  33. STDMETHODIMP Next(ULONG celt, OLEVERB* rgVerbs, ULONG* pceltFetched);
  34. STDMETHODIMP Skip(ULONG celt);
  35. STDMETHODIMP Reset();
  36. STDMETHODIMP Clone(IEnumOLEVERB** ppEnum);
  37. // IOleCommandTarget methods
  38. STDMETHODIMP QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT* pCmdText);
  39. STDMETHODIMP Exec(const GUID* pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG* pvaIn, VARIANTARG* pvaOut);
  40. // IPersistStorage Methods...
  41. STDMETHODIMP GetClassID(LPCLSID pClassID);
  42. STDMETHODIMP IsDirty(void);
  43. STDMETHODIMP InitNew(IStorage* pstg);
  44. STDMETHODIMP Load(IStorage* pstg);
  45. STDMETHODIMP Save(IStorage* pstg, BOOL fSameAsLoad);
  46. STDMETHODIMP SaveCompleted(IStorage* pstg);
  47. STDMETHODIMP HandsOffStorage(void);
  48. // IPersistFile Methods...
  49. // STDMETHODIMP GetClassID(LPCLSID pClassID);
  50. // STDMETHODIMP IsDirty(void);
  51. STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwdMode);
  52. STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember);
  53. STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName);
  54. STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName);
  55. // IDataObject Methods...
  56. STDMETHODIMP GetData(LPFORMATETC pFEIn, LPSTGMEDIUM pSTM);
  57. STDMETHODIMP GetDataHere(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
  58. STDMETHODIMP QueryGetData(LPFORMATETC pFE);
  59. STDMETHODIMP GetCanonicalFormatEtc(LPFORMATETC pFEIn, LPFORMATETC pFEOut);
  60. STDMETHODIMP SetData(LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL fRelease);
  61. STDMETHODIMP EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC *ppEnum);
  62. STDMETHODIMP DAdvise(LPFORMATETC pFE, DWORD grfAdv, LPADVISESINK pAdvSink,
  63. DWORD *pdwConnection);
  64. STDMETHODIMP DUnadvise(DWORD dwConnection);
  65. STDMETHODIMP EnumDAdvise(LPENUMSTATDATA *ppEnum);
  66. // IOleObject Methods...
  67. STDMETHODIMP SetClientSite(LPOLECLIENTSITE pClientSite);
  68. STDMETHODIMP GetClientSite(LPOLECLIENTSITE *ppClientSite);
  69. STDMETHODIMP SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj);
  70. STDMETHODIMP Close(DWORD dwSaveOption);
  71. STDMETHODIMP SetMoniker(DWORD dwWhichMoniker, LPMONIKER pmk);
  72. STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMonkier,LPMONIKER *ppmk);
  73. STDMETHODIMP InitFromData(LPDATAOBJECT pDataObject, BOOL fCreation,
  74. DWORD dwReserved);
  75. STDMETHODIMP GetClipboardData(DWORD dwReserved, LPDATAOBJECT *ppDataObject);
  76. STDMETHODIMP DoVerb(LONG iVerb, LPMSG lpmsg, LPOLECLIENTSITE pActiveSite,
  77. LONG lindex, HWND hwndParent, LPCRECT lprcPosRect);
  78. STDMETHODIMP EnumVerbs(LPENUMOLEVERB *ppEnumOleVerb);
  79. STDMETHODIMP Update(void);
  80. STDMETHODIMP IsUpToDate(void);
  81. STDMETHODIMP GetUserClassID(LPCLSID pClsid);
  82. STDMETHODIMP GetUserType(DWORD dwFromOfType, LPOLESTR *pszUserType);
  83. STDMETHODIMP SetExtent(DWORD dwDrawAspect, LPSIZEL psizel);
  84. STDMETHODIMP GetExtent(DWORD dwDrawAspect, LPSIZEL psizel);
  85. STDMETHODIMP Advise(LPADVISESINK pAdvSink, DWORD *pdwConnection);
  86. STDMETHODIMP Unadvise(DWORD dwConnection);
  87. STDMETHODIMP EnumAdvise(LPENUMSTATDATA *ppenumAdvise);
  88. STDMETHODIMP GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus);
  89. STDMETHODIMP SetColorScheme(LPLOGPALETTE pLogpal);
  90. // IViewObject2 Methods...
  91. STDMETHODIMP Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect,
  92. DVTARGETDEVICE *ptd, HDC hdcTargetDev,
  93. HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds,
  94. BOOL (CALLBACK *pfnContinue)(ULONG_PTR), ULONG_PTR dwContinue);
  95. STDMETHODIMP GetColorSet(DWORD dwAspect, LONG lindex, void *pvAspect,
  96. DVTARGETDEVICE *ptd, HDC hdcTargetDev,
  97. LPLOGPALETTE *ppColorSet);
  98. STDMETHODIMP Freeze(DWORD dwDrawAspect, LONG lindex, void * pvAspect,
  99. DWORD *pdwFreeze);
  100. STDMETHODIMP Unfreeze(DWORD dwFreeze);
  101. STDMETHODIMP SetAdvise(DWORD dwAspects, DWORD dwAdvf,
  102. LPADVISESINK pAdvSink);
  103. STDMETHODIMP GetAdvise(DWORD *pdwAspects, DWORD *pdwAdvf,
  104. LPADVISESINK *ppAdvSink);
  105. STDMETHODIMP GetExtent(DWORD dwAspect, LONG lindex, DVTARGETDEVICE *ptd,
  106. LPSIZEL pszl);
  107. // IAdviseSink Methods...
  108. STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  109. STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
  110. STDMETHODIMP_(void) OnRename(LPMONIKER);
  111. STDMETHODIMP_(void) OnSave(void);
  112. STDMETHODIMP_(void) OnClose(void);
  113. // IRunnable Object methods...
  114. STDMETHODIMP GetRunningClass(LPCLSID);
  115. STDMETHODIMP Run(LPBC);
  116. STDMETHODIMP_(BOOL) IsRunning();
  117. STDMETHODIMP LockRunning(BOOL,BOOL);
  118. STDMETHODIMP SetContainedObject(BOOL);
  119. // IOleCache methods
  120. // We need an IOLECache Interface to Keep Office97 happy.
  121. STDMETHODIMP Cache(FORMATETC * pFormatetc, DWORD advf, DWORD * pdwConnection);
  122. STDMETHODIMP Uncache(DWORD dwConnection);
  123. STDMETHODIMP EnumCache(IEnumSTATDATA ** ppenumSTATDATA);
  124. STDMETHODIMP InitCache(IDataObject *pDataObject);
  125. // IExternalConnection
  126. // Some applications RealeaseConnect and then we never hear from them again.
  127. // This allows us to call OnClose() after the activations.
  128. STDMETHODIMP_(DWORD) AddConnection(DWORD exconn, DWORD dwreserved );
  129. STDMETHODIMP_(DWORD) ReleaseConnection(DWORD extconn, DWORD dwreserved, BOOL fLastReleaseCloses );
  130. protected:
  131. LONG _cRef; // package reference count
  132. UINT _cf; // package clipboard format
  133. LPIC _lpic; // icon for the packaged object
  134. PANETYPE _panetype; // tells us whether we have a cmdlink or embed
  135. PSSTATE _psState; // persistent storage state
  136. // These are mutually exclusive, so should probably be made into a union,
  137. // but that's a minor point.
  138. LPEMBED _pEmbed; // embedded file structure
  139. LPCML _pCml; // command line structure
  140. BOOL _fLoaded; // true if data from persistent storage
  141. // IOleObject vars from SetHostNames
  142. LPOLESTR _lpszContainerApp;
  143. LPOLESTR _lpszContainerObj;
  144. BOOL _fIsDirty; // dirty flag for our internal storage from the pov of our container
  145. DWORD _dwCookie; // connection value for AdviseSink
  146. // Advise interfaces
  147. LPDATAADVISEHOLDER _pIDataAdviseHolder;
  148. LPOLEADVISEHOLDER _pIOleAdviseHolder;
  149. LPOLECLIENTSITE _pIOleClientSite;
  150. // Excel hack: when Excel hosts what it thinks is a link it always NULLs out
  151. // it's "object" pointer. If we call anything on IOleClientSite other than
  152. // save then it will fault.
  153. BOOL _fNoIOleClientSiteCalls;
  154. BOOL _fFrozen;
  155. // to be able to send view change notifications we need these vars
  156. IAdviseSink *_pViewSink;
  157. DWORD _dwViewAspects;
  158. DWORD _dwViewAdvf;
  159. // IEnumOLEVERB variables:
  160. ULONG _cVerbs;
  161. ULONG _nCurVerb;
  162. OLEVERB* _pVerbs;
  163. IContextMenu* _pcm;
  164. // IEnumOLEVERB helper methods:
  165. HRESULT InitVerbEnum(OLEVERB* pVerbs, ULONG cVerbs);
  166. HRESULT GetContextMenu(IContextMenu** ppcm);
  167. VOID ReleaseContextMenu();
  168. // if fInitFile is TRUE, then we will totally initialize ourselves
  169. // from the given filename. In other words, all our structures will be
  170. // initialized after calling this is fInitFile = TRUE. On the other hand,
  171. // if it's FALSE, then we'll just reinit our data and not update icon
  172. // and filename information.
  173. //
  174. HRESULT EmbedInitFromFile(LPCTSTR lpFileName, BOOL fInitFile);
  175. HRESULT CmlInitFromFile(LPTSTR lpFilename, BOOL fUpdateIcon, PANETYPE paneType);
  176. HRESULT InitFromPackInfo(LPPACKAGER_INFO lppi);
  177. HRESULT CreateTempFile(bool deleteExisting = false);
  178. HRESULT CreateTempFileName();
  179. HRESULT _IconRefresh();
  180. void _DestroyIC();
  181. BOOL _IconCalcSize(LPIC lpic);
  182. VOID _IconDraw(LPIC,HDC, LPRECT);
  183. LPIC _IconCreateFromFile(LPCTSTR lpstrFile);
  184. VOID _GetCurrentIcon(LPIC lpic);
  185. void _CreateSaferIconTitle(LPTSTR szSaferTitle, LPCTSTR szIconTitle);
  186. void _DrawIconToDC(HDC hdcMF, LPIC lpic, bool stripAlpha, LPCTSTR pszActualFileName);
  187. // Data Transfer functions...
  188. HRESULT GetFileDescriptor(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
  189. HRESULT GetFileContents(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
  190. HRESULT GetMetafilePict(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
  191. HRESULT GetEnhMetafile(LPFORMATETC pFE, LPSTGMEDIUM pSTM);
  192. HRESULT GetObjectDescriptor(LPFORMATETC pFE, LPSTGMEDIUM pSTM) ;
  193. HRESULT CreateShortcutOnStream(IStream* pstm);
  194. // Packager Read/Write Functions...
  195. HRESULT PackageReadFromStream(IStream* pstm);
  196. HRESULT IconReadFromStream(IStream* pstm);
  197. HRESULT EmbedReadFromStream(IStream* pstm);
  198. HRESULT CmlReadFromStream(IStream* pstm);
  199. HRESULT PackageWriteToStream(IStream* pstm);
  200. HRESULT IconWriteToStream(IStream* pstm, DWORD *pdw);
  201. HRESULT EmbedWriteToStream(IStream* pstm, DWORD *pdw);
  202. HRESULT CmlWriteToStream(IStream* pstm, DWORD *pdw);
  203. // Some utility functions and data
  204. void _FixupTempFile(IPersistFile * ppf, LPEMBED pEmbed);
  205. int _GiveWarningMsg();
  206. // Misc AppCompat Stuff
  207. int _iPropertiesMenuItem;
  208. BOOL _bClosed; // the close happened
  209. BOOL _bCloseIt; // that we should close at the end of the activate
  210. };
  211. ////////////////////////////////////////////
  212. //
  213. // Package Wizard and Edit Package Dialog Procs and functions
  214. //
  215. // Pages for Wizard
  216. INT_PTR APIENTRY PackWiz_CreatePackageDlgProc(HWND, UINT, WPARAM, LPARAM);
  217. INT_PTR APIENTRY PackWiz_SelectFileDlgProc(HWND, UINT, WPARAM, LPARAM);
  218. INT_PTR APIENTRY PackWiz_SelectLabelDlgProc(HWND, UINT, WPARAM, LPARAM);
  219. // Edit dialog procs
  220. INT_PTR APIENTRY PackWiz_EditEmbedPackageDlgProc(HWND, UINT, WPARAM, LPARAM);
  221. INT_PTR APIENTRY PackWiz_EditCmdPackakgeDlgProc(HWND, UINT, WPARAM, LPARAM);
  222. // functions
  223. int PackWiz_CreateWizard(HWND,LPPACKAGER_INFO);
  224. int PackWiz_EditPackage(HWND,int,LPPACKAGER_INFO);
  225. VOID PackWiz_FillInPropertyPage(PROPSHEETPAGE *, INT, DLGPROC);
  226. #endif // __cplusplus
  227. #endif