tdf#132169 we always get the value in MapUnit::Map100thMM

but must set it in the core metric of the target application

since...

commit f7c751439d4616f43509301d71af92b13b576a84
Date:   Thu Nov 7 15:53:49 2019 +0100

    jsdialog: consume .uno:LineWidth double value

added parameters for online, but with parameters its no longer considered a
simple slot and for non-simple slots the auto-conversion of values to/from
twips isn't done.

there's probably a much and older deeper bug here, but lets get this
known broken line width working

Change-Id: I8683431f02d2d14936411d35ba070944b9b80e1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94200
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/svx/itemwin.hxx b/include/svx/itemwin.hxx
index 02ca954..f7da4cc 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 657d0f7..62f428a 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 930bab9..68dca2e 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 90d2b12..148bb6a 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);