weld SvxPositionSizeTabPage

Change-Id: Ic642d6ab2470a14b3a1d83284407fc690d5eba88
Reviewed-on: https://gerrit.libreoffice.org/54945
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx
index 654facf..7e7aa264 100644
--- a/cui/source/inc/transfrm.hxx
+++ b/cui/source/inc/transfrm.hxx
@@ -74,32 +74,6 @@ class SvxPositionSizeTabPage : public SvxTabPage
    static const sal_uInt16 pPosSizeRanges[];

private:
    // position
    VclPtr<VclFrame>            m_pFlPosition;
    VclPtr<MetricField>         m_pMtrPosX;
    VclPtr<MetricField>         m_pMtrPosY;
    VclPtr<SvxRectCtl>          m_pCtlPos;

    // size
    VclPtr<VclFrame>            m_pFlSize;
    VclPtr<FixedText>           m_pFtWidth;
    VclPtr<MetricField>         m_pMtrWidth;
    VclPtr<FixedText>           m_pFtHeight;
    VclPtr<MetricField>         m_pMtrHeight;
    VclPtr<CheckBox>            m_pCbxScale;
    VclPtr<SvxRectCtl>          m_pCtlSize;

    // protect
    VclPtr<VclFrame>            m_pFlProtect;
    VclPtr<TriStateBox>         m_pTsbPosProtect;
    VclPtr<TriStateBox>         m_pTsbSizeProtect;

    // adjust
    VclPtr<VclFrame>            m_pFlAdjust;
    VclPtr<TriStateBox>         m_pTsbAutoGrowWidth;
    VclPtr<TriStateBox>         m_pTsbAutoGrowHeight;

private:
    const SfxItemSet&   mrOutAttrs;

    const SdrView*      mpView;
@@ -123,22 +97,48 @@ private:
    double              mfOldHeight;
    RectPoint          meRP;

    RectCtl          m_aCtlPos;
    RectCtl          m_aCtlSize;

    DECL_LINK( ChangePosProtectHdl, Button*, void );
    DECL_LINK( ChangeSizeProtectHdl, Button*, void );
    // position
    std::unique_ptr<weld::Widget> m_xFlPosition;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrPosX;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrPosY;
    std::unique_ptr<weld::CustomWeld> m_xCtlPos;

    // size
    std::unique_ptr<weld::Widget> m_xFlSize;
    std::unique_ptr<weld::Label> m_xFtWidth;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrWidth;
    std::unique_ptr<weld::Label> m_xFtHeight;
    std::unique_ptr<weld::MetricSpinButton> m_xMtrHeight;
    std::unique_ptr<weld::CheckButton> m_xCbxScale;
    std::unique_ptr<weld::CustomWeld> m_xCtlSize;

    // protect
    std::unique_ptr<weld::Widget> m_xFlProtect;
    std::unique_ptr<weld::CheckButton> m_xTsbPosProtect;
    std::unique_ptr<weld::CheckButton> m_xTsbSizeProtect;

    // adjust
    std::unique_ptr<weld::Widget> m_xFlAdjust;
    std::unique_ptr<weld::CheckButton> m_xTsbAutoGrowWidth;
    std::unique_ptr<weld::CheckButton> m_xTsbAutoGrowHeight;

    DECL_LINK(ChangePosProtectHdl, weld::ToggleButton&, void);
    DECL_LINK(ChangeSizeProtectHdl, weld::ToggleButton&, void);

    void SetMinMaxPosition();
    void GetTopLeftPosition(double& rfX, double& rfY, const basegfx::B2DRange& rRange);

    DECL_LINK( ChangeWidthHdl, Edit&, void );
    DECL_LINK( ChangeHeightHdl, Edit&, void );
    DECL_LINK( ClickSizeProtectHdl, Button*, void );
    DECL_LINK( ClickAutoHdl, Button*, void );
    DECL_LINK( ChangeWidthHdl, weld::MetricSpinButton&, void );
    DECL_LINK( ChangeHeightHdl, weld::MetricSpinButton&, void );
    DECL_LINK( ClickSizeProtectHdl, weld::ToggleButton&, void );
    DECL_LINK( ClickAutoHdl, weld::ToggleButton&, void );

public:
    SvxPositionSizeTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs  );
    SvxPositionSizeTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs);
    virtual ~SvxPositionSizeTabPage() override;
    virtual void dispose() override;

    static VclPtr<SfxTabPage> Create( TabPageParent, const SfxItemSet* );
    static const sal_uInt16* GetRanges() {  return pPosSizeRanges; }
@@ -149,8 +149,8 @@ public:
    virtual void ActivatePage( const SfxItemSet& rSet ) override;
    virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;

    virtual void PointChanged( vcl::Window* pWindow, RectPoint eRP ) override;
    virtual void PointChanged( weld::DrawingArea* pWindow, RectPoint eRP ) override;
    virtual void PointChanged( vcl::Window* pWindow, RectPoint eRP ) override;

    void         Construct();
    void         SetView( const SdrView* pSdrView ) { mpView = pSdrView; }
diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx
index 2095550..b37d366 100644
--- a/cui/source/tabpages/transfrm.cxx
+++ b/cui/source/tabpages/transfrm.cxx
@@ -773,8 +773,8 @@ void SvxSlantTabPage::PointChanged( weld::DrawingArea*, RectPoint )
|*      Dialog for changing position and size of graphic objects
|*
\************************************************************************/
SvxPositionSizeTabPage::SvxPositionSizeTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs)
    : SvxTabPage(pParent,"PositionAndSize","cui/ui/possizetabpage.ui", rInAttrs)
SvxPositionSizeTabPage::SvxPositionSizeTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs)
    : SvxTabPage(pParent, "cui/ui/possizetabpage.ui", "PositionAndSize", rInAttrs)
    , mrOutAttrs(rInAttrs)
    , mpView(nullptr)
    , meDlgUnit(FUNIT_NONE)
@@ -785,28 +785,26 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(vcl::Window* pParent, const SfxIt
    , mbAdjustDisabled(true)
    , mfOldWidth(0.0)
    , mfOldHeight(0.0)
    , m_aCtlPos(this)
    , m_aCtlSize(this)
    , m_xFlPosition(m_xBuilder->weld_widget("FL_POSITION"))
    , m_xMtrPosX(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_X", FUNIT_CM))
    , m_xMtrPosY(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_Y", FUNIT_CM))
    , m_xCtlPos(new weld::CustomWeld(*m_xBuilder, "CTL_POSRECT", m_aCtlPos))
    , m_xFlSize(m_xBuilder->weld_widget("FL_SIZE"))
    , m_xFtWidth(m_xBuilder->weld_label("FT_WIDTH"))
    , m_xMtrWidth(m_xBuilder->weld_metric_spin_button("MTR_FLD_WIDTH", FUNIT_CM))
    , m_xFtHeight(m_xBuilder->weld_label("FT_HEIGHT"))
    , m_xMtrHeight(m_xBuilder->weld_metric_spin_button("MTR_FLD_HEIGHT", FUNIT_CM))
    , m_xCbxScale(m_xBuilder->weld_check_button("CBX_SCALE"))
    , m_xCtlSize(new weld::CustomWeld(*m_xBuilder, "CTL_SIZERECT", m_aCtlSize))
    , m_xFlProtect(m_xBuilder->weld_widget("FL_PROTECT"))
    , m_xTsbPosProtect(m_xBuilder->weld_check_button("TSB_POSPROTECT"))
    , m_xTsbSizeProtect(m_xBuilder->weld_check_button("TSB_SIZEPROTECT"))
    , m_xFlAdjust(m_xBuilder->weld_widget("FL_ADJUST"))
    , m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH"))
    , m_xTsbAutoGrowHeight(m_xBuilder->weld_check_button("TSB_AUTOGROW_HEIGHT"))
{
    get(m_pFlPosition, "FL_POSITION");
    get(m_pMtrPosX, "MTR_FLD_POS_X");
    get(m_pMtrPosY, "MTR_FLD_POS_Y");
    get(m_pCtlPos, "CTL_POSRECT" );

    get(m_pFlSize, "FL_SIZE");
    get(m_pFtWidth, "FT_WIDTH");
    get(m_pMtrWidth, "MTR_FLD_WIDTH");
    get(m_pFtHeight, "FT_HEIGHT");
    get(m_pMtrHeight, "MTR_FLD_HEIGHT");
    get(m_pCbxScale, "CBX_SCALE");
    get(m_pCtlSize, "CTL_SIZERECT" );

    get(m_pFlProtect, "FL_PROTECT");
    get(m_pTsbPosProtect, "TSB_POSPROTECT");
    get(m_pTsbSizeProtect, "TSB_SIZEPROTECT");

    get(m_pFlAdjust, "FL_ADJUST");
    get(m_pTsbAutoGrowWidth, "TSB_AUTOGROW_WIDTH");
    get(m_pTsbAutoGrowHeight, "TSB_AUTOGROW_HEIGHT");

    // this page needs ExchangeSupport
    SetExchangeSupport();

@@ -815,49 +813,25 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(vcl::Window* pParent, const SfxIt
    DBG_ASSERT( pPool, "no pool (!)" );
    mePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X );

    m_pCtlPos->SetActualRP(RectPoint::LT);
    m_pCtlSize->SetActualRP(RectPoint::LT);
    m_aCtlPos.SetActualRP(RectPoint::LT);
    m_aCtlSize.SetActualRP(RectPoint::LT);
    meRP = RectPoint::LT; // see above

    m_pMtrWidth->SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) );
    m_pMtrHeight->SetModifyHdl( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) );
    m_pCbxScale->SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) );
    m_xMtrWidth->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) );
    m_xMtrHeight->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) );
    m_xCbxScale->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) );

    m_pTsbAutoGrowWidth->Disable();
    m_pTsbAutoGrowHeight->Disable();
    m_pFlAdjust->Disable();
    m_xTsbAutoGrowWidth->set_sensitive(false);
    m_xTsbAutoGrowHeight->set_sensitive(false);
    m_xFlAdjust->set_sensitive(false);

    // #i2379# disable controls when protected
    m_pTsbPosProtect->SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangePosProtectHdl ) );
    m_pTsbSizeProtect->SetClickHdl( LINK( this, SvxPositionSizeTabPage, ChangeSizeProtectHdl ) );

    m_xTsbPosProtect->connect_toggled( LINK( this, SvxPositionSizeTabPage, ChangePosProtectHdl ) );
    m_xTsbSizeProtect->connect_toggled( LINK( this, SvxPositionSizeTabPage, ChangeSizeProtectHdl ) );
}

SvxPositionSizeTabPage::~SvxPositionSizeTabPage()
{
    disposeOnce();
}

void SvxPositionSizeTabPage::dispose()
{
    m_pFlPosition.clear();
    m_pMtrPosX.clear();
    m_pMtrPosY.clear();
    m_pCtlPos.clear();
    m_pFlSize.clear();
    m_pFtWidth.clear();
    m_pMtrWidth.clear();
    m_pFtHeight.clear();
    m_pMtrHeight.clear();
    m_pCbxScale.clear();
    m_pCtlSize.clear();
    m_pFlProtect.clear();
    m_pTsbPosProtect.clear();
    m_pTsbSizeProtect.clear();
    m_pFlAdjust.clear();
    m_pTsbAutoGrowWidth.clear();
    m_pTsbAutoGrowHeight.clear();
    SvxTabPage::dispose();
}

void SvxPositionSizeTabPage::Construct()
@@ -865,17 +839,17 @@ void SvxPositionSizeTabPage::Construct()
    // get range and work area
    DBG_ASSERT( mpView, "no valid view (!)" );
    meDlgUnit = GetModuleFieldUnit( GetItemSet() );
    SetFieldUnit( *m_pMtrPosX, meDlgUnit, true );
    SetFieldUnit( *m_pMtrPosY, meDlgUnit, true );
    SetFieldUnit( *m_pMtrWidth, meDlgUnit, true );
    SetFieldUnit( *m_pMtrHeight, meDlgUnit, true );
    SetFieldUnit( *m_xMtrPosX, meDlgUnit, true );
    SetFieldUnit( *m_xMtrPosY, meDlgUnit, true );
    SetFieldUnit( *m_xMtrWidth, meDlgUnit, true );
    SetFieldUnit( *m_xMtrHeight, meDlgUnit, true );

    if(FUNIT_MILE == meDlgUnit || FUNIT_KM == meDlgUnit)
    {
        m_pMtrPosX->SetDecimalDigits( 3 );
        m_pMtrPosY->SetDecimalDigits( 3 );
        m_pMtrWidth->SetDecimalDigits( 3 );
        m_pMtrHeight->SetDecimalDigits( 3 );
        m_xMtrPosX->set_digits( 3 );
        m_xMtrPosY->set_digits( 3 );
        m_xMtrWidth->set_digits( 3 );
        m_xMtrHeight->set_digits( 3 );
    }

    { // #i75273#
@@ -907,8 +881,8 @@ void SvxPositionSizeTabPage::Construct()
                if(maAnchor != basegfx::B2DPoint(pObj->GetAnchorPos().X(), pObj->GetAnchorPos().Y()))
                {
                    // different anchor positions
                    m_pMtrPosX->SetText( "" );
                    m_pMtrPosY->SetText( "" );
                    m_xMtrPosX->set_text("");
                    m_xMtrPosY->set_text("");
                    mbPageDisabled = true;
                    return;
                }
@@ -932,14 +906,10 @@ void SvxPositionSizeTabPage::Construct()
        {
            mbAdjustDisabled = false;

            m_pFlAdjust->Enable();
            m_xFlAdjust->set_sensitive(true);

            m_pTsbAutoGrowWidth->SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
            m_pTsbAutoGrowHeight->SetClickHdl( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );

            // is used as flag to evaluate if its selectable
            m_pTsbAutoGrowWidth->EnableTriState( false );
            m_pTsbAutoGrowHeight->EnableTriState( false );
            m_xTsbAutoGrowWidth->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
            m_xTsbAutoGrowHeight->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) );
        }
    }

@@ -949,7 +919,7 @@ void SvxPositionSizeTabPage::Construct()
    TransfrmHelper::ScaleRect( maRange, aUIScale );

    // take UI units into account
    const sal_uInt16 nDigits(m_pMtrPosX->GetDecimalDigits());
    const sal_uInt16 nDigits(m_xMtrPosX->get_digits());
    TransfrmHelper::ConvertRect( maWorkRange, nDigits, mePoolUnit, meDlgUnit );
    TransfrmHelper::ConvertRect( maRange, nDigits, mePoolUnit, meDlgUnit );

@@ -961,23 +931,23 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs )
{
    bool bModified(false);

    if ( m_pMtrWidth->HasFocus() )
    if ( m_xMtrWidth->has_focus() )
    {
        ChangeWidthHdl( *m_pMtrWidth );
        ChangeWidthHdl( *m_xMtrWidth );
    }

    if ( m_pMtrHeight->HasFocus() )
    if ( m_xMtrHeight->has_focus() )
    {
        ChangeHeightHdl( *m_pMtrHeight );
        ChangeHeightHdl( *m_xMtrHeight );
    }

    if( !mbPageDisabled )
    {
        if ( m_pMtrPosX->IsValueModified() || m_pMtrPosY->IsValueModified() )
        if (m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved())
        {
            const double fUIScale(double(mpView->GetModel()->GetUIScale()));
            double fX((GetCoreValue( *m_pMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale);
            double fY((GetCoreValue( *m_pMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale);
            double fX((GetCoreValue( *m_xMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale);
            double fY((GetCoreValue( *m_xMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale);

            { // #i75273#
                ::tools::Rectangle aTempRect(mpView->GetAllMarkedRect());
@@ -994,9 +964,9 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs )
            bModified = true;
        }

        if ( m_pTsbPosProtect->IsValueChangedFromSaved() )
        if (m_xTsbPosProtect->get_state_changed_from_saved())
        {
            if( m_pTsbPosProtect->GetState() == TRISTATE_INDET )
            if( m_xTsbPosProtect->get_inconsistent() )
            {
                rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS );
            }
@@ -1004,30 +974,28 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs )
            {
                rOutAttrs->Put(
                    SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
                    m_pTsbPosProtect->GetState() == TRISTATE_TRUE ) );
                    m_xTsbPosProtect->get_active() ) );
            }

            bModified = true;
        }
    }

    if ( m_pMtrWidth->IsValueModified() || m_pMtrHeight->IsValueModified() )
    if (m_xMtrWidth->get_value_changed_from_saved() || m_xMtrHeight->get_value_changed_from_saved())
    {
        Fraction aUIScale = mpView->GetModel()->GetUIScale();

        // get Width
        double nWidth = static_cast<double>(m_pMtrWidth->GetValue( meDlgUnit ));
        nWidth = MetricField::ConvertDoubleValue( nWidth, m_pMtrWidth->GetBaseValue(), m_pMtrWidth->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
        double nWidth = static_cast<double>(m_xMtrWidth->get_value(FUNIT_100TH_MM));
        long lWidth = long(nWidth * static_cast<double>(aUIScale));
        lWidth = OutputDevice::LogicToLogic( lWidth, MapUnit::Map100thMM, mePoolUnit );
        lWidth = static_cast<long>(m_pMtrWidth->Denormalize( lWidth ));
        lWidth = static_cast<long>(m_xMtrWidth->denormalize( lWidth ));

        // get Height
        double nHeight = static_cast<double>(m_pMtrHeight->GetValue( meDlgUnit ));
        nHeight = MetricField::ConvertDoubleValue( nHeight, m_pMtrHeight->GetBaseValue(), m_pMtrHeight->GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM );
        double nHeight = static_cast<double>(m_xMtrHeight->get_value(FUNIT_100TH_MM));
        long lHeight = long(nHeight * static_cast<double>(aUIScale));
        lHeight = OutputDevice::LogicToLogic( lHeight, MapUnit::Map100thMM, mePoolUnit );
        lHeight = static_cast<long>(m_pMtrHeight->Denormalize( lHeight ));
        lHeight = static_cast<long>(m_xMtrHeight->denormalize( lHeight ));

        // put Width & Height to itemset
        rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), static_cast<sal_uInt32>(lWidth) ) );
@@ -1036,50 +1004,42 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs )
        bModified = true;
    }

    if ( m_pTsbSizeProtect->IsValueChangedFromSaved() )
    if (m_xTsbSizeProtect->get_state_changed_from_saved())
    {
        if ( m_pTsbSizeProtect->GetState() == TRISTATE_INDET )
        if ( m_xTsbSizeProtect->get_inconsistent() )
            rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE );
        else
            rOutAttrs->Put(
                SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
                m_pTsbSizeProtect->GetState() == TRISTATE_TRUE ) );
                m_xTsbSizeProtect->get_active() ) );
        bModified = true;
    }

    if ( m_pTsbAutoGrowWidth->IsValueChangedFromSaved() )
    if (m_xTsbAutoGrowWidth->get_state_changed_from_saved())
    {
        if ( !m_pTsbAutoGrowWidth->IsTriStateEnabled() )
        {
            if( m_pTsbAutoGrowWidth->GetState() == TRISTATE_INDET )
                rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH );
            else
                rOutAttrs->Put(
                    SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ),
                    m_pTsbAutoGrowWidth->GetState() == TRISTATE_TRUE ) );
        }
        if( m_xTsbAutoGrowWidth->get_inconsistent() )
            rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH );
        else
            rOutAttrs->Put(
                SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ),
                m_xTsbAutoGrowWidth->get_active() ) );
        bModified = true;
    }

    if ( m_pTsbAutoGrowHeight->IsValueChangedFromSaved() )
    if (m_xTsbAutoGrowHeight->get_state_changed_from_saved())
    {
        if ( !m_pTsbAutoGrowHeight->IsTriStateEnabled() )
        {
            if( m_pTsbAutoGrowHeight->GetState() == TRISTATE_INDET )
                rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOHEIGHT );
            else
                rOutAttrs->Put(
                    SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ),
                    m_pTsbAutoGrowHeight->GetState() == TRISTATE_TRUE ) );
        }
        if (m_xTsbAutoGrowHeight->get_inconsistent())
            rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOHEIGHT );
        else
            rOutAttrs->Put(
                SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ),
                m_xTsbAutoGrowHeight->get_active() ) );
        bModified = true;
    }


    return bModified;
}


void SvxPositionSizeTabPage::Reset( const SfxItemSet*  )
{
    const SfxPoolItem* pItem;
@@ -1091,107 +1051,90 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet*  )
        if ( pItem )
        {
            const double fTmp((static_cast<const SfxInt32Item*>(pItem)->GetValue() - maAnchor.getX()) / fUIScale);
            SetMetricValue(*m_pMtrPosX, basegfx::fround(fTmp), mePoolUnit);
            SetMetricValue(*m_xMtrPosX, basegfx::fround(fTmp), mePoolUnit);
        }

        pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_POS_Y );
        if ( pItem )
        {
            const double fTmp((static_cast<const SfxInt32Item*>(pItem)->GetValue() - maAnchor.getY()) / fUIScale);
            SetMetricValue(*m_pMtrPosY, basegfx::fround(fTmp), mePoolUnit);
            SetMetricValue(*m_xMtrPosY, basegfx::fround(fTmp), mePoolUnit);
        }

        pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_POS );
        if ( pItem )
        {
            bool bProtected = static_cast<const SfxBoolItem*>( pItem )->GetValue();
            m_pTsbPosProtect->SetState( bProtected ? TRISTATE_TRUE : TRISTATE_FALSE );
            m_pTsbPosProtect->EnableTriState( false );
            m_xTsbPosProtect->set_active(bProtected);
        }
        else
        {
            m_pTsbPosProtect->SetState( TRISTATE_INDET );
            m_xTsbPosProtect->set_inconsistent(true);
        }

        m_pTsbPosProtect->SaveValue();
        m_pCtlPos->Reset();
        m_xTsbPosProtect->save_state();
        m_aCtlPos.Reset();

        // #i2379# Disable controls for protected objects
        ChangePosProtectHdl( nullptr );
        ChangePosProtectHdl(*m_xTsbPosProtect);
    }

    { // #i75273# set width
        pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_WIDTH );
        mfOldWidth = std::max( pItem ? static_cast<double>(static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0.0, 1.0 );
        double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldWidth), mePoolUnit, MapUnit::Map100thMM)) / fUIScale);

        if(m_pMtrWidth->GetDecimalDigits())
            fTmpWidth *= pow(10.0, m_pMtrWidth->GetDecimalDigits());

        fTmpWidth = MetricField::ConvertDoubleValue(fTmpWidth, m_pMtrWidth->GetBaseValue(), m_pMtrWidth->GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
        m_pMtrWidth->SetValue(static_cast<sal_Int64>(fTmpWidth), meDlgUnit);
        m_xMtrWidth->set_value(static_cast<int>(fTmpWidth), FUNIT_100TH_MM);
    }

    { // #i75273# set height
        pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_HEIGHT );
        mfOldHeight = std::max( pItem ? static_cast<double>(static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0.0, 1.0 );
        double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldHeight), mePoolUnit, MapUnit::Map100thMM)) / fUIScale);

        if(m_pMtrHeight->GetDecimalDigits())
            fTmpHeight *= pow(10.0, m_pMtrHeight->GetDecimalDigits());

        fTmpHeight = MetricField::ConvertDoubleValue(fTmpHeight, m_pMtrHeight->GetBaseValue(), m_pMtrHeight->GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit);
        m_pMtrHeight->SetValue(static_cast<sal_Int64>(fTmpHeight), meDlgUnit);
        m_xMtrHeight->set_value(static_cast<int>(fTmpHeight), FUNIT_100TH_MM);
    }

    pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_SIZE );
    if ( pItem )
    {
        m_pTsbSizeProtect->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue()
                              ? TRISTATE_TRUE : TRISTATE_FALSE );
        m_pTsbSizeProtect->EnableTriState( false );
        m_xTsbSizeProtect->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue());
    }
    else
        m_pTsbSizeProtect->SetState( TRISTATE_INDET );
        m_xTsbSizeProtect->set_inconsistent(true);

    pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOWIDTH );
    if ( pItem )
    {
        m_pTsbAutoGrowWidth->SetState( static_cast<const SfxBoolItem*>( pItem )->GetValue()
                           ? TRISTATE_TRUE : TRISTATE_FALSE );
        m_xTsbAutoGrowWidth->set_active(static_cast<const SfxBoolItem*>( pItem )->GetValue());
    }
    else
        m_pTsbAutoGrowWidth->SetState( TRISTATE_INDET );
        m_xTsbAutoGrowWidth->set_inconsistent(true);

    pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_AUTOHEIGHT );
    if ( pItem )
    {
        m_pTsbAutoGrowHeight->SetState( static_cast<const SfxBoolItem*>( pItem )->GetValue()
                           ? TRISTATE_TRUE : TRISTATE_FALSE );
        m_xTsbAutoGrowHeight->set_active(static_cast<const SfxBoolItem*>( pItem )->GetValue());
    }
    else
        m_pTsbAutoGrowHeight->SetState( TRISTATE_INDET );
        m_xTsbAutoGrowHeight->set_inconsistent(true);

    // Is matching set?
    OUString aStr = GetUserData();
    m_pCbxScale->Check( aStr.toInt32() != 0 );
    m_xCbxScale->set_active(aStr.toInt32() != 0);

    m_pTsbSizeProtect->SaveValue();
    m_pTsbAutoGrowWidth->SaveValue();
    m_pTsbAutoGrowHeight->SaveValue();
    ClickSizeProtectHdl( nullptr );
    m_xTsbSizeProtect->save_state();
    m_xTsbAutoGrowWidth->save_state();
    m_xTsbAutoGrowHeight->save_state();
    ClickSizeProtectHdl(*m_xTsbAutoGrowHeight);

    // #i2379# Disable controls for protected objects
    ChangeSizeProtectHdl( nullptr );
    ChangeSizeProtectHdl(*m_xTsbSizeProtect);
}


VclPtr<SfxTabPage> SvxPositionSizeTabPage::Create( TabPageParent pWindow, const SfxItemSet* rOutAttrs )
VclPtr<SfxTabPage> SvxPositionSizeTabPage::Create(TabPageParent pParent, const SfxItemSet* rOutAttrs)
{
    return VclPtr<SvxPositionSizeTabPage>::Create( pWindow.pParent, *rOutAttrs );
    return VclPtr<SvxPositionSizeTabPage>::Create(pParent, *rOutAttrs);
}


void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet& rSet )
{
    SfxRectangleItem const * pRectItem = nullptr;
@@ -1212,8 +1155,8 @@ DeactivateRC SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
{
    if( _pSet )
    {
        double fX(static_cast<double>(m_pMtrPosX->GetValue()));
        double fY(static_cast<double>(m_pMtrPosY->GetValue()));
        double fX(static_cast<double>(m_xMtrPosX->get_value(FUNIT_NONE)));
        double fY(static_cast<double>(m_xMtrPosY->get_value(FUNIT_NONE)));

        GetTopLeftPosition(fX, fY, maRange);
        const ::tools::Rectangle aOutRectangle(
@@ -1221,9 +1164,9 @@ DeactivateRC SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
            basegfx::fround(fX + maRange.getWidth()), basegfx::fround(fY + maRange.getHeight()));
        _pSet->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN, aOutRectangle));
        _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ),
            m_pTsbPosProtect->GetState() == TRISTATE_TRUE ));
            m_xTsbPosProtect->get_state() == TRISTATE_TRUE ));
        _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ),
            m_pTsbSizeProtect->GetState() == TRISTATE_TRUE ));
            m_xTsbSizeProtect->get_state() == TRISTATE_TRUE ));
        FillItemSet(_pSet);
    }

@@ -1231,50 +1174,48 @@ DeactivateRC SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet )
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangePosProtectHdl, Button*, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangePosProtectHdl, weld::ToggleButton&, void)
{
    // #106572# Remember user's last choice
    m_pTsbSizeProtect->SetState( m_pTsbPosProtect->GetState() == TRISTATE_TRUE ?  TRISTATE_TRUE : mnProtectSizeState );
    m_xTsbSizeProtect->set_state(m_xTsbPosProtect->get_state() == TRISTATE_TRUE ?  TRISTATE_TRUE : mnProtectSizeState);
    UpdateControlStates();
}


void SvxPositionSizeTabPage::UpdateControlStates()
{
    const bool bPosProtect =  m_pTsbPosProtect->GetState() == TRISTATE_TRUE;
    const bool bSizeProtect = m_pTsbSizeProtect->GetState() == TRISTATE_TRUE;
    const bool bHeightChecked = !m_pTsbAutoGrowHeight->IsTriStateEnabled() && (m_pTsbAutoGrowHeight->GetState() == TRISTATE_TRUE);
    const bool bWidthChecked = !m_pTsbAutoGrowWidth->IsTriStateEnabled() && (m_pTsbAutoGrowWidth->GetState() == TRISTATE_TRUE);
    const bool bPosProtect =  m_xTsbPosProtect->get_state() == TRISTATE_TRUE;
    const bool bSizeProtect = m_xTsbSizeProtect->get_state() == TRISTATE_TRUE;
    const bool bHeightChecked = !m_xTsbAutoGrowHeight->get_inconsistent() && (m_xTsbAutoGrowHeight->get_active());
    const bool bWidthChecked = !m_xTsbAutoGrowWidth->get_inconsistent() && (m_xTsbAutoGrowWidth->get_active());

    m_pFlPosition->Enable( !bPosProtect && !mbPageDisabled );
    m_xFlPosition->set_sensitive(!bPosProtect && !mbPageDisabled);

    m_pTsbPosProtect->Enable( !mbProtectDisabled && !mbPageDisabled );
    m_xTsbPosProtect->set_sensitive( !mbProtectDisabled && !mbPageDisabled );

    m_pFlSize->Enable( !mbSizeDisabled && !bSizeProtect );
    m_xFlSize->set_sensitive( !mbSizeDisabled && !bSizeProtect );

    m_pFtWidth->Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
    m_pMtrWidth->Enable( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
    m_xFtWidth->set_sensitive( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );
    m_xMtrWidth->set_sensitive( !mbSizeDisabled && !bSizeProtect && !bWidthChecked );

    m_pFtHeight->Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
    m_pMtrHeight->Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
    m_xFtHeight->set_sensitive( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );
    m_xMtrHeight->set_sensitive( !mbSizeDisabled && !bSizeProtect && !bHeightChecked );

    m_pCbxScale->Enable( !mbSizeDisabled && !bSizeProtect && !bHeightChecked && !bWidthChecked );
    m_pCtlSize->Enable( !mbSizeDisabled && !bSizeProtect && (!bHeightChecked || !bWidthChecked) );
    m_xCbxScale->set_sensitive( !mbSizeDisabled && !bSizeProtect && !bHeightChecked && !bWidthChecked );
    m_xCtlSize->set_sensitive( !mbSizeDisabled && !bSizeProtect && (!bHeightChecked || !bWidthChecked) );

    m_pFlProtect->Enable( !mbProtectDisabled );
    m_pTsbSizeProtect->Enable( !mbProtectDisabled && !bPosProtect );
    m_xFlProtect->set_sensitive( !mbProtectDisabled );
    m_xTsbSizeProtect->set_sensitive( !mbProtectDisabled && !bPosProtect );

    m_pFlAdjust->Enable( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );
    m_xFlAdjust->set_sensitive( !mbSizeDisabled && !bSizeProtect && !mbAdjustDisabled );

    m_pCtlSize->Invalidate();
    m_pCtlPos->Invalidate();

    m_aCtlSize.Invalidate();
    m_aCtlPos.Invalidate();
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeSizeProtectHdl, Button*, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeSizeProtectHdl, weld::ToggleButton&, void)
{
    if( m_pTsbSizeProtect->IsEnabled() )
    if (m_xTsbSizeProtect->get_sensitive())
    {
        // #106572# Remember user's last choice

@@ -1284,13 +1225,12 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeSizeProtectHdl, Button*, void)
        // clicked. Thus, if pos protect is selected, the dialog is
        // closed and reopened again, unchecking pos protect will
        // always uncheck size protect, too. That's life.
        mnProtectSizeState = m_pTsbSizeProtect->GetState();
        mnProtectSizeState = m_xTsbSizeProtect->get_state();
    }

    UpdateControlStates();
}


void SvxPositionSizeTabPage::SetMinMaxPosition()
{
    // position
@@ -1299,7 +1239,7 @@ void SvxPositionSizeTabPage::SetMinMaxPosition()
    double fRight(maWorkRange.getMaxX());
    double fBottom(maWorkRange.getMaxY());

    switch ( m_pCtlPos->GetActualRP() )
    switch (m_aCtlPos.GetActualRP())
    {
        case RectPoint::LT:
        {
@@ -1370,14 +1310,8 @@ void SvxPositionSizeTabPage::SetMinMaxPosition()
    fBottom = basegfx::clamp(fBottom, -fMaxLong, fMaxLong);

    // #i75273# normalizing when setting the min/max values was wrong, removed
    m_pMtrPosX->SetMin(basegfx::fround64(fLeft));
    m_pMtrPosX->SetFirst(basegfx::fround64(fLeft));
    m_pMtrPosX->SetMax(basegfx::fround64(fRight));
    m_pMtrPosX->SetLast(basegfx::fround64(fRight));
    m_pMtrPosY->SetMin(basegfx::fround64(fTop));
    m_pMtrPosY->SetFirst(basegfx::fround64(fTop));
    m_pMtrPosY->SetMax(basegfx::fround64(fBottom));
    m_pMtrPosY->SetLast(basegfx::fround64(fBottom));
    m_xMtrPosX->set_range(basegfx::fround64(fLeft), basegfx::fround64(fRight), FUNIT_NONE);
    m_xMtrPosY->set_range(basegfx::fround64(fTop), basegfx::fround64(fBottom), FUNIT_NONE);

    // size
    fLeft = maWorkRange.getMinX();
@@ -1387,7 +1321,7 @@ void SvxPositionSizeTabPage::SetMinMaxPosition()
    double fNewX(0);
    double fNewY(0);

    switch ( m_pCtlSize->GetActualRP() )
    switch (m_aCtlSize.GetActualRP())
    {
        case RectPoint::LT:
        {
@@ -1454,16 +1388,13 @@ void SvxPositionSizeTabPage::SetMinMaxPosition()
    }

    // #i75273# normalizing when setting the min/max values was wrong, removed
    m_pMtrWidth->SetMax(basegfx::fround64(fNewX));
    m_pMtrWidth->SetLast(basegfx::fround64(fNewX));
    m_pMtrHeight->SetMax(basegfx::fround64(fNewY));
    m_pMtrHeight->SetLast(basegfx::fround64(fNewY));
    m_xMtrWidth->set_max(basegfx::fround64(fNewX), FUNIT_NONE);
    m_xMtrHeight->set_max(basegfx::fround64(fNewY), FUNIT_NONE);
}


void SvxPositionSizeTabPage::GetTopLeftPosition(double& rfX, double& rfY, const basegfx::B2DRange& rRange)
{
    switch (m_pCtlPos->GetActualRP())
    switch (m_aCtlPos.GetActualRP())
    {
        case RectPoint::LT:
        {
@@ -1516,65 +1447,70 @@ void SvxPositionSizeTabPage::GetTopLeftPosition(double& rfX, double& rfY, const 
    }
}

void SvxPositionSizeTabPage::PointChanged( vcl::Window* pWindow, RectPoint eRP )
void SvxPositionSizeTabPage::PointChanged(vcl::Window* /*pWindow*/, RectPoint /*eRP*/)
{
    if( pWindow == m_pCtlPos )
    assert(false);
}

void SvxPositionSizeTabPage::PointChanged(weld::DrawingArea* pDrawingArea, RectPoint eRP)
{
    if (pDrawingArea == m_aCtlPos.GetDrawingArea())
    {
        SetMinMaxPosition();
        switch( eRP )
        {
            case RectPoint::LT:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMinX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMinY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
                break;
            }
            case RectPoint::MT:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getCenter().getX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMinY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
                break;
            }
            case RectPoint::RT:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMaxX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMinY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FUNIT_NONE );
                break;
            }
            case RectPoint::LM:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMinX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getCenter().getY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
                break;
            }
            case RectPoint::MM:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getCenter().getX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getCenter().getY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
                break;
            }
            case RectPoint::RM:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMaxX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getCenter().getY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FUNIT_NONE );
                break;
            }
            case RectPoint::LB:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMinX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMaxY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
                break;
            }
            case RectPoint::MB:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getCenter().getX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMaxY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
                break;
            }
            case RectPoint::RB:
            {
                m_pMtrPosX->SetValue( basegfx::fround64(maRange.getMaxX()) );
                m_pMtrPosY->SetValue( basegfx::fround64(maRange.getMaxY()) );
                m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FUNIT_NONE );
                m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FUNIT_NONE );
                break;
            }
        }
@@ -1586,11 +1522,6 @@ void SvxPositionSizeTabPage::PointChanged( vcl::Window* pWindow, RectPoint eRP )
    }
}

void SvxPositionSizeTabPage::PointChanged(weld::DrawingArea* /*pWindow*/, RectPoint /*eRP*/)
{
    assert(false);
}

void SvxPositionSizeTabPage::DisableResize()
{
    mbSizeDisabled = true;
@@ -1603,70 +1534,70 @@ void SvxPositionSizeTabPage::DisableProtect()
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeWidthHdl, Edit&, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeWidthHdl, weld::MetricSpinButton&, void)
{
    if( m_pCbxScale->IsChecked() && m_pCbxScale->IsEnabled() )
    if( m_xCbxScale->get_active() && m_xCbxScale->get_sensitive() )
    {
        sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast<double>(m_pMtrWidth->GetValue())) / mfOldWidth));
        sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast<double>(m_xMtrWidth->get_value(FUNIT_NONE))) / mfOldWidth));
        int nMin, nMax;
        m_xMtrHeight->get_range(nMin, nMax, FUNIT_NONE);

        if(nHeight <= m_pMtrHeight->GetMax(FUNIT_NONE))
        if (nHeight <= nMax)
        {
            m_pMtrHeight->SetUserValue(nHeight, FUNIT_NONE);
            m_xMtrHeight->set_value(nHeight, FUNIT_NONE);
        }
        else
        {
            nHeight = m_pMtrHeight->GetMax(FUNIT_NONE);
            m_pMtrHeight->SetUserValue(nHeight);
            nHeight = nMax;
            m_xMtrHeight->set_value(nHeight, FUNIT_NONE);

            const sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast<double>(nHeight)) / mfOldHeight));
            m_pMtrWidth->SetUserValue(nWidth, FUNIT_NONE);
            m_xMtrWidth->set_value(nWidth, FUNIT_NONE);
        }
    }
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeHeightHdl, Edit&, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeHeightHdl, weld::MetricSpinButton&, void)
{
    if( m_pCbxScale->IsChecked() && m_pCbxScale->IsEnabled() )
    if( m_xCbxScale->get_active() && m_xCbxScale->get_sensitive() )
    {
        sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast<double>(m_pMtrHeight->GetValue())) / mfOldHeight));
        sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast<double>(m_xMtrHeight->get_value(FUNIT_NONE))) / mfOldHeight));
        int nMin, nMax;
        m_xMtrWidth->get_range(nMin, nMax, FUNIT_NONE);

        if(nWidth <= m_pMtrWidth->GetMax(FUNIT_NONE))
        if (nWidth <= nMax)
        {
            m_pMtrWidth->SetUserValue(nWidth, FUNIT_NONE);
            m_xMtrWidth->set_value(nWidth, FUNIT_NONE);
        }
        else
        {
            nWidth = m_pMtrWidth->GetMax(FUNIT_NONE);
            m_pMtrWidth->SetUserValue(nWidth);
            nWidth = nMax;
            m_xMtrWidth->set_value(nWidth, FUNIT_NONE);

            const sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast<double>(nWidth)) / mfOldWidth));
            m_pMtrHeight->SetUserValue(nHeight, FUNIT_NONE);
            m_xMtrHeight->set_value(nHeight, FUNIT_NONE);
        }
    }
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickSizeProtectHdl, Button*, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickSizeProtectHdl, weld::ToggleButton&, void)
{
    UpdateControlStates();
}


IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickAutoHdl, Button*, void)
IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickAutoHdl, weld::ToggleButton&, void)
{
    if( m_pCbxScale->IsChecked() )
    if (m_xCbxScale->get_active())
    {
        mfOldWidth  = std::max( static_cast<double>(GetCoreValue( *m_pMtrWidth,  mePoolUnit )), 1.0 );
        mfOldHeight = std::max( static_cast<double>(GetCoreValue( *m_pMtrHeight, mePoolUnit )), 1.0 );
        mfOldWidth  = std::max( static_cast<double>(GetCoreValue( *m_xMtrWidth,  mePoolUnit )), 1.0 );
        mfOldHeight = std::max( static_cast<double>(GetCoreValue( *m_xMtrHeight, mePoolUnit )), 1.0 );
    }
}


void SvxPositionSizeTabPage::FillUserData()
{
    // matching is saved in the Ini-file
    OUString aStr = m_pCbxScale->IsChecked() ? OUString("1") : OUString("0");
    OUString aStr = m_xCbxScale->get_active() ? OUString("1") : OUString("0");
    SetUserData( aStr );
}

diff --git a/cui/uiconfig/ui/possizetabpage.ui b/cui/uiconfig/ui/possizetabpage.ui
index 4ea336b..76fffb8 100644
--- a/cui/uiconfig/ui/possizetabpage.ui
+++ b/cui/uiconfig/ui/possizetabpage.ui
@@ -1,7 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
  <!-- interface-requires gtk+ 3.0 -->
  <!-- interface-requires LibreOffice 1.0 -->
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkAdjustment" id="adjustmentPOS">
    <property name="lower">-120</property>
    <property name="upper">240</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustmentPOS1">
    <property name="lower">-120</property>
    <property name="upper">240</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustmentSIZE">
    <property name="upper">100</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustmentSIZE1">
    <property name="upper">100</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkBox" id="PositionAndSize">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -36,58 +59,54 @@
                      <object class="GtkLabel" id="FT_POS_X">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="possizetabpage|FT_POS_X">Position _X:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_POS_X:0.00cm</property>
                        <property name="mnemonic_widget">MTR_FLD_POS_X</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">0</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="FT_POS_Y">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="possizetabpage|FT_POS_Y">Position _Y:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_POS_Y:0.00cm</property>
                        <property name="mnemonic_widget">MTR_FLD_POS_Y</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">1</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_POS_X:0.00cm">
                      <object class="GtkSpinButton" id="MTR_FLD_POS_X">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustmentPOS</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">0</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_POS_Y:0.00cm">
                      <object class="GtkSpinButton" id="MTR_FLD_POS_Y">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustmentPOS1</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">1</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                  </object>
@@ -118,10 +137,27 @@
                      </packing>
                    </child>
                    <child>
                      <object class="svxlo-SvxRectCtl" id="CTL_POSRECT">
                      <object class="GtkScrolledWindow">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="can_focus">True</property>
                        <property name="halign">center</property>
                        <property name="valign">center</property>
                        <property name="hscrollbar_policy">never</property>
                        <property name="vscrollbar_policy">never</property>
                        <property name="shadow_type">in</property>
                        <child>
                          <object class="GtkViewport">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <child>
                              <object class="GtkDrawingArea" id="CTL_POSRECT">
                                <property name="visible">True</property>
                                <property name="can_focus">True</property>
                                <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
                              </object>
                            </child>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -144,8 +180,8 @@
          <object class="GtkLabel" id="label1">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="xalign">0</property>
            <property name="label" translatable="yes" context="possizetabpage|label1">Position</property>
            <property name="xalign">0</property>
            <attributes>
              <attribute name="weight" value="bold"/>
            </attributes>
@@ -186,60 +222,54 @@
                      <object class="GtkLabel" id="FT_WIDTH">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="possizetabpage|FT_WIDTH">Wi_dth:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_WIDTH:0.00cm</property>
                        <property name="mnemonic_widget">MTR_FLD_WIDTH</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">0</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="FT_HEIGHT">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="xalign">0</property>
                        <property name="label" translatable="yes" context="possizetabpage|FT_HEIGHT">H_eight:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">MTR_FLD_HEIGHT:0.00cm</property>
                        <property name="mnemonic_widget">MTR_FLD_HEIGHT</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">1</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_WIDTH:0.00cm">
                      <object class="GtkSpinButton" id="MTR_FLD_WIDTH">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustmentSIZE</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">0</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="MTR_FLD_HEIGHT:0.00cm">
                      <object class="GtkSpinButton" id="MTR_FLD_HEIGHT">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="adjustment">adjustmentSIZE</property>
                        <property name="activates_default">True</property>
                        <property name="adjustment">adjustmentSIZE1</property>
                        <property name="digits">2</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">1</property>
                        <property name="width">1</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                    <child>
@@ -256,7 +286,6 @@
                        <property name="left_attach">0</property>
                        <property name="top_attach">2</property>
                        <property name="width">2</property>
                        <property name="height">1</property>
                      </packing>
                    </child>
                  </object>
@@ -287,10 +316,27 @@
                      </packing>
                    </child>
                    <child>
                      <object class="svxlo-SvxRectCtl" id="CTL_SIZERECT">
                       <object class="GtkScrolledWindow">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="can_focus">True</property>
                        <property name="halign">center</property>
                        <property name="valign">center</property>
                        <property name="hscrollbar_policy">never</property>
                        <property name="vscrollbar_policy">never</property>
                        <property name="shadow_type">in</property>
                        <child>
                          <object class="GtkViewport">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <child>
                              <object class="GtkDrawingArea" id="CTL_SIZERECT">
                                <property name="visible">True</property>
                                <property name="can_focus">True</property>
                                <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
                              </object>
                            </child>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="expand">False</property>
@@ -313,8 +359,8 @@
          <object class="GtkLabel" id="label2">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="xalign">0</property>
            <property name="label" translatable="yes" context="possizetabpage|label2">Size</property>
            <property name="xalign">0</property>
            <attributes>
              <attribute name="weight" value="bold"/>
            </attributes>
@@ -393,8 +439,8 @@
              <object class="GtkLabel" id="label3">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="possizetabpage|label3">Protect</property>
                <property name="xalign">0</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -467,8 +513,8 @@
              <object class="GtkLabel" id="label4">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="possizetabpage|label4">Adapt</property>
                <property name="xalign">0</property>
                <attributes>
                  <attribute name="weight" value="bold"/>
                </attributes>
@@ -489,17 +535,6 @@
      </packing>
    </child>
  </object>
  <object class="GtkAdjustment" id="adjustmentPOS">
    <property name="lower">-120</property>
    <property name="upper">240</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustmentSIZE">
    <property name="upper">100</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkSizeGroup" id="sizegroup1">
    <widgets>
      <widget name="FT_POS_X"/>
@@ -510,10 +545,10 @@
  </object>
  <object class="GtkSizeGroup" id="sizegroup2">
    <widgets>
      <widget name="MTR_FLD_POS_X:0.00cm"/>
      <widget name="MTR_FLD_POS_Y:0.00cm"/>
      <widget name="MTR_FLD_WIDTH:0.00cm"/>
      <widget name="MTR_FLD_HEIGHT:0.00cm"/>
      <widget name="MTR_FLD_POS_X"/>
      <widget name="MTR_FLD_POS_Y"/>
      <widget name="MTR_FLD_WIDTH"/>
      <widget name="MTR_FLD_HEIGHT"/>
    </widgets>
  </object>
</interface>
diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx
index 2395bc5..203c6e0 100644
--- a/include/vcl/customweld.hxx
+++ b/include/vcl/customweld.hxx
@@ -104,6 +104,7 @@ public:
    void show() { m_xDrawingArea->show(); }
    void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); }
    void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); }
    void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); }
};
}
#endif