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

dba33h: #i113991# handle ImageURL and Graphic properties ourselves, do not leave…

dba33h: #i113991# handle ImageURL and Graphic properties ourselves, do not leave this to the aggregate. Otherwise, both the aggregate and we try to sync those, which is good for some problems ...
üst 93f90c4e
......@@ -152,10 +152,12 @@ OImageControlModel::OImageControlModel(const Reference<XMultiServiceFactory>& _r
// use the old control name for compytibility reasons
,m_pImageProducer( NULL )
,m_bReadOnly( sal_False )
,m_sImageURL()
,m_xGraphic()
{
DBG_CTOR( OImageControlModel, NULL );
m_nClassId = FormComponentType::IMAGECONTROL;
initValueProperty( PROPERTY_IMAGE_URL, PROPERTY_ID_IMAGE_URL);
initOwnValueProperty( PROPERTY_IMAGE_URL );
implConstruct();
}
......@@ -165,22 +167,19 @@ OImageControlModel::OImageControlModel( const OImageControlModel* _pOriginal, co
:OBoundControlModel( _pOriginal, _rxFactory )
// use the old control name for compytibility reasons
,m_pImageProducer( NULL )
,m_bReadOnly( _pOriginal->m_bReadOnly )
,m_sImageURL( _pOriginal->m_sImageURL )
,m_xGraphic( _pOriginal->m_xGraphic )
{
DBG_CTOR( OImageControlModel, NULL );
implConstruct();
m_bReadOnly = _pOriginal->m_bReadOnly;
osl_incrementInterlockedCount( &m_refCount );
{
// simulate a propertyChanged event for the ImageURL
// 2003-05-15 - #109591# - fs@openoffice.org
Any aImageURL;
getFastPropertyValue( aImageURL, PROPERTY_ID_IMAGE_URL );
::rtl::OUString sImageURL;
aImageURL >>= sImageURL;
::osl::MutexGuard aGuard( m_aMutex );
impl_handleNewImageURL_lck( sImageURL, eOther );
impl_handleNewImageURL_lck( eOther );
}
osl_decrementInterlockedCount( &m_refCount );
}
......@@ -244,32 +243,20 @@ sal_Bool OImageControlModel::approveDbColumnType( sal_Int32 _nColumnType )
return ImageStoreInvalid != lcl_getImageStoreType( _nColumnType );
}
//------------------------------------------------------------------------------
void OImageControlModel::_propertyChanged( const PropertyChangeEvent& _rEvent )
throw( RuntimeException )
{
if ( m_xColumnUpdate.is() )
{
OBoundControlModel::_propertyChanged( _rEvent );
}
else
{ // we're not bound. In this case, we have to manually care for updating the
// image producer, since the base class will not do this
::rtl::OUString sImageURL;
_rEvent.NewValue >>= sImageURL;
::osl::MutexGuard aGuard( m_aMutex );
impl_handleNewImageURL_lck( sImageURL, eOther );
}
}
//------------------------------------------------------------------------------
void OImageControlModel::getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const
{
switch (nHandle)
{
case PROPERTY_ID_READONLY : rValue <<= (sal_Bool)m_bReadOnly; break;
case PROPERTY_ID_READONLY:
rValue <<= (sal_Bool)m_bReadOnly;
break;
case PROPERTY_ID_IMAGE_URL:
rValue <<= m_sImageURL;
break;
case PROPERTY_ID_GRAPHIC:
rValue <<= m_xGraphic;
break;
default:
OBoundControlModel::getFastPropertyValue(rValue, nHandle);
}
......@@ -285,8 +272,24 @@ void OImageControlModel::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, con
m_bReadOnly = getBOOL(rValue);
break;
case PROPERTY_ID_IMAGE_URL:
OSL_VERIFY( rValue >>= m_sImageURL );
impl_handleNewImageURL_lck( eOther );
{
ControlModelLock aLock( *this );
// that's a fake ... onValuePropertyChange expects to receive the only lock to our instance,
// but we're already called with our mutex locked ...
onValuePropertyChange( aLock );
}
break;
case PROPERTY_ID_GRAPHIC:
OSL_VERIFY( rValue >>= m_xGraphic );
break;
default:
OBoundControlModel::setFastPropertyValue_NoBroadcast(nHandle, rValue);
break;
}
}
......@@ -299,6 +302,12 @@ sal_Bool OImageControlModel::convertFastPropertyValue(Any& rConvertedValue, Any&
case PROPERTY_ID_READONLY :
return tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bReadOnly);
case PROPERTY_ID_IMAGE_URL:
return tryPropertyValue( rConvertedValue, rOldValue, rValue, m_sImageURL );
case PROPERTY_ID_GRAPHIC:
return tryPropertyValue( rConvertedValue, rOldValue, rValue, m_xGraphic );
default:
return OBoundControlModel::convertFastPropertyValue(rConvertedValue, rOldValue, nHandle, rValue);
}
......@@ -307,12 +316,24 @@ sal_Bool OImageControlModel::convertFastPropertyValue(Any& rConvertedValue, Any&
//------------------------------------------------------------------------------
void OImageControlModel::describeFixedProperties( Sequence< Property >& _rProps ) const
{
BEGIN_DESCRIBE_PROPERTIES( 2, OBoundControlModel )
DECL_BOOL_PROP1 ( READONLY, BOUND );
DECL_PROP1 ( TABINDEX, sal_Int16, BOUND );
BEGIN_DESCRIBE_PROPERTIES( 4, OBoundControlModel )
DECL_IFACE_PROP2( GRAPHIC, XGraphic, BOUND, TRANSIENT );
DECL_PROP1 ( IMAGE_URL, ::rtl::OUString, BOUND );
DECL_BOOL_PROP1 ( READONLY, BOUND );
DECL_PROP1 ( TABINDEX, sal_Int16, BOUND );
END_DESCRIBE_PROPERTIES();
}
//------------------------------------------------------------------------------
void OImageControlModel::describeAggregateProperties( Sequence< Property >& /* [out] */ o_rAggregateProperties ) const
{
OBoundControlModel::describeAggregateProperties( o_rAggregateProperties );
// remove ImageULR and Graphic properties, we "overload" them. This is because our aggregate synchronizes those
// two, but we have an own sychronization mechanism.
RemoveProperty( o_rAggregateProperties, PROPERTY_IMAGE_URL );
RemoveProperty( o_rAggregateProperties, PROPERTY_GRAPHIC );
}
//------------------------------------------------------------------------------
::rtl::OUString OImageControlModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
{
......@@ -411,18 +432,18 @@ sal_Bool OImageControlModel::impl_updateStreamForURL_lck( const ::rtl::OUString&
}
//------------------------------------------------------------------------------
sal_Bool OImageControlModel::impl_handleNewImageURL_lck( const ::rtl::OUString& _rURL, ValueChangeInstigator _eInstigator )
sal_Bool OImageControlModel::impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator )
{
switch ( lcl_getImageStoreType( getFieldType() ) )
{
case ImageStoreBinary:
if ( impl_updateStreamForURL_lck( _rURL, _eInstigator ) )
if ( impl_updateStreamForURL_lck( m_sImageURL, _eInstigator ) )
return sal_True;
break;
case ImageStoreLink:
{
::rtl::OUString sCommitURL( _rURL );
::rtl::OUString sCommitURL( m_sImageURL );
if ( m_sDocumentURL.getLength() )
sCommitURL = URIHelper::simpleNormalizedMakeRelative( m_sDocumentURL, sCommitURL );
OSL_ENSURE( m_xColumnUpdate.is(), "OImageControlModel::impl_handleNewImageURL_lck: no bound field, but ImageStoreLink?!" );
......@@ -435,7 +456,7 @@ sal_Bool OImageControlModel::impl_handleNewImageURL_lck( const ::rtl::OUString&
break;
case ImageStoreInvalid:
OSL_ENSURE( false, "OImageControlModel::impl_handleNewImageURL_lck: invalid current field type!" );
OSL_ENSURE( false, "OImageControlModel::impl_handleNewImageURL_lck: image storage type type!" );
break;
}
......@@ -462,10 +483,7 @@ sal_Bool OImageControlModel::commitControlValueToDbColumn( bool _bPostReset )
else
{
::osl::MutexGuard aGuard(m_aMutex);
::rtl::OUString sImageURL;
m_xAggregateSet->getPropertyValue( PROPERTY_IMAGE_URL ) >>= sImageURL;
return impl_handleNewImageURL_lck( sImageURL, eDbColumnBinding );
return impl_handleNewImageURL_lck( eDbColumnBinding );
}
return sal_True;
......@@ -544,6 +562,12 @@ Any OImageControlModel::translateDbColumnToControlValue()
return Any();
}
//------------------------------------------------------------------------------
Any OImageControlModel::getControlValue( ) const
{
return makeAny( m_sImageURL );
}
//------------------------------------------------------------------------------
void OImageControlModel::doSetControlValue( const Any& _rValue )
{
......@@ -599,11 +623,6 @@ void OImageControlModel::doSetControlValue( const Any& _rValue )
void SAL_CALL OImageControlModel::disposing()
{
OBoundControlModel::disposing();
{
::osl::MutexGuard aGuard( m_aMutex ); // setControlValue expects this
setControlValue( Any(), eOther );
}
}
//------------------------------------------------------------------------------
......
......@@ -33,6 +33,7 @@
#include <com/sun/star/form/XImageProducerSupplier.hpp>
#include <com/sun/star/awt/XMouseListener.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <comphelper/propmultiplex.hxx>
#include <comphelper/implementationreference.hxx>
#include <cppuhelper/implbase2.hxx>
......@@ -58,6 +59,9 @@ class OImageControlModel
::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageProducer> m_xImageProducer;
ImageProducer* m_pImageProducer;
sal_Bool m_bReadOnly;
::rtl::OUString m_sImageURL;
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
m_xGraphic;
::rtl::OUString m_sDocumentURL;
protected:
......@@ -86,9 +90,6 @@ public:
// OComponentHelper
virtual void SAL_CALL disposing();
// OPropertyChangeListener
virtual void _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& ) throw(::com::sun::star::uno::RuntimeException);
// XPersistObject
virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
......@@ -103,6 +104,9 @@ public:
virtual void SAL_CALL startProduction( ) throw (::com::sun::star::uno::RuntimeException);
// OControlModel's property handling
virtual void describeAggregateProperties(
::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
) const;
virtual void describeFixedProperties(
::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps
) const;
......@@ -119,6 +123,8 @@ protected:
translateDbColumnToControlValue( );
virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset );
virtual ::com::sun::star::uno::Any
getControlValue( ) const;
virtual void doSetControlValue( const ::com::sun::star::uno::Any& _rValue );
virtual sal_Bool approveDbColumnType(sal_Int32 _nColumnType);
......@@ -134,7 +140,7 @@ protected:
@precond
our own mutex is locked
*/
sal_Bool impl_handleNewImageURL_lck( const ::rtl::OUString& _rURL, ValueChangeInstigator _eInstigator );
sal_Bool impl_handleNewImageURL_lck( ValueChangeInstigator _eInstigator );
/** updates the binary stream, created from loading the file which the given URL points to, into our
bound field, or the control itself if there is no bound field
......
......@@ -759,6 +759,18 @@ protected:
sal_Int32 _nValuePropertyExternalHandle
);
/** initializes the part of the class which is related to the control value.
<p>In opposite to ->initValueProperty, this method is to be used for value properties which are <em>not</em>
implemented by our aggregate, but by ourselves.</p>
<p>Certain functionality is not available when using own value properties. This includes binding to an external
value and external validation. (This is not a conceptual limit, but simply missing implementation.)</p>
*/
void initOwnValueProperty(
const ::rtl::OUString& i_rValuePropertyName
);
/** suspends listening at the value property
<p>As long as this listening is suspended, changes in the value property will not be
......@@ -782,6 +794,16 @@ protected:
*/
void resumeValueListening( );
/** (to be) called when the value property changed
Normally, this is done automatically, since the value property is a property of our aggregate, and we're
a listener at this property.
However, in some cases the value property might not be an aggregate property, but a property of the
delegator instance. In this case, you'll need to call <code>onValuePropertyChange</code> whenever this
property changes.
*/
void onValuePropertyChange( ControlModelLock& i_rControLock );
/** starts listening at the aggregate, for changes in the given property
<p>The OBoundControlModel automatically registers a multiplexer which listens for
......
......@@ -141,6 +141,7 @@ namespace frm
FORMS_CONSTASCII_STRING( PROPERTY_SUBMIT_METHOD, "SubmitMethod" );
FORMS_CONSTASCII_STRING( PROPERTY_SUBMIT_ENCODING, "SubmitEncoding" );
FORMS_CONSTASCII_STRING( PROPERTY_IMAGE_URL, "ImageURL" );
FORMS_CONSTASCII_STRING( PROPERTY_GRAPHIC, "Graphic" );
FORMS_CONSTASCII_STRING( PROPERTY_IMAGE_POSITION, "ImagePosition" );
FORMS_CONSTASCII_STRING( PROPERTY_EMPTY_IS_NULL, "ConvertEmptyToNull" );
FORMS_CONSTASCII_STRING( PROPERTY_LISTSOURCETYPE, "ListSourceType" );
......
......@@ -61,7 +61,7 @@ namespace frm
#define PROPERTY_ID_WRITING_MODE (PROPERTY_ID_START + 20)
#define PROPERTY_ID_CONTEXT_WRITING_MODE (PROPERTY_ID_START + 21)
#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22)
// free
#define PROPERTY_ID_GRAPHIC (PROPERTY_ID_START + 23)
// free
// free
// free
......
......@@ -134,6 +134,7 @@ void PropertyInfoService::initialize()
ADD_PROP_ASSIGNMENT(SUBMIT_METHOD);
ADD_PROP_ASSIGNMENT(SUBMIT_ENCODING);
ADD_PROP_ASSIGNMENT(IMAGE_URL);
ADD_PROP_ASSIGNMENT(GRAPHIC);
ADD_PROP_ASSIGNMENT(EMPTY_IS_NULL);
ADD_PROP_ASSIGNMENT(LISTSOURCETYPE);
ADD_PROP_ASSIGNMENT(LISTSOURCE);
......
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