1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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 class 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
;
55 std::unique_ptr
<OleComponentNative_Impl
> m_pNativeImpl
;
57 OleEmbeddedObject
* m_pUnoOleObject
;
58 OleWrapperClientSite
* m_pOleWrapClientSite
;
59 OleWrapperAdviseSink
* m_pImplAdviseSink
;
61 css::uno::Sequence
< css::embed::VerbDescriptor
> m_aVerbList
;
62 css::uno::Sequence
< css::datatransfer::DataFlavor
> m_aDataFlavors
;
64 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
66 bool m_bOleInitialized
;
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
;
72 void InitializeObject_Impl();
74 OUString
getTempURL() const;
76 void RetrieveObjectDataFlavors_Impl();
81 OleComponent( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
82 OleEmbeddedObject
* pOleObj
);
84 virtual ~OleComponent() override
;
86 OleComponent
* createEmbeddedCopyOfLink();
88 void disconnectEmbeddedObject();
90 static css::awt::Size
CalculateWithFactor( const css::awt::Size
& aSize
,
91 const css::awt::Size
& aMultiplier
,
92 const css::awt::Size
& aDivisor
);
94 css::awt::Size
CalculateTheRealSize( const css::awt::Size
& aContSize
, bool bUpdate
);
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
);
107 void RunObject(); // switch OLE object to running state
108 void CloseObject(); // switch OLE object to loaded state
110 css::uno::Sequence
< css::embed::VerbDescriptor
> GetVerbList();
112 void ExecuteVerb( sal_Int32 nVerbID
);
113 void SetHostName( const OUString
& aEmbDocName
);
114 void SetExtent( const css::awt::Size
& aVisAreaSize
, sal_Int64 nAspect
);
116 css::awt::Size
GetExtent( sal_Int64 nAspect
);
117 css::awt::Size
GetCachedExtent( sal_Int64 nAspect
);
118 css::awt::Size
GetRecommendedExtent( sal_Int64 nAspect
);
120 sal_Int64
GetMiscStatus( sal_Int64 nAspect
);
122 css::uno::Sequence
< sal_Int8
> GetCLSID();
124 bool IsWorkaroundActive() const { return m_bWorkaroundActive
; }
127 void StoreOwnTmpIfNecessary();
129 bool SaveObject_Impl();
130 bool OnShowWindow_Impl( bool bShow
);
131 void OnViewChange_Impl( sal_uInt32 dwAspect
);
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
;
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
;
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
;
150 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
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
;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */