From 161cd3c3a2bc1d9d1b3d65de45aad1200bb4fd8e Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Thu, 5 Dec 2024 21:29:16 +0530 Subject: lok: use locale units in dialogs and sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Jenkins CollaboraOffice Reviewed-by: Caolán McNamara Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178203 Tested-by: Jenkins --- sfx2/source/sidebar/ControllerItem.cxx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'sfx2/source/sidebar/ControllerItem.cxx') 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 xClose(pState->Clone()); + MeasurementSystem eSystem + = LocaleDataWrapper(comphelper::LibreOfficeKit::getLocale()).getMeasurementSystemEnum(); + FieldUnit eUnit = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH; + static_cast(xClose.get())->SetValue(static_cast(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 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(pState.get())->SetValue(static_cast(eUnit)); - } - mrItemUpdateReceiver.NotifyItemUpdate(GetId(), eState, pState.get()); + ReceiverNotifyItemUpdate(GetId(), eState, pState.get()); } ControllerItem::ItemUpdateReceiverInterface::~ItemUpdateReceiverInterface() -- cgit