[Libreoffice-commits] core.git: include/toolkit toolkit/inc toolkit/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 18 14:29:03 UTC 2020
include/toolkit/controls/unocontrol.hxx | 2 +-
toolkit/inc/awt/vclxtabpagecontainer.hxx | 5 +++++
toolkit/inc/controls/tabpagecontainer.hxx | 3 +++
toolkit/source/awt/vclxtabpagecontainer.cxx | 23 +++++++++++++++++++++++
toolkit/source/controls/tabpagecontainer.cxx | 9 +++++++++
5 files changed, 41 insertions(+), 1 deletion(-)
New commits:
commit 92289c5f121499959b6f5edf859e5f34b5b96a78
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Mon May 18 10:51:14 2020 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Mon May 18 16:28:22 2020 +0200
tdf#133142 UnoControlTabPageContainer: Handle tab property changes
In the model, changing a tab page's title or enabled/disabled
status is done via methods 'XTabPageModel.setTitle' and
'XTabPageModel.setEnabled'.
Changes to the title and enabled/disabled status are
propagated to the tab page container containing the
tab page (s.a. 25c692c2a94ab83c2c859ac5ab334b62ac8b825e
("ControlModelContainerBase: Use property for enabled status",
2020-05-15)).
Make 'VCLXTabPageContainer' derive from 'XPropertiesChangeListener'
and implement the 'propertiesChange' method defined in that
interface to handle property changes for the tab pages and have
'UnoControlTabPageContainer' forward 'PropertyChangeEvent's
to its peer so they can be handled there.
This way, changes for those tab page properties via UNO
are now properly updated in the UI as well.
Change-Id: I6fa1fadf781575c4ad1d066aed9c3a651b10869d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94402
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/include/toolkit/controls/unocontrol.hxx b/include/toolkit/controls/unocontrol.hxx
index cc83a6b7a934..a406a22bc5e8 100644
--- a/include/toolkit/controls/unocontrol.hxx
+++ b/include/toolkit/controls/unocontrol.hxx
@@ -218,7 +218,7 @@ public:
// XStyleSettingsSupplier
virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override;
-private:
+protected:
// css::beans::XPropertiesChangeListener
void SAL_CALL propertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) override;
};
diff --git a/toolkit/inc/awt/vclxtabpagecontainer.hxx b/toolkit/inc/awt/vclxtabpagecontainer.hxx
index fee096cc04ba..54fe0e0503aa 100644
--- a/toolkit/inc/awt/vclxtabpagecontainer.hxx
+++ b/toolkit/inc/awt/vclxtabpagecontainer.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <com/sun/star/awt/tab/XTabPageContainer.hpp>
#include <cppuhelper/implbase.hxx>
#include <toolkit/helper/listenermultiplexer.hxx>
@@ -28,6 +29,7 @@
typedef cppu::ImplInheritanceHelper< VCLXContainer,
css::awt::tab::XTabPageContainer,
+ css::beans::XPropertiesChangeListener,
css::container::XContainerListener
> VCLXTabPageContainer_Base;
class VCLXTabPageContainer final : public VCLXTabPageContainer_Base
@@ -56,6 +58,9 @@ public:
virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
+ // css::beans::XPropertiesChangeListener
+ virtual void SAL_CALL propertiesChange( const ::css::uno::Sequence< ::css::beans::PropertyChangeEvent >& aEvent ) override;
+
// css::awt::XVclWindowPeer
void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override;
private:
diff --git a/toolkit/inc/controls/tabpagecontainer.hxx b/toolkit/inc/controls/tabpagecontainer.hxx
index 9873ad3272b1..e00c0bd89e58 100644
--- a/toolkit/inc/controls/tabpagecontainer.hxx
+++ b/toolkit/inc/controls/tabpagecontainer.hxx
@@ -111,6 +111,9 @@ public:
virtual void SAL_CALL addTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override;
virtual void SAL_CALL removeTabPageContainerListener( const css::uno::Reference< css::awt::tab::XTabPageContainerListener >& listener ) override;
+ // css::beans::XPropertiesChangeListener
+ virtual void SAL_CALL propertiesChange( const ::css::uno::Sequence< ::css::beans::PropertyChangeEvent >& aEvent ) override;
+
virtual void SAL_CALL addControl( const OUString& Name, const css::uno::Reference< css::awt::XControl >& Control ) override;
// css::lang::XServiceInfo
DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, "com.sun.star.awt.tab.UnoControlTabPageContainer" )
diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx
index 0bfacc695136..bc5d19964d2e 100644
--- a/toolkit/source/awt/vclxtabpagecontainer.cxx
+++ b/toolkit/source/awt/vclxtabpagecontainer.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/awt/tab/XTabPageModel.hpp>
#include <com/sun/star/awt/XControl.hpp>
#include <sal/log.hxx>
+#include <toolkit/helper/property.hxx>
#include <vcl/image.hxx>
#include <vcl/tabpage.hxx>
#include <vcl/tabctrl.hxx>
@@ -208,4 +209,26 @@ void SAL_CALL VCLXTabPageContainer::elementReplaced( const css::container::Conta
{
}
+void VCLXTabPageContainer::propertiesChange(const::css::uno::Sequence<PropertyChangeEvent>& rEvents)
+{
+ SolarMutexGuard aGuard;
+ VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
+ if (!pTabCtrl)
+ return;
+
+ for (const beans::PropertyChangeEvent& rEvent : rEvents) {
+ // handle property changes for tab pages
+ Reference< css::awt::tab::XTabPageModel > xTabPageModel(rEvent.Source, uno::UNO_QUERY);
+ if (!xTabPageModel.is())
+ continue;
+
+ const sal_Int16 nId = xTabPageModel->getTabPageID();
+ if (rEvent.PropertyName == GetPropertyName(BASEPROPERTY_ENABLED)) {
+ pTabCtrl->SetPageEnabled(nId, xTabPageModel->getEnabled());
+ } else if (rEvent.PropertyName == GetPropertyName(BASEPROPERTY_TITLE)) {
+ pTabCtrl->SetPageText(nId, xTabPageModel->getTitle());
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/controls/tabpagecontainer.cxx b/toolkit/source/controls/tabpagecontainer.cxx
index 25c50c387abe..979718e73865 100644
--- a/toolkit/source/controls/tabpagecontainer.cxx
+++ b/toolkit/source/controls/tabpagecontainer.cxx
@@ -294,6 +294,15 @@ void SAL_CALL UnoControlTabPageContainer::removeTabPageContainerListener( const
m_aTabPageListeners.removeInterface( listener );
}
+void UnoControlTabPageContainer::propertiesChange(const::css::uno::Sequence<PropertyChangeEvent> &aEvent)
+{
+ UnoControlTabPageContainer_Base::propertiesChange(aEvent);
+
+ SolarMutexGuard aSolarGuard;
+ Reference< XPropertiesChangeListener > xPropertiesChangeListener( getPeer(), UNO_QUERY_THROW );
+ return xPropertiesChangeListener->propertiesChange(aEvent);
+}
+
void UnoControlTabPageContainer::updateFromModel()
{
UnoControlTabPageContainer_Base::updateFromModel();
More information about the Libreoffice-commits
mailing list