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