Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / embedserv / source / inc / embeddoc.hxx
blob2db4a8dc62440661666780cde636d43fdfd54693
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_INC_EMBEDDOC_HXX
21 #define INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOC_HXX
22 #ifdef _MSC_VER
23 #pragma warning(disable : 4917 4555)
24 #endif
26 #include "common.h"
27 #include <oleidl.h>
28 #include <objidl.h>
30 #include <com/sun/star/uno/Reference.h>
31 #include <com/sun/star/uno/SEQUENCE.h>
32 #include <unordered_map>
34 #include "embeddocaccess.hxx"
35 #include "docholder.hxx"
37 typedef std::unordered_map< DWORD, IAdviseSink* > AdviseSinkHashMap;
38 typedef std::unordered_map< DWORD, IAdviseSink* >::iterator AdviseSinkHashMapIterator;
40 class GDIMetaFile;
41 class CIIAObj;
43 class EmbedDocument_Impl
44 : public IPersistStorage,
45 public IDataObject,
46 public IOleObject,
47 public IOleInPlaceObject,
48 public IPersistFile,
49 public IDispatch,
50 public IExternalConnection
52 protected:
53 css::uno::Sequence< css::beans::PropertyValue >
54 fillArgsForLoading_Impl( css::uno::Reference< css::io::XInputStream > xStream,
55 DWORD nStreamMode,
56 LPCOLESTR pFilePath = NULL );
57 css::uno::Sequence< css::beans::PropertyValue >
58 fillArgsForStoring_Impl( css::uno::Reference< css::io::XOutputStream > xStream );
60 HRESULT SaveTo_Impl( IStorage* pStg );
62 sal_uInt64 getMetaFileHandle_Impl( sal_Bool isEnhMeta );
64 public:
65 EmbedDocument_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& smgr,
66 const GUID* guid );
67 virtual ~EmbedDocument_Impl();
69 /* IUnknown methods */
70 STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
71 STDMETHOD_(ULONG, AddRef)();
72 STDMETHOD_(ULONG, Release)();
74 /* IPersistMethod */
75 STDMETHOD(GetClassID)(CLSID *pClassID);
77 /* IPersistStorage methods */
78 STDMETHOD(IsDirty) ();
79 STDMETHOD(InitNew) ( IStorage *pStg );
80 STDMETHOD(Load) ( IStorage* pStr );
81 STDMETHOD(Save) ( IStorage *pStgSave, BOOL fSameAsLoad );
82 STDMETHOD(SaveCompleted) ( IStorage *pStgNew );
83 STDMETHOD(HandsOffStorage) (void);
85 /* IDataObject methods */
86 STDMETHOD(GetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
87 STDMETHOD(GetDataHere) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium );
88 STDMETHOD(QueryGetData) ( FORMATETC * pFormatetc );
89 STDMETHOD(GetCanonicalFormatEtc) ( FORMATETC * pFormatetcIn, FORMATETC * pFormatetcOut );
90 STDMETHOD(SetData) ( FORMATETC * pFormatetc, STGMEDIUM * pMedium, BOOL fRelease );
91 STDMETHOD(EnumFormatEtc) ( DWORD dwDirection, IEnumFORMATETC ** ppFormatetc );
92 STDMETHOD(DAdvise) ( FORMATETC * pFormatetc, DWORD advf, IAdviseSink * pAdvSink, DWORD * pdwConnection );
93 STDMETHOD(DUnadvise) ( DWORD dwConnection );
94 STDMETHOD(EnumDAdvise) ( IEnumSTATDATA ** ppenumAdvise );
96 /* IOleObject methods */
97 STDMETHOD(SetClientSite) ( IOleClientSite* pSite );
98 STDMETHOD(GetClientSite) ( IOleClientSite** pSite );
99 STDMETHOD(SetHostNames) ( LPCOLESTR szContainerApp, LPCOLESTR szContainerObj );
100 STDMETHOD(Close) ( DWORD dwSaveOption);
101 STDMETHOD(SetMoniker) ( DWORD dwWhichMoniker, IMoniker *pmk );
102 STDMETHOD(GetMoniker) ( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk );
103 STDMETHOD(InitFromData) ( IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved );
104 STDMETHOD(GetClipboardData) ( DWORD dwReserved, IDataObject **ppDataObject );
105 STDMETHOD(DoVerb) ( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect );
106 STDMETHOD(EnumVerbs) ( IEnumOLEVERB **ppEnumOleVerb );
107 STDMETHOD(Update) ();
108 STDMETHOD(IsUpToDate) ();
109 STDMETHOD(GetUserClassID) ( CLSID *pClsid );
110 STDMETHOD(GetUserType) ( DWORD dwFormOfType, LPOLESTR *pszUserType );
111 STDMETHOD(SetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
112 STDMETHOD(GetExtent) ( DWORD dwDrawAspect, SIZEL *psizel );
113 STDMETHOD(Advise) ( IAdviseSink *pAdvSink, DWORD *pdwConnection );
114 STDMETHOD(Unadvise) ( DWORD dwConnection );
115 STDMETHOD(EnumAdvise) ( IEnumSTATDATA **ppenumAdvise );
116 STDMETHOD(GetMiscStatus) ( DWORD dwAspect, DWORD *pdwStatus );
117 STDMETHOD(SetColorScheme) ( LOGPALETTE *pLogpal );
119 /* IOleInPlaceObject methods */
120 STDMETHOD(GetWindow)(HWND *);
121 STDMETHOD(ContextSensitiveHelp)(BOOL);
122 STDMETHOD(InPlaceDeactivate)();
123 STDMETHOD(UIDeactivate)();
124 STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT);
125 STDMETHOD(ReactivateAndUndo)();
127 /* IPersistFile methods */
128 STDMETHOD(Load) ( LPCOLESTR pszFileName, DWORD dwMode );
129 STDMETHOD(Save) ( LPCOLESTR pszFileName, BOOL fRemember );
130 STDMETHOD(SaveCompleted) ( LPCOLESTR pszFileName );
131 STDMETHOD(GetCurFile) ( LPOLESTR *ppszFileName );
133 /* IDispatch methods */
134 STDMETHOD(GetTypeInfoCount) ( unsigned int FAR* pctinfo );
135 STDMETHOD(GetTypeInfo) ( unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo );
136 STDMETHOD(GetIDsOfNames) ( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId );
137 STDMETHOD(Invoke) ( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo, unsigned int FAR* puArgErr );
139 /* IExternalConnection methods */
140 virtual DWORD STDMETHODCALLTYPE AddConnection( DWORD extconn, DWORD reserved);
141 virtual DWORD STDMETHODCALLTYPE ReleaseConnection( DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses);
143 // c++ - methods
145 void notify( bool bDataChanged = true );
146 HRESULT SaveObject();
147 HRESULT ShowObject();
148 GUID GetGUID() const { return m_guid; }
149 HRESULT OLENotifyClosing();
151 void Deactivate();
152 HRESULT OLENotifyDeactivation();
154 protected:
155 oslInterlockedCount m_refCount;
157 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
159 DocumentHolder* m_pDocHolder;
160 OUString m_aFileName;
162 CComPtr< IStorage > m_pMasterStorage;
163 CComPtr< IStream > m_pOwnStream;
164 CComPtr< IStream > m_pExtStream;
165 GUID m_guid;
167 sal_Bool m_bIsDirty;
169 CComPtr< IOleClientSite > m_pClientSite;
170 CComPtr< IDataAdviseHolder > m_pDAdviseHolder;
172 AdviseSinkHashMap m_aAdviseHashMap;
173 DWORD m_nAdviseNum;
175 ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOwnAccess;
177 sal_Bool m_bIsInVerbHandling;
180 class BooleanGuard_Impl
182 sal_Bool& m_bValue;
184 public:
185 BooleanGuard_Impl( sal_Bool& bValue )
186 : m_bValue( bValue )
188 m_bValue = sal_True;
191 ~BooleanGuard_Impl()
193 m_bValue = sal_False;
197 #endif // INCLUDED_EMBEDSERV_SOURCE_INC_EMBEDDOC_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */