diff options
-rw-r--r-- | include/svx/itemwin.hxx | 4 | ||||
-rw-r--r-- | include/svx/linectrl.hxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 14 | ||||
-rw-r--r-- | svx/source/tbxctrls/linewidthctrl.cxx | 17 |
4 files changed, 23 insertions, 14 deletions
diff --git a/include/svx/itemwin.hxx b/include/svx/itemwin.hxx index 02ca9548bd45..f7da4cc9becf 100644 --- a/include/svx/itemwin.hxx +++ b/include/svx/itemwin.hxx @@ -52,7 +52,7 @@ class SvxMetricField final : public InterimItemWindow private: std::unique_ptr<weld::MetricSpinButton> m_xWidget; int nCurValue; - MapUnit ePoolUnit; + MapUnit eDestPoolUnit; FieldUnit eDlgUnit; css::uno::Reference< css::frame::XFrame > mxFrame; @@ -73,7 +73,7 @@ public: virtual ~SvxMetricField() override; void Update( const XLineWidthItem* pItem ); - void SetCoreUnit( MapUnit eUnit ); + void SetDestCoreUnit( MapUnit eUnit ); void RefreshDlgUnit(); void set_sensitive(bool bSensitive); diff --git a/include/svx/linectrl.hxx b/include/svx/linectrl.hxx index 657d0f7d9262..62f428aa5136 100644 --- a/include/svx/linectrl.hxx +++ b/include/svx/linectrl.hxx @@ -69,6 +69,8 @@ private: class SVX_DLLPUBLIC SvxLineWidthToolBoxControl final : public SfxToolBoxControl { + static MapUnit GetCoreMetric(); + public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index 930bab99641b..68dca2e43ad9 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -48,7 +48,7 @@ SvxMetricField::SvxMetricField( : InterimItemWindow(pParent, "svx/ui/metricfieldbox.ui", "MetricFieldBox") , m_xWidget(m_xBuilder->weld_metric_spin_button("metricfield", FieldUnit::MM)) , nCurValue(0) - , ePoolUnit(MapUnit::MapCM) + , eDestPoolUnit(MapUnit::Map100thMM) , eDlgUnit(SfxModule::GetModuleFieldUnit(rFrame)) , mxFrame(rFrame) { @@ -85,8 +85,10 @@ void SvxMetricField::Update( const XLineWidthItem* pItem ) { if ( pItem ) { - if (pItem->GetValue() != GetCoreValue(*m_xWidget, ePoolUnit)) - SetMetricValue(*m_xWidget, pItem->GetValue(), ePoolUnit); + // tdf#132169 we always get the value in MapUnit::Map100thMM but have + // to set it in the core metric of the target application + if (pItem->GetValue() != GetCoreValue(*m_xWidget, MapUnit::Map100thMM)) + SetMetricValue(*m_xWidget, pItem->GetValue(), MapUnit::Map100thMM); } else m_xWidget->set_text(""); @@ -94,7 +96,7 @@ void SvxMetricField::Update( const XLineWidthItem* pItem ) IMPL_LINK_NOARG(SvxMetricField, ModifyHdl, weld::MetricSpinButton&, void) { - auto nTmp = GetCoreValue(*m_xWidget, ePoolUnit); + auto nTmp = GetCoreValue(*m_xWidget, eDestPoolUnit); XLineWidthItem aLineWidthItem( nTmp ); Any a; @@ -117,9 +119,9 @@ void SvxMetricField::ReleaseFocus_Impl() } } -void SvxMetricField::SetCoreUnit( MapUnit eUnit ) +void SvxMetricField::SetDestCoreUnit( MapUnit eUnit ) { - ePoolUnit = eUnit; + eDestPoolUnit = eUnit; } void SvxMetricField::RefreshDlgUnit() diff --git a/svx/source/tbxctrls/linewidthctrl.cxx b/svx/source/tbxctrls/linewidthctrl.cxx index 90d2b1299917..148bb6a36c88 100644 --- a/svx/source/tbxctrls/linewidthctrl.cxx +++ b/svx/source/tbxctrls/linewidthctrl.cxx @@ -18,7 +18,8 @@ */ #include <vcl/toolbox.hxx> - +#include <sfx2/app.hxx> +#include <sfx2/objsh.hxx> #include <svx/svxids.hrc> #include <svx/xlnwtit.hxx> #include <svx/linectrl.hxx> @@ -45,7 +46,6 @@ SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl() { } - void SvxLineWidthToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { @@ -71,10 +71,7 @@ void SvxLineWidthToolBoxControl::StateChanged( { DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" ); - // Core-Unit handed over to MetricField - // Should not happen in CreateItemWin ()! - // CD!!! GetCoreMetric(); - pFld->SetCoreUnit( MapUnit::Map100thMM ); + pFld->SetDestCoreUnit(GetCoreMetric()); pFld->Update( static_cast<const XLineWidthItem*>(pState) ); } @@ -84,6 +81,14 @@ void SvxLineWidthToolBoxControl::StateChanged( } } +MapUnit SvxLineWidthToolBoxControl::GetCoreMetric() +{ + SfxObjectShell* pSh = SfxObjectShell::Current(); + SfxItemPool& rPool = pSh ? pSh->GetPool() : SfxGetpApp()->GetPool(); + sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_LINE_WIDTH); + return rPool.GetMetric(nWhich); +} + VclPtr<InterimItemWindow> SvxLineWidthToolBoxControl::CreateItemWindow(vcl::Window *pParent) { VclPtr<SvxMetricField> pWindow = VclPtr<SvxMetricField>::Create(pParent, m_xFrame); |