Update ooo320-m1
[ooovba.git] / embedserv / source / inc / embeddoc.hxx
blob902643ae380e78b3c58e410bffe2164ffd084b33
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: embeddoc.hxx,v $
10 * $Revision: 1.18.10.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EMBEDDOC_HXX_
32 #define _EMBEDDOC_HXX_
33 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
34 #undef _DEBUG
35 #endif
36 #if defined(_MSC_VER) && (_MSC_VER > 1310)
37 #pragma warning(disable : 4917 4555)
38 #endif
40 #include "common.h"
41 #include <oleidl.h>
42 #include <objidl.h>
44 #include <hash_map>
45 #include <com/sun/star/uno/Reference.h>
46 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
47 #include <com/sun/star/uno/SEQUENCE.h>
48 #endif
50 #include "embeddocaccess.hxx"
51 #include "docholder.hxx"
53 typedef ::std::hash_map< DWORD, IAdviseSink* > AdviseSinkHashMap;
54 typedef ::std::hash_map< DWORD, IAdviseSink* >::iterator AdviseSinkHashMapIterator;
56 class GDIMetaFile;
57 class CIIAObj;
59 class EmbedDocument_Impl
60 : public IPersistStorage,
61 public IDataObject,
62 public IOleObject,
63 public IOleInPlaceObject,
64 public IPersistFile,
65 public IDispatch,
66 public IExternalConnection
68 protected:
69 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
70 fillArgsForLoading_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xStream,
71 DWORD nStreamMode,
72 LPCOLESTR pFilePath = NULL );
73 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
74 fillArgsForStoring_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream );
76 HRESULT SaveTo_Impl( IStorage* pStg );
78 sal_uInt64 getMetaFileHandle_Impl( sal_Bool isEnhMeta );
80 public:
81 EmbedDocument_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& smgr,
82 const GUID* guid );
83 virtual ~EmbedDocument_Impl();
85 /* IUnknown methods */
86 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
87 STDMETHOD_(ULONG, AddRef)();
88 STDMETHOD_(ULONG, Release)();
90 /* IPersistMethod */
91 STDMETHOD(GetClassID)(CLSID *pClassID);
93 /* IPersistStorage methods */
94 STDMETHOD(IsDirty) ();
95 STDMETHOD(InitNew) ( IStorage *pStg );
96 STDMETHOD(Load) ( IStorage* pStr );
97 STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
98 STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
99 STDMETHOD(HandsOffStorage) (void);
101 /* IDataObject methods */
102 STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
103 STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
104 STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
105 STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
106 STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
107 STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
108 STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
109 STDMETHOD(DUnadvise) ( DWORD dwConnection );
110 STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
112 /* IOleObject methods */
113 STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
114 STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
115 STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
116 STDMETHOD(Close) ( DWORD dwSaveOption);
117 STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
118 STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
119 STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
120 STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
121 STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
122 STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
123 STDMETHOD(Update) ();
124 STDMETHOD(IsUpToDate) ();
125 STDMETHOD(GetUserClassID) ( CLSID *pClsid );
126 STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
127 STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
128 STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
129 STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
130 STDMETHOD(Unadvise) ( DWORD dwConnection );
131 STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
132 STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
133 STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
135 /* IOleInPlaceObject methods */
136 STDMETHOD(GetWindow)(HWND *);
137 STDMETHOD(ContextSensitiveHelp)(BOOL);
138 STDMETHOD(InPlaceDeactivate)();
139 STDMETHOD(UIDeactivate)();
140 STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT);
141 STDMETHOD(ReactivateAndUndo)();
143 /* IPersistFile methods */
144 STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode );
145 STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember );
146 STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName );
147 STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName );
149 /* IDispatch methods */
150 STDMETHOD(GetTypeInfoCount) ( unsigned int FAR* pctinfo );
151 STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo );
152 STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId );
153 STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr );
155 /* IExternalConnection methods */
156 virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved);
157 virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses);
159 // c++ - methods
161 void notify( bool bDataChanged = true );
162 HRESULT SaveObject();
163 HRESULT ShowObject();
164 GUID GetGUID() const { return m_guid; }
165 HRESULT OLENotifyClosing();
167 void Deactivate();
168 HRESULT OLENotifyDeactivation();
170 protected:
171 oslInterlockedCount m_refCount;
173 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
175 DocumentHolder* m_pDocHolder;
176 ::rtl::OUString m_aFileName;
178 CComPtr< IStorage > m_pMasterStorage;
179 CComPtr< IStream > m_pOwnStream;
180 CComPtr< IStream > m_pExtStream;
181 GUID m_guid;
183 sal_Bool m_bIsDirty;
185 CComPtr< IOleClientSite > m_pClientSite;
186 CComPtr< IDataAdviseHolder > m_pDAdviseHolder;
188 AdviseSinkHashMap m_aAdviseHashMap;
189 DWORD m_nAdviseNum;
191 ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOwnAccess;
193 sal_Bool m_bIsInVerbHandling;
196 class BooleanGuard_Impl
198 sal_Bool& m_bValue;
200 public:
201 BooleanGuard_Impl( sal_Bool& bValue )
202 : m_bValue( bValue )
204 m_bValue = sal_True;
207 ~BooleanGuard_Impl()
209 m_bValue = sal_False;
213 #endif //_EMBEDDOC_HXX_