weld SwCaptionOptDlg

Change-Id: Iac2cb2ab3239e23a64dbc528f0d07d4071c4815c
Reviewed-on: https://gerrit.libreoffice.org/65011
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx
index 6c2c375..cbba585 100644
--- a/sw/source/ui/config/optload.cxx
+++ b/sw/source/ui/config/optload.cxx
@@ -393,12 +393,13 @@ IMPL_LINK_NOARG(SwLoadOptPage, MetricHdl, ListBox&, void)
    }
}

SwCaptionOptDlg::SwCaptionOptDlg(vcl::Window* pParent, const SfxItemSet& rSet)
    : SfxSingleTabDialog(pParent, rSet, "CaptionDialog",
        "modules/swriter/ui/captiondialog.ui")
SwCaptionOptDlg::SwCaptionOptDlg(weld::Window* pParent, const SfxItemSet& rSet)
    : SfxSingleTabDialogController(pParent, rSet, "modules/swriter/ui/captiondialog.ui",
                                   "CaptionDialog")
{
    // create TabPage
    SetTabPage(SwCaptionOptPage::Create(get_content_area(), &rSet));
    TabPageParent aParent(get_content_area(), this);
    SetTabPage(SwCaptionOptPage::Create(aParent, &rSet));
}

SwCaptionPreview::SwCaptionPreview(vcl::Window* pParent, WinBits nStyle)
@@ -889,10 +890,8 @@ void SwCaptionOptPage::ModifyHdl()
{
    const OUString sFieldTypeName = m_xCategoryBox->get_active_text();

    SfxSingleTabDialog *pDlg = dynamic_cast<SfxSingleTabDialog*>(GetTabDialog());
    PushButton *pBtn = pDlg ? pDlg->GetOKButton() : nullptr;
    if (pBtn)
        pBtn->Enable(!sFieldTypeName.isEmpty());
    if (SfxSingleTabDialogController* pDlg = dynamic_cast<SfxSingleTabDialogController*>(GetDialogController()))
        pDlg->GetOKButton().set_sensitive(!sFieldTypeName.isEmpty());
    bool bEnable = m_xCategoryBox->get_sensitive() && sFieldTypeName != m_sNone;

    m_xFormatText->set_sensitive(bEnable);
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 3f650c1..cf1668f 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -352,8 +352,8 @@ IMPL_LINK_NOARG(SwCaptionDialog, ModifyHdl, Edit&, void)
IMPL_LINK_NOARG(SwCaptionDialog, CaptionHdl, Button*, void)
{
    SfxItemSet  aSet( rView.GetDocShell()->GetDoc()->GetAttrPool() );
    ScopedVclPtrInstance< SwCaptionOptDlg > aDlg( this, aSet );
    aDlg->Execute();
    SwCaptionOptDlg aDlg(GetFrameWeld(), aSet);
    aDlg.run();
}

void SwCaptionDialog::DrawSample()
diff --git a/sw/source/uibase/inc/optload.hxx b/sw/source/uibase/inc/optload.hxx
index c027a99..6f23242 100644
--- a/sw/source/uibase/inc/optload.hxx
+++ b/sw/source/uibase/inc/optload.hxx
@@ -95,10 +95,10 @@ public:
    virtual void        Reset( const SfxItemSet* rSet ) override;
};

class SwCaptionOptDlg : public SfxSingleTabDialog
class SwCaptionOptDlg : public SfxSingleTabDialogController
{
public:
    SwCaptionOptDlg(vcl::Window* pParent, const SfxItemSet& rSet);
    SwCaptionOptDlg(weld::Window* pParent, const SfxItemSet& rSet);
};

class SwCaptionPreview : public vcl::Window
diff --git a/sw/uiconfig/swriter/ui/captiondialog.ui b/sw/uiconfig/swriter/ui/captiondialog.ui
index 8ed3590..776b1cc 100644
--- a/sw/uiconfig/swriter/ui/captiondialog.ui
+++ b/sw/uiconfig/swriter/ui/captiondialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkDialog" id="CaptionDialog">
@@ -7,7 +7,13 @@
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="captiondialog|CaptionDialog">Caption</property>
    <property name="resizable">False</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
    </child>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
        <property name="can_focus">False</property>
diff --git a/sw/uiconfig/swriter/ui/optcaptionpage.ui b/sw/uiconfig/swriter/ui/optcaptionpage.ui
index 133505e..9abdce1 100644
--- a/sw/uiconfig/swriter/ui/optcaptionpage.ui
+++ b/sw/uiconfig/swriter/ui/optcaptionpage.ui
@@ -441,7 +441,6 @@
                                <property name="alignment">0.5</property>
                                <child>
                                  <object class="GtkCellRendererToggle" id="cellrenderer2">
                                    <property name="radio">True</property>
                                  </object>
                                  <attributes>
                                    <attribute name="active">0</attribute>