Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / embeddedobj / source / msole / olecomponent.hxx
blob2ec7f8922db320be596df129433e9645f1cde51b
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 _INC_OLECOMPONENT_HXX_
21 #define _INC_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/implbase5.hxx>
37 #include <com/sun/star/util/XModifiable.hpp>
38 #include <com/sun/star/util/XModifyListener.hpp>
40 #include <vector>
43 namespace com { namespace sun { namespace star {
44 }}}
46 namespace cppu {
47 class OMultiTypeInterfaceContainerHelper;
50 class OleWrapperClientSite;
51 class OleWrapperAdviseSink;
52 class OleEmbeddedObject;
53 struct OleComponentNative_Impl;
55 class OleComponent : public ::cppu::WeakImplHelper5< ::com::sun::star::util::XCloseable, ::com::sun::star::lang::XComponent,
56 ::com::sun::star::lang::XUnoTunnel, ::com::sun::star::util::XModifiable,
57 ::com::sun::star::datatransfer::XTransferable >
59 ::osl::Mutex m_aMutex;
60 ::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer;
62 sal_Bool m_bDisposed;
63 sal_Bool m_bModified;
64 OleComponentNative_Impl* m_pNativeImpl;
66 OleEmbeddedObject* m_pUnoOleObject;
67 OleWrapperClientSite* m_pOleWrapClientSite;
68 OleWrapperAdviseSink* m_pImplAdviseSink;
70 sal_Int32 m_nOLEMiscFlags;
71 sal_Int32 m_nAdvConn;
73 ::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > m_aVerbList;
74 ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavors;
76 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
78 sal_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 sal_Bool m_bWorkaroundActive;
84 sal_Bool InitializeObject_Impl();
86 void CreateNewIStorage_Impl();
87 void RetrieveObjectDataFlavors_Impl();
88 void Dispose();
91 public:
92 OleComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& m_xFactory,
93 OleEmbeddedObject* pOleObj );
95 virtual ~OleComponent();
97 OleComponent* createEmbeddedCopyOfLink();
99 void disconnectEmbeddedObject();
101 static ::com::sun::star::awt::Size CalculateWithFactor( const ::com::sun::star::awt::Size& aSize,
102 const ::com::sun::star::awt::Size& aMultiplier,
103 const ::com::sun::star::awt::Size& aDivisor );
105 ::com::sun::star::awt::Size CalculateTheRealSize( const ::com::sun::star::awt::Size& aContSize, sal_Bool bUpdate );
107 // ==== Initialization ==================================================
108 void LoadEmbeddedObject( const OUString& aTempURL );
109 void CreateObjectFromClipboard();
110 void CreateNewEmbeddedObject( const ::com::sun::star::uno::Sequence< sal_Int8 >& aSeqCLSID );
111 void CreateObjectFromData(
112 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransfer );
113 void CreateObjectFromFile( const OUString& aFileName );
114 void CreateLinkFromFile( const OUString& aFileName );
115 void InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent );
117 // ======================================================================
118 void RunObject(); // switch OLE object to running state
119 void CloseObject(); // switch OLE object to loaded state
121 ::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > GetVerbList();
123 void ExecuteVerb( sal_Int32 nVerbID );
124 void SetHostName( const OUString& aContName, const OUString& aEmbDocName );
125 void SetExtent( const ::com::sun::star::awt::Size& aVisAreaSize, sal_Int64 nAspect );
127 ::com::sun::star::awt::Size GetExtent( sal_Int64 nAspect );
128 ::com::sun::star::awt::Size GetCachedExtent( sal_Int64 nAspect );
129 ::com::sun::star::awt::Size GetReccomendedExtent( sal_Int64 nAspect );
131 sal_Int64 GetMiscStatus( sal_Int64 nAspect );
133 ::com::sun::star::uno::Sequence< sal_Int8 > GetCLSID();
135 sal_Bool IsWorkaroundActive() { return m_bWorkaroundActive; }
136 sal_Bool IsDirty();
138 void StoreOwnTmpIfNecessary();
140 sal_Bool SaveObject_Impl();
141 sal_Bool OnShowWindow_Impl( bool bShow );
142 void OnViewChange_Impl( sal_uInt32 dwAspect );
143 void OnClose_Impl();
145 // XCloseable
146 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
147 virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
148 virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
150 // XTransferable
151 virtual ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
152 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (::com::sun::star::uno::RuntimeException);
153 virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw (::com::sun::star::uno::RuntimeException);
155 // XComponent
156 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
157 virtual void SAL_CALL addEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
158 virtual void SAL_CALL removeEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
160 // XUnoTunnel
161 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException) ;
163 // XModifiable
164 virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
165 virtual void SAL_CALL setModified( sal_Bool bModified )
166 throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
167 virtual void SAL_CALL addModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
168 virtual void SAL_CALL removeModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */