From 4c4cca5a49da75f24e860a7612cd45f552de8f7d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Apr 2010 10:05:04 +0200 Subject: fs33a: #i111238# add support for images to AWT's ListBoxControl/Model --- toolkit/inc/toolkit/awt/vclxwindows.hxx | 31 +- toolkit/inc/toolkit/controls/roadmapcontrol.hxx | 6 - toolkit/inc/toolkit/controls/unocontrol.hxx | 2 +- toolkit/inc/toolkit/controls/unocontrolmodel.hxx | 1 - toolkit/inc/toolkit/controls/unocontrols.hxx | 123 +++-- toolkit/source/awt/vclxwindows.cxx | 136 +++++- toolkit/source/controls/unocontrolmodel.cxx | 21 +- toolkit/source/controls/unocontrols.cxx | 558 +++++++++++++++++++++-- vcl/inc/vcl/lstbox.hxx | 1 + vcl/source/control/lstbox.cxx | 9 + 10 files changed, 759 insertions(+), 129 deletions(-) diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index c334e4d9af65..8efe01b526ba 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -83,7 +83,9 @@ #include #include #include +#include #include +#include #include #include "toolkit/awt/vclxwindow.hxx" @@ -677,9 +679,12 @@ public: // ---------------------------------------------------- // class VCLXListBox // ---------------------------------------------------- -class VCLXListBox : public ::com::sun::star::awt::XListBox, - public ::com::sun::star::awt::XTextLayoutConstrains, - public VCLXWindow +typedef ::cppu::ImplInheritanceHelper3 < VCLXWindow + , ::com::sun::star::awt::XListBox + , ::com::sun::star::awt::XTextLayoutConstrains + , ::com::sun::star::awt::XItemListListener + > VCLXListBox_Base; +class VCLXListBox : public VCLXListBox_Base { private: ActionListenerMultiplexer maActionListeners; @@ -694,16 +699,6 @@ protected: public: VCLXListBox(); - // ::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(); } - void SAL_CALL release() throw() { OWeakObject::release(); } - - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XComponent void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); @@ -744,6 +739,16 @@ public: void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + // XItemListListener + virtual void SAL_CALL listItemInserted( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemRemoved( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemModified( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL allItemsRemoved( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL itemListChanged( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_rEvent ) throw (::com::sun::star::uno::RuntimeException); + static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } }; diff --git a/toolkit/inc/toolkit/controls/roadmapcontrol.hxx b/toolkit/inc/toolkit/controls/roadmapcontrol.hxx index 7ac858a6a7b7..46f31947b276 100644 --- a/toolkit/inc/toolkit/controls/roadmapcontrol.hxx +++ b/toolkit/inc/toolkit/controls/roadmapcontrol.hxx @@ -132,15 +132,9 @@ namespace toolkit{ // ::com::sun::star::io::XPersistObject ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::beans::XMultiPropertySet -// ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoControlRoadmapModel, UnoControlModel, szServiceName2_UnoControlRoadmapModel ) -// void ImplPropertyChanged( sal_uInt16 nPropId ); - sal_Int32 SAL_CALL getCount() throw (RuntimeException); virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); diff --git a/toolkit/inc/toolkit/controls/unocontrol.hxx b/toolkit/inc/toolkit/controls/unocontrol.hxx index 578b5070e8e8..19d498ef2a85 100644 --- a/toolkit/inc/toolkit/controls/unocontrol.hxx +++ b/toolkit/inc/toolkit/controls/unocontrol.hxx @@ -119,7 +119,7 @@ protected: ::osl::Mutex& GetMutex() { return maMutex; } ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > getParentPeer() const; - void updateFromModel(); + virtual void updateFromModel(); void peerCreated(); bool ImplCheckLocalize( ::rtl::OUString& _rPossiblyLocalizable ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ImplGetCompatiblePeer( sal_Bool bAcceptExistingPeer ); diff --git a/toolkit/inc/toolkit/controls/unocontrolmodel.hxx b/toolkit/inc/toolkit/controls/unocontrolmodel.hxx index 2de5e36aa02c..a443cb4d2d6b 100644 --- a/toolkit/inc/toolkit/controls/unocontrolmodel.hxx +++ b/toolkit/inc/toolkit/controls/unocontrolmodel.hxx @@ -74,7 +74,6 @@ protected: void ImplRegisterProperties( const std::list< sal_uInt16 > &rIds ); void ImplRegisterProperty( sal_uInt16 nPropId, const ::com::sun::star::uno::Any& rDefault ); ::com::sun::star::uno::Sequence ImplGetPropertyIds() const; - virtual void ImplPropertyChanged( sal_uInt16 nPropId ); virtual ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; sal_Bool ImplHasProperty( sal_uInt16 nPropId ) const; diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index a4015dfd3b44..5c612c887859 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -58,12 +59,17 @@ #include #include #include +#include #include #include #include #include #include +#include + +#include +#include #define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" #define UNO_NAME_GRAPHOBJ_URLPKGPREFIX "vnd.sun.star.Package:" @@ -751,19 +757,18 @@ public: // ---------------------------------------------------- // class UnoControlListBoxModel // ---------------------------------------------------- -class UnoControlListBoxModel : public UnoControlModel +struct UnoControlListBoxModel_Data; +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , ::com::sun::star::awt::XItemList + > UnoControlListBoxModel_Base; +class UnoControlListBoxModel :public UnoControlListBoxModel_Base { -protected: - ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; - ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - public: UnoControlListBoxModel(); - UnoControlListBoxModel( const UnoControlListBoxModel& rModel ) : UnoControlModel( rModel ) {;} + UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ); UnoControlModel* Clone() const { return new UnoControlListBoxModel( *this ); } - void ImplPropertyChanged( sal_uInt16 nPropId ); virtual void ImplNormalizePropertySequence( const sal_Int32 _nCount, /// the number of entries in the arrays sal_Int32* _pHandles, /// the handles of the properties to set @@ -780,41 +785,85 @@ public: // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel ) + // ::com::sun::star::awt::XItemList + virtual ::sal_Int32 SAL_CALL getItemCount() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertItem( ::sal_Int32 Position, const ::rtl::OUString& ItemText, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertItemText( ::sal_Int32 Position, const ::rtl::OUString& ItemText ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertItemImage( ::sal_Int32 Position, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeItem( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAllItems( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemText( ::sal_Int32 Position, const ::rtl::OUString& ItemText ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemImage( ::sal_Int32 Position, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemTextAndImage( ::sal_Int32 Position, const ::rtl::OUString& ItemText, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getItemText( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getItemImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL getItemTextAndImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL getAllItems( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); + +protected: + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + +private: + void impl_notifyItemListEvent_nolck( + const sal_Int32 i_nItemPosition, + const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, + void ( SAL_CALL ::com::sun::star::awt::XItemListListener::*NotificationMethod )( const ::com::sun::star::awt::ItemListEvent& ) + ); + + void impl_handleInsert( + const sal_Int32 i_nItemPosition, + const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_handleRemove( + const sal_Int32 i_nItemPosition, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_handleModify( + const sal_Int32 i_nItemPosition, + const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, + ::osl::ClearableMutexGuard& i_rClearBeforeNotify + ); + + void impl_getStringItemList( ::std::vector< ::rtl::OUString >& o_rStringItems ) const; + void impl_setStringItemList_nolck( const ::std::vector< ::rtl::OUString >& i_rStringItems ); + +private: + ::boost::scoped_ptr< UnoControlListBoxModel_Data > m_pData; + ::cppu::OInterfaceContainerHelper m_aItemListListeners; }; // ---------------------------------------------------- // class UnoListBoxControl // ---------------------------------------------------- -class UnoListBoxControl : public UnoControlBase, - public ::com::sun::star::awt::XListBox, - public ::com::sun::star::awt::XItemListener, - public ::com::sun::star::awt::XLayoutConstrains, - public ::com::sun::star::awt::XTextLayoutConstrains +typedef ::cppu::AggImplInheritanceHelper5 < UnoControlBase + , ::com::sun::star::awt::XListBox + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::awt::XLayoutConstrains + , ::com::sun::star::awt::XTextLayoutConstrains + , ::com::sun::star::awt::XItemListListener + > UnoListBoxControl_Base; +class UnoListBoxControl : public UnoListBoxControl_Base { -private: - ActionListenerMultiplexer maActionListeners; - ItemListenerMultiplexer maItemListeners; - public: - UnoListBoxControl(); ::rtl::OUString GetComponentServiceName(); - void ImplUpdateSelectedItemsProperty(); - void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); - - ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlBase::queryInterface(rType); } - ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } - void SAL_CALL release() throw() { OWeakAggObject::release(); } void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); } - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::awt::XListBox void SAL_CALL addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw(::com::sun::star::uno::RuntimeException); @@ -851,9 +900,27 @@ public: ::com::sun::star::awt::Size SAL_CALL getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(::com::sun::star::uno::RuntimeException); + // XUnoControl + sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw ( ::com::sun::star::uno::RuntimeException ); + + // XItemListListener + virtual void SAL_CALL listItemInserted( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemRemoved( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemModified( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL allItemsRemoved( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL itemListChanged( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox ) +protected: + void ImplUpdateSelectedItemsProperty(); + virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); + virtual void updateFromModel(); + +private: + ActionListenerMultiplexer maActionListeners; + ItemListenerMultiplexer maItemListeners; }; // ---------------------------------------------------- diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index e2fc78421d5e..ff4dc6fb5ec4 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -29,7 +29,7 @@ #include "precompiled_toolkit.hxx" #include #include -#include +#include #include #include #include @@ -43,6 +43,9 @@ #include #include #include +#include +#include +#include #include #ifndef _SV_BUTTON_HXX @@ -58,12 +61,17 @@ #include #include #include -#include +#include using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::makeAny; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::lang::EventObject; +using ::com::sun::star::awt::ItemListEvent; +using ::com::sun::star::awt::XItemList; using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::graphic::XGraphicProvider; using namespace ::com::sun::star; using namespace ::com::sun::star::awt::VisualEffect; @@ -1550,22 +1558,6 @@ VCLXListBox::VCLXListBox() { } -// ::com::sun::star::uno::XInterface -::com::sun::star::uno::Any VCLXListBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::XListBox*, this ), - SAL_STATIC_CAST( ::com::sun::star::awt::XTextLayoutConstrains*, this ) ); - return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); -} - -// ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( VCLXListBox ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XListBox>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains>* ) NULL ), - VCLXWindow::getTypes() -IMPL_XTYPEPROVIDER_END - void VCLXListBox::dispose() throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -2096,6 +2088,114 @@ void VCLXListBox::ImplCallItemListeners() } } +namespace +{ + Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL ) + { + if ( !i_rImageURL.getLength() ) + return Image(); + + try + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XGraphicProvider > xProvider; + if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + { + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_rImageURL ); + Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + return Image( xGraphic ); + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return Image(); + } +} + +void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemInserted: no ListBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pListBox->GetEntryCount() ) ), + "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" ); + pListBox->InsertEntry( + i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(), + i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), + i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXListBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemRemoved: no ListBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ), + "VCLXListBox::listItemRemoved: illegal (inconsistent) item position!" ); + + pListBox->RemoveEntry( i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pListBox->GetEntryCount() ) ), + "VCLXListBox::listItemModified: illegal (inconsistent) item position!" ); + + // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert + + const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pListBox->GetEntry( i_rEvent.ItemPosition ); + const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) ); + + pListBox->RemoveEntry( i_rEvent.ItemPosition ); + pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXListBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); + + pListBox->Clear(); + + (void)i_rEvent; +} + +void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ListBox* pListBox = dynamic_cast< ListBox* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pListBox, "VCLXListBox::listItemModified: no ListBox?!" ); + + pListBox->Clear(); + + Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW ); + uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems(); + for ( sal_Int32 i=0; iInsertEntry( aItems[i].First, lcl_getImageFromURL( aItems[i].Second ) ); + } +} + +void SAL_CALL VCLXListBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException) +{ + // just disambiguate + VCLXWindow::disposing( i_rEvent ); +} // ---------------------------------------------------- // class VCLXMessageBox diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 29b683a5ed40..d34f5d9d9006 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -216,10 +216,6 @@ sal_Bool UnoControlModel::ImplHasProperty( sal_uInt16 nPropId ) const return mpData->Get( nPropId ) ? sal_True : sal_False; } -void UnoControlModel::ImplPropertyChanged( sal_uInt16 ) -{ -} - ::com::sun::star::uno::Any UnoControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { ::com::sun::star::uno::Any aDefault; @@ -1259,22 +1255,13 @@ sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & void UnoControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception) { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - // Fehlt: Die gefakten Einzelproperties des FontDescriptors... ImplControlProperty* pProp = mpData->Get( nPropId ); - if ( pProp ) - { - DBG_ASSERT( ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID ) || ( GetPropertyAttribs( (sal_uInt16)nPropId ) & ::com::sun::star::beans::PropertyAttribute::MAYBEVOID ), "Property darf nicht VOID sein!" ); - ImplPropertyChanged( (sal_uInt16)nPropId ); - pProp->SetValue( rValue ); - } - else - { - // exception... - DBG_ERROR( "SetPropertyValues: Invalid Property!" ); - } + ENSURE_OR_RETURN_VOID( pProp, "UnoControlModel::setFastPropertyValue_NoBroadcast: invalid property id!" ); + + DBG_ASSERT( ( rValue.getValueType().getTypeClass() != ::com::sun::star::uno::TypeClass_VOID ) || ( GetPropertyAttribs( (sal_uInt16)nPropId ) & ::com::sun::star::beans::PropertyAttribute::MAYBEVOID ), "Property darf nicht VOID sein!" ); + pProp->SetValue( rValue ); } void UnoControlModel::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nPropId ) const diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index ae9e59d045e7..a4b7037b3b73 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -73,8 +73,11 @@ #include #include +#include using namespace ::com::sun::star; +using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::uno::Reference; using namespace ::toolkit; @@ -1841,19 +1844,100 @@ sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException) return sal_True; } -// ---------------------------------------------------- -// class UnoControlListBoxModel -// ---------------------------------------------------- +// ===================================================================================================================== +// = UnoControlListBoxModel_Data +// ===================================================================================================================== +typedef beans::Pair< ::rtl::OUString, ::rtl::OUString > ListItem; +struct UnoControlListBoxModel_Data +{ + UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl ) + :m_rAntiImpl( i_rAntiImpl ) + ,m_aListItems() + ,m_bSettingLegacyProperty( false ) + { + } + + sal_Int32 getItemCount() const { return sal_Int32( m_aListItems.size() ); } + + const ListItem& getItem( const sal_Int32 i_nIndex ) const + { + if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); + return m_aListItems[ i_nIndex ]; + } + + ListItem& getItem( const sal_Int32 i_nIndex ) + { + return const_cast< ListItem& >( static_cast< const UnoControlListBoxModel_Data* >( this )->getItem( i_nIndex ) ); + } + + ListItem& insertItem( const sal_Int32 i_nIndex ) + { + if ( ( i_nIndex < 0 ) || ( i_nIndex > sal_Int32( m_aListItems.size() ) ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); + return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() ); + } + + Sequence< ListItem > getAllItems() const + { + Sequence< ListItem > aItems( sal_Int32( m_aListItems.size() ) ); + ::std::copy( m_aListItems.begin(), m_aListItems.end(), aItems.getArray() ); + return aItems; + } + + void setAllItems( const ::std::vector< ListItem >& i_rItems ) + { + m_aListItems = i_rItems; + } + + void removeItem( const sal_Int32 i_nIndex ) + { + if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), m_rAntiImpl ); + m_aListItems.erase( m_aListItems.begin() + i_nIndex ); + } + + void removeAllItems() + { + ::std::vector< ListItem > aEmpty; + m_aListItems.swap( aEmpty ); + } + +public: + bool m_bSettingLegacyProperty; + +private: + UnoControlListBoxModel& m_rAntiImpl; + ::std::vector< ListItem > m_aListItems; +}; + +// ===================================================================================================================== +// = UnoControlListBoxModel +// ===================================================================================================================== +// --------------------------------------------------------------------------------------------------------------------- UnoControlListBoxModel::UnoControlListBoxModel() + :UnoControlListBoxModel_Base() + ,m_pData( new UnoControlListBoxModel_Data( *this ) ) + ,m_aItemListListeners( GetMutex() ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox ); } +// --------------------------------------------------------------------------------------------------------------------- +UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ) + :UnoControlListBoxModel_Base( i_rSource ) + ,m_pData( new UnoControlListBoxModel_Data( *this ) ) + ,m_aItemListListeners( GetMutex() ) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) { return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel ); } +// --------------------------------------------------------------------------------------------------------------------- uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) @@ -1865,6 +1949,7 @@ uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return UnoControlModel::ImplGetDefaultValue( nPropId ); } +// --------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -1876,6 +1961,7 @@ uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } +// --------------------------------------------------------------------------------------------------------------------- // beans::XMultiPropertySet uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) { @@ -1883,19 +1969,61 @@ uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySet return xInfo; } -void UnoControlListBoxModel::ImplPropertyChanged( sal_uInt16 nPropId ) +// --------------------------------------------------------------------------------------------------------------------- +namespace +{ + struct CreateListItem : public ::std::unary_function< ::rtl::OUString, ListItem > + { + ListItem operator()( const ::rtl::OUString& i_rItemText ) + { + return ListItem( i_rItemText, ::rtl::OUString() ); + } + }; +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) { - if ( nPropId == BASEPROPERTY_STRINGITEMLIST ) + UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + + if ( nHandle == BASEPROPERTY_STRINGITEMLIST ) { + // reset selection uno::Sequence aSeq; uno::Any aAny; aAny <<= aSeq; setPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny ); - } - UnoControlModel::ImplPropertyChanged( nPropId ); + if ( !m_pData->m_bSettingLegacyProperty ) + { + // synchronize the legacy StringItemList property with our list items + Sequence< ::rtl::OUString > aStringItemList; + Any aPropValue; + getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); + OSL_VERIFY( aPropValue >>= aStringItemList ); + + ::std::vector< ListItem > aItems( aStringItemList.getLength() ); + ::std::transform( + aStringItemList.getConstArray(), + aStringItemList.getConstArray() + aStringItemList.getLength(), + aItems.begin(), + CreateListItem() + ); + m_pData->setAllItems( aItems ); + + // since an XItemListListener does not have a "all items modified" or some such method, + // we simulate this by notifying removal of all items, followed by insertion of all new + // items + lang::EventObject aEvent; + aEvent.Source = *this; + m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent ); + // TODO: OPropertySetHelper calls into this method with the mutex locked ... + // which is wrong for the above notifications ... + } + } } +// --------------------------------------------------------------------------------------------------------------------- void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles, uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(()) { @@ -1906,12 +2034,311 @@ void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCo UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles ); } +// --------------------------------------------------------------------------------------------------------------------- +::sal_Int32 SAL_CALL UnoControlListBoxModel::getItemCount() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + return m_pData->getItemCount(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->insertItem( i_nPosition ) ); + rItem.First = i_rItemText; + rItem.Second = i_rItemImageURL; + + impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->insertItem( i_nPosition ) ); + rItem.First = i_rItemText; + + impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->insertItem( i_nPosition ) ); + rItem.Second = i_rItemImageURL; + + impl_handleInsert( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + m_pData->removeItem( i_nPosition ); + + impl_handleRemove( i_nPosition, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::removeAllItems( ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + m_pData->removeAllItems(); + + impl_handleRemove( -1, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + rItem.First = i_rItemText; + + impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + rItem.Second = i_rItemImageURL; + + impl_handleModify( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition, const ::rtl::OUString& i_rItemText, const ::rtl::OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // SYNCHRONIZED -----> + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + rItem.First = i_rItemText; + rItem.Second = i_rItemImageURL; + + impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem.First; +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem.Second; +} + +// --------------------------------------------------------------------------------------------------------------------- +beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem; +} + +// --------------------------------------------------------------------------------------------------------------------- +Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL UnoControlListBoxModel::getAllItems( ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + return m_pData->getAllItems(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::addItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException) +{ + if ( i_Listener.is() ) + m_aItemListListeners.addInterface( i_Listener ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::removeItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException) +{ + if ( i_Listener.is() ) + m_aItemListListeners.removeInterface( i_Listener ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< ::rtl::OUString >& o_rStringItems ) const +{ + Sequence< ::rtl::OUString > aStringItemList; + Any aPropValue; + getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); + OSL_VERIFY( aPropValue >>= aStringItemList ); + + o_rStringItems.resize( size_t( aStringItemList.getLength() ) ); + ::std::copy( + aStringItemList.getConstArray(), + aStringItemList.getConstArray() + aStringItemList.getLength(), + o_rStringItems.begin() + ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< ::rtl::OUString >& i_rStringItems ) +{ + Sequence< ::rtl::OUString > aStringItems( i_rStringItems.size() ); + ::std::copy( + i_rStringItems.begin(), + i_rStringItems.end(), + aStringItems.getArray() + ); + m_pData->m_bSettingLegacyProperty = true; + try + { + setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST, uno::makeAny( aStringItems ) ); + } + catch( const Exception& ) + { + m_pData->m_bSettingLegacyProperty = false; + throw; + } + m_pData->m_bSettingLegacyProperty = false; +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) +{ + // SYNCHRONIZED -----> + // sync with legacy StringItemList property + ::std::vector< ::rtl::OUString > aStringItems; + impl_getStringItemList( aStringItems ); + OSL_ENSURE( size_t( i_nItemPosition ) <= aStringItems.size(), "UnoControlListBoxModel::impl_handleInsert" ); + if ( size_t( i_nItemPosition ) <= aStringItems.size() ) + { + const ::rtl::OUString sItemText( !!i_rItemText ? *i_rItemText : ::rtl::OUString() ); + aStringItems.insert( aStringItems.begin() + i_nItemPosition, sItemText ); + } + + i_rClearBeforeNotify.clear(); + // <----- SYNCHRONIZED + impl_setStringItemList_nolck( aStringItems ); + + // notify ItemListListeners + impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemInserted ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) +{ + // SYNCHRONIZED -----> + const bool bAllItems = ( i_nItemPosition < 0 ); + // sync with legacy StringItemList property + ::std::vector< ::rtl::OUString > aStringItems; + impl_getStringItemList( aStringItems ); + if ( !bAllItems ) + { + OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleRemove" ); + if ( size_t( i_nItemPosition ) < aStringItems.size() ) + { + aStringItems.erase( aStringItems.begin() + i_nItemPosition ); + } + } + else + { + aStringItems.resize(0); + } + + i_rClearBeforeNotify.clear(); + // <----- SYNCHRONIZED + impl_setStringItemList_nolck( aStringItems ); + + // notify ItemListListeners + if ( bAllItems ) + { + EventObject aEvent( *this ); + m_aItemListListeners.notifyEach( &XItemListListener::allItemsRemoved, aEvent ); + } + else + { + impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< ::rtl::OUString >(), ::boost::optional< ::rtl::OUString >(), + &XItemListListener::listItemRemoved ); + } +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify ) +{ + // SYNCHRONIZED -----> + if ( !!i_rItemText ) + { + // sync with legacy StringItemList property + ::std::vector< ::rtl::OUString > aStringItems; + impl_getStringItemList( aStringItems ); + OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleModify" ); + if ( size_t( i_nItemPosition ) < aStringItems.size() ) + { + aStringItems[ i_nItemPosition] = *i_rItemText; + } + + i_rClearBeforeNotify.clear(); + // <----- SYNCHRONIZED + impl_setStringItemList_nolck( aStringItems ); + } + else + { + i_rClearBeforeNotify.clear(); + // <----- SYNCHRONIZED + } + + // notify ItemListListeners + impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemModified ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< ::rtl::OUString >& i_rItemText, + const ::boost::optional< ::rtl::OUString >& i_rItemImageURL, + void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) ) +{ + ItemListEvent aEvent; + aEvent.Source = *this; + aEvent.ItemPosition = i_nItemPosition; + if ( !!i_rItemText ) + { + aEvent.ItemText.IsPresent = sal_True; + aEvent.ItemText.Value = *i_rItemText; + } + if ( !!i_rItemImageURL ) + { + aEvent.ItemImageURL.IsPresent = sal_True; + aEvent.ItemImageURL.Value = *i_rItemImageURL; + } + + m_aItemListListeners.notifyEach( NotificationMethod, aEvent ); +} + // ---------------------------------------------------- // class UnoListBoxControl // ---------------------------------------------------- UnoListBoxControl::UnoListBoxControl() - : maActionListeners( *this ), - maItemListeners( *this ) + :maActionListeners( *this ) + ,maItemListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -1922,27 +2349,6 @@ UnoListBoxControl::UnoListBoxControl() return ::rtl::OUString::createFromAscii( "listbox" ); } -// uno::XInterface -uno::Any UnoListBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) -{ - uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( awt::XListBox*, this ), - SAL_STATIC_CAST( awt::XItemListener*, this ), - SAL_STATIC_CAST( lang::XEventListener*, SAL_STATIC_CAST( awt::XItemListener*, this ) ), - SAL_STATIC_CAST( awt::XLayoutConstrains*, this ), - SAL_STATIC_CAST( awt::XTextLayoutConstrains*, this ) ); - return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType )); -} - -// lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( UnoListBoxControl ) - getCppuType( ( uno::Reference< awt::XListBox>* ) NULL ), - getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ), - getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ), - getCppuType( ( uno::Reference< awt::XTextLayoutConstrains>* ) NULL ), - UnoControlBase::getTypes() -IMPL_XTYPEPROVIDER_END - void UnoListBoxControl::dispose() throw(uno::RuntimeException) { lang::EventObject aEvt; @@ -1966,24 +2372,26 @@ void UnoListBoxControl::ImplUpdateSelectedItemsProperty() } } -void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) +void UnoListBoxControl::updateFromModel() { - UnoControl::ImplSetPeerProperty( rPropName, rVal ); + UnoControlBase::updateFromModel(); + + Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); + + EventObject aEvent( getModel() ); + xItemListListener->itemListChanged( aEvent ); +} - // Wenn die SelectedItems vor der StringItemList gesetzt werden, - // hat das keine Auswirkung... +void UnoListBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) +{ if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ) - { - ::rtl::OUString aSelPropName = GetPropertyName( BASEPROPERTY_SELECTEDITEMS ); - uno::Any aVal = ImplGetPropertyValue( aSelPropName ); - if ( !( aVal.getValueType().getTypeClass() == uno::TypeClass_VOID ) ) - { - uno::Reference< awt::XVclWindowPeer > xW( getPeer(), uno::UNO_QUERY ); - if (xW.is()) - // same comment as in UnoControl::ImplSetPeerProperty - see there - xW->setProperty( aSelPropName, aVal ); - } - } + // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item + // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes + // will be forwarded to the peer, which will update itself accordingly. + return; + + UnoControl::ImplSetPeerProperty( rPropName, rVal ); } void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) @@ -2281,6 +2689,66 @@ void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines Impl_getColumnsAndLines( nCols, nLines ); } +sal_Bool SAL_CALL UnoListBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + + const Reference< XItemList > xOldItems( getModel(), UNO_QUERY ); + OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" ); + const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY ); + OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoListBoxControl::setModel: illegal new model!" ); + + if ( !UnoListBoxControl_Base::setModel( i_rModel ) ) + return sal_False; + + if ( xOldItems.is() ) + xOldItems->removeItemListListener( this ); + if ( xNewItems.is() ) + xNewItems->addItemListListener( this ); + + return sal_True; +} + +void SAL_CALL UnoListBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemInserted( i_rEvent ); +} + +void SAL_CALL UnoListBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemRemoved( i_rEvent ); +} + +void SAL_CALL UnoListBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemModified( i_rEvent ); +} + +void SAL_CALL UnoListBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->allItemsRemoved( i_rEvent ); +} + +void SAL_CALL UnoListBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->itemListChanged( i_rEvent ); +} + // ---------------------------------------------------- // class UnoControlComboBoxModel // ---------------------------------------------------- diff --git a/vcl/inc/vcl/lstbox.hxx b/vcl/inc/vcl/lstbox.hxx index 98cd05d999dd..3659e5aee485 100644 --- a/vcl/inc/vcl/lstbox.hxx +++ b/vcl/inc/vcl/lstbox.hxx @@ -130,6 +130,7 @@ public: virtual USHORT GetEntryPos( const XubString& rStr ) const; virtual USHORT GetEntryPos( const void* pData ) const; + Image GetEntryImage( USHORT nPos ) const; virtual XubString GetEntry( USHORT nPos ) const; virtual USHORT GetEntryCount() const; diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 70b67c0a3d57..dde34d52806c 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1081,6 +1081,15 @@ void ListBox::RemoveEntry( USHORT nPos ) // ----------------------------------------------------------------------- +Image ListBox::GetEntryImage( USHORT nPos ) const +{ + if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) ) + return mpImplLB->GetEntryList()->GetEntryImage( nPos ); + return Image(); +} + +// ----------------------------------------------------------------------- + USHORT ListBox::GetEntryPos( const XubString& rStr ) const { USHORT nPos = mpImplLB->GetEntryList()->FindEntry( rStr ); -- cgit v1.2.3 From 850d1272686417389b67794ace4a01d3269ea2e6 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Apr 2010 14:10:03 +0200 Subject: fs33a: #i111238# now with UserData support --- toolkit/inc/toolkit/controls/unocontrols.hxx | 2 + toolkit/source/controls/unocontrols.cxx | 84 +++++++++++++++++++++------- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 5c612c887859..71e0a915788d 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -795,9 +795,11 @@ public: virtual void SAL_CALL setItemText( ::sal_Int32 Position, const ::rtl::OUString& ItemText ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setItemImage( ::sal_Int32 Position, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setItemTextAndImage( ::sal_Int32 Position, const ::rtl::OUString& ItemText, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setUserData( ::sal_Int32 Position, const ::com::sun::star::uno::Any& DataValue ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getItemText( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getItemImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL getItemTextAndImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getUserData( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL getAllItems( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index a4b7037b3b73..975040ca9070 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1847,7 +1847,37 @@ sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException) // ===================================================================================================================== // = UnoControlListBoxModel_Data // ===================================================================================================================== -typedef beans::Pair< ::rtl::OUString, ::rtl::OUString > ListItem; +struct ListItem +{ + ::rtl::OUString ItemText; + ::rtl::OUString ItemImageURL; + Any ItemUserData; + + ListItem() + :ItemText() + ,ItemImageURL() + ,ItemUserData() + { + } + + ListItem( const ::rtl::OUString& i_rItemText ) + :ItemText( i_rItemText ) + ,ItemImageURL() + ,ItemUserData() + { + } +}; + +typedef beans::Pair< ::rtl::OUString, ::rtl::OUString > UnoListItem; + +struct StripItemData : public ::std::unary_function< ListItem, UnoListItem > +{ + UnoListItem operator()( const ListItem& i_rItem ) + { + return UnoListItem( i_rItem.ItemText, i_rItem.ItemImageURL ); + } +}; + struct UnoControlListBoxModel_Data { UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl ) @@ -1878,10 +1908,10 @@ struct UnoControlListBoxModel_Data return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() ); } - Sequence< ListItem > getAllItems() const + Sequence< UnoListItem > getAllItems() const { - Sequence< ListItem > aItems( sal_Int32( m_aListItems.size() ) ); - ::std::copy( m_aListItems.begin(), m_aListItems.end(), aItems.getArray() ); + Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) ); + ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() ); return aItems; } @@ -1976,7 +2006,7 @@ namespace { ListItem operator()( const ::rtl::OUString& i_rItemText ) { - return ListItem( i_rItemText, ::rtl::OUString() ); + return ListItem( i_rItemText ); } }; } @@ -2047,8 +2077,8 @@ void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->insertItem( i_nPosition ) ); - rItem.First = i_rItemText; - rItem.Second = i_rItemImageURL; + rItem.ItemText = i_rItemText; + rItem.ItemImageURL = i_rItemImageURL; impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); // <----- SYNCHRONIZED @@ -2060,7 +2090,7 @@ void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, c ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->insertItem( i_nPosition ) ); - rItem.First = i_rItemText; + rItem.ItemText = i_rItemText; impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); // <----- SYNCHRONIZED @@ -2072,7 +2102,7 @@ void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->insertItem( i_nPosition ) ); - rItem.Second = i_rItemImageURL; + rItem.ItemImageURL = i_rItemImageURL; impl_handleInsert( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); // <----- SYNCHRONIZED @@ -2106,7 +2136,7 @@ void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, cons ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->getItem( i_nPosition ) ); - rItem.First = i_rItemText; + rItem.ItemText = i_rItemText; impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< ::rtl::OUString >(), aGuard ); // <----- SYNCHRONIZED @@ -2118,7 +2148,7 @@ void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, con ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->getItem( i_nPosition ) ); - rItem.Second = i_rItemImageURL; + rItem.ItemImageURL = i_rItemImageURL; impl_handleModify( i_nPosition, ::boost::optional< ::rtl::OUString >(), i_rItemImageURL, aGuard ); // <----- SYNCHRONIZED @@ -2130,35 +2160,51 @@ void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPositi ::osl::ClearableMutexGuard aGuard( GetMutex() ); // SYNCHRONIZED -----> ListItem& rItem( m_pData->getItem( i_nPosition ) ); - rItem.First = i_rItemText; - rItem.Second = i_rItemImageURL; + rItem.ItemText = i_rItemText; + rItem.ItemImageURL = i_rItemImageURL; impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); // <----- SYNCHRONIZED } +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoControlListBoxModel::setUserData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + ListItem& rItem( m_pData->getItem( i_nPosition ) ); + rItem.ItemUserData = i_rDataValue; +} + // --------------------------------------------------------------------------------------------------------------------- ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) { ::osl::MutexGuard aGuard( GetMutex() ); - ListItem& rItem( m_pData->getItem( i_nPosition ) ); - return rItem.First; + const ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem.ItemText; } // --------------------------------------------------------------------------------------------------------------------- ::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) { ::osl::MutexGuard aGuard( GetMutex() ); - ListItem& rItem( m_pData->getItem( i_nPosition ) ); - return rItem.Second; + const ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem.ItemImageURL; } // --------------------------------------------------------------------------------------------------------------------- beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) { ::osl::MutexGuard aGuard( GetMutex() ); - ListItem& rItem( m_pData->getItem( i_nPosition ) ); - return rItem; + const ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return beans::Pair< ::rtl::OUString, ::rtl::OUString >( rItem.ItemText, rItem.ItemImageURL ); +} + +// --------------------------------------------------------------------------------------------------------------------- +Any SAL_CALL UnoControlListBoxModel::getUserData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + const ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return rItem.ItemUserData; } // --------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From 6b310decbc330847cd88bd001e6120f3042d1b7c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 29 Apr 2010 15:29:46 +0200 Subject: fs33a: #i111238# [s|g]etUserData -> [s|g]etItemData --- toolkit/inc/toolkit/controls/unocontrols.hxx | 4 ++-- toolkit/source/controls/unocontrols.cxx | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 71e0a915788d..88449418c70a 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -795,11 +795,11 @@ public: virtual void SAL_CALL setItemText( ::sal_Int32 Position, const ::rtl::OUString& ItemText ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setItemImage( ::sal_Int32 Position, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setItemTextAndImage( ::sal_Int32 Position, const ::rtl::OUString& ItemText, const ::rtl::OUString& ItemImageURL ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setUserData( ::sal_Int32 Position, const ::com::sun::star::uno::Any& DataValue ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setItemData( ::sal_Int32 Position, const ::com::sun::star::uno::Any& DataValue ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getItemText( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getItemImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL getItemTextAndImage( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getUserData( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getItemData( ::sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Pair< ::rtl::OUString, ::rtl::OUString > > SAL_CALL getAllItems( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeItemListListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 975040ca9070..8b37978c58e6 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1851,19 +1851,19 @@ struct ListItem { ::rtl::OUString ItemText; ::rtl::OUString ItemImageURL; - Any ItemUserData; + Any ItemData; ListItem() :ItemText() ,ItemImageURL() - ,ItemUserData() + ,ItemData() { } ListItem( const ::rtl::OUString& i_rItemText ) :ItemText( i_rItemText ) ,ItemImageURL() - ,ItemUserData() + ,ItemData() { } }; @@ -2168,11 +2168,11 @@ void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPositi } // --------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoControlListBoxModel::setUserData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException) +void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException) { ::osl::ClearableMutexGuard aGuard( GetMutex() ); ListItem& rItem( m_pData->getItem( i_nPosition ) ); - rItem.ItemUserData = i_rDataValue; + rItem.ItemData = i_rDataValue; } // --------------------------------------------------------------------------------------------------------------------- @@ -2200,11 +2200,11 @@ beans::Pair< ::rtl::OUString, ::rtl::OUString > SAL_CALL UnoControlListBoxModel: } // --------------------------------------------------------------------------------------------------------------------- -Any SAL_CALL UnoControlListBoxModel::getUserData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) { ::osl::ClearableMutexGuard aGuard( GetMutex() ); const ListItem& rItem( m_pData->getItem( i_nPosition ) ); - return rItem.ItemUserData; + return rItem.ItemData; } // --------------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From 3bb8f0226dca5c1e565feaed3aeff7c1ee1a6042 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Sun, 2 May 2010 13:19:38 +0200 Subject: fs33a: compile errors on unxlngi6.pro / unxmacxi.pro --- toolkit/source/awt/vclxwindows.cxx | 2 +- toolkit/source/controls/unocontrols.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index ff4dc6fb5ec4..43e0e50c315d 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2155,7 +2155,7 @@ void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) thr // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert - const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : pListBox->GetEntry( i_rEvent.ItemPosition ); + const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) ); const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) ); pListBox->RemoveEntry( i_rEvent.ItemPosition ); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 8b37978c58e6..3b037e3ca0d3 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1881,9 +1881,9 @@ struct StripItemData : public ::std::unary_function< ListItem, UnoListItem > struct UnoControlListBoxModel_Data { UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl ) - :m_rAntiImpl( i_rAntiImpl ) + :m_bSettingLegacyProperty( false ) + ,m_rAntiImpl( i_rAntiImpl ) ,m_aListItems() - ,m_bSettingLegacyProperty( false ) { } -- cgit v1.2.3 From 00647682535858694ab42cc90e0db6142053df3b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 16 Jun 2010 09:53:37 +0200 Subject: fs33a: fixed supportsService --- toolkit/source/controls/unocontrol.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 1abe0b34004f..4db6dbb17b81 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -1463,7 +1463,7 @@ sal_Bool UnoControl::supportsService( const ::rtl::OUString& rServiceName ) thro Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); const ::rtl::OUString* pArray = aSNL.getConstArray(); - const ::rtl::OUString* pArrayEnd = aSNL.getConstArray(); + const ::rtl::OUString* pArrayEnd = aSNL.getConstArray() + aSNL.getLength(); for (; pArray != pArrayEnd; ++pArray ) if( *pArray == rServiceName ) break; -- cgit v1.2.3 From 90f2e0f4128d9fa122957a5657d16308ce7af3c0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 16 Jun 2010 14:30:30 +0200 Subject: fs33a: fixed VCLXFixedText::calcAdjustedSize to respect the given size --- toolkit/source/awt/vclxwindows.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 43e0e50c315d..8b8cb23e1276 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2965,16 +2965,15 @@ short VCLXFixedText::getAlignment() throw(::com::sun::star::uno::RuntimeExceptio return getMinimumSize(); } -::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException) +::com::sun::star::awt::Size VCLXFixedText::calcAdjustedSize( const ::com::sun::star::awt::Size& rMaxSize ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - ::com::sun::star::awt::Size aSz = rNewSize; - ::com::sun::star::awt::Size aMinSz = getMinimumSize(); - if ( aSz.Height != aMinSz.Height ) - aSz.Height = aMinSz.Height; - - return aSz; + Size aAdjustedSize( VCLUnoHelper::ConvertToVCLSize( rMaxSize ) ); + FixedText* pFixedText = (FixedText*)GetWindow(); + if ( pFixedText ) + aAdjustedSize = pFixedText->CalcMinimumSize( rMaxSize.Width ); + return VCLUnoHelper::ConvertToAWTSize( aAdjustedSize ); } // ---------------------------------------------------- -- cgit v1.2.3 From b2d41aee0de65be4cc2e906316f6fb590a6921a1 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 1 Jul 2010 11:46:35 +0200 Subject: unoawt2: add missing GetEntryImage, same as listbox --- vcl/inc/vcl/combobox.hxx | 1 + vcl/source/control/combobox.cxx | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx index e35474a84d53..640c70e7116f 100644 --- a/vcl/inc/vcl/combobox.hxx +++ b/vcl/inc/vcl/combobox.hxx @@ -138,6 +138,7 @@ public: USHORT GetEntryPos( const XubString& rStr ) const; USHORT GetEntryPos( const void* pData ) const; + Image GetEntryImage( USHORT nPos ) const; XubString GetEntry( USHORT nPos ) const; USHORT GetEntryCount() const; diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index f5c04b7c3cfa..ebdfeae0f1d9 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1011,6 +1011,14 @@ void ComboBox::Clear() mpImplLB->Clear(); CallEventListeners( VCLEVENT_COMBOBOX_ITEMREMOVED, (void*) sal_IntPtr(-1) ); } +// ----------------------------------------------------------------------- + +Image ComboBox::GetEntryImage( USHORT nPos ) const +{ + if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) ) + return mpImplLB->GetEntryList()->GetEntryImage( nPos ); + return Image(); +} // ----------------------------------------------------------------------- -- cgit v1.2.3 From 297f3ea4c0b7772cd6b0e4720ea4ee751a932605 Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 1 Jul 2010 11:50:54 +0200 Subject: unoawt2: add XItemList to combobox as well, the sma eas for listbox --- toolkit/inc/toolkit/awt/vclxwindows.hxx | 24 +-- toolkit/inc/toolkit/controls/unocontrols.hxx | 41 +++++- toolkit/source/awt/vclxwindows.cxx | 128 +++++++++++++--- toolkit/source/controls/unocontrols.cxx | 209 +++++++++++++++++++++++---- 4 files changed, 331 insertions(+), 71 deletions(-) diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index 80e3a37279d3..fb110cb74391 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -747,8 +747,10 @@ public: // ---------------------------------------------------- // class VCLXComboBox // ---------------------------------------------------- -class VCLXComboBox : public ::com::sun::star::awt::XComboBox, - public VCLXEdit +typedef ::cppu::ImplInheritanceHelper2 < VCLXEdit + , ::com::sun::star::awt::XComboBox + , ::com::sun::star::awt::XItemListListener > VCLXComboBox_Base; +class VCLXComboBox : public VCLXComboBox_Base { private: ActionListenerMultiplexer maActionListeners; @@ -763,15 +765,6 @@ public: VCLXComboBox(); ~VCLXComboBox(); - // ::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(); } - void SAL_CALL release() throw() { OWeakObject::release(); } - - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::lang::XComponent void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); @@ -802,6 +795,15 @@ public: void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + // XItemListListener + virtual void SAL_CALL listItemInserted( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemRemoved( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemModified( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL allItemsRemoved( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL itemListChanged( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_rEvent ) throw (::com::sun::star::uno::RuntimeException); + static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } }; diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 6223e47a6871..1bcbfec7a556 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -727,6 +727,8 @@ typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel > UnoControlListBoxModel_Base; class TOOLKIT_DLLPUBLIC UnoControlListBoxModel :public UnoControlListBoxModel_Base { +protected: + UnoControlListBoxModel(bool asComboBox); public: UnoControlListBoxModel(); UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ); @@ -806,7 +808,7 @@ private: void impl_getStringItemList( ::std::vector< ::rtl::OUString >& o_rStringItems ) const; void impl_setStringItemList_nolck( const ::std::vector< ::rtl::OUString >& i_rStringItems ); -private: +protected: ::boost::scoped_ptr< UnoControlListBoxModel_Data > m_pData; ::cppu::OInterfaceContainerHelper m_aItemListListeners; }; @@ -895,7 +897,7 @@ private: // ---------------------------------------------------- // class UnoControlComboBoxModel // ---------------------------------------------------- -class UnoControlComboBoxModel : public UnoControlModel +class UnoControlComboBoxModel : public UnoControlListBoxModel { protected: ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; @@ -903,7 +905,7 @@ protected: public: UnoControlComboBoxModel(); - UnoControlComboBoxModel( const UnoControlComboBoxModel& rModel ) : UnoControlModel( rModel ) {;} + UnoControlComboBoxModel( const UnoControlComboBoxModel& rModel ) : UnoControlListBoxModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlComboBoxModel( *this ); } @@ -912,6 +914,8 @@ public: // ::com::sun::star::beans::XMultiPropertySet ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + // OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel ) @@ -921,8 +925,10 @@ public: // ---------------------------------------------------- // class UnoComboBoxControl // ---------------------------------------------------- -class UnoComboBoxControl : public UnoEditControl, - public ::com::sun::star::awt::XComboBox +class UnoComboBoxControl : public UnoEditControl + , public ::com::sun::star::awt::XComboBox + , public ::com::sun::star::awt::XItemListener + , public ::com::sun::star::awt::XItemListListener { private: ActionListenerMultiplexer maActionListeners; @@ -933,12 +939,15 @@ public: UnoComboBoxControl(); ::rtl::OUString GetComponentServiceName(); + void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoEditControl::disposing( Source ); } + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoEditControl::queryInterface(rType); } ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } void SAL_CALL release() throw() { OWeakAggObject::release(); } - void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::lang::XTypeProvider ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); @@ -958,8 +967,26 @@ public: sal_Int16 SAL_CALL getDropDownLineCount( ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL setDropDownLineCount( sal_Int16 nLines ) throw(::com::sun::star::uno::RuntimeException); + // XUnoControl + virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model) throw ( ::com::sun::star::uno::RuntimeException ); + + // XItemListListener + virtual void SAL_CALL listItemInserted( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemRemoved( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL listItemModified( const ::com::sun::star::awt::ItemListEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL allItemsRemoved( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL itemListChanged( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XItemListener + virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox ) +protected: + virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); + virtual void updateFromModel(); + ActionListenerMultiplexer& getActionListeners(); + ItemListenerMultiplexer& getItemListeners(); }; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 4a68b4c80e3f..8b00cd450ab6 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -3896,20 +3896,6 @@ VCLXComboBox::~VCLXComboBox() #endif } -// ::com::sun::star::uno::XInterface -::com::sun::star::uno::Any VCLXComboBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::XComboBox*, this ) ); - return (aRet.hasValue() ? aRet : VCLXEdit::queryInterface( rType )); -} - -// ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( VCLXComboBox ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XComboBox>* ) NULL ), - VCLXEdit::getTypes() -IMPL_XTYPEPROVIDER_END - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXComboBox::CreateAccessibleContext() { ::vos::OGuard aGuard( GetMutex() ); @@ -3973,8 +3959,12 @@ void VCLXComboBox::addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUStr for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ ) { pBox->InsertEntry( aItems.getConstArray()[n], nP ); - if ( (sal_uInt16)nPos < 0xFFFF ) // Nicht wenn 0xFFFF, weil LIST_APPEND - nP++; + if ( nP == 0xFFFF ) + { + OSL_ENSURE( false, "VCLXComboBox::addItems: too many entries!" ); + // skip remaining entries, list cannot hold them, anyway + break; + } } } } @@ -4078,14 +4068,8 @@ void VCLXComboBox::setProperty( const ::rtl::OUString& PropertyName, const ::com ::com::sun::star::uno::Sequence< ::rtl::OUString> aItems; if ( Value >>= aItems ) { - sal_Bool bUpdate = pComboBox->IsUpdateMode(); - pComboBox->SetUpdateMode( sal_False ); pComboBox->Clear(); - const ::rtl::OUString* pStrings = aItems.getConstArray(); - sal_Int32 nItems = aItems.getLength(); - for ( sal_Int32 n = 0; n < nItems; n++ ) - pComboBox->InsertEntry( pStrings[n], LISTBOX_APPEND ); - pComboBox->SetUpdateMode( bUpdate ); + addItems( aItems, 0 ); } } break; @@ -4255,6 +4239,104 @@ void VCLXComboBox::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) thr nLines = nL; } } +void SAL_CALL VCLXComboBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemInserted: no ComboBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition <= sal_Int32( pComboBox->GetEntryCount() ) ), + "VCLXComboBox::listItemInserted: illegal (inconsistent) item position!" ); + pComboBox->InsertEntry( + i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(), + i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), + i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXComboBox::listItemRemoved( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemRemoved: no ComboBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), + "VCLXComboBox::listItemRemoved: illegal (inconsistent) item position!" ); + + pComboBox->RemoveEntry( i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXComboBox::listItemModified( const ItemListEvent& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + + ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); + ENSURE_OR_RETURN_VOID( ( i_rEvent.ItemPosition >= 0 ) && ( i_rEvent.ItemPosition < sal_Int32( pComboBox->GetEntryCount() ) ), + "VCLXComboBox::listItemModified: illegal (inconsistent) item position!" ); + + // VCL's ComboBox does not support changing an entry's text or image, so remove and re-insert + + const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pComboBox->GetEntry( i_rEvent.ItemPosition ) ); + const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pComboBox->GetEntryImage( i_rEvent.ItemPosition ) ); + + pComboBox->RemoveEntry( i_rEvent.ItemPosition ); + pComboBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition ); +} + +void SAL_CALL VCLXComboBox::allItemsRemoved( const EventObject& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); + + pComboBox->Clear(); + + (void)i_rEvent; +} + +void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent ) throw (RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + ComboBox* pComboBox = dynamic_cast< ComboBox* >( GetWindow() ); + ENSURE_OR_RETURN_VOID( pComboBox, "VCLXComboBox::listItemModified: no ComboBox?!" ); + + pComboBox->Clear(); + + uno::Reference< beans::XPropertySet > xPropSet( i_rEvent.Source, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW ); + // bool localize = xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ); + uno::Reference< resource::XStringResourceResolver > xStringResourceResolver; + if ( xPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ) ) + { + xStringResourceResolver.set( + xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ) ) ), + uno::UNO_QUERY + ); + } + + + Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW ); + uno::Sequence< beans::Pair< ::rtl::OUString, ::rtl::OUString > > aItems = xItemList->getAllItems(); + for ( sal_Int32 i=0; iresolveString(aLocalizationKey.copy( 1 )); + } + pComboBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) ); + } +} +void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent ) throw (RuntimeException) +{ + // just disambiguate + VCLXEdit::disposing( i_rEvent ); +} // ---------------------------------------------------- // class VCLXFormattedSpinField diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 6599b039600f..b6f654a02145 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -1826,6 +1826,13 @@ UnoControlListBoxModel::UnoControlListBoxModel() { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox ); } +// --------------------------------------------------------------------------------------------------------------------- +UnoControlListBoxModel::UnoControlListBoxModel(bool) + :UnoControlListBoxModel_Base() + ,m_pData( new UnoControlListBoxModel_Data( *this ) ) + ,m_aItemListListeners( GetMutex() ) +{ +} // --------------------------------------------------------------------------------------------------------------------- UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ) @@ -1842,7 +1849,6 @@ UnoControlListBoxModel::~UnoControlListBoxModel() { return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel ); } - // --------------------------------------------------------------------------------------------------------------------- uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { @@ -2687,28 +2693,16 @@ ItemListenerMultiplexer& UnoListBoxControl::getItemListeners() // ---------------------------------------------------- // class UnoControlComboBoxModel // ---------------------------------------------------- -UnoControlComboBoxModel::UnoControlComboBoxModel() +UnoControlComboBoxModel::UnoControlComboBoxModel() : UnoControlListBoxModel(true) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox ); } - -::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) -{ - return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel ); -} - -uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const +uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) { - if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) - { - uno::Any aAny; - aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox ); - return aAny; - } - return UnoControlModel::ImplGetDefaultValue( nPropId ); + static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; } - - +// --------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -2720,14 +2714,53 @@ uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) cons return *pHelper; } -// beans::XMultiPropertySet -uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) + +::rtl::OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); - return xInfo; + return ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBoxModel ); } +void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception) +{ + UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_pData->m_bSettingLegacyProperty) + { + // synchronize the legacy StringItemList property with our list items + Sequence< ::rtl::OUString > aStringItemList; + Any aPropValue; + getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST ); + OSL_VERIFY( aPropValue >>= aStringItemList ); + + ::std::vector< ListItem > aItems( aStringItemList.getLength() ); + ::std::transform( + aStringItemList.getConstArray(), + aStringItemList.getConstArray() + aStringItemList.getLength(), + aItems.begin(), + CreateListItem() + ); + m_pData->setAllItems( aItems ); + + // since an XItemListListener does not have a "all items modified" or some such method, + // we simulate this by notifying removal of all items, followed by insertion of all new + // items + lang::EventObject aEvent; + aEvent.Source = *this; + m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent ); + // TODO: OPropertySetHelper calls into this method with the mutex locked ... + // which is wrong for the above notifications ... + } +} +uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const +{ + if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) + { + uno::Any aAny; + aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlComboBox ); + return aAny; + } + return UnoControlModel::ImplGetDefaultValue( nPropId ); +} // ---------------------------------------------------- // class UnoComboBoxControl @@ -2745,29 +2778,58 @@ UnoComboBoxControl::UnoComboBoxControl() return ::rtl::OUString::createFromAscii( "combobox" ); } -// uno::XInterface +void UnoComboBoxControl::dispose() throw(uno::RuntimeException) +{ + lang::EventObject aEvt; + aEvt.Source = (::cppu::OWeakObject*)this; + maActionListeners.disposeAndClear( aEvt ); + maItemListeners.disposeAndClear( aEvt ); + UnoControl::dispose(); +} uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) { uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XComboBox*, this ) ); + if ( !aRet.hasValue() ) + { + aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( awt::XItemListener*, this ) ); + if ( !aRet.hasValue() ) + { + aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( awt::XItemListListener*, this ) ); + } + } return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType )); } - // lang::XTypeProvider IMPL_XTYPEPROVIDER_START( UnoComboBoxControl ) getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ), + getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ), + getCppuType( ( uno::Reference< awt::XItemListListener>* ) NULL ), UnoEditControl::getTypes() IMPL_XTYPEPROVIDER_END -void UnoComboBoxControl::dispose() throw(uno::RuntimeException) +void UnoComboBoxControl::updateFromModel() { - lang::EventObject aEvt; - aEvt.Source = (::cppu::OWeakObject*)this; - maActionListeners.disposeAndClear( aEvt ); - maItemListeners.disposeAndClear( aEvt ); - UnoControl::dispose(); + UnoEditControl::updateFromModel(); + + Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); + + EventObject aEvent( getModel() ); + xItemListListener->itemListChanged( aEvent ); } +void UnoComboBoxControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const uno::Any& rVal ) +{ + if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) ) + // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item + // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes + // will be forwarded to the peer, which will update itself accordingly. + return; + UnoEditControl::ImplSetPeerProperty( rPropName, rVal ); +} void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) { UnoEditControl::createPeer( rxToolkit, rParentPeer ); @@ -2818,6 +2880,93 @@ void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemLis } maItemListeners.removeInterface( l ); } +void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException) +{ + if ( maItemListeners.getLength() ) + { + try + { + maItemListeners.itemStateChanged( rEvent ); + } + catch( const Exception& e ) + { +#if OSL_DEBUG_LEVEL == 0 + (void) e; // suppress warning +#else + ::rtl::OString sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" ); + sMessage += ::rtl::OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US ); + OSL_ENSURE( sal_False, sMessage.getStr() ); +#endif + } + } +} +sal_Bool SAL_CALL UnoComboBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + + const Reference< XItemList > xOldItems( getModel(), UNO_QUERY ); + OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" ); + const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY ); + OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoComboBoxControl::setModel: illegal new model!" ); + + if ( !UnoEditControl::setModel( i_rModel ) ) + return sal_False; + + if ( xOldItems.is() ) + xOldItems->removeItemListListener( this ); + if ( xNewItems.is() ) + xNewItems->addItemListListener( this ); + + return sal_True; +} + +void SAL_CALL UnoComboBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemInserted( i_rEvent ); +} + +void SAL_CALL UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemRemoved( i_rEvent ); +} + +void SAL_CALL UnoComboBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->listItemModified( i_rEvent ); +} + +void SAL_CALL UnoComboBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->allItemsRemoved( i_rEvent ); +} + +void SAL_CALL UnoComboBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException) +{ + const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY ); + OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" ); + if ( xPeerListener.is() ) + xPeerListener->itemListChanged( i_rEvent ); +} +ActionListenerMultiplexer& UnoComboBoxControl::getActionListeners() +{ + return maActionListeners; +} +ItemListenerMultiplexer& UnoComboBoxControl::getItemListeners() +{ + return maItemListeners; +} void UnoComboBoxControl::addItem( const ::rtl::OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException) { -- cgit v1.2.3 From 29996eb2ffd0239accf1ea425cd737bf4ce78ccf Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 1 Jul 2010 15:52:47 +0200 Subject: unoawt2: do not inline methods of exported classes --- toolkit/inc/toolkit/controls/unocontrols.hxx | 16 ++++++++++++---- toolkit/source/controls/unocontrols.cxx | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 1bcbfec7a556..01ff047ee3de 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -750,7 +750,9 @@ public: ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XServiceInfo - DECLIMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel ) + //DECLIMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel ) + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::XItemList virtual ::sal_Int32 SAL_CALL getItemCount() throw (::com::sun::star::uno::RuntimeException); @@ -880,7 +882,9 @@ public: virtual void SAL_CALL itemListChanged( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XServiceInfo - DECLIMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox ) + // DECLIMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox ) + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); protected: void ImplUpdateSelectedItemsProperty(); @@ -918,7 +922,9 @@ public: void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); // ::com::sun::star::lang::XServiceInfo - DECLIMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel ) + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + // DECLIMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel ) }; @@ -981,7 +987,9 @@ public: virtual void SAL_CALL itemStateChanged( const ::com::sun::star::awt::ItemEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XServiceInfo - DECLIMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox ) + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + //DECLIMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox ) protected: virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); virtual void updateFromModel(); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index b6f654a02145..d0961188d06c 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -80,6 +80,18 @@ using ::com::sun::star::graphic::XGraphic; using ::com::sun::star::uno::Reference; using namespace ::toolkit; +#define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \ + ::rtl::OUString SAL_CALL ImplName::getImplementationName( ) throw(::com::sun::star::uno::RuntimeException) { return ::rtl::OUString::createFromAscii( "stardiv.Toolkit." #ImplName ); } \ + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = BaseClass::getSupportedServiceNames( ); \ + aNames.realloc( aNames.getLength() + 1 ); \ + aNames[ aNames.getLength() - 1 ] = ::rtl::OUString::createFromAscii( ServiceName ); \ + return aNames; \ + } \ + + + // ---------------------------------------------------- // class UnoControlEditModel // ---------------------------------------------------- @@ -1844,6 +1856,7 @@ UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_ UnoControlListBoxModel::~UnoControlListBoxModel() { } +IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel ) // --------------------------------------------------------------------------------------------------------------------- ::rtl::OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException) { @@ -2276,6 +2289,7 @@ UnoListBoxControl::UnoListBoxControl() { return ::rtl::OUString::createFromAscii( "listbox" ); } +IMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox ) void UnoListBoxControl::dispose() throw(uno::RuntimeException) { @@ -2697,6 +2711,9 @@ UnoControlComboBoxModel::UnoControlComboBoxModel() : UnoControlListBoxModel(true { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox ); } + +IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel ) + uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) { static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); @@ -2772,6 +2789,7 @@ UnoComboBoxControl::UnoComboBoxControl() maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; } +IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox ) ::rtl::OUString UnoComboBoxControl::GetComponentServiceName() { -- cgit v1.2.3 From a37ba38fa326b3541fe20287d98a8d4fc672cb5e Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 19 Aug 2010 17:46:08 +0200 Subject: fs33a: #i113988# properly retrieve standard images --- svtools/source/graphic/provider.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index fbf95406a63a..f1674dcd7d4a 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -231,19 +231,19 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( co if( ( 0 == rResourceURL.getToken( 0, '/', nIndex ).compareToAscii( "private:standardimage" ) ) ) { rtl::OUString sImageName( rResourceURL.copy( nIndex ) ); - if ( sImageName.compareToAscii( "info" ) ) + if ( sImageName.equalsAscii( "info" ) ) { xRet = InfoBox::GetStandardImage().GetXGraphic(); } - else if ( sImageName.compareToAscii( "warning" ) ) + else if ( sImageName.equalsAscii( "warning" ) ) { xRet = WarningBox::GetStandardImage().GetXGraphic(); } - else if ( sImageName.compareToAscii( "error" ) ) + else if ( sImageName.equalsAscii( "error" ) ) { xRet = ErrorBox::GetStandardImage().GetXGraphic(); } - else if ( sImageName.compareToAscii( "query" ) ) + else if ( sImageName.equalsAscii( "query" ) ) { xRet = QueryBox::GetStandardImage().GetXGraphic(); } -- cgit v1.2.3 From 45e7a1e3f6b01c1fce6056f80e4642a452a42dfd Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 23 Aug 2010 15:18:37 +0200 Subject: fs33a: expose the WB_HIDESELECTION but of the tree control at its UNO API --- svtools/inc/svtools/svtreebx.hxx | 1 + svtools/source/contnr/svtreebx.cxx | 9 +++++++++ svtools/source/uno/treecontrolpeer.cxx | 18 ++++++++++++++++++ toolkit/source/controls/tree/treecontrol.cxx | 1 + 4 files changed, 29 insertions(+) diff --git a/svtools/inc/svtools/svtreebx.hxx b/svtools/inc/svtools/svtreebx.hxx index a600b91db1c4..787e0956888f 100644 --- a/svtools/inc/svtools/svtreebx.hxx +++ b/svtools/inc/svtools/svtreebx.hxx @@ -156,6 +156,7 @@ protected: virtual void CursorMoved( SvLBoxEntry* pNewCursor ); virtual void PreparePaint( SvLBoxEntry* ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void StateChanged( StateChangedType nStateChange ); void InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground); BOOL IsCellFocusEnabled() const; diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index b11a3f12ddf3..3b1430e0df77 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -2516,6 +2516,15 @@ void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt ) Control::DataChanged( rDCEvt ); } +void SvTreeListBox::StateChanged( StateChangedType i_nStateChange ) +{ + SvLBox::StateChanged( i_nStateChange ); + if ( ( i_nStateChange & STATE_CHANGE_STYLE ) != 0 ) + { + SetWindowBits( GetStyle() ); + } +} + void SvTreeListBox::InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 7fb1a007960f..5c1f4925783a 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -1322,6 +1322,21 @@ void TreeControlPeer::setProperty( const ::rtl::OUString& PropertyName, const An switch( GetPropertyId( PropertyName ) ) { + case BASEPROPERTY_HIDEINACTIVESELECTION: + { + sal_Bool bEnabled = sal_False; + if ( aValue >>= bEnabled ) + { + WinBits nStyle = rTree.GetStyle(); + if ( bEnabled ) + nStyle |= WB_HIDESELECTION; + else + nStyle &= ~WB_HIDESELECTION; + rTree.SetStyle( nStyle ); + } + } + break; + case BASEPROPERTY_TREE_SELECTIONTYPE: { SelectionType eSelectionType; @@ -1412,6 +1427,9 @@ Any TreeControlPeer::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow(); switch(nPropId) { + case BASEPROPERTY_HIDEINACTIVESELECTION: + return Any( ( rTree.GetStyle() & WB_HIDESELECTION ) != 0 ? sal_True : sal_False ); + case BASEPROPERTY_TREE_SELECTIONTYPE: { SelectionType eSelectionType; diff --git a/toolkit/source/controls/tree/treecontrol.cxx b/toolkit/source/controls/tree/treecontrol.cxx index 8606792fdf2f..d56ca82bb845 100644 --- a/toolkit/source/controls/tree/treecontrol.cxx +++ b/toolkit/source/controls/tree/treecontrol.cxx @@ -76,6 +76,7 @@ UnoTreeModel::UnoTreeModel() ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSROOTHANDLES ); ImplRegisterProperty( BASEPROPERTY_TREE_ROWHEIGHT ); ImplRegisterProperty( BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING ); + ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); } UnoTreeModel::UnoTreeModel( const UnoTreeModel& rModel ) -- cgit v1.2.3 From 6554b3de755e7b07c8d313d8bc7ae7b0c6638133 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 1 Sep 2010 12:27:38 +0200 Subject: fs33a: +i114247# sync WindowBits and Style --- svtools/source/contnr/svtreebx.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index 3b1430e0df77..fa3cf8e734c1 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -1513,6 +1513,11 @@ void SvTreeListBox::SetWindowBits( WinBits nWinStyle ) pImp->SetWindowBits( nWinStyle ); pImp->Resize(); Invalidate(); + + if ( nWindowStyle != GetStyle() ) + { + SetStyle( nWindowStyle ); + } } void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry ) @@ -2521,7 +2526,12 @@ void SvTreeListBox::StateChanged( StateChangedType i_nStateChange ) SvLBox::StateChanged( i_nStateChange ); if ( ( i_nStateChange & STATE_CHANGE_STYLE ) != 0 ) { - SetWindowBits( GetStyle() ); + if ( GetStyle() != nWindowStyle ) + // keep in sync with our WindowBits + // TODO: SetWindowBits is weird, it should be completely replaced (in all clients) with SetStyle + // (or are there WindowBits which have a different meaning when interpreted as style? Wouldn't + // be the first time, but all of those should be fixed meanwhile ...) + SetWindowBits( GetStyle() ); } } -- cgit v1.2.3 From 0b78b565774f51ba9770783b5e4b5d0474307ee7 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 3 Sep 2010 14:50:14 +0200 Subject: fs33a: revert the original fix for HideInactiveSelection support in the tree list box, causing too much regressions. Fix it by using SetWindowBits instead of SetStyle --- svtools/source/contnr/svtreebx.cxx | 14 -------------- svtools/source/uno/treecontrolpeer.cxx | 6 +++--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index fa3cf8e734c1..a8635c99d127 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -1513,11 +1513,6 @@ void SvTreeListBox::SetWindowBits( WinBits nWinStyle ) pImp->SetWindowBits( nWinStyle ); pImp->Resize(); Invalidate(); - - if ( nWindowStyle != GetStyle() ) - { - SetStyle( nWindowStyle ); - } } void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry ) @@ -2524,15 +2519,6 @@ void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt ) void SvTreeListBox::StateChanged( StateChangedType i_nStateChange ) { SvLBox::StateChanged( i_nStateChange ); - if ( ( i_nStateChange & STATE_CHANGE_STYLE ) != 0 ) - { - if ( GetStyle() != nWindowStyle ) - // keep in sync with our WindowBits - // TODO: SetWindowBits is weird, it should be completely replaced (in all clients) with SetStyle - // (or are there WindowBits which have a different meaning when interpreted as style? Wouldn't - // be the first time, but all of those should be fixed meanwhile ...) - SetWindowBits( GetStyle() ); - } } void SvTreeListBox::InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground) diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 5c1f4925783a..d1ea854cce61 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -1327,12 +1327,12 @@ void TreeControlPeer::setProperty( const ::rtl::OUString& PropertyName, const An sal_Bool bEnabled = sal_False; if ( aValue >>= bEnabled ) { - WinBits nStyle = rTree.GetStyle(); + WinBits nStyle = rTree.GetWindowBits(); if ( bEnabled ) nStyle |= WB_HIDESELECTION; else nStyle &= ~WB_HIDESELECTION; - rTree.SetStyle( nStyle ); + rTree.SetWindowBits( nStyle ); } } break; @@ -1428,7 +1428,7 @@ Any TreeControlPeer::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru switch(nPropId) { case BASEPROPERTY_HIDEINACTIVESELECTION: - return Any( ( rTree.GetStyle() & WB_HIDESELECTION ) != 0 ? sal_True : sal_False ); + return Any( ( rTree.GetWindowBits() & WB_HIDESELECTION ) != 0 ? sal_True : sal_False ); case BASEPROPERTY_TREE_SELECTIONTYPE: { -- cgit v1.2.3