include/sfx2/sidebar/ControllerItem.hxx | 1 + sfx2/source/sidebar/ControllerItem.cxx | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-)
New commits: commit ac72690e731d6526ecd0a4b9fe29a9a0c7596b73 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Dec 5 21:29:16 2024 +0530 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Thu Feb 13 03:58:11 2025 +1030 lok: use locale units in dialogs and sidebar this patch updates fix for the dialog which were not fixed by e2708fecb34fb4084f8db5f2c5ffb4d8923002ca Change-Id: I7a9531d5af5b388cd6d763ea8c8d62ff4e7f12ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177896 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178203 Tested-by: Jenkins (cherry picked from commit 161cd3c3a2bc1d9d1b3d65de45aad1200bb4fd8e) diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx index a8f82195a496..5d7e7918a71b 100644 --- a/include/sfx2/sidebar/ControllerItem.hxx +++ b/include/sfx2/sidebar/ControllerItem.hxx @@ -70,6 +70,7 @@ private: virtual void StateChangedAtToolBoxControl (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override; virtual void GetControlState (sal_uInt16 nSId, boost::property_tree::ptree& rState) override; + void ReceiverNotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState); ItemUpdateReceiverInterface& mrItemUpdateReceiver; }; diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx index 9f8b856be86c..313cf1c49566 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -44,12 +44,28 @@ ControllerItem::~ControllerItem() dispose(); } +void ControllerItem::ReceiverNotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) +{ + if (nSID == SID_ATTR_METRIC && pState && comphelper::LibreOfficeKit::isActive()) + { + std::unique_ptr<SfxPoolItem> xClose(pState->Clone()); + MeasurementSystem eSystem + = LocaleDataWrapper(comphelper::LibreOfficeKit::getLocale()).getMeasurementSystemEnum(); + FieldUnit eUnit = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH; + static_cast<SfxUInt16Item*>(xClose.get())->SetValue(static_cast<sal_uInt16>(eUnit)); + mrItemUpdateReceiver.NotifyItemUpdate(nSID, eState, xClose.get()); + return; + } + mrItemUpdateReceiver.NotifyItemUpdate(nSID, eState, pState); +} + void ControllerItem::StateChangedAtToolBoxControl ( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) { - mrItemUpdateReceiver.NotifyItemUpdate(nSID, eState, pState); + ReceiverNotifyItemUpdate(nSID, eState, pState); } void ControllerItem::GetControlState ( @@ -63,14 +79,7 @@ void ControllerItem::RequestUpdate() { std::unique_ptr<SfxPoolItem> pState; const SfxItemState eState (GetBindings().QueryState(GetId(), pState)); - if (GetId() == SID_ATTR_METRIC && pState && comphelper::LibreOfficeKit::isActive()) - { - MeasurementSystem eSystem - = LocaleDataWrapper(comphelper::LibreOfficeKit::getLocale()).getMeasurementSystemEnum(); - FieldUnit eUnit = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH; - static_cast<SfxUInt16Item*>(pState.get())->SetValue(static_cast<sal_uInt16>(eUnit)); - } - mrItemUpdateReceiver.NotifyItemUpdate(GetId(), eState, pState.get()); + ReceiverNotifyItemUpdate(GetId(), eState, pState.get()); } ControllerItem::ItemUpdateReceiverInterface::~ItemUpdateReceiverInterface()