Update ooo320-m1
[ooovba.git] / embedserv / source / inprocserv / inprocembobj.h
blob7eacd7ba0662c07c28c079323cab03ab4fff8f33
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: inprocembobj.h,v $
7 * $Revision: 1.1.8.2 $
9 * last change: $Author: mav $ $Date: 2008/10/30 11:59:06 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 #ifndef _INPROCEMBOBJ_HXX_
37 #define _INPROCEMBOBJ_HXX_
39 #pragma warning(disable : 4668)
41 #include <windows.h>
42 #include <oleidl.h>
44 #include "smartpointer.hxx"
45 #include "advisesink.hxx"
47 #define DEFAULT_ARRAY_LEN 256
49 namespace inprocserv {
51 enum InitModes {
52 NOINIT,
53 INIT_FROM_STORAGE,
54 LOAD_FROM_STORAGE,
55 LOAD_FROM_FILE
58 // ==================================
59 // this is a common baseclass that is used to count the objects
60 // ==================================
61 class InprocCountedObject_Impl
63 public:
64 InprocCountedObject_Impl();
65 ~InprocCountedObject_Impl();
68 // ==================================
69 // this is the inprocess embedded object implementation class
70 // ==================================
71 class InprocEmbedDocument_Impl : public InprocCountedObject_Impl
72 , public IOleObject
73 , public IDataObject
74 , public IPersistStorage
75 , public IPersistFile
76 , public IRunnableObject
77 , public IViewObject2
78 // , public IExternalConnection
79 , public IOleInPlaceObject
80 , public IDispatch
82 ULONG m_refCount;
83 BOOLEAN m_bDeleted;
85 GUID m_guid;
87 ComSmart< IUnknown > m_pDefHandler;
88 InitModes m_nInitMode;
90 DWORD m_nFileOpenMode;
91 wchar_t* m_pFileName;
93 ComSmart< IStorage > m_pStorage;
95 ComSmart< IOleClientSite > m_pClientSite;
96 ComSmart< IOleContainer > m_pOleContainer;
98 ULONG m_nCallsOnStack;
100 // the listeners have wrappers that are directly connected to the object and call the listeners,
101 // the wrappers will be reconnected correctly to the new default inprocess holder object
102 ComSmart< OleWrapperAdviseSink > m_pOleAdvises[DEFAULT_ARRAY_LEN];
103 ComSmart< OleWrapperAdviseSink > m_pDataAdvises[DEFAULT_ARRAY_LEN];
104 ComSmart< OleWrapperAdviseSink > m_pViewAdvise;
106 class InternalCacheWrapper : public IOleCache2
108 InprocEmbedDocument_Impl& m_rOwnDocument;
110 public:
111 InternalCacheWrapper( InprocEmbedDocument_Impl& rOwnDocument )
112 : m_rOwnDocument( rOwnDocument )
115 /* IUnknown methods */
116 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
117 STDMETHOD_(ULONG, AddRef)();
118 STDMETHOD_(ULONG, Release)();
120 /* IOleCache2 methods */
121 STDMETHOD(Cache)( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection);
122 STDMETHOD(Uncache)( DWORD dwConnection);
123 STDMETHOD(EnumCache)( IEnumSTATDATA **ppenumSTATDATA);
124 STDMETHOD(InitCache)( IDataObject *pDataObject);
125 STDMETHOD(SetData)( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease);
126 STDMETHOD(UpdateCache)( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved);
127 STDMETHOD(DiscardCache)( DWORD dwDiscardOptions);
128 } m_aInternalCache;
131 DWORD InsertAdviseLinkToList( const ComSmart<OleWrapperAdviseSink>& pOwnAdvise, ComSmart< OleWrapperAdviseSink > pAdvises[] );
132 void Clean();
135 public:
137 InprocEmbedDocument_Impl( const GUID& guid )
138 : m_refCount( 0 )
139 , m_bDeleted( FALSE )
140 , m_guid( guid )
141 , m_nInitMode( NOINIT )
142 , m_nFileOpenMode( 0 )
143 , m_pFileName( NULL )
144 , m_nCallsOnStack( 0 )
145 , m_aInternalCache( *this )
148 virtual ~InprocEmbedDocument_Impl()
151 HRESULT Init();
152 void SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName );
154 BOOL CheckDefHandler();
155 ComSmart< IUnknown >& GetDefHandler() { return m_pDefHandler; }
157 /* IUnknown methods */
158 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
159 STDMETHOD_(ULONG, AddRef)();
160 STDMETHOD_(ULONG, Release)();
162 /* IOleObject methods */
163 STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
164 STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
165 STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
166 STDMETHOD(Close) ( DWORD dwSaveOption);
167 STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
168 STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
169 STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
170 STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
171 STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
172 STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
173 STDMETHOD(Update) ();
174 STDMETHOD(IsUpToDate) ();
175 STDMETHOD(GetUserClassID) ( CLSID *pClsid );
176 STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
177 STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
178 STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
179 STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
180 STDMETHOD(Unadvise) ( DWORD dwConnection );
181 STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
182 STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
183 STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
185 /* IDataObject methods */
186 STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
187 STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
188 STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
189 STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
190 STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
191 STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
192 STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
193 STDMETHOD(DUnadvise) ( DWORD dwConnection );
194 STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
196 /* IPersistMethod */
197 STDMETHOD(GetClassID)(CLSID *pClassID);
199 /* IPersistStorage methods */
200 STDMETHOD(IsDirty) ();
201 STDMETHOD(InitNew) ( IStorage *pStg );
202 STDMETHOD(Load) ( IStorage* pStr );
203 STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
204 STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
205 STDMETHOD(HandsOffStorage) (void);
207 /* IPersistFile methods */
208 STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode );
209 STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember );
210 STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName );
211 STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName );
213 /* IRunnableObject methods */
214 STDMETHOD(GetRunningClass) ( LPCLSID lpClsid);
215 STDMETHOD(Run) ( LPBINDCTX pbc);
216 virtual BOOL STDMETHODCALLTYPE IsRunning( void);
217 STDMETHOD(LockRunning) ( BOOL fLock, BOOL fLastUnlockCloses );
218 STDMETHOD(SetContainedObject) ( BOOL fContained);
220 /* IViewObject2 methods */
221 STDMETHOD(Draw)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL ( STDMETHODCALLTYPE *pfnContinue )( ULONG_PTR dwContinue ), ULONG_PTR dwContinue);
222 STDMETHOD(GetColorSet)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet);
223 STDMETHOD(Freeze)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze);
224 STDMETHOD(Unfreeze)( DWORD dwFreeze);
225 STDMETHOD(SetAdvise)( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink);
226 STDMETHOD(GetAdvise)( DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink);
227 STDMETHOD(GetExtent)( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel);
229 /* IOleWindow methods */
230 STDMETHOD(GetWindow)( HWND *phwnd);
231 STDMETHOD(ContextSensitiveHelp)( BOOL fEnterMode);
233 /* IOleInPlaceObject methods */
234 STDMETHOD(InPlaceDeactivate)( void);
235 STDMETHOD(UIDeactivate)( void);
236 STDMETHOD(SetObjectRects)( LPCRECT lprcPosRect, LPCRECT lprcClipRect);
237 STDMETHOD(ReactivateAndUndo)( void);
239 /*IDispatch methods*/
240 STDMETHOD(GetTypeInfoCount)( UINT *pctinfo);
241 STDMETHOD(GetTypeInfo)( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
242 STDMETHOD(GetIDsOfNames)( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
243 STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
247 } // namespace inprocserv
249 #endif