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