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 .
20 #ifndef INCLUDED_EMBEDDEDOBJ_SOURCE_MSOLE_OLECOMPONENT_HXX
21 #define INCLUDED_EMBEDDEDOBJ_SOURCE_MSOLE_OLECOMPONENT_HXX
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/util/XCloseable.hpp>
28 #include <com/sun/star/datatransfer/XTransferable.hpp>
29 #include <com/sun/star/io/XInputStream.hpp>
30 #include <com/sun/star/io/XOutputStream.hpp>
31 #include <com/sun/star/embed/XOptimizedStorage.hpp>
32 #include <com/sun/star/embed/VerbDescriptor.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/awt/Size.hpp>
35 #include <com/sun/star/lang/XUnoTunnel.hpp>
36 #include <cppuhelper/implbase.hxx>
37 #include <com/sun/star/util/XModifiable.hpp>
38 #include <com/sun/star/util/XModifyListener.hpp>
43 namespace com
{ namespace sun
{ namespace star
{
47 class OMultiTypeInterfaceContainerHelper
;
50 class OleWrapperClientSite
;
51 class OleWrapperAdviseSink
;
52 class OleEmbeddedObject
;
53 struct OleComponentNative_Impl
;
55 class OleComponent
: public ::cppu::WeakImplHelper
< css::util::XCloseable
, css::lang::XComponent
,
56 css::lang::XUnoTunnel
, css::util::XModifiable
,
57 css::datatransfer::XTransferable
>
59 ::osl::Mutex m_aMutex
;
60 ::cppu::OMultiTypeInterfaceContainerHelper
* m_pInterfaceContainer
;
64 OleComponentNative_Impl
* m_pNativeImpl
;
66 OleEmbeddedObject
* m_pUnoOleObject
;
67 OleWrapperClientSite
* m_pOleWrapClientSite
;
68 OleWrapperAdviseSink
* m_pImplAdviseSink
;
70 sal_Int32 m_nOLEMiscFlags
;
73 css::uno::Sequence
< css::embed::VerbDescriptor
> m_aVerbList
;
74 css::uno::Sequence
< css::datatransfer::DataFlavor
> m_aDataFlavors
;
76 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
;
78 bool m_bOleInitialized
;
80 // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
81 // such objects report the dirty state wrongly sometimes and do not allow to store them any time
82 bool m_bWorkaroundActive
;
84 bool InitializeObject_Impl();
86 void CreateNewIStorage_Impl();
87 void RetrieveObjectDataFlavors_Impl();
92 OleComponent( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& m_xFactory
,
93 OleEmbeddedObject
* pOleObj
);
95 virtual ~OleComponent() override
;
97 OleComponent
* createEmbeddedCopyOfLink();
99 void disconnectEmbeddedObject();
101 static css::awt::Size
CalculateWithFactor( const css::awt::Size
& aSize
,
102 const css::awt::Size
& aMultiplier
,
103 const css::awt::Size
& aDivisor
);
105 css::awt::Size
CalculateTheRealSize( const css::awt::Size
& aContSize
, bool bUpdate
);
107 // ==== Initialization ==================================================
108 void LoadEmbeddedObject( const OUString
& aTempURL
);
109 void CreateObjectFromClipboard();
110 void CreateNewEmbeddedObject( const css::uno::Sequence
< sal_Int8
>& aSeqCLSID
);
111 static void CreateObjectFromData(
112 const css::uno::Reference
< css::datatransfer::XTransferable
>& xTransfer
);
113 void CreateObjectFromFile( const OUString
& aFileName
);
114 void CreateLinkFromFile( const OUString
& aFileName
);
115 void InitEmbeddedCopyOfLink( OleComponent
* pOleLinkComponent
);
118 void RunObject(); // switch OLE object to running state
119 void CloseObject(); // switch OLE object to loaded state
121 css::uno::Sequence
< css::embed::VerbDescriptor
> GetVerbList();
123 void ExecuteVerb( sal_Int32 nVerbID
);
124 void SetHostName( const OUString
& aContName
, const OUString
& aEmbDocName
);
125 void SetExtent( const css::awt::Size
& aVisAreaSize
, sal_Int64 nAspect
);
127 css::awt::Size
GetExtent( sal_Int64 nAspect
);
128 css::awt::Size
GetCachedExtent( sal_Int64 nAspect
);
129 css::awt::Size
GetReccomendedExtent( sal_Int64 nAspect
);
131 sal_Int64
GetMiscStatus( sal_Int64 nAspect
);
133 css::uno::Sequence
< sal_Int8
> GetCLSID();
135 bool IsWorkaroundActive() { return m_bWorkaroundActive
; }
138 void StoreOwnTmpIfNecessary();
140 bool SaveObject_Impl();
141 bool OnShowWindow_Impl( bool bShow
);
142 void OnViewChange_Impl( sal_uInt32 dwAspect
);
146 virtual void SAL_CALL
close( sal_Bool DeliverOwnership
) throw (css::util::CloseVetoException
, css::uno::RuntimeException
) override
;
147 virtual void SAL_CALL
addCloseListener( const css::uno::Reference
< css::util::XCloseListener
>& Listener
) throw (css::uno::RuntimeException
) override
;
148 virtual void SAL_CALL
removeCloseListener( const css::uno::Reference
< css::util::XCloseListener
>& Listener
) throw (css::uno::RuntimeException
) override
;
151 virtual css::uno::Any SAL_CALL
getTransferData( const css::datatransfer::DataFlavor
& aFlavor
) throw (css::datatransfer::UnsupportedFlavorException
, css::io::IOException
, css::uno::RuntimeException
) override
;
152 virtual css::uno::Sequence
< css::datatransfer::DataFlavor
> SAL_CALL
getTransferDataFlavors( ) throw (css::uno::RuntimeException
) override
;
153 virtual sal_Bool SAL_CALL
isDataFlavorSupported( const css::datatransfer::DataFlavor
& aFlavor
) throw (css::uno::RuntimeException
) override
;
156 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
) override
;
157 virtual void SAL_CALL
addEventListener(const css::uno::Reference
< css::lang::XEventListener
>& aListener
) throw (css::uno::RuntimeException
) override
;
158 virtual void SAL_CALL
removeEventListener(const css::uno::Reference
< css::lang::XEventListener
>& aListener
) throw (css::uno::RuntimeException
) override
;
161 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(css::uno::RuntimeException
) override
;
164 virtual sal_Bool SAL_CALL
isModified() throw (css::uno::RuntimeException
) override
;
165 virtual void SAL_CALL
setModified( sal_Bool bModified
)
166 throw (css::beans::PropertyVetoException
, css::uno::RuntimeException
) override
;
167 virtual void SAL_CALL
addModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& xListener
) throw(css::uno::RuntimeException
) override
;
168 virtual void SAL_CALL
removeModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& xListener
) throw(css::uno::RuntimeException
) override
;
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */