xref: /aoo41x/main/embedserv/source/inc/embeddoc.hxx (revision 67e470da)
1*a20fd023SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*a20fd023SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*a20fd023SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*a20fd023SAndrew Rist  * distributed with this work for additional information
6*a20fd023SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*a20fd023SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*a20fd023SAndrew Rist  * "License"); you may not use this file except in compliance
9*a20fd023SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*a20fd023SAndrew Rist  *
11*a20fd023SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*a20fd023SAndrew Rist  *
13*a20fd023SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*a20fd023SAndrew Rist  * software distributed under the License is distributed on an
15*a20fd023SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*a20fd023SAndrew Rist  * KIND, either express or implied.  See the License for the
17*a20fd023SAndrew Rist  * specific language governing permissions and limitations
18*a20fd023SAndrew Rist  * under the License.
19*a20fd023SAndrew Rist  *
20*a20fd023SAndrew Rist  *************************************************************/
21*a20fd023SAndrew Rist 
22*a20fd023SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _EMBEDDOC_HXX_
25cdf0e10cSrcweir #define _EMBEDDOC_HXX_
26cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER >= 1300)
27cdf0e10cSrcweir #undef _DEBUG
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER > 1310)
30cdf0e10cSrcweir #pragma warning(disable : 4917 4555)
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "common.h"
34cdf0e10cSrcweir #include <oleidl.h>
35cdf0e10cSrcweir #include <objidl.h>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <hash_map>
38cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
40cdf0e10cSrcweir #include <com/sun/star/uno/SEQUENCE.h>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "embeddocaccess.hxx"
44cdf0e10cSrcweir #include "docholder.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir typedef ::std::hash_map< DWORD, IAdviseSink* > AdviseSinkHashMap;
47cdf0e10cSrcweir typedef ::std::hash_map< DWORD, IAdviseSink* >::iterator AdviseSinkHashMapIterator;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class GDIMetaFile;
50cdf0e10cSrcweir class CIIAObj;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir class EmbedDocument_Impl
53cdf0e10cSrcweir 	: public IPersistStorage,
54cdf0e10cSrcweir 	  public IDataObject,
55cdf0e10cSrcweir 	  public IOleObject,
56cdf0e10cSrcweir 	  public IOleInPlaceObject,
57cdf0e10cSrcweir 	  public IPersistFile,
58cdf0e10cSrcweir 	  public IDispatch,
59cdf0e10cSrcweir       public IExternalConnection
60cdf0e10cSrcweir {
61cdf0e10cSrcweir protected:
62cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
63cdf0e10cSrcweir 				fillArgsForLoading_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xStream,
64cdf0e10cSrcweir 										 DWORD nStreamMode,
65cdf0e10cSrcweir 										 LPCOLESTR pFilePath = NULL );
66cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
67cdf0e10cSrcweir 				fillArgsForStoring_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	HRESULT SaveTo_Impl( IStorage* pStg );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	sal_uInt64 getMetaFileHandle_Impl( sal_Bool isEnhMeta );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir public:
74cdf0e10cSrcweir 	EmbedDocument_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& smgr,
75cdf0e10cSrcweir 						const GUID* guid );
76cdf0e10cSrcweir 	virtual ~EmbedDocument_Impl();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	/* IUnknown methods */
79cdf0e10cSrcweir 	STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
80cdf0e10cSrcweir 	STDMETHOD_(ULONG, AddRef)();
81cdf0e10cSrcweir 	STDMETHOD_(ULONG, Release)();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	/* IPersistMethod */
84cdf0e10cSrcweir 	STDMETHOD(GetClassID)(CLSID *pClassID);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	/* IPersistStorage methods */
87cdf0e10cSrcweir 	STDMETHOD(IsDirty) ();
88cdf0e10cSrcweir 	STDMETHOD(InitNew) ( IStorage *pStg );
89cdf0e10cSrcweir 	STDMETHOD(Load) ( IStorage* pStr );
90cdf0e10cSrcweir 	STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
91cdf0e10cSrcweir 	STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
92cdf0e10cSrcweir 	STDMETHOD(HandsOffStorage) (void);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	/* IDataObject methods */
95cdf0e10cSrcweir 	STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
96cdf0e10cSrcweir 	STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
97cdf0e10cSrcweir 	STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
98cdf0e10cSrcweir 	STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
99cdf0e10cSrcweir 	STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
100cdf0e10cSrcweir 	STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
101cdf0e10cSrcweir 	STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
102cdf0e10cSrcweir 	STDMETHOD(DUnadvise) ( DWORD dwConnection );
103cdf0e10cSrcweir 	STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	/* IOleObject methods */
106cdf0e10cSrcweir 	STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
107cdf0e10cSrcweir 	STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
108cdf0e10cSrcweir     STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
109cdf0e10cSrcweir     STDMETHOD(Close) ( DWORD dwSaveOption);
110cdf0e10cSrcweir     STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
111cdf0e10cSrcweir     STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
112cdf0e10cSrcweir     STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
113cdf0e10cSrcweir     STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
114cdf0e10cSrcweir     STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
115cdf0e10cSrcweir     STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
116cdf0e10cSrcweir     STDMETHOD(Update) ();
117cdf0e10cSrcweir     STDMETHOD(IsUpToDate) ();
118cdf0e10cSrcweir     STDMETHOD(GetUserClassID) ( CLSID *pClsid );
119cdf0e10cSrcweir     STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
120cdf0e10cSrcweir     STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
121cdf0e10cSrcweir     STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
122cdf0e10cSrcweir     STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
123cdf0e10cSrcweir     STDMETHOD(Unadvise) ( DWORD dwConnection );
124cdf0e10cSrcweir     STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
125cdf0e10cSrcweir     STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
126cdf0e10cSrcweir     STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	/* IOleInPlaceObject methods */
129cdf0e10cSrcweir 	STDMETHOD(GetWindow)(HWND *);
130cdf0e10cSrcweir 	STDMETHOD(ContextSensitiveHelp)(BOOL);
131cdf0e10cSrcweir 	STDMETHOD(InPlaceDeactivate)();
132cdf0e10cSrcweir 	STDMETHOD(UIDeactivate)();
133cdf0e10cSrcweir 	STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT);
134cdf0e10cSrcweir 	STDMETHOD(ReactivateAndUndo)();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	/* IPersistFile methods */
137cdf0e10cSrcweir 	STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode );
138cdf0e10cSrcweir 	STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember );
139cdf0e10cSrcweir 	STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName );
140cdf0e10cSrcweir 	STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	/* IDispatch methods */
143cdf0e10cSrcweir 	STDMETHOD(GetTypeInfoCount) ( unsigned int FAR*  pctinfo );
144cdf0e10cSrcweir 	STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo );
145cdf0e10cSrcweir 	STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId );
146cdf0e10cSrcweir 	STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	/* IExternalConnection methods */
149cdf0e10cSrcweir     virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved);
150cdf0e10cSrcweir     virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// c++ - methods
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     void notify( bool bDataChanged = true );
155cdf0e10cSrcweir 	HRESULT SaveObject();
156cdf0e10cSrcweir 	HRESULT ShowObject();
GetGUID() const157cdf0e10cSrcweir     GUID GetGUID() const { return m_guid; }
158cdf0e10cSrcweir 	HRESULT OLENotifyClosing();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     void Deactivate();
161cdf0e10cSrcweir     HRESULT OLENotifyDeactivation();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir protected:
164cdf0e10cSrcweir 	oslInterlockedCount					m_refCount;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	DocumentHolder*						m_pDocHolder;
169cdf0e10cSrcweir 	::rtl::OUString						m_aFileName;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	CComPtr< IStorage >					m_pMasterStorage;
172cdf0e10cSrcweir 	CComPtr< IStream >					m_pOwnStream;
173cdf0e10cSrcweir 	CComPtr< IStream >					m_pExtStream;
174cdf0e10cSrcweir 	GUID								m_guid;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	sal_Bool							m_bIsDirty;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	CComPtr< IOleClientSite >			m_pClientSite;
179cdf0e10cSrcweir 	CComPtr< IDataAdviseHolder >		m_pDAdviseHolder;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	AdviseSinkHashMap					m_aAdviseHashMap;
182cdf0e10cSrcweir 	DWORD								m_nAdviseNum;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOwnAccess;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	sal_Bool							m_bIsInVerbHandling;
187cdf0e10cSrcweir };
188cdf0e10cSrcweir 
189cdf0e10cSrcweir class BooleanGuard_Impl
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	sal_Bool& m_bValue;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir public:
BooleanGuard_Impl(sal_Bool & bValue)194cdf0e10cSrcweir 	BooleanGuard_Impl( sal_Bool& bValue )
195cdf0e10cSrcweir 	: m_bValue( bValue )
196cdf0e10cSrcweir 	{
197cdf0e10cSrcweir 		m_bValue = sal_True;
198cdf0e10cSrcweir 	}
199cdf0e10cSrcweir 
~BooleanGuard_Impl()200cdf0e10cSrcweir 	~BooleanGuard_Impl()
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		m_bValue = sal_False;
203cdf0e10cSrcweir 	}
204cdf0e10cSrcweir };
205cdf0e10cSrcweir 
206cdf0e10cSrcweir #endif //_EMBEDDOC_HXX_
207