[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - 3 commits - include/toolkit toolkit/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 18 14:56:28 UTC 2020
include/toolkit/awt/vclxtabpagecontainer.hxx | 5 +++
include/toolkit/controls/controlmodelcontainerbase.hxx | 1
include/toolkit/controls/tabpagecontainer.hxx | 3 ++
include/toolkit/controls/unocontrol.hxx | 2 -
toolkit/source/awt/vclxtabpagecontainer.cxx | 23 +++++++++++++++++
toolkit/source/controls/controlmodelcontainerbase.cxx | 13 ++++++---
toolkit/source/controls/tabpagecontainer.cxx | 11 +++++++-
7 files changed, 51 insertions(+), 7 deletions(-)
New commits:
commit 71a734b66731219b1a2f543d45ff1b85872ecd11
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:55:40 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.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94402
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
(cherry picked from commit 92289c5f121499959b6f5edf859e5f34b5b96a78)
Conflicts:
toolkit/inc/awt/vclxtabpagecontainer.hxx
toolkit/inc/controls/tabpagecontainer.hxx
Change-Id: I6fa1fadf781575c4ad1d066aed9c3a651b10869d
diff --git a/include/toolkit/awt/vclxtabpagecontainer.hxx b/include/toolkit/awt/vclxtabpagecontainer.hxx
index ffb6feb5ad73..756bbe4733c6 100644
--- a/include/toolkit/awt/vclxtabpagecontainer.hxx
+++ b/include/toolkit/awt/vclxtabpagecontainer.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_TOOLKIT_AWT_VCLXTABPAGECONTAINER_HXX
#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>
@@ -29,6 +30,7 @@
typedef cppu::ImplInheritanceHelper< VCLXContainer,
css::awt::tab::XTabPageContainer,
+ css::beans::XPropertiesChangeListener,
css::container::XContainerListener
> VCLXTabPageContainer_Base;
class VCLXTabPageContainer final : public VCLXTabPageContainer_Base
@@ -57,6 +59,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/include/toolkit/controls/tabpagecontainer.hxx b/include/toolkit/controls/tabpagecontainer.hxx
index 2e071ae16f3c..0a3c117bc8b4 100644
--- a/include/toolkit/controls/tabpagecontainer.hxx
+++ b/include/toolkit/controls/tabpagecontainer.hxx
@@ -113,6 +113,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/include/toolkit/controls/unocontrol.hxx b/include/toolkit/controls/unocontrol.hxx
index 94b3f09a1999..e77479656f3d 100644
--- a/include/toolkit/controls/unocontrol.hxx
+++ b/include/toolkit/controls/unocontrol.hxx
@@ -219,7 +219,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/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx
index 81e6e9b51232..51789915de42 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>
@@ -209,4 +210,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 42cf153d35ec..3aae64d72bca 100644
--- a/toolkit/source/controls/tabpagecontainer.cxx
+++ b/toolkit/source/controls/tabpagecontainer.cxx
@@ -296,6 +296,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();
commit d68c1ad86dc0206f87d504e9d9165bab966ebe5d
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri May 15 15:28:14 2020 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Mon May 18 12:47:37 2020 +0200
ControlModelContainerBase: Use property for enabled status
Use the property BASEPROPERTY_ENABLED for getting and setting
the status instead of handling it in a custom bool member
variable.
This way, property changes are also automatically propagated
and can be handled by the corresponding listeners.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94310
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
Conflicts:
toolkit/inc/controls/controlmodelcontainerbase.hxx
Change-Id: I3a36ac8738a7caae987894ac9dd271d2713c1e09
diff --git a/include/toolkit/controls/controlmodelcontainerbase.hxx b/include/toolkit/controls/controlmodelcontainerbase.hxx
index 5a56b9b3a1f1..2bd7a7feafa7 100644
--- a/include/toolkit/controls/controlmodelcontainerbase.hxx
+++ b/include/toolkit/controls/controlmodelcontainerbase.hxx
@@ -86,7 +86,6 @@ protected:
AllGroups maGroups;
bool mbGroupsUpToDate;
- bool m_bEnabled;
OUString m_sImageURL;
OUString m_sTooltip;
sal_Int16 m_nTabPageId;
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 140d9c103db6..3b2fcaa891a7 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -186,9 +186,9 @@ ControlModelContainerBase::ControlModelContainerBase( const Reference< XComponen
,maContainerListeners( *this )
,maChangeListeners ( GetMutex() )
,mbGroupsUpToDate( false )
- ,m_bEnabled( true )
,m_nTabPageId(0)
{
+ ImplRegisterProperty(BASEPROPERTY_ENABLED);
}
ControlModelContainerBase::ControlModelContainerBase( const ControlModelContainerBase& rModel )
@@ -196,7 +196,6 @@ ControlModelContainerBase::ControlModelContainerBase( const ControlModelContaine
, maContainerListeners( *this )
, maChangeListeners ( GetMutex() )
, mbGroupsUpToDate( false )
- , m_bEnabled( rModel.m_bEnabled )
, m_nTabPageId( rModel.m_nTabPageId )
{
}
@@ -752,11 +751,17 @@ void SAL_CALL ControlModelContainerBase::initialize (const Sequence<Any>& rArgum
}
sal_Bool SAL_CALL ControlModelContainerBase::getEnabled()
{
- return m_bEnabled;
+ SolarMutexGuard aGuard;
+ Reference<XPropertySet> xThis(*this, UNO_QUERY);
+ bool bEnabled;
+ xThis->getPropertyValue(GetPropertyName(BASEPROPERTY_ENABLED)) >>= bEnabled;
+ return bEnabled;
}
void SAL_CALL ControlModelContainerBase::setEnabled( sal_Bool _enabled )
{
- m_bEnabled = _enabled;
+ SolarMutexGuard aGuard;
+ Reference<XPropertySet> xThis(*this, UNO_QUERY);
+ xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_ENABLED), makeAny(_enabled));
}
OUString SAL_CALL ControlModelContainerBase::getTitle()
{
commit 49b6978d9118f77198fcf2985ff49ebaea9e10d0
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri May 15 10:00:21 2020 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Mon May 18 12:43:19 2020 +0200
Forward 'removeTabPageContainerListener' as such
Calling 'addTabPageContainerListener' for the peer
instead looks like it was probably a copy paste mistake
when adding this forwarding in both,
'UnoControlTabPageContainer::addTabPageContainerListener',
and 'UnoControlTabPageContainer::removeTabPageContainerListener'
in commit 559f957fc3e4295b049866efe3582b2aaa17c414
("tabcontrol: notify tab listener", 2010-09-06).
Change-Id: I98f20b9cb3e658143b362118189adfbed85f3b43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94262
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
(cherry picked from commit 8d4dee8ee96c27454968d19518153ca892194a77)
diff --git a/toolkit/source/controls/tabpagecontainer.cxx b/toolkit/source/controls/tabpagecontainer.cxx
index b424b5757b9e..42cf153d35ec 100644
--- a/toolkit/source/controls/tabpagecontainer.cxx
+++ b/toolkit/source/controls/tabpagecontainer.cxx
@@ -291,7 +291,7 @@ void SAL_CALL UnoControlTabPageContainer::removeTabPageContainerListener( const
if( getPeer().is() && m_aTabPageListeners.getLength() == 1 )
{
uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY );
- xTabPageContainer->addTabPageContainerListener( &m_aTabPageListeners );
+ xTabPageContainer->removeTabPageContainerListener( &m_aTabPageListeners );
}
m_aTabPageListeners.removeInterface( listener );
}
More information about the Libreoffice-commits
mailing list