From ddc43ba8f731c103d24daf8537d5437800ae0c09 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Sun, 20 Jun 2010 22:36:14 +0200 Subject: unoawt: now that the image control/model are not connected via XImageProducer/Consumer anymore, ensure that images loaded from a database document are displayed, too --- forms/source/component/ImageControl.cxx | 11 +++++++++ forms/source/component/ImageControl.hxx | 2 ++ forms/source/component/imgprod.cxx | 43 +++++---------------------------- forms/source/component/imgprod.hxx | 22 +++-------------- 4 files changed, 23 insertions(+), 55 deletions(-) (limited to 'forms') diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index 72d22d3f30a5..f74e82135708 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -190,6 +190,7 @@ void OImageControlModel::implConstruct() { m_pImageProducer = new ImageProducer; m_xImageProducer = m_pImageProducer; + m_pImageProducer->SetDoneHdl( LINK( this, OImageControlModel, OnImageImportDone ) ); } //------------------------------------------------------------------ @@ -630,6 +631,16 @@ void SAL_CALL OImageControlModel::startProduction( ) throw (RuntimeException) GetImageProducer()->startProduction(); } +//------------------------------------------------------------------------------ +IMPL_LINK( OImageControlModel, OnImageImportDone, ::Graphic*, i_pGraphic ) +{ + ENSURE_OR_RETURN( i_pGraphic, "OImageControlModel::OnImageImportDone: illegal graphic!", 0L ); + setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Graphic" ) ), + makeAny( Image( i_pGraphic->GetBitmapEx() ).GetXGraphic() ) + ); + return 1L; +} //================================================================== // OImageControlControl diff --git a/forms/source/component/ImageControl.hxx b/forms/source/component/ImageControl.hxx index eb0e15660ca6..c31216fc8aca 100644 --- a/forms/source/component/ImageControl.hxx +++ b/forms/source/component/ImageControl.hxx @@ -140,6 +140,8 @@ protected: bound field, or the control itself if there is no bound field */ sal_Bool impl_updateStreamForURL_lck( const ::rtl::OUString& _rURL, ValueChangeInstigator _eInstigator ); + + DECL_LINK( OnImageImportDone, ::Graphic* ); }; //================================================================== diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index 8bd02173fc3f..8ee2315f366b 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -190,11 +190,7 @@ ErrCode ImgProdLockBytes::Stat( SvLockBytesStat* pStat, SvLockBytesStatFlag eFla ImageProducer::ImageProducer() : mpStm ( NULL ), - mpFilter ( NULL ), - mnStatus ( 0UL ), - mbConsInit ( sal_False ), - mnLastError ( 0UL ), - mbAsync ( sal_False ) + mbConsInit ( sal_False ) { mpGraphic = new Graphic; DBG_ASSERT( Application::GetFilterHdl().IsSet(), "ImageProducer::ImageProducer(): No filter handler set" ); @@ -207,9 +203,6 @@ ImageProducer::~ImageProducer() delete mpGraphic; mpGraphic = NULL; - delete mpFilter; - mpFilter = NULL; - delete mpStm; mpStm = NULL; @@ -261,7 +254,6 @@ void ImageProducer::SetImage( const ::rtl::OUString& rPath ) maURL = rPath; mpGraphic->Clear(); mbConsInit = sal_False; - mbAsync = sal_False; delete mpStm; if ( ::svt::GraphicAccess::isSupportedURL( maURL ) ) @@ -284,7 +276,6 @@ void ImageProducer::SetImage( SvStream& rStm ) maURL = ::rtl::OUString(); mpGraphic->Clear(); mbConsInit = sal_False; - mbAsync = sal_False; delete mpStm; mpStm = new SvStream( new ImgProdLockBytes( &rStm, sal_False ) ); @@ -297,7 +288,6 @@ void ImageProducer::setImage( ::com::sun::star::uno::Reference< ::com::sun::star maURL = ::rtl::OUString(); mpGraphic->Clear(); mbConsInit = sal_False; - mbAsync = sal_False; delete mpStm; if( rInputStmRef.is() ) @@ -318,9 +308,7 @@ void ImageProducer::NewDataAvailable() void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeException) { - ResetLastError(); - - if( maConsList.Count() ) + if( maConsList.Count() || maDoneHdl.IsSet() ) { bool bNotifyEmptyGraphics = false; @@ -331,8 +319,8 @@ void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeExcept // graphic is cleared if a new Stream is set if( ( mpGraphic->GetType() == GRAPHIC_NONE ) || mpGraphic->GetContext() ) { - if( !ImplImportGraphic( *mpGraphic ) && maErrorHdl.IsSet() ) - maErrorHdl.Call( this ); + if ( ImplImportGraphic( *mpGraphic ) && maDoneHdl.IsSet() ) + maDoneHdl.Call( mpGraphic ); } if( mpGraphic->GetType() != GRAPHIC_NONE ) @@ -372,32 +360,17 @@ void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeExcept sal_Bool ImageProducer::ImplImportGraphic( Graphic& rGraphic ) { USHORT nFilter = GRFILTER_FORMAT_DONTKNOW; - short nRet; - sal_Bool bRet = sal_False; if( ERRCODE_IO_PENDING == mpStm->GetError() ) mpStm->ResetError(); mpStm->Seek( 0UL ); - if( mpFilter ) - nRet = mpFilter->ImportGraphic( rGraphic, String(), *mpStm, nFilter ); - else - { - if( GraphicConverter::Import( *mpStm, rGraphic ) == ERRCODE_NONE ) - nRet = GRFILTER_OK; - else - nRet = GRFILTER_FILTERERROR; - } + sal_Bool bRet = GraphicConverter::Import( *mpStm, rGraphic ) == ERRCODE_NONE; if( ERRCODE_IO_PENDING == mpStm->GetError() ) mpStm->ResetError(); - if( nRet == GRFILTER_OK ) - bRet = sal_True; - else - mnLastError = nRet; - return bRet; } @@ -405,10 +378,6 @@ sal_Bool ImageProducer::ImplImportGraphic( Graphic& rGraphic ) void ImageProducer::ImplUpdateData( const Graphic& rGraphic ) { - // asynchronous? - if( mpGraphic->GetContext() ) - mbAsync = sal_True; - ImplInitConsumer( rGraphic ); if( mbConsInit && maConsList.Count() ) @@ -425,7 +394,7 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic ) // iterate through interfaces for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() ) - ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->complete( mnStatus = ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this ); + ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this ); // delete interfaces in temporary list for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() ) diff --git a/forms/source/component/imgprod.hxx b/forms/source/component/imgprod.hxx index 0da5d04755df..170fc186fa73 100644 --- a/forms/source/component/imgprod.hxx +++ b/forms/source/component/imgprod.hxx @@ -64,20 +64,9 @@ private: List maConsList; Graphic* mpGraphic; SvStream* mpStm; - GraphicFilter* mpFilter; sal_uInt32 mnTransIndex; - sal_uInt32 mnStatus; sal_Bool mbConsInit; - sal_Bool mbStmDel; - Link maErrorHdl; - sal_uInt32 mnLastError; - - sal_uInt32 mnExtra2; - - sal_Bool mbAsync; - sal_Bool mbExtra1; - sal_Bool mbExtra2; - sal_Bool mbExtra3; + Link maDoneHdl; sal_Bool ImplImportGraphic( Graphic& rGraphic ); void ImplUpdateData( const Graphic& rGraphic ); @@ -92,14 +81,11 @@ public: void SetImage( const ::rtl::OUString& rPath ); void SetImage( SvStream& rStm ); - void SetErrorHandler( const Link& rErrorHdl ) { maErrorHdl = rErrorHdl; } - const Link& GetErrorHandler() const { return maErrorHdl; } - - sal_uInt32 GetLastError() const { return mnLastError; } - void ResetLastError() { mnLastError = 0; } - void NewDataAvailable(); + void SetDoneHdl( const Link& i_rHdl ) { maDoneHdl = i_rHdl; } + const Link& GetDoneHdl() const { return maDoneHdl; } + // ::com::sun::star::uno::XInterface ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL acquire() throw() { OWeakObject::acquire(); } -- cgit v1.2.3