diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-06-03 17:54:37 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-06-03 17:54:37 +0200 |
commit | 80391167818510cac71e423c4a69850f8f638f92 (patch) | |
tree | 35ad9eaf96ee4a562db848669495f035bc71984f /toolkit | |
parent | 4d1c1eae73df67c115f532b7078deaf7caf4cde8 (diff) | |
parent | 9e2ed49397eda707bca5326d09ff58b10fa05147 (diff) |
unoawt: merged in latest changes from CWS slidecopy (rebase to m80)
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxwindow.hxx | 18 | ||||
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxwindows.hxx | 31 | ||||
-rw-r--r-- | toolkit/inc/toolkit/controls/roadmapcontrol.hxx | 6 | ||||
-rw-r--r-- | toolkit/inc/toolkit/controls/unocontrol.hxx | 14 | ||||
-rw-r--r-- | toolkit/inc/toolkit/controls/unocontrolmodel.hxx | 1 | ||||
-rw-r--r-- | toolkit/inc/toolkit/controls/unocontrols.hxx | 125 | ||||
-rw-r--r-- | toolkit/inc/toolkit/helper/property.hxx | 3 | ||||
-rw-r--r-- | toolkit/source/awt/vclxmenu.cxx | 44 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 10 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 319 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 156 | ||||
-rw-r--r-- | toolkit/source/controls/dialogcontrol.cxx | 12 | ||||
-rw-r--r-- | toolkit/source/controls/tree/treecontrol.cxx | 8 | ||||
-rw-r--r-- | toolkit/source/controls/tree/treecontrol.hxx | 1 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrol.cxx | 52 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrolmodel.cxx | 22 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrols.cxx | 604 | ||||
-rw-r--r-- | toolkit/source/helper/property.cxx | 1 |
18 files changed, 1066 insertions, 361 deletions
diff --git a/toolkit/inc/toolkit/awt/vclxwindow.hxx b/toolkit/inc/toolkit/awt/vclxwindow.hxx index 97f36850dff9..6ad3c3ab6076 100644 --- a/toolkit/inc/toolkit/awt/vclxwindow.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindow.hxx @@ -51,6 +51,7 @@ #include <stdarg.h> #include <list> +#include <boost/function.hpp> class Window; class VclSimpleEvent; @@ -114,6 +115,23 @@ protected: ::cppu::OInterfaceContainerHelper& GetTopWindowListeners(); public: + typedef ::boost::function0< void > Callback; + +protected: + /** executes the given callback asynchronously + + At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that + you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e. + having a ref count > 0). + + As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers + care for the disposed state themself, and are alive as long as |this| is alive. + */ + void ImplExecuteAsyncWithoutSolarLock( + const Callback& i_callback + ); + +public: VCLXWindow( bool bWithDefaultProps = false ); ~VCLXWindow(); 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 <com/sun/star/awt/XComboBox.hpp> #include <com/sun/star/awt/XCheckBox.hpp> #include <com/sun/star/awt/XImageConsumer.hpp> +#include <com/sun/star/awt/XItemListListener.hpp> #include <cppuhelper/weak.hxx> +#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase2.hxx> #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..0515abe27128 100644 --- a/toolkit/inc/toolkit/controls/unocontrol.hxx +++ b/toolkit/inc/toolkit/controls/unocontrol.hxx @@ -38,6 +38,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/awt/XUnitConversion.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> #include <cppuhelper/weakagg.hxx> #include <osl/mutex.hxx> @@ -46,7 +47,7 @@ #include <cppuhelper/propshlp.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weakref.hxx> -#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/implbase8.hxx> #include <com/sun/star/util/XModeChangeBroadcaster.hpp> #include <com/sun/star/awt/XVclWindowPeer.hpp> @@ -73,13 +74,14 @@ struct UnoControl_Data; // ---------------------------------------------------- // class UnoControl // ---------------------------------------------------- -typedef ::cppu::WeakAggImplHelper7 < ::com::sun::star::awt::XControl +typedef ::cppu::WeakAggImplHelper8 < ::com::sun::star::awt::XControl , ::com::sun::star::awt::XWindow2 , ::com::sun::star::awt::XView , ::com::sun::star::beans::XPropertiesChangeListener , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::accessibility::XAccessible , ::com::sun::star::util::XModeChangeBroadcaster + , ::com::sun::star::awt::XUnitConversion > UnoControl_Base; class TOOLKIT_DLLPUBLIC UnoControl : public UnoControl_Base @@ -119,7 +121,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 ); @@ -220,6 +222,12 @@ public: virtual void SAL_CALL addModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeModeChangeApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModeChangeApproveListener >& _rxListener ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // XUnitConversion + virtual ::com::sun::star::awt::Point SAL_CALL convertPointToLogic( const ::com::sun::star::awt::Point& Point, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL convertPointToPixel( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL convertSizeToLogic( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL convertSizeToPixel( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + private: // ::com::sun::star::beans::XPropertiesChangeListener void SAL_CALL propertiesChange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt ) throw(::com::sun::star::uno::RuntimeException); 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<sal_Int32> 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..88449418c70a 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -51,6 +51,7 @@ #include <com/sun/star/awt/XCurrencyField.hpp> #include <com/sun/star/awt/XPatternField.hpp> #include <com/sun/star/awt/XProgressBar.hpp> +#include <com/sun/star/awt/XItemList.hpp> #include <com/sun/star/graphic/XGraphicObject.hpp> #include <toolkit/controls/unocontrolmodel.hxx> #include <toolkit/controls/unocontrolbase.hxx> @@ -58,12 +59,17 @@ #include <toolkit/helper/servicenames.hxx> #include <vcl/imgcons.hxx> #include <vcl/bitmapex.hxx> +#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase1.hxx> #include <comphelper/uno3.hxx> #include <list> +#include <vector> + +#include <boost/scoped_ptr.hpp> +#include <boost/optional.hpp> #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,87 @@ 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 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 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); + + // 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 +902,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/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index d5f484145316..ed86c3fe4ded 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -199,7 +199,8 @@ namespace rtl { #define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 148 #define BASEPROPERTY_GRID_HEADER_BACKGROUND 149 #define BASEPROPERTY_GRID_LINE_COLOR 150 -#define BASEPROPERTY_GRID_ROW_BACKGROUND 151 +#define BASEPROPERTY_GRID_ROW_BACKGROUND 151 +#define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 1992a8d721a6..5e44df58318e 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -37,11 +37,13 @@ #include <cppuhelper/typeprovider.hxx> #include <rtl/memory.h> #include <rtl/uuid.h> +#include <vos/mutex.hxx> #include <vcl/menu.hxx> #include <vcl/keycod.hxx> #include <vcl/image.hxx> #include <vcl/mnemonic.hxx> +#include <vcl/svapp.hxx> #include <com/sun/star/awt/KeyModifier.hpp> @@ -416,6 +418,7 @@ void VCLXMenu::removeMenuListener( const ::com::sun::star::uno::Reference< ::com void VCLXMenu::insertItem( sal_Int16 nItemId, const ::rtl::OUString& aText, sal_Int16 nItemStyle, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -424,6 +427,7 @@ void VCLXMenu::insertItem( sal_Int16 nItemId, const ::rtl::OUString& aText, sal_ void VCLXMenu::removeItem( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); sal_Int32 nItemCount = (sal_Int32)mpMenu->GetItemCount(); @@ -438,6 +442,7 @@ void VCLXMenu::removeItem( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun:: sal_Int16 VCLXMenu::getItemCount( ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->GetItemCount() : 0; @@ -445,6 +450,7 @@ sal_Int16 VCLXMenu::getItemCount( ) throw(::com::sun::star::uno::RuntimeExcepti sal_Int16 VCLXMenu::getItemId( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->GetItemId( nPos ) : 0; @@ -452,6 +458,7 @@ sal_Int16 VCLXMenu::getItemId( sal_Int16 nPos ) throw(::com::sun::star::uno::Run sal_Int16 VCLXMenu::getItemPos( sal_Int16 nId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->GetItemPos( nId ) : 0; @@ -459,6 +466,7 @@ sal_Int16 VCLXMenu::getItemPos( sal_Int16 nId ) throw(::com::sun::star::uno::Run void VCLXMenu::enableItem( sal_Int16 nItemId, sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -467,6 +475,7 @@ void VCLXMenu::enableItem( sal_Int16 nItemId, sal_Bool bEnable ) throw(::com::su sal_Bool VCLXMenu::isItemEnabled( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->IsItemEnabled( nItemId ) : sal_False; @@ -474,6 +483,7 @@ sal_Bool VCLXMenu::isItemEnabled( sal_Int16 nItemId ) throw(::com::sun::star::un void VCLXMenu::setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -482,6 +492,7 @@ void VCLXMenu::setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) th ::rtl::OUString VCLXMenu::getItemText( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::rtl::OUString aItemText; @@ -492,6 +503,7 @@ void VCLXMenu::setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) th void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& rxPopupMenu ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); VCLXMenu* pVCLMenu = VCLXMenu::GetImplementation( rxPopupMenu ); @@ -510,6 +522,7 @@ void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Ref ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > VCLXMenu::getPopupMenu( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > aRef; @@ -533,6 +546,7 @@ void VCLXMenu::setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Ref // ::com::sun::star::awt::XPopupMenu void VCLXMenu::insertSeparator( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -541,6 +555,7 @@ void VCLXMenu::insertSeparator( sal_Int16 nPos ) throw(::com::sun::star::uno::Ru void VCLXMenu::setDefaultItem( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -549,6 +564,7 @@ void VCLXMenu::setDefaultItem( sal_Int16 nItemId ) throw(::com::sun::star::uno:: sal_Int16 VCLXMenu::getDefaultItem( ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->GetDefaultItem() : 0; @@ -556,6 +572,7 @@ sal_Int16 VCLXMenu::getDefaultItem( ) throw(::com::sun::star::uno::RuntimeExcep void VCLXMenu::checkItem( sal_Int16 nItemId, sal_Bool bCheck ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -564,6 +581,7 @@ void VCLXMenu::checkItem( sal_Int16 nItemId, sal_Bool bCheck ) throw(::com::sun: sal_Bool VCLXMenu::isItemChecked( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return mpMenu ? mpMenu->IsItemChecked( nItemId ) : sal_False; @@ -571,6 +589,7 @@ sal_Bool VCLXMenu::isItemChecked( sal_Int16 nItemId ) throw(::com::sun::star::un sal_Int16 VCLXMenu::execute( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxWindowPeer, const ::com::sun::star::awt::Rectangle& rArea, sal_Int16 nFlags ) throw(::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); sal_Int16 nRet = 0; @@ -582,6 +601,7 @@ sal_Int16 VCLXMenu::execute( const ::com::sun::star::uno::Reference< ::com::sun: void SAL_CALL VCLXMenu::setCommand( sal_Int16 nItemId, const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -590,6 +610,7 @@ void SAL_CALL VCLXMenu::setCommand( sal_Int16 nItemId, const ::rtl::OUString& aC ::rtl::OUString SAL_CALL VCLXMenu::getCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::rtl::OUString aItemCommand; @@ -600,6 +621,7 @@ void SAL_CALL VCLXMenu::setCommand( sal_Int16 nItemId, const ::rtl::OUString& aC void SAL_CALL VCLXMenu::setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString& aHelp ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -608,6 +630,7 @@ void SAL_CALL VCLXMenu::setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString ::rtl::OUString SAL_CALL VCLXMenu::getHelpCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::rtl::OUString aHelpCommand; @@ -708,12 +731,14 @@ namespace ::sal_Bool SAL_CALL VCLXMenu::isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); return IsPopupMenu(); } void SAL_CALL VCLXMenu::clear( ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) mpMenu->Clear(); @@ -724,6 +749,7 @@ void SAL_CALL VCLXMenu::clear( ) throw (::com::sun::star::uno::RuntimeException throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::com::sun::star::awt::MenuItemType aMenuItemType = @@ -740,6 +766,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, void SAL_CALL VCLXMenu::hideDisabledEntries( ::sal_Bool bHide ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) { @@ -761,6 +788,7 @@ throw (::com::sun::star::uno::RuntimeException) ::sal_Bool SAL_CALL VCLXMenu::isInExecute( ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -773,6 +801,7 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL VCLXMenu::endExecute() throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -783,6 +812,7 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL VCLXMenu::setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) @@ -807,6 +837,7 @@ throw (::com::sun::star::uno::RuntimeException) ::com::sun::star::awt::MenuLogo SAL_CALL VCLXMenu::getLogo( ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::com::sun::star::awt::MenuLogo aAWTMenuLogo; @@ -827,6 +858,7 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL VCLXMenu::enableAutoMnemonics( ::sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu ) { @@ -843,6 +875,7 @@ void SAL_CALL VCLXMenu::setAcceleratorKeyEvent( ::sal_Int16 nItemId, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -858,6 +891,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::com::sun::star::awt::KeyEvent aKeyEvent; @@ -876,6 +910,7 @@ void SAL_CALL VCLXMenu::setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -890,6 +925,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); rtl::OUString sHelpText; @@ -907,6 +943,7 @@ void SAL_CALL VCLXMenu::setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUStri throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -921,6 +958,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); rtl::OUString sTipHelpText; @@ -939,6 +977,7 @@ void SAL_CALL VCLXMenu::setItemImage( throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -954,6 +993,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > rxGraphic; @@ -973,6 +1013,7 @@ void SAL_CALL VCLXMenu::setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAng throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -987,6 +1028,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); ::sal_Int32 nItemImageAngle( 0 ); @@ -1003,6 +1045,7 @@ void SAL_CALL VCLXMenu::setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); if ( mpMenu && IsPopupMenu() ) @@ -1017,6 +1060,7 @@ throw ( ::com::sun::star::container::NoSuchElementException, throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); sal_Bool bMirrorMode( sal_False ); diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 2eeafa73d2d2..f85e29c21099 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -632,7 +632,15 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // Wenn die Component einen Parent braucht, dann NULL zurueckgeben, // spaeter mal ::com::sun::star::uno::Exception... sal_Bool bException = sal_True; - if ( ( nType == WINDOW_DIALOG ) || ( nType == WINDOW_MODALDIALOG ) || ( nType == WINDOW_MODELESSDIALOG ) ) + if ( ( nType == WINDOW_DIALOG ) + || ( nType == WINDOW_MODALDIALOG ) + || ( nType == WINDOW_MODELESSDIALOG ) + || ( nType == WINDOW_MESSBOX ) + || ( nType == WINDOW_INFOBOX ) + || ( nType == WINDOW_WARNINGBOX ) + || ( nType == WINDOW_ERRORBOX ) + || ( nType == WINDOW_QUERYBOX ) + ) bException = sal_False; else if ( ( nType == WINDOW_WINDOW ) || ( nType == WINDOW_WORKWINDOW ) || diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 248571819067..dd4d56586b03 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -67,6 +67,8 @@ #include <toolkit/helper/unopropertyarrayhelper.hxx> +#include <boost/bind.hpp> + using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -109,117 +111,15 @@ namespace m_rFlag = false; } }; - - //................................................................ - //. MouseEventType - //................................................................ - enum MouseEventType - { - META_FIRST_MOUSE_EVENT = 0, - - EVENT_MOUSE_PRESSED = 0, - EVENT_MOUSE_RELEASED = 1, - EVENT_MOUSE_ENTERED = 2, - EVENT_MOUSE_EXITED = 3, - - META_LAST_MOUSE_EVENT = 3 - }; - - //................................................................ - //. PlainEventType - //................................................................ - enum PlainEventType - { - META_FIRST_PLAIN_EVENT = 4, - - EVENT_WINDOW_ENABLED = 4, - EVENT_WINDOW_DISABLED = 5, - - META_LAST_PLAIN_EVENT = 5 - }; - -#if OSL_DEBUG_LEVEL > 0 - static void checkEventDefinitions() - { - OSL_ENSURE( (int)META_LAST_MOUSE_EVENT < (int)META_FIRST_PLAIN_EVENT, "checkEventDefinitions: invalid event definitions!" ); - } - #define DBG_CHECK_EVENTS() checkEventDefinitions() -#else - #define DBG_CHECK_EVENTS() -#endif - - //................................................................ - //. AnyWindowEvent - //................................................................ - struct AnyWindowEvent : public ::comphelper::AnyEvent - { - private: - awt::MouseEvent m_aMouseEvent; - lang::EventObject m_aPlainEvent; - - sal_Int32 m_nEventType; - - public: - AnyWindowEvent( const awt::MouseEvent& _rEvent, MouseEventType _nType ) - :comphelper::AnyEvent() - ,m_aMouseEvent( _rEvent ) - ,m_nEventType( static_cast< sal_Int32 >( _nType ) ) - { - DBG_CHECK_EVENTS(); - } - - AnyWindowEvent( const lang::EventObject& _rEvent, PlainEventType _nType ) - :comphelper::AnyEvent() - ,m_aPlainEvent( _rEvent ) - ,m_nEventType( static_cast< sal_Int32 >( _nType ) ) - { - DBG_CHECK_EVENTS(); - } - - bool isMouseEvent() const - { - return ( META_FIRST_MOUSE_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_MOUSE_EVENT ); - } - - bool isPlainEvent() const - { - return ( META_FIRST_PLAIN_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_PLAIN_EVENT ); - } - - const awt::MouseEvent& getMouseEvent() const - { - OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEvent: no mouse event!" ); - return m_aMouseEvent; - } - - MouseEventType getMouseEventType() const - { - OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEventType: no mouse event!" ); - return static_cast< MouseEventType >( m_nEventType ); - } - - const lang::EventObject& getPlainEvent() const - { - OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEvent: no plain event!" ); - return m_aPlainEvent; - } - - PlainEventType getPlainEventType() const - { - OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEventType: no mouse event!" ); - return static_cast< PlainEventType >( m_nEventType ); - } - }; } //==================================================================== //= VCLXWindowImpl //==================================================================== -class SAL_DLLPRIVATE VCLXWindowImpl : public ::comphelper::IEventProcessor +class SAL_DLLPRIVATE VCLXWindowImpl { private: - typedef ::std::vector< ::rtl::Reference< ::comphelper::AnyEvent > > - EventArray; + typedef ::std::vector< VCLXWindow::Callback > CallbackArray; private: VCLXWindow& mrAntiImpl; @@ -243,8 +143,8 @@ private: VclContainerListenerMultiplexer maContainerListeners; TopWindowListenerMultiplexer maTopWindowListeners; - EventArray maEvents; - ULONG mnEventId; + CallbackArray maCallbackEvents; + ULONG mnCallbackEventId; public: bool mbDisposing : 1; @@ -285,13 +185,9 @@ public: void setDirectVisible( sal_Bool bDirectVisible ) { mbDirectVisible = bDirectVisible; } sal_Bool isDirectVisible() { return mbDirectVisible; } - /** asynchronously notifies a mouse event to the VCLXWindow's XMouseListeners - */ - void notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType ); - - /** asynchronously notifies an event described by an EventObject to the respective listeners + /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock */ - void notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType ); + void callBackAsync( const VCLXWindow::Callback& i_callback ); /** notifies the object that its VCLXWindow is being disposed */ @@ -322,21 +218,10 @@ protected: virtual void SAL_CALL acquire(); virtual void SAL_CALL release(); - // IEventProcessor - virtual void processEvent( const ::comphelper::AnyEvent& _rEvent ); - private: - DECL_LINK( OnProcessEvent, void* ); + DECL_LINK( OnProcessCallbacks, void* ); private: - /** notifies an arbitrary event - @param _rEvent - the event to notify - */ - void impl_notifyAnyEvent( - const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent - ); - private: /** determines whether the instance is already disposed @precond @@ -373,7 +258,7 @@ VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, ::vos::IMutex& _rMutex, ,maPaintListeners( _rAntiImpl ) ,maContainerListeners( _rAntiImpl ) ,maTopWindowListeners( _rAntiImpl ) - ,mnEventId( 0 ) + ,mnCallbackEventId( 0 ) ,mbDisposing( false ) ,mbDesignMode( false ) ,mbSynthesizingVCLEvent( false ) @@ -394,9 +279,10 @@ VCLXWindowImpl::~VCLXWindowImpl() void VCLXWindowImpl::disposing() { ::vos::OGuard aGuard( mrMutex ); - if ( mnEventId ) - Application::RemoveUserEvent( mnEventId ); - mnEventId = 0; + if ( mnCallbackEventId ) + Application::RemoveUserEvent( mnCallbackEventId ); + mnCallbackEventId = 0; + mbDisposed= true; ::com::sun::star::lang::EventObject aEvent; @@ -415,54 +301,48 @@ void VCLXWindowImpl::disposing() } //-------------------------------------------------------------------- -void VCLXWindowImpl::impl_notifyAnyEvent( const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent ) +void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback& i_callback ) { - maEvents.push_back( _rEvent ); - if ( !mnEventId ) - mnEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessEvent ) ); -} - -//-------------------------------------------------------------------- -void VCLXWindowImpl::notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType ) -{ - ::vos::OClearableGuard aGuard( mrMutex ); - if ( maMouseListeners.getLength() ) - impl_notifyAnyEvent( new AnyWindowEvent( _rMouseEvent, _nType ) ); + DBG_TESTSOLARMUTEX(); + maCallbackEvents.push_back( i_callback ); + if ( !mnCallbackEventId ) + { + // ensure our VCLXWindow is not destroyed while the event is underway + mrAntiImpl.acquire(); + mnCallbackEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessCallbacks ) ); + } } -//-------------------------------------------------------------------- -void VCLXWindowImpl::notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType ) +//---------------------------------------------------------------------------------------------------------------------- +IMPL_LINK( VCLXWindowImpl, OnProcessCallbacks, void*, EMPTYARG ) { - ::vos::OClearableGuard aGuard( mrMutex ); - if ( maWindow2Listeners.getLength() ) - impl_notifyAnyEvent( new AnyWindowEvent( _rPlainEvent, _nType ) ); -} + const Reference< uno::XInterface > xKeepAlive( mrAntiImpl ); -//-------------------------------------------------------------------- -IMPL_LINK( VCLXWindowImpl, OnProcessEvent, void*, EMPTYARG ) -{ - // work on a copy of the events array - EventArray aEventsCopy; + // work on a copy of the callback array + CallbackArray aCallbacksCopy; { ::vos::OGuard aGuard( mrMutex ); - aEventsCopy = maEvents; - maEvents.clear(); + aCallbacksCopy = maCallbackEvents; + maCallbackEvents.clear(); - if ( !mnEventId ) + // we acquired our VCLXWindow once before posting the event, release this one ref now + mrAntiImpl.release(); + + if ( !mnCallbackEventId ) // we were disposed while waiting for the mutex to lock return 1L; - mnEventId = 0; + mnCallbackEventId = 0; } { ::toolkit::ReleaseSolarMutex aReleaseSolar; - for ( EventArray::const_iterator loop = aEventsCopy.begin(); - loop != aEventsCopy.end(); + for ( CallbackArray::const_iterator loop = aCallbacksCopy.begin(); + loop != aCallbacksCopy.end(); ++loop ) { - processEvent( *(*loop) ); + (*loop)(); } } @@ -470,59 +350,6 @@ IMPL_LINK( VCLXWindowImpl, OnProcessEvent, void*, EMPTYARG ) } //-------------------------------------------------------------------- -void VCLXWindowImpl::processEvent( const ::comphelper::AnyEvent& _rEvent ) -{ - ::vos::OGuard aGuard( mrMutex ); - if ( impl_isDisposed() ) - // while we were waiting for our mutex, another thread disposed us - return; - - const AnyWindowEvent& rEventDescriptor( static_cast< const AnyWindowEvent& >( _rEvent ) ); - if ( rEventDescriptor.isMouseEvent() ) - { - const awt::MouseEvent& rEvent( rEventDescriptor.getMouseEvent() ); - switch ( rEventDescriptor.getMouseEventType() ) - { - case EVENT_MOUSE_PRESSED: - maMouseListeners.mousePressed( rEvent ); - break; - case EVENT_MOUSE_RELEASED: - maMouseListeners.mouseReleased( rEvent ); - break; - case EVENT_MOUSE_ENTERED: - maMouseListeners.mouseEntered( rEvent ); - break; - case EVENT_MOUSE_EXITED: - maMouseListeners.mouseExited( rEvent ); - break; - default: - DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (1)?" ); - break; - } - } - else if ( rEventDescriptor.isPlainEvent() ) - { - const lang::EventObject& rEvent( rEventDescriptor.getPlainEvent() ); - switch ( rEventDescriptor.getPlainEventType() ) - { - case EVENT_WINDOW_ENABLED: - maWindow2Listeners.notifyEach( &XWindowListener2::windowEnabled, rEvent ); - break; - case EVENT_WINDOW_DISABLED: - maWindow2Listeners.notifyEach( &XWindowListener2::windowDisabled, rEvent ); - break; - default: - DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (2)?" ); - break; - } - } - else - { - DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (3)?" ); - } -} - -//-------------------------------------------------------------------- void SAL_CALL VCLXWindowImpl::acquire() { mrAntiImpl.acquire(); @@ -581,6 +408,13 @@ VCLXWindow::~VCLXWindow() } } +//---------------------------------------------------------------------------------------------------------------------- +void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback& i_callback ) +{ + mpImpl->callBackAsync( i_callback ); +} + +//---------------------------------------------------------------------------------------------------------------------- ::toolkit::IAccessibleFactory& VCLXWindow::getAccessibleFactory() { return mpImpl->getAccessibleFactory().getFactory(); @@ -641,6 +475,28 @@ IMPL_LINK( VCLXWindow, WindowEventListener, VclSimpleEvent*, pEvent ) return 0; } +namespace +{ + struct CallWindow2Listener + { + CallWindow2Listener( ::cppu::OInterfaceContainerHelper& i_rWindow2Listeners, const bool i_bEnabled, const EventObject& i_rEvent ) + :m_rWindow2Listeners( i_rWindow2Listeners ) + ,m_bEnabled( i_bEnabled ) + ,m_aEvent( i_rEvent ) + { + } + + void operator()() + { + m_rWindow2Listeners.notifyEach( m_bEnabled ? &XWindowListener2::windowEnabled : &XWindowListener2::windowDisabled, m_aEvent ); + } + + ::cppu::OInterfaceContainerHelper& m_rWindow2Listeners; + const bool m_bEnabled; + const EventObject m_aEvent; + }; +} + void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis( (::cppu::OWeakObject*)this ); @@ -650,10 +506,12 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) case VCLEVENT_WINDOW_ENABLED: case VCLEVENT_WINDOW_DISABLED: { - bool bEnabled = ( VCLEVENT_WINDOW_ENABLED == rVclWindowEvent.GetId() ); - EventObject aEvent( *this ); - mpImpl->notifyPlainEvent( aEvent, - bEnabled ? EVENT_WINDOW_ENABLED : EVENT_WINDOW_DISABLED ); + Callback aCallback = CallWindow2Listener( + mpImpl->getWindow2Listeners(), + ( VCLEVENT_WINDOW_ENABLED == rVclWindowEvent.GetId() ), + EventObject( *this ) + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } break; @@ -884,7 +742,13 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) MouseEvent aMEvt( aWhere, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT, 0 ); awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( aMEvt, *this ) ); aEvent.PopupTrigger = sal_True; - mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED ); + + Callback aCallback = ::boost::bind( + &MouseListenerMultiplexer::mousePressed, + &mpImpl->getMouseListeners(), + aEvent + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } } break; @@ -894,10 +758,13 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) ) { awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); - mpImpl->notifyMouseEvent( - aEvent, - pMouseEvt->IsEnterWindow() ? EVENT_MOUSE_ENTERED : EVENT_MOUSE_EXITED + + Callback aCallback = ::boost::bind( + pMouseEvt->IsEnterWindow() ? &MouseListenerMultiplexer::mouseEntered : &MouseListenerMultiplexer::mouseExited, + &mpImpl->getMouseListeners(), + aEvent ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() ) @@ -916,7 +783,12 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) if ( mpImpl->getMouseListeners().getLength() ) { awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) ); - mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED ); + Callback aCallback = ::boost::bind( + &MouseListenerMultiplexer::mousePressed, + &mpImpl->getMouseListeners(), + aEvent + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } } break; @@ -925,7 +797,12 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) if ( mpImpl->getMouseListeners().getLength() ) { awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) ); - mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_RELEASED ); + Callback aCallback = ::boost::bind( + &MouseListenerMultiplexer::mouseReleased, + &mpImpl->getMouseListeners(), + aEvent + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } } break; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index e2fc78421d5e..5649ed4248dd 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -29,7 +29,7 @@ #include "precompiled_toolkit.hxx" #include <toolkit/awt/vclxwindows.hxx> #include <com/sun/star/awt/ScrollBarOrientation.hpp> -#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/graphic/XGraphicProvider.hpp> #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/macros.hxx> #include <toolkit/helper/property.hxx> @@ -43,6 +43,9 @@ #include <com/sun/star/system/XSystemShellExecute.hpp> #include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/awt/ImageScaleMode.hpp> +#include <com/sun/star/awt/XItemList.hpp> +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> #ifndef _SV_BUTTON_HXX @@ -58,12 +61,20 @@ #include <vcl/scrbar.hxx> #include <vcl/svapp.hxx> #include <vcl/tabpage.hxx> -#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> + +#include <boost/bind.hpp> +#include <boost/function.hpp> 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; @@ -626,7 +637,13 @@ void VCLXButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) ::com::sun::star::awt::ActionEvent aEvent; aEvent.Source = (::cppu::OWeakObject*)this; aEvent.ActionCommand = maActionCommand; - maActionListeners.actionPerformed( aEvent ); + + Callback aCallback = ::boost::bind( + &ActionListenerMultiplexer::actionPerformed, + &maActionListeners, + aEvent + ); + ImplExecuteAsyncWithoutSolarLock( aCallback ); } } break; @@ -1529,6 +1546,7 @@ void VCLXListBox::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_HELPURL, BASEPROPERTY_LINECOUNT, BASEPROPERTY_MULTISELECTION, + BASEPROPERTY_MULTISELECTION_SIMPLEMODE, BASEPROPERTY_PRINTABLE, BASEPROPERTY_SELECTEDITEMS, BASEPROPERTY_STRINGITEMLIST, @@ -1550,22 +1568,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() ); @@ -1928,6 +1930,9 @@ void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com: pListBox->EnableMultiSelection( b ); } break; + case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: + ::toolkit::adjustBooleanWindowStyle( Value, pListBox, WB_SIMPLEMODE, sal_False ); + break; case BASEPROPERTY_LINECOUNT: { sal_Int16 n = sal_Int16(); @@ -1992,6 +1997,11 @@ void VCLXListBox::setProperty( const ::rtl::OUString& PropertyName, const ::com: aProp <<= (sal_Bool) pListBox->IsMultiSelectionEnabled(); } break; + case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: + { + aProp <<= (sal_Bool)( ( pListBox->GetStyle() & WB_SIMPLEMODE ) == 0 ); + } + break; case BASEPROPERTY_LINECOUNT: { aProp <<= (sal_Int16) pListBox->GetDropDownLineCount(); @@ -2096,6 +2106,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 : ::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 ); + 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; i<aItems.getLength(); ++i ) + { + pListBox->InsertEntry( 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/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index db9634fb44a1..cf1bff991430 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -2081,24 +2081,24 @@ throw (RuntimeException) ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ) { - - - ::rtl::OUString ret; - ::rtl::OUString baseLocation; ::rtl::OUString url; rbase >>= baseLocation; rUrl >>= url; + ::rtl::OUString absoluteURL( url ); if ( url.getLength() > 0 ) { INetURLObject urlObj(baseLocation); urlObj.removeSegment(); baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE ); - ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, ret ); + + ::rtl::OUString testAbsoluteURL; + if ( ::osl::FileBase::E_None == ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, testAbsoluteURL ) ) + absoluteURL = testAbsoluteURL; } - return ret; + return absoluteURL; } diff --git a/toolkit/source/controls/tree/treecontrol.cxx b/toolkit/source/controls/tree/treecontrol.cxx index 5655e4e10abc..8606792fdf2f 100644 --- a/toolkit/source/controls/tree/treecontrol.cxx +++ b/toolkit/source/controls/tree/treecontrol.cxx @@ -67,6 +67,7 @@ UnoTreeModel::UnoTreeModel() ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); ImplRegisterProperty( BASEPROPERTY_HELPURL ); ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); + ImplRegisterProperty( BASEPROPERTY_TABSTOP ); ImplRegisterProperty( BASEPROPERTY_TREE_SELECTIONTYPE ); ImplRegisterProperty( BASEPROPERTY_TREE_EDITABLE ); ImplRegisterProperty( BASEPROPERTY_TREE_DATAMODEL ); @@ -361,6 +362,13 @@ Reference< XTreeNode > SAL_CALL UnoTreeControl::getClosestNodeForLocation( sal_I // ------------------------------------------------------------------- +awt::Rectangle SAL_CALL UnoTreeControl::getNodeRect( const Reference< XTreeNode >& Node ) throw (IllegalArgumentException, RuntimeException) +{ + return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->getNodeRect( Node ); +} + +// ------------------------------------------------------------------- + sal_Bool SAL_CALL UnoTreeControl::isEditing( ) throw (RuntimeException) { return Reference< XTreeControl >( getPeer(), UNO_QUERY_THROW )->isEditing(); diff --git a/toolkit/source/controls/tree/treecontrol.hxx b/toolkit/source/controls/tree/treecontrol.hxx index 0cae86616aa4..e646664c4a64 100644 --- a/toolkit/source/controls/tree/treecontrol.hxx +++ b/toolkit/source/controls/tree/treecontrol.hxx @@ -114,6 +114,7 @@ public: virtual void SAL_CALL removeTreeExpansionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeExpansionListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode > SAL_CALL getClosestNodeForLocation( ::sal_Int32 x, ::sal_Int32 y ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getNodeRect( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tree::XTreeNode >& Node ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isEditing( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL stopEditing( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL cancelEditing( ) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index 1abe0b34004f..d91077823495 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -1535,3 +1535,55 @@ void SAL_CALL UnoControl::removeModeChangeApproveListener( const Reference< XMod throw NoSupportException( ); } +//---------------------------------------------------------------------------------------------------------------------- +awt::Point SAL_CALL UnoControl::convertPointToLogic( const awt::Point& i_Point, ::sal_Int16 i_TargetUnit ) throw (IllegalArgumentException, RuntimeException) +{ + Reference< XUnitConversion > xPeerConversion; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xPeerConversion = xPeerConversion.query( getPeer() ); + } + if ( xPeerConversion.is() ) + return xPeerConversion->convertPointToLogic( i_Point, i_TargetUnit ); + return awt::Point( ); +} + +//---------------------------------------------------------------------------------------------------------------------- +awt::Point SAL_CALL UnoControl::convertPointToPixel( const awt::Point& i_Point, ::sal_Int16 i_SourceUnit ) throw (IllegalArgumentException, RuntimeException) +{ + Reference< XUnitConversion > xPeerConversion; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xPeerConversion = xPeerConversion.query( getPeer() ); + } + if ( xPeerConversion.is() ) + return xPeerConversion->convertPointToPixel( i_Point, i_SourceUnit ); + return awt::Point( ); +} + +//---------------------------------------------------------------------------------------------------------------------- +awt::Size SAL_CALL UnoControl::convertSizeToLogic( const awt::Size& i_Size, ::sal_Int16 i_TargetUnit ) throw (IllegalArgumentException, RuntimeException) +{ + Reference< XUnitConversion > xPeerConversion; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xPeerConversion = xPeerConversion.query( getPeer() ); + } + if ( xPeerConversion.is() ) + return xPeerConversion->convertSizeToLogic( i_Size, i_TargetUnit ); + return awt::Size( ); +} + +//---------------------------------------------------------------------------------------------------------------------- +awt::Size SAL_CALL UnoControl::convertSizeToPixel( const awt::Size& i_Size, ::sal_Int16 i_SourceUnit ) throw (IllegalArgumentException, RuntimeException) +{ + Reference< XUnitConversion > xPeerConversion; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xPeerConversion = xPeerConversion.query( getPeer() ); + } + if ( xPeerConversion.is() ) + return xPeerConversion->convertSizeToPixel( i_Size, i_SourceUnit ); + return awt::Size( ); +} + diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 29b683a5ed40..c5e1f70b15b8 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; @@ -342,6 +338,7 @@ void UnoControlModel::ImplPropertyChanged( sal_uInt16 ) case BASEPROPERTY_HARDLINEBREAKS: case BASEPROPERTY_NOLABEL: aDefault <<= (sal_Bool) sal_False; break; + case BASEPROPERTY_MULTISELECTION_SIMPLEMODE: case BASEPROPERTY_HIDEINACTIVESELECTION: case BASEPROPERTY_ENFORCE_FORMAT: case BASEPROPERTY_AUTOCOMPLETE: @@ -1259,22 +1256,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..3b037e3ca0d3 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -73,8 +73,11 @@ #include <tools/time.hxx> #include <algorithm> +#include <functional> using namespace ::com::sun::star; +using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::uno::Reference; using namespace ::toolkit; @@ -1841,19 +1844,130 @@ sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException) return sal_True; } -// ---------------------------------------------------- -// class UnoControlListBoxModel -// ---------------------------------------------------- +// ===================================================================================================================== +// = UnoControlListBoxModel_Data +// ===================================================================================================================== +struct ListItem +{ + ::rtl::OUString ItemText; + ::rtl::OUString ItemImageURL; + Any ItemData; + + ListItem() + :ItemText() + ,ItemImageURL() + ,ItemData() + { + } + + ListItem( const ::rtl::OUString& i_rItemText ) + :ItemText( i_rItemText ) + ,ItemImageURL() + ,ItemData() + { + } +}; + +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 ) + :m_bSettingLegacyProperty( false ) + ,m_rAntiImpl( i_rAntiImpl ) + ,m_aListItems() + { + } + + 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< UnoListItem > getAllItems() const + { + Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) ); + ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() ); + 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 +1979,7 @@ uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return UnoControlModel::ImplGetDefaultValue( nPropId ); } +// --------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -1876,6 +1991,7 @@ uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } +// --------------------------------------------------------------------------------------------------------------------- // beans::XMultiPropertySet uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo( ) throw(uno::RuntimeException) { @@ -1883,19 +1999,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 ); + } + }; +} + +// --------------------------------------------------------------------------------------------------------------------- +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<sal_Int16> 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 +2064,327 @@ 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.ItemText = i_rItemText; + rItem.ItemImageURL = 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.ItemText = 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.ItemImageURL = 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.ItemText = 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.ItemImageURL = 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.ItemText = i_rItemText; + rItem.ItemImageURL = i_rItemImageURL; + + impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard ); + // <----- SYNCHRONIZED +} + +// --------------------------------------------------------------------------------------------------------------------- +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.ItemData = i_rDataValue; +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + 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() ); + 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() ); + const ListItem& rItem( m_pData->getItem( i_nPosition ) ); + return beans::Pair< ::rtl::OUString, ::rtl::OUString >( rItem.ItemText, rItem.ItemImageURL ); +} + +// --------------------------------------------------------------------------------------------------------------------- +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.ItemData; +} + +// --------------------------------------------------------------------------------------------------------------------- +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 +2395,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 +2418,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 +2735,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/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 6711e4503511..b878112eed69 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -203,6 +203,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_1 ( "MouseTransparent", MOUSETRANSPARENT, bool, BOUND ), DECL_PROP_2 ( "MultiLine", MULTILINE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "MultiSelection", MULTISELECTION, bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "MultiSelectionSimpleMode", MULTISELECTION_SIMPLEMODE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "NativeWidgetLook", NATIVE_WIDGET_LOOK, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "NoLabel", NOLABEL, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "Orientation", ORIENTATION, sal_Int32, BOUND, MAYBEDEFAULT ), |