1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _INC_OLECOMPONENT_HXX_
30 #define _INC_OLECOMPONENT_HXX_
32 #include <com/sun/star/uno/Sequence.hxx>
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <com/sun/star/uno/Any.hxx>
35 #include <com/sun/star/lang/XComponent.hpp>
36 #include <com/sun/star/util/XCloseable.hpp>
37 #include <com/sun/star/datatransfer/XTransferable.hpp>
38 #include <com/sun/star/io/XInputStream.hpp>
39 #include <com/sun/star/io/XOutputStream.hpp>
40 #include <com/sun/star/embed/XOptimizedStorage.hpp>
41 #include <com/sun/star/embed/VerbDescriptor.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #include <com/sun/star/awt/Size.hpp>
44 #include <com/sun/star/lang/XUnoTunnel.hpp>
45 #include <cppuhelper/implbase5.hxx>
46 #include <com/sun/star/util/XModifiable.hpp>
47 #include <com/sun/star/util/XModifyListener.hpp>
52 namespace com
{ namespace sun
{ namespace star
{
56 class OMultiTypeInterfaceContainerHelper
;
59 class OleWrapperClientSite
;
60 class OleWrapperAdviseSink
;
61 class OleEmbeddedObject
;
62 struct OleComponentNative_Impl
;
64 class OleComponent
: public ::cppu::WeakImplHelper5
< ::com::sun::star::util::XCloseable
, ::com::sun::star::lang::XComponent
,
65 ::com::sun::star::lang::XUnoTunnel
, ::com::sun::star::util::XModifiable
,
66 ::com::sun::star::datatransfer::XTransferable
>
68 ::osl::Mutex m_aMutex
;
69 ::cppu::OMultiTypeInterfaceContainerHelper
* m_pInterfaceContainer
;
73 OleComponentNative_Impl
* m_pNativeImpl
;
75 OleEmbeddedObject
* m_pUnoOleObject
;
76 OleWrapperClientSite
* m_pOleWrapClientSite
;
77 OleWrapperAdviseSink
* m_pImplAdviseSink
;
79 sal_Int32 m_nOLEMiscFlags
;
82 ::com::sun::star::uno::Sequence
< ::com::sun::star::embed::VerbDescriptor
> m_aVerbList
;
83 ::com::sun::star::uno::Sequence
< ::com::sun::star::datatransfer::DataFlavor
> m_aDataFlavors
;
85 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xFactory
;
87 sal_Bool m_bOleInitialized
;
89 // specifies whether the workaround for some rare embedded objects is activated ( f.e. AcrobatReader 7.0.8 object )
90 // such objects report the dirty state wrongly sometimes and do not allow to store them any time
91 sal_Bool m_bWorkaroundActive
;
93 sal_Bool
InitializeObject_Impl();
95 void CreateNewIStorage_Impl();
96 void RetrieveObjectDataFlavors_Impl();
101 OleComponent( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& m_xFactory
,
102 OleEmbeddedObject
* pOleObj
);
104 virtual ~OleComponent();
106 OleComponent
* createEmbeddedCopyOfLink();
108 void disconnectEmbeddedObject();
110 static ::com::sun::star::awt::Size
CalculateWithFactor( const ::com::sun::star::awt::Size
& aSize
,
111 const ::com::sun::star::awt::Size
& aMultiplier
,
112 const ::com::sun::star::awt::Size
& aDivisor
);
114 ::com::sun::star::awt::Size
CalculateTheRealSize( const ::com::sun::star::awt::Size
& aContSize
, sal_Bool bUpdate
);
116 // ==== Initialization ==================================================
117 void LoadEmbeddedObject( const ::rtl::OUString
& aTempURL
);
118 void CreateObjectFromClipboard();
119 void CreateNewEmbeddedObject( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aSeqCLSID
);
120 void CreateObjectFromData(
121 const ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
>& xTransfer
);
122 void CreateObjectFromFile( const ::rtl::OUString
& aFileName
);
123 void CreateLinkFromFile( const ::rtl::OUString
& aFileName
);
124 void InitEmbeddedCopyOfLink( OleComponent
* pOleLinkComponent
);
126 // ======================================================================
127 void RunObject(); // switch OLE object to running state
128 void CloseObject(); // switch OLE object to loaded state
130 ::com::sun::star::uno::Sequence
< ::com::sun::star::embed::VerbDescriptor
> GetVerbList();
132 void ExecuteVerb( sal_Int32 nVerbID
);
133 void SetHostName( const ::rtl::OUString
& aContName
, const ::rtl::OUString
& aEmbDocName
);
134 void SetExtent( const ::com::sun::star::awt::Size
& aVisAreaSize
, sal_Int64 nAspect
);
136 ::com::sun::star::awt::Size
GetExtent( sal_Int64 nAspect
);
137 ::com::sun::star::awt::Size
GetCachedExtent( sal_Int64 nAspect
);
138 ::com::sun::star::awt::Size
GetReccomendedExtent( sal_Int64 nAspect
);
140 sal_Int64
GetMiscStatus( sal_Int64 nAspect
);
142 ::com::sun::star::uno::Sequence
< sal_Int8
> GetCLSID();
144 sal_Bool
IsWorkaroundActive() { return m_bWorkaroundActive
; }
147 void StoreOwnTmpIfNecessary();
149 sal_Bool
SaveObject_Impl();
150 sal_Bool
OnShowWindow_Impl( bool bShow
);
151 void OnViewChange_Impl( sal_uInt32 dwAspect
);
155 virtual void SAL_CALL
close( sal_Bool DeliverOwnership
) throw (::com::sun::star::util::CloseVetoException
, ::com::sun::star::uno::RuntimeException
);
156 virtual void SAL_CALL
addCloseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
157 virtual void SAL_CALL
removeCloseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseListener
>& Listener
) throw (::com::sun::star::uno::RuntimeException
);
160 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
);
161 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::datatransfer::DataFlavor
> SAL_CALL
getTransferDataFlavors( ) throw (::com::sun::star::uno::RuntimeException
);
162 virtual sal_Bool SAL_CALL
isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor
& aFlavor
) throw (::com::sun::star::uno::RuntimeException
);
165 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
);
166 virtual void SAL_CALL
addEventListener(const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
167 virtual void SAL_CALL
removeEventListener(const com::sun::star::uno::Reference
< com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
170 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aIdentifier
) throw(::com::sun::star::uno::RuntimeException
) ;
173 virtual sal_Bool SAL_CALL
isModified() throw (::com::sun::star::uno::RuntimeException
);
174 virtual void SAL_CALL
setModified( sal_Bool bModified
)
175 throw (::com::sun::star::beans::PropertyVetoException
, ::com::sun::star::uno::RuntimeException
);
176 virtual void SAL_CALL
addModifyListener( const com::sun::star::uno::Reference
< com::sun::star::util::XModifyListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
177 virtual void SAL_CALL
removeModifyListener( const com::sun::star::uno::Reference
< com::sun::star::util::XModifyListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */