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