From d688a8a5a59f9a152229f005964697218b31c621 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 30 Aug 2019 20:15:17 +0100 Subject: move SVTXRoadmap to toolkit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If1ef35fe778b67ab028fdadb3804f437e127aa67 Reviewed-on: https://gerrit.libreoffice.org/78322 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svtools/source/inc/unoiface.hxx | 63 -------- svtools/source/uno/unoiface.cxx | 257 ------------------------------ toolkit/source/awt/vclxtoolkit.cxx | 314 +++++++++++++++++++++++++++++++++++++ 3 files changed, 314 insertions(+), 320 deletions(-) diff --git a/svtools/source/inc/unoiface.hxx b/svtools/source/inc/unoiface.hxx index 1cccc09369cc..41d47405fb4e 100644 --- a/svtools/source/inc/unoiface.hxx +++ b/svtools/source/inc/unoiface.hxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -212,68 +211,6 @@ protected: }; -// class SVTXRoadmap - - -namespace vcl -{ - class ORoadmap; -} - -struct RMItemData -{ - bool b_Enabled; - sal_Int32 n_ID; - OUString Label; -}; - -typedef ::cppu::ImplInheritanceHelper < VCLXGraphicControl - , css::container::XContainerListener - , css::beans::XPropertyChangeListener - , css::awt::XItemEventBroadcaster - > SVTXRoadmap_Base; -class SVTXRoadmap final : public SVTXRoadmap_Base -{ -public: - SVTXRoadmap(); - - void SAL_CALL disposing( const css::lang::EventObject& Source ) override { VCLXWindow::disposing( Source ); } - - // css::awt::XVclWindowPeer - void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; - - css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; - - // XContainerListener - void SAL_CALL elementInserted( const css::container::ContainerEvent& rEvent ) override; - void SAL_CALL elementRemoved( const css::container::ContainerEvent& rEvent ) override; - void SAL_CALL elementReplaced( const css::container::ContainerEvent& rEvent ) override; - - // XItemEventBroadcaster - virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; - virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; - - // XPropertyChangeListener - virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; - -private: - - // VCLXGraphicControl overridables - virtual void ImplSetNewImage() override; - - static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); - virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } - - static RMItemData GetRMItemData( const css::container::ContainerEvent& _rEvent ); - - virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; - - virtual ~SVTXRoadmap() override; - - ItemListenerMultiplexer maItemListeners; -}; - - // class SVTXNumericField class SVTXNumericField : public css::awt::XNumericField, public SVTXFormattedField diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 39b95fbee5b0..5d45cb8362e9 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -116,11 +115,6 @@ SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const cs *ppNewComp = newComp; newComp->SetFormatter( static_cast(static_cast(pWindow)) ); } - else if (aServiceName.equalsIgnoreAsciiCase("roadmap") ) - { - pWindow = VclPtr< ::vcl::ORoadmap>::Create( pParent, WB_TABSTOP ); - *ppNewComp = new SVTXRoadmap; - } else if ( aServiceName.equalsIgnoreAsciiCase( "ProgressBar" ) ) { if ( pParent ) @@ -1397,257 +1391,6 @@ void SVTXFormattedField::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) } -// class SVTXRoadmap - -using namespace svt; - -SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this ) -{ -} - -SVTXRoadmap::~SVTXRoadmap() -{ -} - -void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) -{ - switch ( rVclWindowEvent.GetId() ) - { - case VclEventId::RoadmapItemSelected: - { - SolarMutexGuard aGuard; - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); - css::awt::ItemEvent aEvent; - aEvent.Selected = CurItemID; - aEvent.Highlighted = CurItemID; - aEvent.ItemId = CurItemID; - maItemListeners.itemStateChanged( aEvent ); - } - } - break; - default: - SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent ); - break; - } -} - - -void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) -{ - SolarMutexGuard aGuard; - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( !pField ) - return; - - css::uno::Reference< css::uno::XInterface > xRoadmapItem = evt.Source; - sal_Int32 nID = 0; - css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); - css::uno::Any aValue = xPropertySet->getPropertyValue("ID"); - aValue >>= nID; - - OUString sPropertyName = evt.PropertyName; - if ( sPropertyName == "Enabled" ) - { - bool bEnable = false; - evt.NewValue >>= bEnable; - pField->EnableRoadmapItem( static_cast(nID) , bEnable ); - } - else if ( sPropertyName == "Label" ) - { - OUString sLabel; - evt.NewValue >>= sLabel; - pField->ChangeRoadmapItemLabel( static_cast(nID) , sLabel ); - } - else if ( sPropertyName == "ID" ) - { - sal_Int32 nNewID = 0; - evt.NewValue >>= nNewID; - evt.OldValue >>= nID; - pField->ChangeRoadmapItemID( static_cast(nID), static_cast(nNewID) ); - } -// else - // TODO handle Interactive appropriately -} - - -void SVTXRoadmap::addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) -{ - maItemListeners.addInterface( l ); -} - -void SVTXRoadmap::removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) -{ - maItemListeners.removeInterface( l ); -} - -RMItemData SVTXRoadmap::GetRMItemData( const css::container::ContainerEvent& _rEvent ) -{ - RMItemData aCurRMItemData; - css::uno::Reference< css::uno::XInterface > xRoadmapItem; - _rEvent.Element >>= xRoadmapItem; - css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); - if ( xPropertySet.is() ) - { - css::uno::Any aValue = xPropertySet->getPropertyValue("Label"); - aValue >>= aCurRMItemData.Label; - aValue = xPropertySet->getPropertyValue("ID"); - aValue >>= aCurRMItemData.n_ID; - aValue = xPropertySet->getPropertyValue("Enabled"); - aValue >>= aCurRMItemData.b_Enabled; - } - else - { - aCurRMItemData.b_Enabled = false; - aCurRMItemData.n_ID = 0; - } - return aCurRMItemData; -} - -void SVTXRoadmap::elementInserted( const css::container::ContainerEvent& _rEvent ) -{ - SolarMutexGuard aGuard; - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - RMItemData CurItemData = GetRMItemData( _rEvent ); - sal_Int32 InsertIndex = 0; - _rEvent.Accessor >>= InsertIndex; - pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); - } -} - -void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent ) -{ - SolarMutexGuard aGuard; - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - sal_Int32 DelIndex = 0; - _rEvent.Accessor >>= DelIndex; - pField->DeleteRoadmapItem(DelIndex); - } -} - -void SVTXRoadmap::elementReplaced( const css::container::ContainerEvent& _rEvent ) -{ - SolarMutexGuard aGuard; - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - RMItemData CurItemData = GetRMItemData( _rEvent ); - sal_Int32 ReplaceIndex = 0; - _rEvent.Accessor >>= ReplaceIndex; - pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); - } -} - - -void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any& Value) -{ - SolarMutexGuard aGuard; - - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch (nPropType) - { - case BASEPROPERTY_COMPLETE: - { - bool b = false; - Value >>= b; - pField->SetRoadmapComplete( b); - } - break; - - case BASEPROPERTY_ACTIVATED: - { - bool b = false; - Value >>= b; - pField->SetRoadmapInteractive( b); - } - break; - - case BASEPROPERTY_CURRENTITEMID: - { - sal_Int32 nId = 0; - Value >>= nId; - pField->SelectRoadmapItemByID( static_cast(nId) ); - } - break; - - case BASEPROPERTY_TEXT: - { - OUString aStr; - Value >>= aStr; - pField->SetText( aStr ); - pField->Invalidate(); - } - break; - - default: - SVTXRoadmap_Base::setProperty( PropertyName, Value ); - break; - } - - } - else - SVTXRoadmap_Base::setProperty( PropertyName, Value ); -} - - -css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) -{ - SolarMutexGuard aGuard; - - css::uno::Any aReturn; - - VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); - if ( pField ) - { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch (nPropType) - { - case BASEPROPERTY_COMPLETE: - aReturn <<= pField->IsRoadmapComplete(); - break; - case BASEPROPERTY_ACTIVATED: - aReturn <<= pField->IsRoadmapInteractive(); - break; - case BASEPROPERTY_CURRENTITEMID: - aReturn <<= pField->GetCurrentRoadmapItemID(); - break; - default: - aReturn = SVTXRoadmap_Base::getProperty(PropertyName); - break; - } - } - return aReturn; -} - -void SVTXRoadmap::ImplSetNewImage() -{ - OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); - VclPtr< ::vcl::ORoadmap > pButton = GetAs< ::vcl::ORoadmap >(); - pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); -} - -void SVTXRoadmap::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) -{ - PushPropertyIds( rIds, - BASEPROPERTY_COMPLETE, - BASEPROPERTY_ACTIVATED, - BASEPROPERTY_CURRENTITEMID, - BASEPROPERTY_TEXT, - 0); - VCLXWindow::ImplGetPropertyIds( rIds, true ); - VCLXGraphicControl::ImplGetPropertyIds( rIds ); -} - - // class SVTXNumericField SVTXNumericField::SVTXNumericField() diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 7ede778ef9f5..79073b719b2c 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include #include @@ -69,6 +71,7 @@ #include #include #include +#include #include #include @@ -79,6 +82,7 @@ #include #include #include +#include #include #include @@ -1082,6 +1086,311 @@ public: } }; +// class SVTXRoadmap + +struct RMItemData +{ + bool b_Enabled; + sal_Int32 n_ID; + OUString Label; +}; + +typedef ::cppu::ImplInheritanceHelper < VCLXGraphicControl + , css::container::XContainerListener + , css::beans::XPropertyChangeListener + , css::awt::XItemEventBroadcaster + > SVTXRoadmap_Base; +class SVTXRoadmap final : public SVTXRoadmap_Base +{ +public: + SVTXRoadmap(); + + void SAL_CALL disposing( const css::lang::EventObject& Source ) override { VCLXWindow::disposing( Source ); } + + // css::awt::XVclWindowPeer + void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override; + + css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override; + + // XContainerListener + void SAL_CALL elementInserted( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementRemoved( const css::container::ContainerEvent& rEvent ) override; + void SAL_CALL elementReplaced( const css::container::ContainerEvent& rEvent ) override; + + // XItemEventBroadcaster + virtual void SAL_CALL addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + virtual void SAL_CALL removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) override; + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& evt ) override; + +private: + + // VCLXGraphicControl overridables + virtual void ImplSetNewImage() override; + + static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds ) override { return ImplGetPropertyIds( aIds ); } + + static RMItemData GetRMItemData( const css::container::ContainerEvent& _rEvent ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + virtual ~SVTXRoadmap() override; + + ItemListenerMultiplexer maItemListeners; +}; + + + +// class SVTXRoadmap + +SVTXRoadmap::SVTXRoadmap() : maItemListeners( *this ) +{ +} + +SVTXRoadmap::~SVTXRoadmap() +{ +} + +void SVTXRoadmap::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + switch ( rVclWindowEvent.GetId() ) + { + case VclEventId::RoadmapItemSelected: + { + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_Int16 CurItemID = pField->GetCurrentRoadmapItemID(); + css::awt::ItemEvent aEvent; + aEvent.Selected = CurItemID; + aEvent.Highlighted = CurItemID; + aEvent.ItemId = CurItemID; + maItemListeners.itemStateChanged( aEvent ); + } + } + break; + default: + SVTXRoadmap_Base::ProcessWindowEvent( rVclWindowEvent ); + break; + } +} + +void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( !pField ) + return; + + css::uno::Reference< css::uno::XInterface > xRoadmapItem = evt.Source; + sal_Int32 nID = 0; + css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); + css::uno::Any aValue = xPropertySet->getPropertyValue("ID"); + aValue >>= nID; + + OUString sPropertyName = evt.PropertyName; + if ( sPropertyName == "Enabled" ) + { + bool bEnable = false; + evt.NewValue >>= bEnable; + pField->EnableRoadmapItem( static_cast(nID) , bEnable ); + } + else if ( sPropertyName == "Label" ) + { + OUString sLabel; + evt.NewValue >>= sLabel; + pField->ChangeRoadmapItemLabel( static_cast(nID) , sLabel ); + } + else if ( sPropertyName == "ID" ) + { + sal_Int32 nNewID = 0; + evt.NewValue >>= nNewID; + evt.OldValue >>= nID; + pField->ChangeRoadmapItemID( static_cast(nID), static_cast(nNewID) ); + } +// else + // TODO handle Interactive appropriately +} + +void SVTXRoadmap::addItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) +{ + maItemListeners.addInterface( l ); +} + +void SVTXRoadmap::removeItemListener( const css::uno::Reference< css::awt::XItemListener >& l ) +{ + maItemListeners.removeInterface( l ); +} + +RMItemData SVTXRoadmap::GetRMItemData( const css::container::ContainerEvent& _rEvent ) +{ + RMItemData aCurRMItemData; + css::uno::Reference< css::uno::XInterface > xRoadmapItem; + _rEvent.Element >>= xRoadmapItem; + css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); + if ( xPropertySet.is() ) + { + css::uno::Any aValue = xPropertySet->getPropertyValue("Label"); + aValue >>= aCurRMItemData.Label; + aValue = xPropertySet->getPropertyValue("ID"); + aValue >>= aCurRMItemData.n_ID; + aValue = xPropertySet->getPropertyValue("Enabled"); + aValue >>= aCurRMItemData.b_Enabled; + } + else + { + aCurRMItemData.b_Enabled = false; + aCurRMItemData.n_ID = 0; + } + return aCurRMItemData; +} + +void SVTXRoadmap::elementInserted( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + RMItemData CurItemData = GetRMItemData( _rEvent ); + sal_Int32 InsertIndex = 0; + _rEvent.Accessor >>= InsertIndex; + pField->InsertRoadmapItem( InsertIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + } +} + +void SVTXRoadmap::elementRemoved( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_Int32 DelIndex = 0; + _rEvent.Accessor >>= DelIndex; + pField->DeleteRoadmapItem(DelIndex); + } +} + +void SVTXRoadmap::elementReplaced( const css::container::ContainerEvent& _rEvent ) +{ + SolarMutexGuard aGuard; + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + RMItemData CurItemData = GetRMItemData( _rEvent ); + sal_Int32 ReplaceIndex = 0; + _rEvent.Accessor >>= ReplaceIndex; + pField->ReplaceRoadmapItem( ReplaceIndex, CurItemData.Label, static_cast(CurItemData.n_ID), CurItemData.b_Enabled ); + } +} + +void SVTXRoadmap::setProperty( const OUString& PropertyName, const css::uno::Any& Value) +{ + SolarMutexGuard aGuard; + + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch (nPropType) + { + case BASEPROPERTY_COMPLETE: + { + bool b = false; + Value >>= b; + pField->SetRoadmapComplete( b); + } + break; + + case BASEPROPERTY_ACTIVATED: + { + bool b = false; + Value >>= b; + pField->SetRoadmapInteractive( b); + } + break; + + case BASEPROPERTY_CURRENTITEMID: + { + sal_Int32 nId = 0; + Value >>= nId; + pField->SelectRoadmapItemByID( static_cast(nId) ); + } + break; + + case BASEPROPERTY_TEXT: + { + OUString aStr; + Value >>= aStr; + pField->SetText( aStr ); + pField->Invalidate(); + } + break; + + default: + SVTXRoadmap_Base::setProperty( PropertyName, Value ); + break; + } + + } + else + SVTXRoadmap_Base::setProperty( PropertyName, Value ); +} + + +css::uno::Any SVTXRoadmap::getProperty( const OUString& PropertyName ) +{ + SolarMutexGuard aGuard; + + css::uno::Any aReturn; + + VclPtr<::vcl::ORoadmap> pField = GetAs< vcl::ORoadmap >(); + if ( pField ) + { + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch (nPropType) + { + case BASEPROPERTY_COMPLETE: + aReturn <<= pField->IsRoadmapComplete(); + break; + case BASEPROPERTY_ACTIVATED: + aReturn <<= pField->IsRoadmapInteractive(); + break; + case BASEPROPERTY_CURRENTITEMID: + aReturn <<= pField->GetCurrentRoadmapItemID(); + break; + default: + aReturn = SVTXRoadmap_Base::getProperty(PropertyName); + break; + } + } + return aReturn; +} + +void SVTXRoadmap::ImplSetNewImage() +{ + OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); + VclPtr< ::vcl::ORoadmap > pButton = GetAs< ::vcl::ORoadmap >(); + pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); +} + +void SVTXRoadmap::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_COMPLETE, + BASEPROPERTY_ACTIVATED, + BASEPROPERTY_CURRENTITEMID, + BASEPROPERTY_TEXT, + 0); + VCLXWindow::ImplGetPropertyIds( rIds, true ); + VCLXGraphicControl::ImplGetPropertyIds( rIds ); +} + + + + vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor& rDescriptor, vcl::Window* pParent, WinBits nWinBits, MessBoxStyle nMessBoxStyle ) @@ -1485,6 +1794,11 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = VclPtr::Create( pParent, nWinBits ); *ppNewComp = new ::toolkit::AnimatedImagesPeer; } + else if (aServiceName == "roadmap") + { + pNewWindow = VclPtr<::vcl::ORoadmap>::Create( pParent, WB_TABSTOP ); + *ppNewComp = new SVTXRoadmap; + } break; default: OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); -- cgit