Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / embeddedobj / source / msole / olecomponent.hxx
blob5a96b64fcbfc14d5b487f5ed99bbb333326ae4b6
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 #pragma once
22 #include <com/sun/star/uno/Sequence.hxx>
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/Any.hxx>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/util/XCloseable.hpp>
27 #include <com/sun/star/datatransfer/XTransferable.hpp>
28 #include <com/sun/star/embed/VerbDescriptor.hpp>
29 #include <com/sun/star/awt/Size.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <com/sun/star/util/XModifiable.hpp>
33 #include <com/sun/star/util/XModifyListener.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <rtl/ref.hxx>
37 namespace comphelper {
38 class OMultiTypeInterfaceContainerHelper2;
41 class OleWrapperClientSite;
42 class OleWrapperAdviseSink;
43 class OleEmbeddedObject;
44 struct OleComponentNative_Impl;
46 class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css::lang::XComponent,
47 css::lang::XUnoTunnel, css::util::XModifiable,
48 css::datatransfer::XTransferable >
50 ::osl::Mutex m_aMutex;
51 comphelper::OMultiTypeInterfaceContainerHelper2* m_pInterfaceContainer;
53 bool m_bDisposed;
54 bool m_bModified;
55 OleComponentNative_Impl* m_pNativeImpl;
57 OleEmbeddedObject* m_pUnoOleObject;
58 OleWrapperClientSite* m_pOleWrapClientSite;
59 OleWrapperAdviseSink* m_pImplAdviseSink;
61 sal_Int32 m_nOLEMiscFlags;
62 sal_Int32 m_nAdvConn;
64 css::uno::Sequence< css::embed::VerbDescriptor > m_aVerbList;
65 css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavors;
67 css::uno::Reference< css::uno::XComponentContext > m_xContext;
69 bool m_bOleInitialized;
71 // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
72 // such objects report the dirty state wrongly sometimes and do not allow to store them any time
73 bool m_bWorkaroundActive;
75 bool InitializeObject_Impl();
77 void CreateNewIStorage_Impl();
78 void RetrieveObjectDataFlavors_Impl();
79 void Dispose();
82 public:
83 OleComponent( const css::uno::Reference< css::uno::XComponentContext >& xContext,
84 OleEmbeddedObject* pOleObj );
86 virtual ~OleComponent() override;
88 OleComponent* createEmbeddedCopyOfLink();
90 void disconnectEmbeddedObject();
92 static css::awt::Size CalculateWithFactor( const css::awt::Size& aSize,
93 const css::awt::Size& aMultiplier,
94 const css::awt::Size& aDivisor );
96 css::awt::Size CalculateTheRealSize( const css::awt::Size& aContSize, bool bUpdate );
98 // ==== Initialization ==================================================
99 void LoadEmbeddedObject( const OUString& aTempURL );
100 void CreateObjectFromClipboard();
101 void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID );
102 static void CreateObjectFromData(
103 const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer );
104 void CreateObjectFromFile( const OUString& aFileName );
105 void CreateLinkFromFile( const OUString& aFileName );
106 void InitEmbeddedCopyOfLink( rtl::Reference<OleComponent> const & pOleLinkComponent );
109 void RunObject(); // switch OLE object to running state
110 void CloseObject(); // switch OLE object to loaded state
112 css::uno::Sequence< css::embed::VerbDescriptor > GetVerbList();
114 void ExecuteVerb( sal_Int32 nVerbID );
115 void SetHostName( const OUString& aEmbDocName );
116 void SetExtent( const css::awt::Size& aVisAreaSize, sal_Int64 nAspect );
118 css::awt::Size GetExtent( sal_Int64 nAspect );
119 css::awt::Size GetCachedExtent( sal_Int64 nAspect );
120 css::awt::Size GetRecommendedExtent( sal_Int64 nAspect );
122 sal_Int64 GetMiscStatus( sal_Int64 nAspect );
124 css::uno::Sequence< sal_Int8 > GetCLSID();
126 bool IsWorkaroundActive() const { return m_bWorkaroundActive; }
127 bool IsDirty();
129 void StoreOwnTmpIfNecessary();
131 bool SaveObject_Impl();
132 bool OnShowWindow_Impl( bool bShow );
133 void OnViewChange_Impl( sal_uInt32 dwAspect );
134 void OnClose_Impl();
136 // XCloseable
137 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) override;
138 virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
139 virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override;
141 // XTransferable
142 virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
143 virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
144 virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
146 // XComponent
147 virtual void SAL_CALL dispose() override;
148 virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override;
149 virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override;
151 // XUnoTunnel
152 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
154 // XModifiable
155 virtual sal_Bool SAL_CALL isModified() override;
156 virtual void SAL_CALL setModified( sal_Bool bModified ) override;
157 virtual void SAL_CALL addModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener ) override;
158 virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) override;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */