Kaydet (Commit) ddc43ba8 authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]

unoawt: now that the image control/model are not connected via…

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
üst 16ae4c15
......@@ -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
......
......@@ -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* );
};
//==================================================================
......
......@@ -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() )
......
......@@ -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(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment