diff options
author | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-02-08 14:04:15 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-02-08 14:04:15 +0100 |
commit | 1e76109004db25f8d4906852124252738e54403a (patch) | |
tree | 6fccdc8cd97c61b5ecf33ae22070706f987834dc /svx | |
parent | 4bc4c4dd44b568249db5585b24248b630302336d (diff) |
dba33f: #i53377# handle read-only columns in grid control
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 3 | ||||
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 65 | ||||
-rw-r--r-- | svx/source/inc/gridcell.hxx | 3 |
3 files changed, 57 insertions, 14 deletions
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 89b18a05f650..b12cd41a9872 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -1741,11 +1741,12 @@ void FmGridControl::InitColumnByField( _pColumn->SetObject( (sal_Int16)nFieldPos ); return; } - +/* // handle readonly columns sal_Bool bReadOnly = sal_True; xField->getPropertyValue( FM_PROP_ISREADONLY ) >>= bReadOnly; _pColumn->SetReadOnly( bReadOnly ); +*/ } // the control type is determined by the ColumnServiceName diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 92e8d9aebaa1..69f099da8c7e 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -557,6 +557,7 @@ TYPEINIT1( DbFilterField, DbCellControl ) //------------------------------------------------------------------------------ DbCellControl::DbCellControl( DbGridColumn& _rColumn, sal_Bool /*_bText*/ ) :OPropertyChangeListener(m_aMutex) + ,m_pFieldChangeBroadcaster(NULL) ,m_bTransparent( sal_False ) ,m_bAlignedController( sal_True ) ,m_bAccessingValueProperty( sal_False ) @@ -580,6 +581,31 @@ DbCellControl::DbCellControl( DbGridColumn& _rColumn, sal_Bool /*_bText*/ ) implDoPropertyListening( FM_PROP_STATE, sal_False ); implDoPropertyListening( FM_PROP_TEXT, sal_False ); implDoPropertyListening( FM_PROP_EFFECTIVE_VALUE, sal_False ); + + // be listener at the bound field as well + try + { + Reference< XPropertySet > xColModelProps( m_rColumn.getModel(), UNO_QUERY ); + Reference< XPropertySetInfo > xPSI; + if ( xColModelProps.is() ) + xPSI = xColModelProps->getPropertySetInfo(); + + if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) ) + { + Reference< XPropertySet > xField; + xColModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField; + if ( xField.is() ) + { + m_pFieldChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, xField); + m_pFieldChangeBroadcaster->acquire(); + m_pFieldChangeBroadcaster->addProperty( FM_PROP_ISREADONLY ); + } + } + } + catch( const Exception& ) + { + DBG_ERROR( "DbCellControl::doPropertyListening: caught an exception!" ); + } } } @@ -611,17 +637,22 @@ void DbCellControl::doPropertyListening( const ::rtl::OUString& _rPropertyName ) { implDoPropertyListening( _rPropertyName ); } - //------------------------------------------------------------------------------ -DbCellControl::~DbCellControl() +void lcl_clearBroadCaster(::comphelper::OPropertyChangeMultiplexer*& _pBroadcaster) { - if ( m_pModelChangeBroadcaster ) + if ( _pBroadcaster ) { - m_pModelChangeBroadcaster->dispose(); - m_pModelChangeBroadcaster->release(); - m_pModelChangeBroadcaster = NULL; + _pBroadcaster->dispose(); + _pBroadcaster->release(); + _pBroadcaster = NULL; // no delete, this is done implicitly } +} +//------------------------------------------------------------------------------ +DbCellControl::~DbCellControl() +{ + lcl_clearBroadCaster(m_pModelChangeBroadcaster); + lcl_clearBroadCaster(m_pFieldChangeBroadcaster); delete m_pWindow; delete m_pPainter; @@ -666,7 +697,14 @@ void DbCellControl::_propertyChanged(const PropertyChangeEvent& _rEvent) throw(R } else if ( _rEvent.PropertyName.equals( FM_PROP_READONLY ) ) { - implAdjustReadOnly( xSourceProps ); + implAdjustReadOnly( xSourceProps, true); + } + else if ( _rEvent.PropertyName.equals( FM_PROP_ISREADONLY ) ) + { + sal_Bool bReadOnly = sal_True; + _rEvent.NewValue >>= bReadOnly; + m_rColumn.SetReadOnly(bReadOnly); + implAdjustReadOnly( xSourceProps, false); } else if ( _rEvent.PropertyName.equals( FM_PROP_ENABLED ) ) { @@ -804,7 +842,7 @@ void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eIni } //------------------------------------------------------------------------------ -void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxModel ) +void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxModel,bool i_bReadOnly ) { DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustReadOnly: not to be called without window!" ); DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" ); @@ -813,9 +851,12 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode Edit* pEditWindow = dynamic_cast< Edit* >( m_pWindow ); if ( pEditWindow ) { - sal_Bool bReadOnly = sal_True; - _rxModel->getPropertyValue( FM_PROP_READONLY ) >>= bReadOnly; - static_cast< Edit* >( m_pWindow )->SetReadOnly( m_rColumn.IsReadOnly() || bReadOnly ); + sal_Bool bReadOnly = m_rColumn.IsReadOnly(); + if ( !bReadOnly ) + { + _rxModel->getPropertyValue( i_bReadOnly ? FM_PROP_READONLY : FM_PROP_ISREADONLY) >>= bReadOnly; + } + static_cast< Edit* >( m_pWindow )->SetReadOnly( bReadOnly ); } } } @@ -852,7 +893,7 @@ void DbCellControl::Init( Window& rParent, const Reference< XRowSet >& _rxCursor if ( xModelPSI->hasPropertyByName( FM_PROP_READONLY ) ) { - implAdjustReadOnly( xModel ); + implAdjustReadOnly( xModel,true ); } if ( xModelPSI->hasPropertyByName( FM_PROP_ENABLED ) ) diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index b3792b76422c..a81e860844f3 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -222,6 +222,7 @@ class DbCellControl { private: ::comphelper::OPropertyChangeMultiplexer* m_pModelChangeBroadcaster; + ::comphelper::OPropertyChangeMultiplexer* m_pFieldChangeBroadcaster; private: sal_Bool m_bTransparent : 1; @@ -351,7 +352,7 @@ private: void implDoPropertyListening( const ::rtl::OUString& _rPropertyName, sal_Bool _bWarnIfNotExistent = sal_True ); /// updates the "readonly" setting on m_pWindow, according to the respective property value in the given model - void implAdjustReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel ); + void implAdjustReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel,bool i_bReadOnly ); /// updates the "enabled" setting on m_pWindow, according to the respective property value in the given model void implAdjustEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel ); |