1*08421ca6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*08421ca6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*08421ca6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*08421ca6SAndrew Rist  * distributed with this work for additional information
6*08421ca6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*08421ca6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*08421ca6SAndrew Rist  * "License"); you may not use this file except in compliance
9*08421ca6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*08421ca6SAndrew Rist  *
11*08421ca6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*08421ca6SAndrew Rist  *
13*08421ca6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*08421ca6SAndrew Rist  * software distributed under the License is distributed on an
15*08421ca6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*08421ca6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*08421ca6SAndrew Rist  * specific language governing permissions and limitations
18*08421ca6SAndrew Rist  * under the License.
19*08421ca6SAndrew Rist  *
20*08421ca6SAndrew Rist  *************************************************************/
21*08421ca6SAndrew Rist 
22*08421ca6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _INC_OLECOMPONENT_HXX_
25cdf0e10cSrcweir #define _INC_OLECOMPONENT_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
28cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
29cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
30cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
31cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
32cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
34cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
35cdf0e10cSrcweir #include <com/sun/star/embed/XOptimizedStorage.hpp>
36cdf0e10cSrcweir #include <com/sun/star/embed/VerbDescriptor.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
39cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
40cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
41cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
42cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <vector>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace com { namespace sun { namespace star {
48cdf0e10cSrcweir }}}
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace cppu {
51cdf0e10cSrcweir 	class OMultiTypeInterfaceContainerHelper;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir class OleWrapperClientSite;
55cdf0e10cSrcweir class OleWrapperAdviseSink;
56cdf0e10cSrcweir class OleEmbeddedObject;
57cdf0e10cSrcweir struct OleComponentNative_Impl;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir class OleComponent : public ::cppu::WeakImplHelper5< ::com::sun::star::util::XCloseable, ::com::sun::star::lang::XComponent,
60cdf0e10cSrcweir                                                      ::com::sun::star::lang::XUnoTunnel, ::com::sun::star::util::XModifiable,
61cdf0e10cSrcweir 													 ::com::sun::star::datatransfer::XTransferable >
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	::osl::Mutex m_aMutex;
64cdf0e10cSrcweir 	::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	sal_Bool m_bDisposed;
67cdf0e10cSrcweir     sal_Bool m_bModified;
68cdf0e10cSrcweir 	OleComponentNative_Impl* m_pNativeImpl;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	OleEmbeddedObject* m_pUnoOleObject;
71cdf0e10cSrcweir 	OleWrapperClientSite* m_pOleWrapClientSite;
72cdf0e10cSrcweir 	OleWrapperAdviseSink* m_pImplAdviseSink;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	sal_Int32 m_nOLEMiscFlags;
75cdf0e10cSrcweir 	sal_Int32 m_nAdvConn;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > m_aVerbList;
78cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavors;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	sal_Bool m_bOleInitialized;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	// specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
85cdf0e10cSrcweir 	// such objects report the dirty state wrongly sometimes and do not allow to store them any time
86cdf0e10cSrcweir 	sal_Bool m_bWorkaroundActive;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	sal_Bool InitializeObject_Impl();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	void CreateNewIStorage_Impl();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	void RetrieveObjectDataFlavors_Impl();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	void Dispose();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir 	OleComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& m_xFactory,
100cdf0e10cSrcweir 				  OleEmbeddedObject* pOleObj );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	virtual ~OleComponent();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	OleComponent* createEmbeddedCopyOfLink();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	void disconnectEmbeddedObject();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	static ::com::sun::star::awt::Size CalculateWithFactor( const ::com::sun::star::awt::Size& aSize,
109cdf0e10cSrcweir 															const ::com::sun::star::awt::Size& aMultiplier,
110cdf0e10cSrcweir 															const ::com::sun::star::awt::Size& aDivisor );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	::com::sun::star::awt::Size CalculateTheRealSize( const ::com::sun::star::awt::Size& aContSize, sal_Bool bUpdate );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	// ==== Initialization ==================================================
115cdf0e10cSrcweir 	void LoadEmbeddedObject( const ::rtl::OUString& aTempURL );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	void CreateObjectFromClipboard();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	void CreateNewEmbeddedObject( const ::com::sun::star::uno::Sequence< sal_Int8 >& aSeqCLSID );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	void CreateObjectFromData(
122cdf0e10cSrcweir 						const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransfer );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	void CreateObjectFromFile( const ::rtl::OUString& aFileName );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	void CreateLinkFromFile( const ::rtl::OUString& aFileName );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	void InitEmbeddedCopyOfLink( OleComponent* pOleLinkComponent );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	// ======================================================================
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	void RunObject(); // switch OLE object to running state
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	void CloseObject(); // switch OLE object to loaded state
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::embed::VerbDescriptor > GetVerbList();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	void ExecuteVerb( sal_Int32 nVerbID );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	void SetHostName( const ::rtl::OUString& aContName, const ::rtl::OUString& aEmbDocName );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	void SetExtent( const ::com::sun::star::awt::Size& aVisAreaSize, sal_Int64 nAspect );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	::com::sun::star::awt::Size GetExtent( sal_Int64 nAspect );
145cdf0e10cSrcweir 	::com::sun::star::awt::Size GetCachedExtent( sal_Int64 nAspect );
146cdf0e10cSrcweir 	::com::sun::star::awt::Size GetReccomendedExtent( sal_Int64 nAspect );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	sal_Int64 GetMiscStatus( sal_Int64 nAspect );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< sal_Int8 > GetCLSID();
151cdf0e10cSrcweir 
IsWorkaroundActive()152cdf0e10cSrcweir 	sal_Bool IsWorkaroundActive() { return m_bWorkaroundActive; }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	sal_Bool IsDirty();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	void StoreOwnTmpIfNecessary();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	sal_Bool SaveObject_Impl();
159cdf0e10cSrcweir 	sal_Bool OnShowWindow_Impl( bool bShow );
160cdf0e10cSrcweir 	void OnViewChange_Impl( sal_uInt32 dwAspect );
161cdf0e10cSrcweir 	void OnClose_Impl();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	// XCloseable
164cdf0e10cSrcweir     virtual void SAL_CALL close( sal_Bool DeliverOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
165cdf0e10cSrcweir     virtual void SAL_CALL addCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
166cdf0e10cSrcweir     virtual void SAL_CALL removeCloseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	// XTransferable
169cdf0e10cSrcweir     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);
170cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors(  ) throw (::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw (::com::sun::star::uno::RuntimeException);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     // XComponent
174cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
175cdf0e10cSrcweir     virtual void SAL_CALL addEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
176cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener(const com::sun::star::uno::Reference < com::sun::star::lang::XEventListener >& aListener) throw (::com::sun::star::uno::RuntimeException);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	// XUnoTunnel
179cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException) ;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     // XModifiable
182cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
183cdf0e10cSrcweir 	virtual void SAL_CALL setModified( sal_Bool bModified )
184cdf0e10cSrcweir         throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
185cdf0e10cSrcweir     virtual void SAL_CALL addModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
186cdf0e10cSrcweir     virtual void SAL_CALL removeModifyListener( const com::sun::star::uno::Reference < com::sun::star::util::XModifyListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir };
188cdf0e10cSrcweir 
189cdf0e10cSrcweir #endif
190cdf0e10cSrcweir 
191