weld SvxCaptionTabPage

Change-Id: I163e00ce91cc207f735e67c32269ee2df0ffbfb6
Reviewed-on: https://gerrit.libreoffice.org/60245
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/inc/labdlg.hxx b/cui/source/inc/labdlg.hxx
index 8950167..fd06c5d 100644
--- a/cui/source/inc/labdlg.hxx
+++ b/cui/source/inc/labdlg.hxx
@@ -39,16 +39,6 @@ class SvxCaptionTabPage : public SfxTabPage
{
private:
    static const sal_uInt16 pCaptionRanges[];
    VclPtr<ValueSet>       m_pCT_CAPTTYPE;
    VclPtr<MetricField>    m_pMF_SPACING;
    VclPtr<ListBox>        m_pLB_EXTENSION;
    VclPtr<FixedText>      m_pFT_BYFT;
    VclPtr<MetricField>    m_pMF_BY;
    VclPtr<FixedText>      m_pFT_POSITIONFT;
    VclPtr<ListBox>        m_pLB_POSITION;
    VclPtr<FixedText>      m_pFT_LENGTHFT;
    VclPtr<MetricField>    m_pMF_LENGTH;
    VclPtr<CheckBox>       m_pCB_OPTIMAL;

    Image           m_aBmpCapTypes[CAPTYPE_BITMAPS_COUNT];

@@ -67,18 +57,31 @@ private:
    sal_uInt16          nPosition;
    sal_uInt16          nExtension;

    void            SetupExtension_Impl( sal_uInt16 nType );
    void            SetupType_Impl( SdrCaptionType nType );
    DECL_LINK( ExtensionSelectHdl_Impl, ListBox&, void );
    DECL_LINK( PositionSelectHdl_Impl, ListBox&, void );
    DECL_LINK( LineOptHdl_Impl, Button *, void );
    DECL_LINK( SelectCaptTypeHdl_Impl, ValueSet*, void );

    const SfxItemSet&   rOutAttrs;
    const SdrView*      pView;

    std::unique_ptr<weld::MetricSpinButton> m_xMF_SPACING;
    std::unique_ptr<weld::ComboBoxText> m_xLB_EXTENSION;
    std::unique_ptr<weld::Label> m_xFT_BYFT;
    std::unique_ptr<weld::MetricSpinButton> m_xMF_BY;
    std::unique_ptr<weld::Label> m_xFT_POSITIONFT;
    std::unique_ptr<weld::ComboBoxText> m_xLB_POSITION;
    std::unique_ptr<weld::ComboBoxText> m_xLineTypes;
    std::unique_ptr<weld::Label> m_xFT_LENGTHFT;
    std::unique_ptr<weld::MetricSpinButton> m_xMF_LENGTH;
    std::unique_ptr<weld::CheckButton> m_xCB_OPTIMAL;
    std::unique_ptr<SvtValueSet> m_xCT_CAPTTYPE;
    std::unique_ptr<weld::CustomWeld> m_xCT_CAPTTYPEWin;

    void            SetupExtension_Impl( sal_uInt16 nType );
    void            SetupType_Impl( SdrCaptionType nType );
    DECL_LINK(ExtensionSelectHdl_Impl, weld::ComboBoxText&, void);
    DECL_LINK(PositionSelectHdl_Impl, weld::ComboBoxText&, void);
    DECL_LINK(LineOptHdl_Impl, weld::ToggleButton&, void);
    DECL_LINK(SelectCaptTypeHdl_Impl, SvtValueSet*, void);

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

diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx
index ef2fff8..e45947c 100644
--- a/cui/source/tabpages/labdlg.cxx
+++ b/cui/source/tabpages/labdlg.cxx
@@ -67,8 +67,8 @@ const sal_uInt16 SvxCaptionTabPage::pCaptionRanges[] =
    0
};

SvxCaptionTabPage::SvxCaptionTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs)
    : SfxTabPage(pParent, "CalloutPage", "cui/ui/calloutpage.ui", &rInAttrs)
SvxCaptionTabPage::SvxCaptionTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs)
    : SfxTabPage(pParent, "cui/ui/calloutpage.ui", "CalloutPage", &rInAttrs)
    , nCaptionType(SdrCaptionType::Type1)
    , nGap(0)
    , nEscDir(SdrCaptionEscDir::Horizontal)
@@ -81,37 +81,34 @@ SvxCaptionTabPage::SvxCaptionTabPage(vcl::Window* pParent, const SfxItemSet& rIn
    , nExtension(0)
    , rOutAttrs(rInAttrs)
    , pView(nullptr)
    , m_xMF_SPACING(m_xBuilder->weld_metric_spin_button("spacing", FUNIT_MM))
    , m_xLB_EXTENSION(m_xBuilder->weld_combo_box_text("extension"))
    , m_xFT_BYFT(m_xBuilder->weld_label("byft"))
    , m_xMF_BY(m_xBuilder->weld_metric_spin_button("by", FUNIT_MM))
    , m_xFT_POSITIONFT(m_xBuilder->weld_label("positionft"))
    , m_xLB_POSITION(m_xBuilder->weld_combo_box_text("position"))
    , m_xLineTypes(m_xBuilder->weld_combo_box_text("linetypes"))
    , m_xFT_LENGTHFT(m_xBuilder->weld_label("lengthft"))
    , m_xMF_LENGTH(m_xBuilder->weld_metric_spin_button("length", FUNIT_MM))
    , m_xCB_OPTIMAL(m_xBuilder->weld_check_button("optimal"))
    , m_xCT_CAPTTYPE(new SvtValueSet(m_xBuilder->weld_scrolled_window("valuesetwin")))
    , m_xCT_CAPTTYPEWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xCT_CAPTTYPE))
{
    get(m_pCT_CAPTTYPE, "valueset");
    Size aSize(m_xCT_CAPTTYPE->GetDrawingArea()->get_ref_device().LogicToPixel(Size(187, 38), MapMode(MapUnit::MapAppFont)));
    m_xCT_CAPTTYPEWin->set_size_request(aSize.Width(), aSize.Height());

    Size aSize(m_pCT_CAPTTYPE->LogicToPixel(Size(187, 38), MapMode(MapUnit::MapAppFont)));
    m_pCT_CAPTTYPE->set_width_request(aSize.Width());
    m_pCT_CAPTTYPE->set_height_request(aSize.Height());

    get(m_pMF_SPACING, "spacing");
    get(m_pLB_EXTENSION, "extension");
    get(m_pFT_BYFT, "byft");
    get(m_pMF_BY, "by");
    get(m_pFT_POSITIONFT, "positionft");
    get(m_pLB_POSITION, "position");

    assert(m_pLB_POSITION->GetEntryCount() == 6);
    assert(m_xLB_POSITION->get_count() == 6);
    for (int i = 0;  i < 3; ++i)
        m_aStrHorzList.push_back(m_pLB_POSITION->GetEntry(i));
        m_aStrHorzList.push_back(m_xLB_POSITION->get_text(i));
    for (int i = 3;  i < 6; ++i)
        m_aStrVertList.push_back(m_pLB_POSITION->GetEntry(i));
    m_pLB_POSITION->Clear();
        m_aStrVertList.push_back(m_xLB_POSITION->get_text(i));
    m_xLB_POSITION->clear();

    ListBox *pLineTypes = get<ListBox>("linetypes");
    assert(pLineTypes->GetEntryCount() == 3);
    assert(m_xLineTypes->get_count() == 3);
    std::vector<OUString> aLineTypes;
    aLineTypes.reserve(3);
    for (int i = 0; i < 3; ++i)
        aLineTypes.push_back(pLineTypes->GetEntry(i));

    get(m_pFT_LENGTHFT, "lengthft");
    get(m_pMF_LENGTH, "length");
    get(m_pCB_OPTIMAL, "optimal");
        aLineTypes.push_back(m_xLineTypes->get_text(i));

    for(sal_uInt16 nBitmap = 0; nBitmap < CAPTYPE_BITMAPS_COUNT; ++nBitmap)
    {
@@ -120,21 +117,21 @@ SvxCaptionTabPage::SvxCaptionTabPage(vcl::Window* pParent, const SfxItemSet& rIn
    }

    //------------install ValueSet--------------------------
    m_pCT_CAPTTYPE->SetStyle( m_pCT_CAPTTYPE->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD );
    m_pCT_CAPTTYPE->SetColCount(5);//XXX
    m_pCT_CAPTTYPE->SetLineCount(1);
    m_pCT_CAPTTYPE->SetSelectHdl(LINK( this, SvxCaptionTabPage, SelectCaptTypeHdl_Impl));
    m_xCT_CAPTTYPE->SetStyle( m_xCT_CAPTTYPE->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD );
    m_xCT_CAPTTYPE->SetColCount(5);//XXX
    m_xCT_CAPTTYPE->SetLineCount(1);
    m_xCT_CAPTTYPE->SetSelectHdl(LINK( this, SvxCaptionTabPage, SelectCaptTypeHdl_Impl));

    Image aImage;
    m_pCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_1, aImage, aLineTypes[0]);
    m_pCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_2, aImage, aLineTypes[1]);
    m_pCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_3, aImage, aLineTypes[2]);
    m_xCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_1, aImage, aLineTypes[0]);
    m_xCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_2, aImage, aLineTypes[1]);
    m_xCT_CAPTTYPE->InsertItem(BMP_CAPTTYPE_3, aImage, aLineTypes[2]);

    FillValueSet();

    m_pLB_EXTENSION->SetSelectHdl(LINK(this, SvxCaptionTabPage, ExtensionSelectHdl_Impl));
    m_pLB_POSITION->SetSelectHdl(LINK(this, SvxCaptionTabPage, PositionSelectHdl_Impl));
    m_pCB_OPTIMAL->SetClickHdl(LINK(this, SvxCaptionTabPage, LineOptHdl_Impl));
    m_xLB_EXTENSION->connect_changed(LINK(this, SvxCaptionTabPage, ExtensionSelectHdl_Impl));
    m_xLB_POSITION->connect_changed(LINK(this, SvxCaptionTabPage, PositionSelectHdl_Impl));
    m_xCB_OPTIMAL->connect_toggled(LINK(this, SvxCaptionTabPage, LineOptHdl_Impl));
}

SvxCaptionTabPage::~SvxCaptionTabPage()
@@ -144,16 +141,8 @@ SvxCaptionTabPage::~SvxCaptionTabPage()

void SvxCaptionTabPage::dispose()
{
    m_pCT_CAPTTYPE.clear();
    m_pMF_SPACING.clear();
    m_pLB_EXTENSION.clear();
    m_pFT_BYFT.clear();
    m_pMF_BY.clear();
    m_pFT_POSITIONFT.clear();
    m_pLB_POSITION.clear();
    m_pFT_LENGTHFT.clear();
    m_pMF_LENGTH.clear();
    m_pCB_OPTIMAL.clear();
    m_xCT_CAPTTYPEWin.reset();
    m_xCT_CAPTTYPE.reset();
    SfxTabPage::dispose();
}

@@ -163,7 +152,6 @@ void SvxCaptionTabPage::Construct()
    DBG_ASSERT( pView, "No valid View transferred!" );
}


bool SvxCaptionTabPage::FillItemSet( SfxItemSet*  _rOutAttrs)
{
    SfxItemPool*    pPool = _rOutAttrs->GetPool();
@@ -171,14 +159,14 @@ bool SvxCaptionTabPage::FillItemSet( SfxItemSet*  _rOutAttrs)

    MapUnit      eUnit;

    nCaptionType = static_cast<SdrCaptionType>(m_pCT_CAPTTYPE->GetSelectedItemId()-1);
    nCaptionType = static_cast<SdrCaptionType>(m_xCT_CAPTTYPE->GetSelectedItemId()-1);

    _rOutAttrs->Put( SdrCaptionTypeItem( nCaptionType ) );

    if( m_pMF_SPACING->IsValueModified() )
    if (m_xMF_SPACING->get_value_changed_from_saved())
    {
        eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONGAP ) );
        _rOutAttrs->Put( SdrCaptionGapItem( GetCoreValue(*m_pMF_SPACING, eUnit ) ) );
        _rOutAttrs->Put( SdrCaptionGapItem( GetCoreValue(*m_xMF_SPACING, eUnit ) ) );
    }

    // special treatment!!! XXX
@@ -194,14 +182,14 @@ bool SvxCaptionTabPage::FillItemSet( SfxItemSet*  _rOutAttrs)

    _rOutAttrs->Put( SdrCaptionEscDirItem( nEscDir ) );

    bEscRel = m_pLB_POSITION->IsVisible();
    bEscRel = m_xLB_POSITION->get_visible();
    _rOutAttrs->Put( SdrCaptionEscIsRelItem( bEscRel ) );

    if( bEscRel )
    {
        long    nVal = 0;

        switch( m_pLB_POSITION->GetSelectedEntryPos() )
        switch (m_xLB_POSITION->get_active())
        {
            case POS_TOP:     nVal=0;break;
            case POS_MIDDLE:  nVal=5000;break;
@@ -211,22 +199,22 @@ bool SvxCaptionTabPage::FillItemSet( SfxItemSet*  _rOutAttrs)
    }
    else
    {
        if( m_pMF_BY->IsValueModified() )
        if (m_xMF_BY->get_value_changed_from_saved())
        {
            eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONESCABS ) );
            _rOutAttrs->Put( SdrCaptionEscAbsItem( GetCoreValue(*m_pMF_BY, eUnit ) ) );
            _rOutAttrs->Put( SdrCaptionEscAbsItem( GetCoreValue(*m_xMF_BY, eUnit ) ) );
        }
    }

    bFitLineLen = m_pCB_OPTIMAL->IsChecked();
    bFitLineLen = m_xCB_OPTIMAL->get_active();
    _rOutAttrs->Put( SdrCaptionFitLineLenItem( bFitLineLen ) );

    if( ! bFitLineLen )
    {
        if( m_pMF_LENGTH->IsValueModified() )
        if (m_xMF_LENGTH->get_value_changed_from_saved())
        {
            eUnit = pPool->GetMetric( GetWhich( SDRATTR_CAPTIONLINELEN ) );
            _rOutAttrs->Put( SdrCaptionLineLenItem( GetCoreValue(*m_pMF_LENGTH, eUnit ) ) );
            _rOutAttrs->Put( SdrCaptionLineLenItem( GetCoreValue(*m_xMF_LENGTH, eUnit ) ) );
        }
    }

@@ -235,7 +223,6 @@ bool SvxCaptionTabPage::FillItemSet( SfxItemSet*  _rOutAttrs)
    return true;
}


void SvxCaptionTabPage::Reset( const SfxItemSet*  )
{

@@ -252,9 +239,9 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
            break;
        default: ;//prevent warning
    }
    SetFieldUnit( *m_pMF_SPACING, eFUnit );
    SetFieldUnit( *m_pMF_BY, eFUnit );
    SetFieldUnit( *m_pMF_LENGTH, eFUnit );
    SetFieldUnit( *m_xMF_SPACING, eFUnit );
    SetFieldUnit( *m_xMF_BY, eFUnit );
    SetFieldUnit( *m_xMF_LENGTH, eFUnit );

    SfxItemPool*    pPool = rOutAttrs.GetPool();
    DBG_ASSERT( pPool, "Where is the pool?" );
@@ -265,8 +252,8 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
    nWhich = GetWhich( SDRATTR_CAPTIONESCABS );
    eUnit = pPool->GetMetric( nWhich );
    nEscAbs = static_cast<const SdrCaptionEscAbsItem&>( rOutAttrs.Get( nWhich ) ).GetValue();
    SetMetricValue( *m_pMF_BY, nEscAbs, eUnit );
    nEscAbs = static_cast<long>(m_pMF_BY->GetValue());
    SetMetricValue( *m_xMF_BY, nEscAbs, eUnit );
    nEscAbs = m_xMF_BY->get_value(FUNIT_NONE);

    nWhich = GetWhich( SDRATTR_CAPTIONESCREL );
    nEscRel = static_cast<long>(static_cast<const SdrCaptionEscRelItem&>( rOutAttrs.Get( nWhich ) ).GetValue());
@@ -275,15 +262,15 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
    nWhich = GetWhich( SDRATTR_CAPTIONLINELEN );
    eUnit = pPool->GetMetric( nWhich );
    nLineLen = static_cast<const SdrCaptionLineLenItem&>( rOutAttrs.Get( nWhich ) ).GetValue();
    SetMetricValue( *m_pMF_LENGTH, nLineLen, eUnit );
    nLineLen = static_cast<long>(m_pMF_LENGTH->GetValue());
    SetMetricValue( *m_xMF_LENGTH, nLineLen, eUnit );
    nLineLen = m_xMF_LENGTH->get_value(FUNIT_NONE);

    //------- distance to box ----------
    nWhich = GetWhich( SDRATTR_CAPTIONGAP );
    eUnit = pPool->GetMetric( nWhich );
    nGap = static_cast<const SdrCaptionGapItem&>( rOutAttrs.Get( nWhich ) ).GetValue();
    SetMetricValue( *m_pMF_SPACING, nGap, eUnit );
    nGap = static_cast<long>(m_pMF_SPACING->GetValue());
    SetMetricValue( *m_xMF_SPACING, nGap, eUnit );
    nGap = m_xMF_SPACING->get_value(FUNIT_NONE);

    nCaptionType = static_cast<const SdrCaptionTypeItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue();
    bFitLineLen = static_cast<const SfxBoolItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFITLINELEN ) ) ).GetValue();
@@ -304,7 +291,7 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
    nPosition = POS_MIDDLE;
    nExtension = EXT_OPTIMAL;

    m_pMF_SPACING->SetValue( nGap );
    m_xMF_SPACING->set_value(nGap, FUNIT_NONE);

    if( nEscDir == SdrCaptionEscDir::Horizontal )
    {
@@ -319,7 +306,7 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
        else
        {
            nExtension = EXT_FROM_TOP;
            m_pMF_BY->SetValue( nEscAbs );
            m_xMF_BY->set_value(nEscAbs, FUNIT_NONE);
        }
    }
    else if( nEscDir == SdrCaptionEscDir::Vertical )
@@ -335,7 +322,7 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
        else
        {
            nExtension = EXT_FROM_LEFT;
            m_pMF_BY->SetValue( nEscAbs );
            m_xMF_BY->set_value(nEscAbs, FUNIT_NONE);
        }
    }
    else if( nEscDir == SdrCaptionEscDir::BestFit )
@@ -343,118 +330,114 @@ void SvxCaptionTabPage::Reset( const SfxItemSet*  )
        nExtension = EXT_OPTIMAL;
    }

    m_pCB_OPTIMAL->Check( bFitLineLen );
    m_pMF_LENGTH->SetValue( nLineLen );
    m_xCB_OPTIMAL->set_active(bFitLineLen);
    m_xMF_LENGTH->set_value(nLineLen, FUNIT_NONE);

    m_pLB_EXTENSION->SelectEntryPos( nExtension );
    m_xLB_EXTENSION->set_active(nExtension);

    SetupExtension_Impl( nExtension );
    m_pCT_CAPTTYPE->SelectItem( static_cast<int>(nCaptionType)+1 ); // Enum starts at 0!
    m_xCT_CAPTTYPE->SelectItem( static_cast<int>(nCaptionType)+1 ); // Enum starts at 0!
    SetupType_Impl( nCaptionType );
}


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


void SvxCaptionTabPage::SetupExtension_Impl( sal_uInt16 nType )
{
    switch( nType )
    {
        case EXT_OPTIMAL:
        m_pMF_BY->Show();
        m_pFT_BYFT->Show();
        m_pFT_POSITIONFT->Hide();
        m_pLB_POSITION->Hide();
        m_xMF_BY->show();
        m_xFT_BYFT->show();
        m_xFT_POSITIONFT->hide();
        m_xLB_POSITION->hide();
        nEscDir = SdrCaptionEscDir::BestFit;
        break;

        case EXT_FROM_TOP:
        m_pMF_BY->Show();
        m_pFT_BYFT->Show();
        m_pFT_POSITIONFT->Hide();
        m_pLB_POSITION->Hide();
        m_xMF_BY->show();
        m_xFT_BYFT->show();
        m_xFT_POSITIONFT->hide();
        m_xLB_POSITION->hide();
        nEscDir = SdrCaptionEscDir::Horizontal;
        break;

        case EXT_FROM_LEFT:
        m_pMF_BY->Show();
        m_pFT_BYFT->Show();
        m_pFT_POSITIONFT->Hide();
        m_pLB_POSITION->Hide();
        m_xMF_BY->show();
        m_xFT_BYFT->show();
        m_xFT_POSITIONFT->hide();
        m_xLB_POSITION->hide();
        nEscDir = SdrCaptionEscDir::Vertical;
        break;

        case EXT_HORIZONTAL:
        m_pLB_POSITION->Clear();
        for (OUString & i : m_aStrHorzList)
            m_pLB_POSITION->InsertEntry(i);
        m_pLB_POSITION->SelectEntryPos(nPosition);
        m_xLB_POSITION->clear();
        for (const OUString & i : m_aStrHorzList)
            m_xLB_POSITION->append_text(i);
        m_xLB_POSITION->set_active(nPosition);

        m_pMF_BY->Hide();
        m_pFT_BYFT->Hide();
        m_pFT_POSITIONFT->Show();
        m_pLB_POSITION->Show();
        m_xMF_BY->hide();
        m_xFT_BYFT->hide();
        m_xFT_POSITIONFT->show();
        m_xLB_POSITION->show();
        nEscDir = SdrCaptionEscDir::Horizontal;
        break;

        case EXT_VERTICAL:
        m_pLB_POSITION->Clear();
        for (OUString & i : m_aStrVertList)
            m_pLB_POSITION->InsertEntry(i);
        m_pLB_POSITION->SelectEntryPos(nPosition);
        m_xLB_POSITION->clear();
        for (const OUString & i : m_aStrVertList)
            m_xLB_POSITION->append_text(i);
        m_xLB_POSITION->set_active(nPosition);

        m_pMF_BY->Hide();
        m_pFT_BYFT->Hide();
        m_pFT_POSITIONFT->Show();
        m_pLB_POSITION->Show();
        m_xMF_BY->hide();
        m_xFT_BYFT->hide();
        m_xFT_POSITIONFT->show();
        m_xLB_POSITION->show();
        nEscDir = SdrCaptionEscDir::Vertical;
        break;
    }
}


IMPL_LINK( SvxCaptionTabPage, ExtensionSelectHdl_Impl, ListBox&, rListBox, void )
IMPL_LINK(SvxCaptionTabPage, ExtensionSelectHdl_Impl, weld::ComboBoxText&, rListBox, void)
{
    if (&rListBox == m_pLB_EXTENSION)
    if (&rListBox == m_xLB_EXTENSION.get())
    {
        SetupExtension_Impl( m_pLB_EXTENSION->GetSelectedEntryPos() );
        SetupExtension_Impl(m_xLB_EXTENSION->get_active());
    }
}

IMPL_LINK( SvxCaptionTabPage, PositionSelectHdl_Impl, ListBox&, rListBox, void )
IMPL_LINK(SvxCaptionTabPage, PositionSelectHdl_Impl, weld::ComboBoxText&, rListBox, void)
{
    if (&rListBox == m_pLB_POSITION)
    if (&rListBox == m_xLB_POSITION.get())
    {
        nPosition = m_pLB_POSITION->GetSelectedEntryPos();
        nPosition = m_xLB_POSITION->get_active();
    }
}

IMPL_LINK( SvxCaptionTabPage, LineOptHdl_Impl, Button *, pButton, void )
IMPL_LINK( SvxCaptionTabPage, LineOptHdl_Impl, weld::ToggleButton&, rButton, void )
{
    if (pButton == m_pCB_OPTIMAL)
    if (&rButton == m_xCB_OPTIMAL.get())
    {
        if( m_pCB_OPTIMAL->IsChecked() || ! m_pCB_OPTIMAL->IsEnabled() )
        if (m_xCB_OPTIMAL->get_active() || !m_xCB_OPTIMAL->get_sensitive())
        {
            m_pFT_LENGTHFT->Disable();
            m_pMF_LENGTH->Disable();
            m_xFT_LENGTHFT->set_sensitive(false);
            m_xMF_LENGTH->set_sensitive(false);
        }
        else
        {
            m_pFT_LENGTHFT->Enable();
            m_pMF_LENGTH->Enable();
            m_xFT_LENGTHFT->set_sensitive(true);
            m_xMF_LENGTH->set_sensitive(true);
        }
    }
}


IMPL_LINK_NOARG(SvxCaptionTabPage, SelectCaptTypeHdl_Impl, ValueSet*, void)
IMPL_LINK_NOARG(SvxCaptionTabPage, SelectCaptTypeHdl_Impl, SvtValueSet*, void)
{
    SetupType_Impl( static_cast<SdrCaptionType>(m_pCT_CAPTTYPE->GetSelectedItemId()) );
    SetupType_Impl( static_cast<SdrCaptionType>(m_xCT_CAPTTYPE->GetSelectedItemId()) );
}

void SvxCaptionTabPage::SetupType_Impl( SdrCaptionType nType )
@@ -463,21 +446,19 @@ void SvxCaptionTabPage::SetupType_Impl( SdrCaptionType nType )
    {
        case SdrCaptionType::Type1:
        case SdrCaptionType::Type2:
        m_pFT_LENGTHFT->Disable();
        m_pCB_OPTIMAL->Disable();
        LineOptHdl_Impl( m_pCB_OPTIMAL );
        break;

            m_xFT_LENGTHFT->set_sensitive(false);
            m_xCB_OPTIMAL->set_sensitive(false);
            LineOptHdl_Impl(*m_xCB_OPTIMAL);
            break;
        case SdrCaptionType::Type3:
        case SdrCaptionType::Type4:
        m_pFT_LENGTHFT->Enable();
        m_pCB_OPTIMAL->Enable();
        LineOptHdl_Impl( m_pCB_OPTIMAL );
        break;
            m_xFT_LENGTHFT->set_sensitive(true);
            m_xCB_OPTIMAL->set_sensitive(true);
            LineOptHdl_Impl(*m_xCB_OPTIMAL);
            break;
    }
}


void SvxCaptionTabPage::DataChanged( const DataChangedEvent& rDCEvt )
{
    SfxTabPage::DataChanged( rDCEvt );
@@ -485,16 +466,13 @@ void SvxCaptionTabPage::DataChanged( const DataChangedEvent& rDCEvt )
    if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
            FillValueSet();
}


void SvxCaptionTabPage::FillValueSet()
{
    m_pCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_1, m_aBmpCapTypes[0] );
    m_pCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_2, m_aBmpCapTypes[1] );
    m_pCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_3, m_aBmpCapTypes[2] );
    m_xCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_1, m_aBmpCapTypes[0] );
    m_xCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_2, m_aBmpCapTypes[1] );
    m_xCT_CAPTTYPE->SetItemImage(BMP_CAPTTYPE_3, m_aBmpCapTypes[2] );
}


SvxCaptionTabDialog::SvxCaptionTabDialog(vcl::Window* pParent, const SdrView* pSdrView,
    SvxAnchorIds nAnchorTypes)
    : SfxTabDialog( pParent, "CalloutDialog", "cui/ui/calloutdialog.ui")
diff --git a/cui/uiconfig/ui/calloutpage.ui b/cui/uiconfig/ui/calloutpage.ui
index 54cd2c1..766d5e5 100644
--- a/cui/uiconfig/ui/calloutpage.ui
+++ b/cui/uiconfig/ui/calloutpage.ui
@@ -1,43 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="upper">2400</property>
    <property name="step_increment">0.5</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name gchararray1 -->
      <column type="gchararray"/>
      <!-- column-name gint1 -->
      <column type="gint"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes" context="calloutpage|liststore1">Optimal</col>
        <col id="1">4</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="calloutpage|liststore1">From top</col>
        <col id="1">3</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="calloutpage|liststore1">From left</col>
        <col id="1">3</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="calloutpage|liststore1">Horizontal</col>
        <col id="1">1</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="calloutpage|liststore1">Vertical</col>
        <col id="1">2</col>
      </row>
    </data>
  </object>
  <object class="GtkBox" id="CalloutPage">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -45,9 +14,26 @@
    <property name="orientation">vertical</property>
    <property name="spacing">12</property>
    <child>
      <object class="svtlo-ValueSet" id="valueset:border">
      <object class="GtkScrolledWindow" id="valuesetwin">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="can_focus">True</property>
        <property name="halign">start</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="valueset">
                <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>
@@ -70,10 +56,10 @@
              <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="calloutpage|label2">_Extension:</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">extension</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -81,10 +67,16 @@
              </packing>
            </child>
            <child>
              <object class="GtkComboBox" id="extension">
              <object class="GtkComboBoxText" id="extension">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="model">liststore1</property>
                <items>
                  <item id="4" translatable="yes" context="calloutpage|liststore1">Optimal</item>
                  <item id="3" translatable="yes" context="calloutpage|liststore1">From top</item>
                  <item id="3" translatable="yes" context="calloutpage|liststore1">From left</item>
                  <item id="1" translatable="yes" context="calloutpage|liststore1">Horizontal</item>
                  <item id="2" translatable="yes" context="calloutpage|liststore1">Vertical</item>
                </items>
              </object>
              <packing>
                <property name="left_attach">1</property>
@@ -103,10 +95,11 @@
            <property name="can_focus">False</property>
            <property name="column_spacing">12</property>
            <child>
              <object class="GtkSpinButton" id="length:0.00mm">
              <object class="GtkSpinButton" id="length">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="text" translatable="no">0.00</property>
                <property name="activates_default">True</property>
                <property name="text">0.00</property>
                <property name="adjustment">adjustment1</property>
                <property name="digits">2</property>
              </object>
@@ -119,10 +112,10 @@
              <object class="GtkLabel" id="lengthft">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="calloutpage|lengthft">_Length:</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">length:0.00mm</property>
                <property name="mnemonic_widget">length</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -160,10 +153,10 @@
              <object class="GtkLabel" id="positionft">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="calloutpage|positionft">_Position:</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">position</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -174,10 +167,10 @@
              <object class="GtkLabel" id="byft">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="calloutpage|byft">_By:</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">by:0.00mm</property>
                <property name="mnemonic_widget">by</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -203,10 +196,11 @@
              </packing>
            </child>
            <child>
              <object class="GtkSpinButton" id="by:0.00mm">
              <object class="GtkSpinButton" id="by">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="text" translatable="no">0.00</property>
                <property name="activates_default">True</property>
                <property name="text">0.00</property>
                <property name="adjustment">adjustment1</property>
                <property name="digits">2</property>
              </object>
@@ -230,10 +224,10 @@
              <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="calloutpage|label1">_Spacing:</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">spacing:0.00mm</property>
                <property name="mnemonic_widget">spacing</property>
                <property name="xalign">0</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -241,10 +235,11 @@
              </packing>
            </child>
            <child>
              <object class="GtkSpinButton" id="spacing:0.00mm">
              <object class="GtkSpinButton" id="spacing">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="text" translatable="no">0.00</property>
                <property name="activates_default">True</property>
                <property name="text">0.00</property>
                <property name="adjustment">adjustment1</property>
                <property name="digits">2</property>
              </object>
@@ -268,7 +263,7 @@
              <object class="GtkImage" id="legtyp1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="pixbuf">svx/res/legtyp1.png</property>
                <property name="icon_name">svx/res/legtyp1.png</property>
              </object>
              <packing>
                <property name="left_attach">0</property>
@@ -279,7 +274,7 @@
              <object class="GtkImage" id="legtyp2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="pixbuf">svx/res/legtyp2.png</property>
                <property name="icon_name">svx/res/legtyp2.png</property>
              </object>
              <packing>
                <property name="left_attach">1</property>
@@ -290,7 +285,7 @@
              <object class="GtkImage" id="legtyp3">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="pixbuf">svx/res/legtyp3.png</property>
                <property name="icon_name">svx/res/legtyp3.png</property>
              </object>
              <packing>
                <property name="left_attach">2</property>
@@ -344,15 +339,15 @@
    <property name="mode">both</property>
    <widgets>
      <widget name="position"/>
      <widget name="by:0.00mm"/>
      <widget name="by"/>
    </widgets>
  </object>
  <object class="GtkSizeGroup" id="sizegroup4">
    <property name="mode">both</property>
    <widgets>
      <widget name="extension"/>
      <widget name="length:0.00mm"/>
      <widget name="spacing:0.00mm"/>
      <widget name="length"/>
      <widget name="spacing"/>
    </widgets>
  </object>
</interface>