diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-10-04 18:55:50 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-10-04 18:55:50 +0000 |
commit | bebff39cbcf4cd2c93d8f403c912587fe43c2b6c (patch) | |
tree | 0c348f1689da31ee2d2d330dd8e1f9b0b8ee1822 /embeddedobj | |
parent | e730782789c7fd7c2eda22ef804e4a18ac860fae (diff) |
INTEGRATION: CWS mav09 (1.2.2); FILE MERGED
2004/09/01 14:52:58 mav 1.2.2.11: #i27773# the case when there is no server for the object
2004/09/01 12:20:03 mav 1.2.2.10: #i27773# caching is still not implemented for windows
2004/09/01 12:15:39 mav 1.2.2.9: #i27773# caching is still not implemented for windows
2004/09/01 12:08:48 mav 1.2.2.8: #i27773# getStatus of OLE object on Unix
2004/08/19 15:59:05 mav 1.2.2.7: #i27773# let the replacement be updated
2004/05/28 16:19:08 mba 1.2.2.6: #27773#: some wrong MediaTypes
2004/05/24 09:02:53 mba 1.2.2.5: #i27773#: some changes about MapUnit
2004/05/18 16:38:32 mav 1.2.2.4: #i27773# resolv resync problems
2004/05/18 12:34:43 mav 1.2.2.3: #i27773# solve resync problems
2004/05/17 18:26:40 mav 1.2.2.2: RESYNC: (1.2-1.3); FILE MERGED
2004/05/12 10:12:32 mav 1.2.2.1: #i27773# graphical replacement and persistance setting related changes
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/msole/olevisual.cxx | 172 |
1 files changed, 136 insertions, 36 deletions
diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx index fe6841f6bbfe..74e3d98fcea5 100644 --- a/embeddedobj/source/msole/olevisual.cxx +++ b/embeddedobj/source/msole/olevisual.cxx @@ -2,9 +2,9 @@ * * $RCSfile: olevisual.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2004-05-10 17:54:24 $ + * last change: $Author: kz $ $Date: 2004-10-04 19:55:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,8 +67,12 @@ #include <com/sun/star/embed/EmbedStates.hpp> #endif -#ifndef _COM_SUN_STAR_EMBED_EMBEDMAPMODES_HPP_ -#include <com/sun/star/embed/EmbedMapModes.hpp> +#ifndef _COM_SUN_STAR_EMBED_EMBEDMAPUNITS_HPP_ +#include <com/sun/star/embed/EmbedMapUnits.hpp> +#endif + +#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_ +#include <com/sun/star/io/XSeekable.hpp> #endif #include <oleembobj.hxx> @@ -77,6 +81,46 @@ using namespace ::com::sun::star; +embed::VisualRepresentation OleEmbeddedObject::GetVisualRepresentationInNativeFormat_Impl( + const uno::Reference< io::XStream > xCachedVisRepr ) + throw ( uno::Exception ) +{ + embed::VisualRepresentation aVisualRepr; + + // TODO: detect the format in the future for now use workaround + uno::Reference< io::XInputStream > xInStream = xCachedVisRepr->getInputStream(); + uno::Reference< io::XSeekable > xSeekable( xCachedVisRepr, uno::UNO_QUERY ); + if ( !xInStream.is() || !xSeekable.is() ) + throw uno::RuntimeException(); + + uno::Sequence< sal_Int8 > aSeq( 2 ); + xInStream->readBytes( aSeq, 2 ); + xSeekable->seek( 0 ); + if ( aSeq.getLength() == 2 && aSeq[0] == 'B' && aSeq[1] == 'M' ) + { + // it's a bitmap + aVisualRepr.Flavor = datatransfer::DataFlavor( + ::rtl::OUString::createFromAscii( "application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"" ), + ::rtl::OUString::createFromAscii( "Bitmap" ), + ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) ); + } + else + { + // it's a metafile + aVisualRepr.Flavor = datatransfer::DataFlavor( + ::rtl::OUString::createFromAscii( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" ), + ::rtl::OUString::createFromAscii( "Windows Metafile" ), + ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) ); + } + + sal_Int32 nStreamLength = (sal_Int32)xSeekable->getLength(); + uno::Sequence< sal_Int8 > aRepresent( nStreamLength ); + xInStream->readBytes( aRepresent, nStreamLength ); + aVisualRepr.Data <<= aRepresent; + + return aVisualRepr; +} + void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize ) throw ( lang::IllegalArgumentException, embed::WrongStateException, @@ -87,18 +131,29 @@ void SAL_CALL OleEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt if ( m_bDisposed ) throw lang::DisposedException(); // TODO - if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ), + if ( m_nObjectState == -1 ) + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not loaded!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); -#ifdef WNT - if ( !m_pOleComponent ) - throw uno::RuntimeException(); - m_pOleComponent->SetExtent( aSize, nAspect ); // will throw an exception in case of failure -#else - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), +#ifdef WNT + if ( m_pOleComponent ) + { + if ( m_nObjectState == embed::EmbedStates::LOADED ) + throw embed::WrongStateException( + ::rtl::OUString::createFromAscii( "The object has no model!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + + m_pOleComponent->SetExtent( aSize, nAspect ); // will throw an exception in case of failure + } + else #endif + { + // cache the values + m_aCachedSize = aSize; + + // throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), + // uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + } } awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) @@ -111,52 +166,97 @@ awt::Size SAL_CALL OleEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect ) if ( m_bDisposed ) throw lang::DisposedException(); // TODO - if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ), + if ( m_nObjectState == -1 ) + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not loaded!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); -#ifdef WNT - if ( !m_pOleComponent ) - throw uno::RuntimeException(); - return m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure -#else - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), +#ifdef WNT + if ( m_pOleComponent ) + { + // TODO/LATER: the caching should be used also + if ( m_nObjectState == embed::EmbedStates::LOADED ) + throw embed::WrongStateException( + ::rtl::OUString::createFromAscii( "The object has no model!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + + return m_pOleComponent->GetExtent( nAspect ); // will throw an exception in case of failure + } + else #endif + { + // return cached value + return m_aCachedSize; + + // throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), + // uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + } } -sal_Int32 SAL_CALL OleEmbeddedObject::getMapMode( sal_Int64 nAspect ) - throw ( uno::Exception, - uno::RuntimeException) +embed::VisualRepresentation SAL_CALL OleEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect ) + throw ( lang::IllegalArgumentException, + embed::WrongStateException, + uno::Exception, + uno::RuntimeException ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO - if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ), + // TODO: if the object has cached representation then it should be returned + // TODO: if the object has no cached representation and is in loaded state it should switch itself to the running state + if ( m_nObjectState == -1 ) + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not loaded!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); - // OLE objects are always controlled in pixels, - // internally a workaround with scaling based on visual representation is used - return embed::EmbedMapModes::PIXEL; + embed::VisualRepresentation aVisualRepr; + + // TODO: in case of different aspects they must be applied to the mediatype and XTransferable must be used + if ( !m_xCachedVisualRepresentation.is() && m_bVisReplInStream ) + m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream ); + + if ( m_xCachedVisualRepresentation.is() ) + { + return GetVisualRepresentationInNativeFormat_Impl( m_xCachedVisualRepresentation ); + } +#ifdef WNT + else if ( m_pOleComponent ) + { + if ( m_nObjectState == embed::EmbedStates::LOADED ) + throw embed::WrongStateException( + ::rtl::OUString::createFromAscii( "The object has no model!\n" ), + uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + + datatransfer::DataFlavor aDataFlavor( + ::rtl::OUString::createFromAscii( "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"" ), + ::rtl::OUString::createFromAscii( "Windows Metafile" ), + ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) ); + + aVisualRepr.Data = m_pOleComponent->getTransferData( aDataFlavor ); + aVisualRepr.Flavor = aDataFlavor; + } +#endif + else + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "Illegal call!\n" ), + uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); + + return aVisualRepr; } -#if 0 -// Probably will be removed!!! -uno::Any SAL_CALL OleEmbeddedObject::getVisualCache( sal_Int64 nAspect ) +sal_Int32 SAL_CALL OleEmbeddedObject::getMapUnit( sal_Int64 nAspect ) throw ( uno::Exception, - uno::RuntimeException ) + uno::RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO - if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED ) - throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The own object has no model!\n" ), + if ( m_nObjectState == -1 ) + throw embed::WrongStateException( ::rtl::OUString::createFromAscii( "The object is not loaded!\n" ), uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) ); - return uno::makeAny( uno::Sequence< sal_Int8 >() ); + // TODO/LATER: ??? OLE objects should be always controlled in pixels, + // internally a workaround with scaling based on visual representation will be used + return embed::EmbedMapUnits::ONE_100TH_MM; } -#endif + |