Kaydet (Commit) 70f15298 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

tdf#47832: Pictures on buttons, created in forms, gone after reopening form

When image is set to a Button control the correspoding graphic object
lives only temporarily, after the graphic is copied from the graphic
object it's destroyed so save can't find it by graphic ID.
Use the same solution which works for ImageControls: use a graphic object
member for the control, so save can find it.

Change-Id: If99a3efc4727a07df9d2daaefbdacc9565920005
üst c657740b
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/awt/ActionEvent.hpp> #include <com/sun/star/awt/ActionEvent.hpp>
#include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/awt/XActionListener.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/graphic/GraphicObject.hpp>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
...@@ -62,6 +64,7 @@ namespace frm ...@@ -62,6 +64,7 @@ namespace frm
using namespace ::com::sun::star::util; using namespace ::com::sun::star::util;
using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::form::submission; using namespace ::com::sun::star::form::submission;
using namespace ::com::sun::star::graphic;
using ::com::sun::star::awt::MouseEvent; using ::com::sun::star::awt::MouseEvent;
using ::com::sun::star::task::XInteractionHandler; using ::com::sun::star::task::XInteractionHandler;
...@@ -451,6 +454,7 @@ namespace frm ...@@ -451,6 +454,7 @@ namespace frm
const OUString& rDefault ) const OUString& rDefault )
:OControlModel( _rxFactory, _rUnoControlModelTypeName, rDefault ) :OControlModel( _rxFactory, _rUnoControlModelTypeName, rDefault )
,OPropertyChangeListener(m_aMutex) ,OPropertyChangeListener(m_aMutex)
,m_xGraphicObject()
,m_pMedium(NULL) ,m_pMedium(NULL)
,m_pProducer( NULL ) ,m_pProducer( NULL )
,m_bDispatchUrlInternal(false) ,m_bDispatchUrlInternal(false)
...@@ -465,6 +469,7 @@ namespace frm ...@@ -465,6 +469,7 @@ namespace frm
OClickableImageBaseModel::OClickableImageBaseModel( const OClickableImageBaseModel* _pOriginal, const Reference<XComponentContext>& _rxFactory ) OClickableImageBaseModel::OClickableImageBaseModel( const OClickableImageBaseModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
:OControlModel( _pOriginal, _rxFactory ) :OControlModel( _pOriginal, _rxFactory )
,OPropertyChangeListener( m_aMutex ) ,OPropertyChangeListener( m_aMutex )
,m_xGraphicObject( _pOriginal->m_xGraphicObject )
,m_pMedium( NULL ) ,m_pMedium( NULL )
,m_pProducer( NULL ) ,m_pProducer( NULL )
,m_bDispatchUrlInternal(false) ,m_bDispatchUrlInternal(false)
...@@ -497,6 +502,7 @@ namespace frm ...@@ -497,6 +502,7 @@ namespace frm
void OClickableImageBaseModel::implConstruct() void OClickableImageBaseModel::implConstruct()
{ {
m_pProducer = new ImageProducer; m_pProducer = new ImageProducer;
m_pProducer->SetDoneHdl( LINK( this, OClickableImageBaseModel, OnImageImportDone ) );
osl_atomic_increment( &m_refCount ); osl_atomic_increment( &m_refCount );
{ {
m_xProducer = m_pProducer; m_xProducer = m_pProducer;
...@@ -851,6 +857,21 @@ namespace frm ...@@ -851,6 +857,21 @@ namespace frm
} }
} }
IMPL_LINK( OClickableImageBaseModel, OnImageImportDone, Graphic*, i_pGraphic )
{
const Reference< XGraphic > xGraphic( i_pGraphic != NULL ? Graphic(i_pGraphic->GetBitmapEx()).GetXGraphic() : NULL );
if ( !xGraphic.is() )
{
m_xGraphicObject.clear();
}
else
{
m_xGraphicObject = GraphicObject::create( m_xContext );
m_xGraphicObject->setGraphic( xGraphic );
}
return 1L;
}
// OImageProducerThread_Impl // OImageProducerThread_Impl
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <com/sun/star/form/submission/XSubmission.hpp> #include <com/sun/star/form/submission/XSubmission.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
#include <com/sun/star/graphic/XGraphicObject.hpp>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
...@@ -64,6 +65,8 @@ namespace frm ...@@ -64,6 +65,8 @@ namespace frm
// ImageProducer stuff // ImageProducer stuff
::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xProducer; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xProducer;
// Store the image in a graphic object to make it accesible via graphic cache using graphic ID.
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > m_xGraphicObject;
SfxMedium* m_pMedium; // Download medium SfxMedium* m_pMedium; // Download medium
ImageProducer* m_pProducer; ImageProducer* m_pProducer;
bool m_bDispatchUrlInternal; // property: is not allowed to set : 1 bool m_bDispatchUrlInternal; // property: is not allowed to set : 1
...@@ -143,6 +146,8 @@ namespace frm ...@@ -143,6 +146,8 @@ namespace frm
// to be called from within the cloning-ctor of your derived class // to be called from within the cloning-ctor of your derived class
void implInitializeImageURL( ); void implInitializeImageURL( );
DECL_LINK( OnImageImportDone, ::Graphic* );
}; };
class ImageModelMethodGuard : public ::osl::MutexGuard class ImageModelMethodGuard : public ::osl::MutexGuard
......
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