include/sfx2/sidebar/ControllerItem.hxx | 1 + sfx2/source/sidebar/ControllerItem.cxx | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-)
New commits: commit 65759ae1ba33cb46f9bc81913b82caf4fcb1f6c7 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Dec 5 21:29:16 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Dec 10 10:28:22 2024 +0100 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> 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 28248710f1a6..f08bb35d0907 100644 --- a/sfx2/source/sidebar/ControllerItem.cxx +++ b/sfx2/source/sidebar/ControllerItem.cxx @@ -45,12 +45,28 @@ ControllerItem::~ControllerItem() dispose(); } +void ControllerItem::ReceiverNotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) +{ + if (nSID == SID_ATTR_METRIC && 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 ( @@ -64,14 +80,7 @@ void ControllerItem::RequestUpdate() { std::unique_ptr<SfxPoolItem> pState; const SfxItemState eState (GetBindings().QueryState(GetId(), pState)); - if (GetId() == SID_ATTR_METRIC && 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()