diff options
Diffstat (limited to 'sfx2/source/sidebar')
-rw-r--r-- | sfx2/source/sidebar/ControllerItem.cxx | 27 |
1 files changed, 18 insertions, 9 deletions
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() |