Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / embedserv / source / inprocserv / inprocembobj.h
blob25ee78f5f5c5ce0a1c42de069bbc9862e2f056b5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_EMBEDSERV_SOURCE_INPROCSERV_INPROCEMBOBJ_H
21 #define INCLUDED_EMBEDSERV_SOURCE_INPROCSERV_INPROCEMBOBJ_H
23 #if defined _MSC_VER
24 #pragma warning(disable : 4668)
25 #endif
27 #include <windows.h>
28 #include <oleidl.h>
30 #include "smartpointer.hxx"
31 #include "advisesink.hxx"
33 #define DEFAULT_ARRAY_LEN 256
35 namespace inprocserv {
37 enum InitModes {
38 NOINIT,
39 INIT_FROM_STORAGE,
40 LOAD_FROM_STORAGE,
41 LOAD_FROM_FILE
45 // this is a common baseclass that is used to count the objects
47 class InprocCountedObject_Impl
49 public:
50 InprocCountedObject_Impl();
51 ~InprocCountedObject_Impl();
55 // this is the inprocess embedded object implementation class
57 class InprocEmbedDocument_Impl : public InprocCountedObject_Impl
58 , public IOleObject
59 , public IDataObject
60 , public IPersistStorage
61 , public IPersistFile
62 , public IRunnableObject
63 , public IViewObject2
64 // , public IExternalConnection
65 , public IOleInPlaceObject
66 , public IDispatch
68 ULONG m_refCount;
69 BOOLEAN m_bDeleted;
71 GUID m_guid;
73 ComSmart< IUnknown > m_pDefHandler;
74 InitModes m_nInitMode;
76 DWORD m_nFileOpenMode;
77 wchar_t* m_pFileName;
79 ComSmart< IStorage > m_pStorage;
81 ComSmart< IOleClientSite > m_pClientSite;
82 ComSmart< IOleContainer > m_pOleContainer;
84 ULONG m_nCallsOnStack;
86 // the listeners have wrappers that are directly connected to the object and call the listeners,
87 // the wrappers will be reconnected correctly to the new default inprocess holder object
88 ComSmart< OleWrapperAdviseSink > m_pOleAdvises[DEFAULT_ARRAY_LEN];
89 ComSmart< OleWrapperAdviseSink > m_pDataAdvises[DEFAULT_ARRAY_LEN];
90 ComSmart< OleWrapperAdviseSink > m_pViewAdvise;
92 class InternalCacheWrapper final: public IOleCache2
94 InprocEmbedDocument_Impl& m_rOwnDocument;
96 public:
97 explicit InternalCacheWrapper( InprocEmbedDocument_Impl& rOwnDocument )
98 : m_rOwnDocument( rOwnDocument )
101 virtual ~InternalCacheWrapper() {}
103 /* IUnknown methods */
104 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
105 STDMETHOD_(ULONG, AddRef)();
106 STDMETHOD_(ULONG, Release)();
108 /* IOleCache2 methods */
109 STDMETHOD(Cache)( FORMATETC *pformatetc, DWORD advf, DWORD *pdwConnection);
110 STDMETHOD(Uncache)( DWORD dwConnection);
111 STDMETHOD(EnumCache)( IEnumSTATDATA **ppenumSTATDATA);
112 STDMETHOD(InitCache)( IDataObject *pDataObject);
113 STDMETHOD(SetData)( FORMATETC *pformatetc, STGMEDIUM *pmedium, BOOL fRelease);
114 STDMETHOD(UpdateCache)( LPDATAOBJECT pDataObject, DWORD grfUpdf, LPVOID pReserved);
115 STDMETHOD(DiscardCache)( DWORD dwDiscardOptions);
116 } m_aInternalCache;
119 DWORD InsertAdviseLinkToList( const ComSmart<OleWrapperAdviseSink>& pOwnAdvise, ComSmart< OleWrapperAdviseSink > pAdvises[] );
120 void Clean();
123 public:
125 explicit InprocEmbedDocument_Impl( const GUID& guid )
126 : m_refCount( 0 )
127 , m_bDeleted( FALSE )
128 , m_guid( guid )
129 , m_nInitMode( NOINIT )
130 , m_nFileOpenMode( 0 )
131 , m_pFileName( NULL )
132 , m_nCallsOnStack( 0 )
133 , m_aInternalCache( *this )
136 virtual ~InprocEmbedDocument_Impl()
139 HRESULT Init();
140 void SetName( LPCOLESTR pszNameFromOutside, wchar_t*& pOwnName );
142 BOOL CheckDefHandler();
143 ComSmart< IUnknown >& GetDefHandler() { return m_pDefHandler; }
145 /* IUnknown methods */
146 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
147 STDMETHOD_(ULONG, AddRef)();
148 STDMETHOD_(ULONG, Release)();
150 /* IOleObject methods */
151 STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
152 STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
153 STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
154 STDMETHOD(Close) ( DWORD dwSaveOption);
155 STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
156 STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
157 STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
158 STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
159 STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
160 STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
161 STDMETHOD(Update) ();
162 STDMETHOD(IsUpToDate) ();
163 STDMETHOD(GetUserClassID) ( CLSID *pClsid );
164 STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
165 STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
166 STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
167 STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
168 STDMETHOD(Unadvise) ( DWORD dwConnection );
169 STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
170 STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
171 STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
173 /* IDataObject methods */
174 STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
175 STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
176 STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
177 STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
178 STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
179 STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
180 STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
181 STDMETHOD(DUnadvise) ( DWORD dwConnection );
182 STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
184 /* IPersistMethod */
185 STDMETHOD(GetClassID)(CLSID *pClassID);
187 /* IPersistStorage methods */
188 STDMETHOD(IsDirty) ();
189 STDMETHOD(InitNew) ( IStorage *pStg );
190 STDMETHOD(Load) ( IStorage* pStr );
191 STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
192 STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
193 STDMETHOD(HandsOffStorage) (void);
195 /* IPersistFile methods */
196 STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode );
197 STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember );
198 STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName );
199 STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName );
201 /* IRunnableObject methods */
202 STDMETHOD(GetRunningClass) ( LPCLSID lpClsid);
203 STDMETHOD(Run) ( LPBINDCTX pbc);
204 virtual BOOL STDMETHODCALLTYPE IsRunning( void);
205 STDMETHOD(LockRunning) ( BOOL fLock, BOOL fLastUnlockCloses );
206 STDMETHOD(SetContainedObject) ( BOOL fContained);
208 /* IViewObject2 methods */
209 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);
210 STDMETHOD(GetColorSet)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet);
211 STDMETHOD(Freeze)( DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze);
212 STDMETHOD(Unfreeze)( DWORD dwFreeze);
213 STDMETHOD(SetAdvise)( DWORD aspects, DWORD advf, IAdviseSink *pAdvSink);
214 STDMETHOD(GetAdvise)( DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink);
215 STDMETHOD(GetExtent)( DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel);
217 /* IOleWindow methods */
218 STDMETHOD(GetWindow)( HWND *phwnd);
219 STDMETHOD(ContextSensitiveHelp)( BOOL fEnterMode);
221 /* IOleInPlaceObject methods */
222 STDMETHOD(InPlaceDeactivate)( void);
223 STDMETHOD(UIDeactivate)( void);
224 STDMETHOD(SetObjectRects)( LPCRECT lprcPosRect, LPCRECT lprcClipRect);
225 STDMETHOD(ReactivateAndUndo)( void);
227 /*IDispatch methods*/
228 STDMETHOD(GetTypeInfoCount)( UINT *pctinfo);
229 STDMETHOD(GetTypeInfo)( UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
230 STDMETHOD(GetIDsOfNames)( REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
231 STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
235 } // namespace inprocserv
237 #endif
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */