1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #pragma warning(disable : 4668)
30 #include "smartpointer.hxx"
31 #include "advisesink.hxx"
33 #define DEFAULT_ARRAY_LEN 256
35 namespace inprocserv
{
45 // this is a common baseclass that is used to count the objects
47 class InprocCountedObject_Impl
50 InprocCountedObject_Impl();
51 ~InprocCountedObject_Impl();
55 // this is the inprocess embedded object implementation class
57 class InprocEmbedDocument_Impl
: public InprocCountedObject_Impl
60 , public IPersistStorage
62 , public IRunnableObject
64 // , public IExternalConnection
65 , public IOleInPlaceObject
73 ComSmart
< IUnknown
> m_pDefHandler
;
74 InitModes m_nInitMode
;
76 DWORD m_nFileOpenMode
;
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
: public IOleCache2
94 InprocEmbedDocument_Impl
& m_rOwnDocument
;
97 InternalCacheWrapper( InprocEmbedDocument_Impl
& rOwnDocument
)
98 : m_rOwnDocument( rOwnDocument
)
101 /* IUnknown methods */
102 STDMETHOD(QueryInterface
)(REFIID riid
, LPVOID FAR
* ppvObj
);
103 STDMETHOD_(ULONG
, AddRef
)();
104 STDMETHOD_(ULONG
, Release
)();
106 /* IOleCache2 methods */
107 STDMETHOD(Cache
)( FORMATETC
*pformatetc
, DWORD advf
, DWORD
*pdwConnection
);
108 STDMETHOD(Uncache
)( DWORD dwConnection
);
109 STDMETHOD(EnumCache
)( IEnumSTATDATA
**ppenumSTATDATA
);
110 STDMETHOD(InitCache
)( IDataObject
*pDataObject
);
111 STDMETHOD(SetData
)( FORMATETC
*pformatetc
, STGMEDIUM
*pmedium
, BOOL fRelease
);
112 STDMETHOD(UpdateCache
)( LPDATAOBJECT pDataObject
, DWORD grfUpdf
, LPVOID pReserved
);
113 STDMETHOD(DiscardCache
)( DWORD dwDiscardOptions
);
117 DWORD
InsertAdviseLinkToList( const ComSmart
<OleWrapperAdviseSink
>& pOwnAdvise
, ComSmart
< OleWrapperAdviseSink
> pAdvises
[] );
123 InprocEmbedDocument_Impl( const GUID
& guid
)
125 , m_bDeleted( FALSE
)
127 , m_nInitMode( NOINIT
)
128 , m_nFileOpenMode( 0 )
129 , m_pFileName( NULL
)
130 , m_nCallsOnStack( 0 )
131 , m_aInternalCache( *this )
134 virtual ~InprocEmbedDocument_Impl()
138 void SetName( LPCOLESTR pszNameFromOutside
, wchar_t*& pOwnName
);
140 BOOL
CheckDefHandler();
141 ComSmart
< IUnknown
>& GetDefHandler() { return m_pDefHandler
; }
143 /* IUnknown methods */
144 STDMETHOD(QueryInterface
)(REFIID riid
, LPVOID FAR
* ppvObj
);
145 STDMETHOD_(ULONG
, AddRef
)();
146 STDMETHOD_(ULONG
, Release
)();
148 /* IOleObject methods */
149 STDMETHOD(SetClientSite
) ( IOleClientSite
* pSite
);
150 STDMETHOD(GetClientSite
) ( IOleClientSite
** pSite
);
151 STDMETHOD(SetHostNames
) ( LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
);
152 STDMETHOD(Close
) ( DWORD dwSaveOption
);
153 STDMETHOD(SetMoniker
) ( DWORD dwWhichMoniker
, IMoniker
*pmk
);
154 STDMETHOD(GetMoniker
) ( DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
**ppmk
);
155 STDMETHOD(InitFromData
) ( IDataObject
*pDataObject
, BOOL fCreation
, DWORD dwReserved
);
156 STDMETHOD(GetClipboardData
) ( DWORD dwReserved
, IDataObject
**ppDataObject
);
157 STDMETHOD(DoVerb
) ( LONG iVerb
, LPMSG lpmsg
, IOleClientSite
*pActiveSite
, LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
);
158 STDMETHOD(EnumVerbs
) ( IEnumOLEVERB
**ppEnumOleVerb
);
159 STDMETHOD(Update
) ();
160 STDMETHOD(IsUpToDate
) ();
161 STDMETHOD(GetUserClassID
) ( CLSID
*pClsid
);
162 STDMETHOD(GetUserType
) ( DWORD dwFormOfType
, LPOLESTR
*pszUserType
);
163 STDMETHOD(SetExtent
) ( DWORD dwDrawAspect
, SIZEL
*psizel
);
164 STDMETHOD(GetExtent
) ( DWORD dwDrawAspect
, SIZEL
*psizel
);
165 STDMETHOD(Advise
) ( IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
);
166 STDMETHOD(Unadvise
) ( DWORD dwConnection
);
167 STDMETHOD(EnumAdvise
) ( IEnumSTATDATA
**ppenumAdvise
);
168 STDMETHOD(GetMiscStatus
) ( DWORD dwAspect
, DWORD
*pdwStatus
);
169 STDMETHOD(SetColorScheme
) ( LOGPALETTE
*pLogpal
);
171 /* IDataObject methods */
172 STDMETHOD(GetData
) ( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
);
173 STDMETHOD(GetDataHere
) ( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
);
174 STDMETHOD(QueryGetData
) ( FORMATETC
* pFormatetc
);
175 STDMETHOD(GetCanonicalFormatEtc
) ( FORMATETC
* pFormatetcIn
, FORMATETC
* pFormatetcOut
);
176 STDMETHOD(SetData
) ( FORMATETC
* pFormatetc
, STGMEDIUM
* pMedium
, BOOL fRelease
);
177 STDMETHOD(EnumFormatEtc
) ( DWORD dwDirection
, IEnumFORMATETC
** ppFormatetc
);
178 STDMETHOD(DAdvise
) ( FORMATETC
* pFormatetc
, DWORD advf
, IAdviseSink
* pAdvSink
, DWORD
* pdwConnection
);
179 STDMETHOD(DUnadvise
) ( DWORD dwConnection
);
180 STDMETHOD(EnumDAdvise
) ( IEnumSTATDATA
** ppenumAdvise
);
183 STDMETHOD(GetClassID
)(CLSID
*pClassID
);
185 /* IPersistStorage methods */
186 STDMETHOD(IsDirty
) ();
187 STDMETHOD(InitNew
) ( IStorage
*pStg
);
188 STDMETHOD(Load
) ( IStorage
* pStr
);
189 STDMETHOD(Save
) ( IStorage
*pStgSave
, BOOL fSameAsLoad
);
190 STDMETHOD(SaveCompleted
) ( IStorage
*pStgNew
);
191 STDMETHOD(HandsOffStorage
) (void);
193 /* IPersistFile methods */
194 STDMETHOD(Load
) ( LPCOLESTR pszFileName
, DWORD dwMode
);
195 STDMETHOD(Save
) ( LPCOLESTR pszFileName
, BOOL fRemember
);
196 STDMETHOD(SaveCompleted
) ( LPCOLESTR pszFileName
);
197 STDMETHOD(GetCurFile
) ( LPOLESTR
*ppszFileName
);
199 /* IRunnableObject methods */
200 STDMETHOD(GetRunningClass
) ( LPCLSID lpClsid
);
201 STDMETHOD(Run
) ( LPBINDCTX pbc
);
202 virtual BOOL STDMETHODCALLTYPE
IsRunning( void);
203 STDMETHOD(LockRunning
) ( BOOL fLock
, BOOL fLastUnlockCloses
);
204 STDMETHOD(SetContainedObject
) ( BOOL fContained
);
206 /* IViewObject2 methods */
207 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
);
208 STDMETHOD(GetColorSet
)( DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
);
209 STDMETHOD(Freeze
)( DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DWORD
*pdwFreeze
);
210 STDMETHOD(Unfreeze
)( DWORD dwFreeze
);
211 STDMETHOD(SetAdvise
)( DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
);
212 STDMETHOD(GetAdvise
)( DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
);
213 STDMETHOD(GetExtent
)( DWORD dwDrawAspect
, LONG lindex
, DVTARGETDEVICE
*ptd
, LPSIZEL lpsizel
);
215 /* IOleWindow methods */
216 STDMETHOD(GetWindow
)( HWND
*phwnd
);
217 STDMETHOD(ContextSensitiveHelp
)( BOOL fEnterMode
);
219 /* IOleInPlaceObject methods */
220 STDMETHOD(InPlaceDeactivate
)( void);
221 STDMETHOD(UIDeactivate
)( void);
222 STDMETHOD(SetObjectRects
)( LPCRECT lprcPosRect
, LPCRECT lprcClipRect
);
223 STDMETHOD(ReactivateAndUndo
)( void);
225 /*IDispatch methods*/
226 STDMETHOD(GetTypeInfoCount
)( UINT
*pctinfo
);
227 STDMETHOD(GetTypeInfo
)( UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
);
228 STDMETHOD(GetIDsOfNames
)( REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
);
229 STDMETHOD(Invoke
)( DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
);
233 } // namespace inprocserv
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */