Update ooo320-m1
[ooovba.git] / embeddedobj / source / msole / olecomponent.hxx
blobf77dbd2330c1f0a7339dff6fc0a3aba2052fc48c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: olecomponent.hxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _INC_OLECOMPONENT_HXX_
32 #define _INC_OLECOMPONENT_HXX_
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <com/sun/star/uno/Reference.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <com/sun/star/util/XCloseable.hpp>
39 #include <com/sun/star/datatransfer/XTransferable.hpp>
40 #include <com/sun/star/io/XInputStream.hpp>
41 #include <com/sun/star/io/XOutputStream.hpp>
42 #include <com/sun/star/embed/XOptimizedStorage.hpp>
43 #include <com/sun/star/embed/VerbDescriptor.hpp>
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/awt/Size.hpp>
46 #include <com/sun/star/lang/XUnoTunnel.hpp>
47 #include <cppuhelper/implbase5.hxx>
48 #include <com/sun/star/util/XModifiable.hpp>
49 #include <com/sun/star/util/XModifyListener.hpp>
51 #include <vector>
54 namespace com { namespace sun { namespace star {
55 }}}
57 namespace cppu {
58 class OMultiTypeInterfaceContainerHelper;
61 class OleWrapperClientSite;
62 class OleWrapperAdviseSink;
63 class OleEmbeddedObject;
64 struct OleComponentNative_Impl;
66 class OleComponent : public ::cppu::WeakImplHelper5< ::com::sun::star::util::XCloseable, ::com::sun::star::lang::XComponent,
67 ::com::sun::star::lang::XUnoTunnel, ::com::sun::star::util::XModifiable,
68 ::com::sun::star::datatransfer::XTransferable >
70 ::osl::Mutex m_aMutex;
71 ::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer;
73 sal_Bool m_bDisposed;
74 sal_Bool m_bModified;
75 OleComponentNative_Impl* m_pNativeImpl;
77 OleEmbeddedObject* m_pUnoOleObject;
78 OleWrapperClientSite* m_pOleWrapClientSite;
79 OleWrapperAdviseSink* m_pImplAdviseSink;
81 sal_Int32 m_nOLEMiscFlags;
82 sal_Int32 m_nAdvConn;
84 ::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > m_aVerbList;
85 ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavors;
87 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
89 sal_Bool m_bOleInitialized;
91 // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
92 // such objects report the dirty state wrongly sometimes and do not allow to store them any time
93 sal_Bool m_bWorkaroundActive;
96 sal_Bool InitializeObject_Impl();
98 void CreateNewIStorage_Impl();
100 void RetrieveObjectDataFlavors_Impl();
102 void Dispose();
105 public:
106 OleComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& m_xFactory,
107 OleEmbeddedObject* pOleObj );
109 virtual ~OleComponent();
111 OleComponent* createEmbeddedCopyOfLink();
113 void disconnectEmbeddedObject();
115 static ::com::sun::star::awt::Size CalculateWithFactor( const ::com::sun::star::awt::Size& aSize,
116 const ::com::sun::star::awt::Size& aMultiplier,
117 const ::com::sun::star::awt::Size& aDivisor );
119 ::com::sun::star::awt::Size CalculateTheRealSize( const ::com::sun::star::awt::Size& aContSize, sal_Bool bUpdate );
121 // ==== Initialization ==================================================
122 void LoadEmbeddedObject( const ::rtl::OUString& aTempURL );
124 void CreateObjectFromClipboard();
126 void CreateNewEmbeddedObject( const ::com::sun::star::uno::Sequence< sal_Int8 >& aSeqCLSID );
128 void CreateObjectFromData(
129 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransfer );
131 void CreateObjectFromFile( const ::rtl::OUString& aFileName );
133 void CreateLinkFromFile( const ::rtl::OUString& aFileName );
135 void InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent );
137 // ======================================================================
139 void RunObject(); // switch OLE object to running state
141 void CloseObject(); // switch OLE object to loaded state
143 ::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > GetVerbList();
145 void ExecuteVerb( sal_Int32 nVerbID );
147 void SetHostName( const ::rtl::OUString& aContName, const ::rtl::OUString& aEmbDocName );
149 void SetExtent( const ::com::sun::star::awt::Size& aVisAreaSize, sal_Int64 nAspect );
151 ::com::sun::star::awt::Size GetExtent( sal_Int64 nAspect );
152 ::com::sun::star::awt::Size GetCachedExtent( sal_Int64 nAspect );
153 ::com::sun::star::awt::Size GetReccomendedExtent( sal_Int64 nAspect );
155 sal_Int64 GetMiscStatus( sal_Int64 nAspect );
157 ::com::sun::star::uno::Sequence< sal_Int8 > GetCLSID();
159 sal_Bool IsWorkaroundActive() { return m_bWorkaroundActive; }
161 sal_Bool IsDirty();
163 void StoreOwnTmpIfNecessary();
165 sal_Bool SaveObject_Impl();
166 sal_Bool OnShowWindow_Impl( bool bShow );
167 void OnViewChange_Impl( sal_uInt32 dwAspect );
168 void OnClose_Impl();
170 // XCloseable
171 virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
172 virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
173 virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
175 // XTransferable
176 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);
177 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw (::com::sun::star::uno::RuntimeException);
178 virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw (::com::sun::star::uno::RuntimeException);
180 // XComponent
181 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
182 virtual void SAL_CALL addEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
183 virtual void SAL_CALL removeEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
185 // XUnoTunnel
186 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException) ;
188 // XModifiable
189 virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
190 virtual void SAL_CALL setModified( sal_Bool bModified )
191 throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
192 virtual void SAL_CALL addModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
193 virtual void SAL_CALL removeModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
196 #endif