/src/libreoffice/embeddedobj/source/msole/olecomponent.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
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> |
36 | | |
37 | | namespace comphelper { |
38 | | class OMultiTypeInterfaceContainerHelper2; |
39 | | } |
40 | | |
41 | | class OleWrapperClientSite; |
42 | | class OleWrapperAdviseSink; |
43 | | class OleEmbeddedObject; |
44 | | class OleComponentNative_Impl; |
45 | | |
46 | | class OleComponent : public ::cppu::WeakImplHelper< css::util::XCloseable, css::lang::XComponent, |
47 | | css::lang::XUnoTunnel, css::util::XModifiable, |
48 | | css::datatransfer::XTransferable > |
49 | | { |
50 | | ::osl::Mutex m_aMutex; |
51 | | comphelper::OMultiTypeInterfaceContainerHelper2* m_pInterfaceContainer; |
52 | | |
53 | | bool m_bDisposed; |
54 | | bool m_bModified; |
55 | | std::unique_ptr<OleComponentNative_Impl> m_pNativeImpl; |
56 | | |
57 | | OleEmbeddedObject* m_pUnoOleObject; |
58 | | OleWrapperClientSite* m_pOleWrapClientSite; |
59 | | OleWrapperAdviseSink* m_pImplAdviseSink; |
60 | | |
61 | | css::uno::Sequence< css::embed::VerbDescriptor > m_aVerbList; |
62 | | css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavors; |
63 | | |
64 | | css::uno::Reference< css::uno::XComponentContext > m_xContext; |
65 | | |
66 | | bool m_bOleInitialized; |
67 | | |
68 | | // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object ) |
69 | | // such objects report the dirty state wrongly sometimes and do not allow to store them any time |
70 | | bool m_bWorkaroundActive; |
71 | | |
72 | | void InitializeObject_Impl(); |
73 | | |
74 | | OUString getTempURL() const; |
75 | | |
76 | | void RetrieveObjectDataFlavors_Impl(); |
77 | | void Dispose(); |
78 | | |
79 | | |
80 | | public: |
81 | | OleComponent( const css::uno::Reference< css::uno::XComponentContext >& xContext, |
82 | | OleEmbeddedObject* pOleObj ); |
83 | | |
84 | | virtual ~OleComponent() override; |
85 | | |
86 | | OleComponent* createEmbeddedCopyOfLink(); |
87 | | |
88 | | void disconnectEmbeddedObject(); |
89 | | |
90 | | static css::awt::Size CalculateWithFactor( const css::awt::Size& aSize, |
91 | | const css::awt::Size& aMultiplier, |
92 | | const css::awt::Size& aDivisor ); |
93 | | |
94 | | css::awt::Size CalculateTheRealSize( const css::awt::Size& aContSize, bool bUpdate ); |
95 | | |
96 | | // ==== Initialization ================================================== |
97 | | void LoadEmbeddedObject( const OUString& aTempURL ); |
98 | | void CreateObjectFromClipboard(); |
99 | | void CreateNewEmbeddedObject( const css::uno::Sequence< sal_Int8 >& aSeqCLSID ); |
100 | | static void CreateObjectFromData( |
101 | | const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer ); |
102 | | void CreateObjectFromFile( const OUString& aFileName ); |
103 | | void CreateLinkFromFile( const OUString& aFileName ); |
104 | | void InitEmbeddedCopyOfLink( rtl::Reference<OleComponent> const & pOleLinkComponent ); |
105 | | |
106 | | |
107 | | void RunObject(); // switch OLE object to running state |
108 | | void CloseObject(); // switch OLE object to loaded state |
109 | | |
110 | | css::uno::Sequence< css::embed::VerbDescriptor > GetVerbList(); |
111 | | |
112 | | void ExecuteVerb( sal_Int32 nVerbID ); |
113 | | void SetHostName( const OUString& aEmbDocName ); |
114 | | void SetExtent( const css::awt::Size& aVisAreaSize, sal_Int64 nAspect ); |
115 | | |
116 | | css::awt::Size GetExtent( sal_Int64 nAspect ); |
117 | | css::awt::Size GetCachedExtent( sal_Int64 nAspect ); |
118 | | css::awt::Size GetRecommendedExtent( sal_Int64 nAspect ); |
119 | | |
120 | | sal_Int64 GetMiscStatus( sal_Int64 nAspect ); |
121 | | |
122 | | css::uno::Sequence< sal_Int8 > GetCLSID(); |
123 | | |
124 | 0 | bool IsWorkaroundActive() const { return m_bWorkaroundActive; } |
125 | | bool IsDirty(); |
126 | | |
127 | | void StoreOwnTmpIfNecessary(); |
128 | | |
129 | | bool SaveObject_Impl(); |
130 | | bool OnShowWindow_Impl( bool bShow ); |
131 | | void OnViewChange_Impl( sal_uInt32 dwAspect ); |
132 | | void OnClose_Impl(); |
133 | | |
134 | | // XCloseable |
135 | | virtual void SAL_CALL close( sal_Bool DeliverOwnership ) override; |
136 | | virtual void SAL_CALL addCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override; |
137 | | virtual void SAL_CALL removeCloseListener( const css::uno::Reference< css::util::XCloseListener >& Listener ) override; |
138 | | |
139 | | // XTransferable |
140 | | virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override; |
141 | | virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override; |
142 | | virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override; |
143 | | |
144 | | // XComponent |
145 | | virtual void SAL_CALL dispose() override; |
146 | | virtual void SAL_CALL addEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override; |
147 | | virtual void SAL_CALL removeEventListener(const css::uno::Reference < css::lang::XEventListener >& aListener) override; |
148 | | |
149 | | // XUnoTunnel |
150 | | virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; |
151 | | |
152 | | // XModifiable |
153 | | virtual sal_Bool SAL_CALL isModified() override; |
154 | | virtual void SAL_CALL setModified( sal_Bool bModified ) override; |
155 | | virtual void SAL_CALL addModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener ) override; |
156 | | virtual void SAL_CALL removeModifyListener( const css::uno::Reference < css::util::XModifyListener >& xListener) override; |
157 | | }; |
158 | | |
159 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |