[Libreoffice-commits] core.git: include/vcl sw/qa sw/source sw/uiconfig vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Apr 9 09:44:24 UTC 2018


 include/vcl/weld.hxx                           |    1 
 sw/qa/uitest/writer_tests/lineNumbering.py     |    4 
 sw/source/ui/dialog/swdlgfact.cxx              |    7 
 sw/source/ui/dialog/swdlgfact.hxx              |   12 +
 sw/source/ui/misc/linenum.cxx                  |  203 +++++++++++--------------
 sw/source/uibase/inc/linenum.hxx               |   52 +++---
 sw/source/uibase/inc/numberingtypelistbox.hxx  |   15 +
 sw/source/uibase/misc/numberingtypelistbox.cxx |  118 ++++++++++++++
 sw/uiconfig/swriter/ui/linenumbering.ui        |   67 +++-----
 vcl/source/app/salvtables.cxx                  |    5 
 vcl/unx/gtk3/gtk3gtkinst.cxx                   |    9 -
 11 files changed, 315 insertions(+), 178 deletions(-)

New commits:
commit 27702e0c7aa04665433426567d4cc7857a126f37
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Apr 8 20:47:09 2018 +0100

    weld SwLineNumberingDlg
    
    and use the same SetFieldUnit as the reset of writer uses
    
    Change-Id: I7fbc4743cdcf057a40b4b84375c62293b8edd074
    Reviewed-on: https://gerrit.libreoffice.org/52607
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 33efcd3e0e41..1f036c563363 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -67,6 +67,7 @@ public:
     virtual void set_margin_bottom(int nMargin) = 0;
 
     virtual void set_accessible_name(const OUString& rName) = 0;
+    virtual OUString get_accessible_name() const = 0;
 
     virtual void connect_focus_in(const Link<Widget&, void>& rLink) = 0;
     virtual void connect_focus_out(const Link<Widget&, void>& rLink) = 0;
diff --git a/sw/qa/uitest/writer_tests/lineNumbering.py b/sw/qa/uitest/writer_tests/lineNumbering.py
index b9d46ecb1ad6..8d1b1103657d 100644
--- a/sw/qa/uitest/writer_tests/lineNumbering.py
+++ b/sw/qa/uitest/writer_tests/lineNumbering.py
@@ -87,7 +87,7 @@ class WriterLineNumbering(UITestCase):
         self.assertEqual(get_state_as_dict(xstyledropdown)["SelectEntryText"], "Bullets")
         self.assertEqual(get_state_as_dict(xformatdropdown)["SelectEntryText"], "A, B, C, ...")
         self.assertEqual(get_state_as_dict(xpositiondropdown)["SelectEntryText"], "Right")
-        self.assertEqual(get_state_as_dict(xspacingspin)["Text"], "1.00 cm")
+        self.assertEqual(get_state_as_dict(xspacingspin)["Text"], "0.60 cm")
         self.assertEqual(get_state_as_dict(xintervalspin)["Text"], "6")
         self.assertEqual(get_state_as_dict(xtextentry)["Text"], ";")
         self.assertEqual(get_state_as_dict(xlinesspin)["Text"], "4")
@@ -118,4 +118,4 @@ class WriterLineNumbering(UITestCase):
         xCancelBtn = xDialog.getChild("cancel")
         self.ui_test.close_dialog_through_button(xCancelBtn)
         self.ui_test.close_doc()
-# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index eae34ddfb912..0bfd7b545bee 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -115,6 +115,10 @@ short AbstractSwMergeTableDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+short AbstractGenericDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 short AbstractSwSortDlg_Impl::Execute()
 {
     return m_xDlg->execute();
@@ -950,8 +954,7 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateTitlePageDlg ( vcl
 
 VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateVclSwViewDialog(SwView& rView)
 {
-    VclPtr<Dialog> pDlg = VclPtr<SwLineNumberingDlg>::Create( &rView );
-    return VclPtr<VclAbstractDialog_Impl>::Create( pDlg );
+    return VclPtr<AbstractGenericDialog_Impl>::Create(new SwLineNumberingDlg(rView));
 }
 
 VclPtr<AbstractInsTableDlg> SwAbstractDialogFactory_Impl::CreateInsTableDlg(SwView& rView)
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index d2e1f5e342a8..a10c4845fde0 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -106,6 +106,18 @@ class VclAbstractDialog_Impl : public VclAbstractDialog
     DECL_ABSTDLG_BASE(VclAbstractDialog_Impl,Dialog)
 };
 
+class AbstractGenericDialog_Impl : public VclAbstractDialog
+{
+protected:
+    std::unique_ptr<weld::GenericDialogController> m_xDlg;
+public:
+    explicit AbstractGenericDialog_Impl(weld::GenericDialogController* p)
+        : m_xDlg(p)
+    {
+    }
+    virtual short Execute() override;
+};
+
 class AbstractSwSortDlg_Impl : public VclAbstractDialog
 {
 protected:
diff --git a/sw/source/ui/misc/linenum.cxx b/sw/source/ui/misc/linenum.cxx
index 3416730d414d..40604b299f1e 100644
--- a/sw/source/ui/misc/linenum.cxx
+++ b/sw/source/ui/misc/linenum.cxx
@@ -19,6 +19,7 @@
 
 #include <sfx2/viewfrm.hxx>
 #include <svl/style.hxx>
+#include <svtools/unitconv.hxx>
 #include <view.hxx>
 #include <wrtsh.hxx>
 #include <docsh.hxx>
@@ -29,7 +30,10 @@
 #include <fldbas.hxx>
 #include <lineinfo.hxx>
 #include <linenum.hxx>
+#include <swmodule.hxx>
 #include <uitool.hxx>
+#include <usrpref.hxx>
+#include <wdocsh.hxx>
 #include <fmtline.hxx>
 #include <strings.hrc>
 
@@ -58,150 +62,133 @@ static void lcl_setLineNumbering(const OUString& rName, SwWrtShell* pSh, bool bL
     xStyleSheet->SetItemSet(rSet);
 }
 
-SwLineNumberingDlg::SwLineNumberingDlg(SwView const *pVw)
-    : SfxModalDialog( &pVw->GetViewFrame()->GetWindow(), "LineNumberingDialog",
-        "modules/swriter/ui/linenumbering.ui" )
-    , pSh(pVw->GetWrtShellPtr())
+SwLineNumberingDlg::SwLineNumberingDlg(const SwView& rVw)
+    : GenericDialogController(rVw.GetViewFrame()->GetWindow().GetFrameWeld(),
+            "modules/swriter/ui/linenumbering.ui", "LineNumberingDialog")
+    , m_pSh(rVw.GetWrtShellPtr())
+    , m_xBodyContent(m_xBuilder->weld_widget("content"))
+    , m_xDivIntervalFT(m_xBuilder->weld_widget("every"))
+    , m_xDivIntervalNF(m_xBuilder->weld_spin_button("linesspin"))
+    , m_xDivRowsFT(m_xBuilder->weld_widget("lines"))
+    , m_xNumIntervalNF(m_xBuilder->weld_spin_button("intervalspin"))
+    , m_xCharStyleLB(m_xBuilder->weld_combo_box_text("styledropdown"))
+    , m_xFormatLB(new NumberingTypeListBox(m_xBuilder->weld_combo_box_text("formatdropdown")))
+    , m_xPosLB(m_xBuilder->weld_combo_box_text("positiondropdown"))
+    , m_xOffsetMF(m_xBuilder->weld_metric_spin_button("spacingspin"))
+    , m_xDivisorED(m_xBuilder->weld_entry("textentry"))
+    , m_xCountEmptyLinesCB(m_xBuilder->weld_check_button("blanklines"))
+    , m_xCountFrameLinesCB(m_xBuilder->weld_check_button("linesintextframes"))
+    , m_xRestartEachPageCB(m_xBuilder->weld_check_button("restarteverynewpage"))
+    , m_xNumberingOnCB(m_xBuilder->weld_check_button("shownumbering"))
+    , m_xNumberingOnFooterHeader(m_xBuilder->weld_check_button("showfooterheadernumbering"))
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
+    , m_xNumIntervalFT(m_xBuilder->weld_widget("interval"))
+    , m_xNumRowsFT(m_xBuilder->weld_widget("intervallines"))
 {
-    get(m_pBodyContent, "content");
-    get(m_pDivIntervalFT, "every");
-    get(m_pDivIntervalNF, "linesspin");
-    get(m_pDivRowsFT, "lines");
-    get(m_pNumIntervalNF, "intervalspin");
-    get(m_pCharStyleLB, "styledropdown");
-    get(m_pFormatLB, "formatdropdown");
-    get(m_pPosLB, "positiondropdown");
-    get(m_pOffsetMF, "spacingspin");
-    get(m_pDivisorED, "textentry");
-    get(m_pCountEmptyLinesCB, "blanklines");
-    get(m_pCountFrameLinesCB, "linesintextframes");
-    get(m_pRestartEachPageCB, "restarteverynewpage");
-    get(m_pNumberingOnCB, "shownumbering");
-    get(m_pNumberingOnFooterHeader, "showfooterheadernumbering");
-
-    OUString sIntervalName = m_pDivIntervalFT->GetAccessibleName()
+    m_xFormatLB->Reload(SwInsertNumTypes::Extended);
+
+    OUString sIntervalName = m_xDivIntervalFT->get_accessible_name()
                              + "("
-                             + m_pDivRowsFT->GetAccessibleName()
+                             + m_xDivRowsFT->get_accessible_name()
                              + ")";
-    m_pDivIntervalNF->SetAccessibleName(sIntervalName);
+    m_xDivIntervalNF->set_accessible_name(sIntervalName);
 
-    vcl::Window *pNumIntervalFT = get<vcl::Window>("interval");
-    vcl::Window *pNumRowsFT = get<vcl::Window>("intervallines");
-    sIntervalName = pNumIntervalFT->GetAccessibleName()
+    sIntervalName = m_xNumIntervalFT->get_accessible_name()
                     + "("
-                    + pNumRowsFT->GetAccessibleName()
+                    + m_xNumRowsFT->get_accessible_name()
                     + ")";
-    m_pNumIntervalNF->SetAccessibleName(sIntervalName);
+    m_xNumIntervalNF->set_accessible_name(sIntervalName);
 
     // char styles
-    ::FillCharStyleListBox(*m_pCharStyleLB, pSh->GetView().GetDocShell());
+    ::FillCharStyleListBox(*m_xCharStyleLB, m_pSh->GetView().GetDocShell());
 
-    const SwLineNumberInfo &rInf = pSh->GetLineNumberInfo();
-    IDocumentStylePoolAccess& rIDSPA = pSh->getIDocumentStylePoolAccess();
+    const SwLineNumberInfo &rInf = m_pSh->GetLineNumberInfo();
+    IDocumentStylePoolAccess& rIDSPA = m_pSh->getIDocumentStylePoolAccess();
 
     OUString sStyleName(rInf.GetCharFormat( rIDSPA )->GetName());
-    const sal_Int32 nPos = m_pCharStyleLB->GetEntryPos(sStyleName);
+    const int nPos = m_xCharStyleLB->find_text(sStyleName);
 
-    if (nPos != LISTBOX_ENTRY_NOTFOUND)
-        m_pCharStyleLB->SelectEntryPos(nPos);
+    if (nPos != -1)
+        m_xCharStyleLB->set_active(nPos);
     else
     {
         if (!sStyleName.isEmpty())
         {
-            m_pCharStyleLB->InsertEntry(sStyleName);
-            m_pCharStyleLB->SelectEntry(sStyleName);
+            m_xCharStyleLB->append_text(sStyleName);
+            m_xCharStyleLB->set_active(sStyleName);
         }
     }
 
     // format
     SvxNumType nSelFormat = rInf.GetNumType().GetNumberingType();
 
-    m_pFormatLB->SelectNumberingType(nSelFormat);
+    m_xFormatLB->SelectNumberingType(nSelFormat);
 
     // position
-    m_pPosLB->SelectEntryPos(static_cast<sal_Int32>(rInf.GetPos()));
+    m_xPosLB->set_active(rInf.GetPos());
 
     // offset
     sal_uInt16 nOffset = rInf.GetPosFromLeft();
     if (nOffset == USHRT_MAX)
         nOffset = 0;
 
-    m_pOffsetMF->SetValue(m_pOffsetMF->Normalize(nOffset), FUNIT_TWIP);
+    FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(dynamic_cast< const SwWebDocShell*>(
+                                rVw.GetDocShell()) != nullptr)->GetMetric();
+    ::SetFieldUnit(*m_xOffsetMF, eFieldUnit);
+    m_xOffsetMF->set_value(m_xOffsetMF->normalize(nOffset), FUNIT_TWIP);
 
     // numbering offset
-    m_pNumIntervalNF->SetValue(rInf.GetCountBy());
+    m_xNumIntervalNF->set_value(rInf.GetCountBy());
 
     // divider
-    m_pDivisorED->SetText(rInf.GetDivider());
+    m_xDivisorED->set_text(rInf.GetDivider());
 
     // divider offset
-    m_pDivIntervalNF->SetValue(rInf.GetDividerCountBy());
+    m_xDivIntervalNF->set_value(rInf.GetDividerCountBy());
 
     // count
-    m_pCountEmptyLinesCB->Check(rInf.IsCountBlankLines());
-    m_pCountFrameLinesCB->Check(rInf.IsCountInFlys());
-    m_pRestartEachPageCB->Check(rInf.IsRestartEachPage());
+    m_xCountEmptyLinesCB->set_active(rInf.IsCountBlankLines());
+    m_xCountFrameLinesCB->set_active(rInf.IsCountInFlys());
+    m_xRestartEachPageCB->set_active(rInf.IsRestartEachPage());
 
-    m_pNumberingOnCB->Check(rInf.IsPaintLineNumbers());
+    m_xNumberingOnCB->set_active(rInf.IsPaintLineNumbers());
 
     // Header/Footer Line Numbering
-    rtl::Reference< SwDocStyleSheet > xStyleSheet = lcl_getDocStyleSheet(SwResId(STR_POOLCOLL_FOOTER), pSh);
+    rtl::Reference< SwDocStyleSheet > xStyleSheet = lcl_getDocStyleSheet(SwResId(STR_POOLCOLL_FOOTER), m_pSh);
     if(xStyleSheet.is())
     {
         SfxItemSet& rSet = xStyleSheet->GetItemSet();
         const SwFormatLineNumber &aFormat = rSet.Get(RES_LINENUMBER);
-        if(aFormat.IsCount())
-            m_pNumberingOnFooterHeader->SetState(TRISTATE_TRUE);
+        if (aFormat.IsCount())
+            m_xNumberingOnFooterHeader->set_state(TRISTATE_TRUE);
         else
-            m_pNumberingOnFooterHeader->SetState(TRISTATE_FALSE);
+            m_xNumberingOnFooterHeader->set_state(TRISTATE_FALSE);
     }
 
     // Line Numbering
-    m_pNumberingOnCB->SetClickHdl(LINK(this, SwLineNumberingDlg, LineOnOffHdl));
-    m_pDivisorED->SetModifyHdl(LINK(this, SwLineNumberingDlg, ModifyHdl));
-    ModifyHdl(*m_pDivisorED);
-    LineOnOffHdl(nullptr);
+    m_xNumberingOnCB->connect_clicked(LINK(this, SwLineNumberingDlg, LineOnOffHdl));
+    m_xDivisorED->connect_changed(LINK(this, SwLineNumberingDlg, ModifyHdl));
+    ModifyHdl(*m_xDivisorED);
+    LineOnOffHdl(*m_xNumberingOnCB);
 
-    get<PushButton>("ok")->SetClickHdl(LINK(this, SwLineNumberingDlg, OKHdl));
+    m_xOKButton->connect_clicked(LINK(this, SwLineNumberingDlg, OKHdl));
 }
 
 SwLineNumberingDlg::~SwLineNumberingDlg()
 {
-    disposeOnce();
 }
 
-void SwLineNumberingDlg::dispose()
-{
-    m_pBodyContent.clear();
-    m_pDivIntervalFT.clear();
-    m_pDivIntervalNF.clear();
-    m_pDivRowsFT.clear();
-    m_pNumIntervalNF.clear();
-    m_pCharStyleLB.clear();
-    m_pFormatLB.clear();
-    m_pPosLB.clear();
-    m_pOffsetMF.clear();
-    m_pDivisorED.clear();
-    m_pCountEmptyLinesCB.clear();
-    m_pCountFrameLinesCB.clear();
-    m_pRestartEachPageCB.clear();
-    m_pNumberingOnCB.clear();
-    m_pNumberingOnFooterHeader.clear();
-    SfxModalDialog::dispose();
-}
-
-
-IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl, Button*, void)
+IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl, weld::Button&, void)
 {
-    SwLineNumberInfo aInf(pSh->GetLineNumberInfo());
+    SwLineNumberInfo aInf(m_pSh->GetLineNumberInfo());
 
     // char styles
-    OUString sCharFormatName(m_pCharStyleLB->GetSelectedEntry());
-    SwCharFormat *pCharFormat = pSh->FindCharFormatByName(sCharFormatName);
+    OUString sCharFormatName(m_xCharStyleLB->get_active_text());
+    SwCharFormat *pCharFormat = m_pSh->FindCharFormatByName(sCharFormatName);
 
     if (!pCharFormat)
     {
-        SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
+        SfxStyleSheetBasePool* pPool = m_pSh->GetView().GetDocShell()->GetStyleSheetPool();
         SfxStyleSheetBase* pBase;
         pBase = pPool->Find(sCharFormatName, SfxStyleFamily::Char);
         if(!pBase)
@@ -214,60 +201,60 @@ IMPL_LINK_NOARG(SwLineNumberingDlg, OKHdl, Button*, void)
 
     // format
     SvxNumberType aType;
-    aType.SetNumberingType(m_pFormatLB->GetSelectedNumberingType());
+    aType.SetNumberingType(m_xFormatLB->GetSelectedNumberingType());
     aInf.SetNumType(aType);
 
     // position
-    aInf.SetPos(static_cast<LineNumberPosition>(m_pPosLB->GetSelectedEntryPos()));
+    aInf.SetPos(static_cast<LineNumberPosition>(m_xPosLB->get_active()));
 
     // offset
-    aInf.SetPosFromLeft(static_cast<sal_uInt16>(m_pOffsetMF->Denormalize(m_pOffsetMF->GetValue(FUNIT_TWIP))));
+    aInf.SetPosFromLeft(static_cast<sal_uInt16>(m_xOffsetMF->denormalize(m_xOffsetMF->get_value(FUNIT_TWIP))));
 
     // numbering offset
-    aInf.SetCountBy(static_cast<sal_uInt16>(m_pNumIntervalNF->GetValue()));
+    aInf.SetCountBy(static_cast<sal_uInt16>(m_xNumIntervalNF->get_value()));
 
     // divider
-    aInf.SetDivider(m_pDivisorED->GetText());
+    aInf.SetDivider(m_xDivisorED->get_text());
 
     // divider offset
-    aInf.SetDividerCountBy(static_cast<sal_uInt16>(m_pDivIntervalNF->GetValue()));
+    aInf.SetDividerCountBy(static_cast<sal_uInt16>(m_xDivIntervalNF->get_value()));
 
     // count
-    aInf.SetCountBlankLines(m_pCountEmptyLinesCB->IsChecked());
-    aInf.SetCountInFlys(m_pCountFrameLinesCB->IsChecked());
-    aInf.SetRestartEachPage(m_pRestartEachPageCB->IsChecked());
+    aInf.SetCountBlankLines(m_xCountEmptyLinesCB->get_active());
+    aInf.SetCountInFlys(m_xCountFrameLinesCB->get_active());
+    aInf.SetRestartEachPage(m_xRestartEachPageCB->get_active());
 
-    aInf.SetPaintLineNumbers(m_pNumberingOnCB->IsChecked());
+    aInf.SetPaintLineNumbers(m_xNumberingOnCB->get_active());
 
-    pSh->SetLineNumberInfo(aInf);
+    m_pSh->SetLineNumberInfo(aInf);
 
     // Set LineNumber explicitly for Header and Footer
-    lcl_setLineNumbering(SwResId(STR_POOLCOLL_FOOTER), pSh, m_pNumberingOnFooterHeader->IsChecked());
-    lcl_setLineNumbering(SwResId(STR_POOLCOLL_HEADER), pSh, m_pNumberingOnFooterHeader->IsChecked());
-    if( m_pNumberingOnFooterHeader->IsChecked())
-       m_pNumberingOnFooterHeader->SetState(TRISTATE_TRUE);
+    lcl_setLineNumbering(SwResId(STR_POOLCOLL_FOOTER), m_pSh, m_xNumberingOnFooterHeader->get_active());
+    lcl_setLineNumbering(SwResId(STR_POOLCOLL_HEADER), m_pSh, m_xNumberingOnFooterHeader->get_active());
+    if( m_xNumberingOnFooterHeader->get_active())
+       m_xNumberingOnFooterHeader->set_state(TRISTATE_TRUE);
     else
-       m_pNumberingOnFooterHeader->SetState(TRISTATE_FALSE);
+       m_xNumberingOnFooterHeader->set_state(TRISTATE_FALSE);
 
-    EndDialog( RET_OK );
+    m_xDialog->response(RET_OK);
 }
 
 // modify
-IMPL_LINK_NOARG(SwLineNumberingDlg, ModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(SwLineNumberingDlg, ModifyHdl, weld::Entry&, void)
 {
-    bool bEnable = m_pNumberingOnCB->IsChecked() && !m_pDivisorED->GetText().isEmpty();
+    bool bEnable = m_xNumberingOnCB->get_active() && !m_xDivisorED->get_text().isEmpty();
 
-    m_pDivIntervalFT->Enable(bEnable);
-    m_pDivIntervalNF->Enable(bEnable);
-    m_pDivRowsFT->Enable(bEnable);
+    m_xDivIntervalFT->set_sensitive(bEnable);
+    m_xDivIntervalNF->set_sensitive(bEnable);
+    m_xDivRowsFT->set_sensitive(bEnable);
 }
 
 // On/Off
-IMPL_LINK_NOARG(SwLineNumberingDlg, LineOnOffHdl, Button*, void)
+IMPL_LINK_NOARG(SwLineNumberingDlg, LineOnOffHdl, weld::Button&, void)
 {
-    bool bEnable = m_pNumberingOnCB->IsChecked();
-    m_pBodyContent->Enable(bEnable);
-    ModifyHdl(*m_pDivisorED);
+    bool bEnable = m_xNumberingOnCB->get_active();
+    m_xBodyContent->set_sensitive(bEnable);
+    ModifyHdl(*m_xDivisorED);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/linenum.hxx b/sw/source/uibase/inc/linenum.hxx
index 80bee87c15bf..6290c17bd2dc 100644
--- a/sw/source/uibase/inc/linenum.hxx
+++ b/sw/source/uibase/inc/linenum.hxx
@@ -19,43 +19,41 @@
 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_LINENUM_HXX
 #define INCLUDED_SW_SOURCE_UIBASE_INC_LINENUM_HXX
 
-#include <sfx2/basedlgs.hxx>
-#include <vcl/button.hxx>
-#include <vcl/layout.hxx>
-#include <vcl/lstbox.hxx>
+#include <vcl/weld.hxx>
 #include "numberingtypelistbox.hxx"
 
-namespace vcl { class Window; }
 class SwView;
 class SwWrtShell;
 
-class SwLineNumberingDlg : public SfxModalDialog
+class SwLineNumberingDlg : public weld::GenericDialogController
 {
 private:
-    SwWrtShell* pSh;
-    VclPtr<VclContainer> m_pBodyContent;
-    VclPtr<vcl::Window> m_pDivIntervalFT;
-    VclPtr<NumericField> m_pDivIntervalNF;
-    VclPtr<vcl::Window> m_pDivRowsFT;
-    VclPtr<NumericField> m_pNumIntervalNF;
-    VclPtr<ListBox> m_pCharStyleLB;
-    VclPtr<SwNumberingTypeListBox> m_pFormatLB;
-    VclPtr<ListBox> m_pPosLB;
-    VclPtr<MetricField> m_pOffsetMF;
-    VclPtr<Edit> m_pDivisorED;
-    VclPtr<CheckBox> m_pCountEmptyLinesCB;
-    VclPtr<CheckBox> m_pCountFrameLinesCB;
-    VclPtr<CheckBox> m_pRestartEachPageCB;
-    VclPtr<CheckBox> m_pNumberingOnCB;
-    VclPtr<CheckBox> m_pNumberingOnFooterHeader;
-    DECL_LINK(OKHdl, Button*, void);
-    DECL_LINK(LineOnOffHdl, Button*, void);
-    DECL_LINK(ModifyHdl, Edit&, void);
+    SwWrtShell* m_pSh;
+    std::unique_ptr<weld::Widget> m_xBodyContent;
+    std::unique_ptr<weld::Widget> m_xDivIntervalFT;
+    std::unique_ptr<weld::SpinButton> m_xDivIntervalNF;
+    std::unique_ptr<weld::Widget> m_xDivRowsFT;
+    std::unique_ptr<weld::SpinButton> m_xNumIntervalNF;
+    std::unique_ptr<weld::ComboBoxText> m_xCharStyleLB;
+    std::unique_ptr<NumberingTypeListBox> m_xFormatLB;
+    std::unique_ptr<weld::ComboBoxText> m_xPosLB;
+    std::unique_ptr<weld::MetricSpinButton> m_xOffsetMF;
+    std::unique_ptr<weld::Entry> m_xDivisorED;
+    std::unique_ptr<weld::CheckButton> m_xCountEmptyLinesCB;
+    std::unique_ptr<weld::CheckButton> m_xCountFrameLinesCB;
+    std::unique_ptr<weld::CheckButton> m_xRestartEachPageCB;
+    std::unique_ptr<weld::CheckButton> m_xNumberingOnCB;
+    std::unique_ptr<weld::CheckButton> m_xNumberingOnFooterHeader;
+    std::unique_ptr<weld::Button> m_xOKButton;
+    std::unique_ptr<weld::Widget> m_xNumIntervalFT;
+    std::unique_ptr<weld::Widget> m_xNumRowsFT;
+    DECL_LINK(OKHdl, weld::Button&, void);
+    DECL_LINK(LineOnOffHdl, weld::Button&, void);
+    DECL_LINK(ModifyHdl, weld::Entry&, void);
 
 public:
-    SwLineNumberingDlg(SwView const *pVw);
+    SwLineNumberingDlg(const SwView& rVw);
     virtual ~SwLineNumberingDlg() override;
-    virtual void dispose() override;
 };
 
 #endif
diff --git a/sw/source/uibase/inc/numberingtypelistbox.hxx b/sw/source/uibase/inc/numberingtypelistbox.hxx
index 658b4b765ce5..393a60df2ee7 100644
--- a/sw/source/uibase/inc/numberingtypelistbox.hxx
+++ b/sw/source/uibase/inc/numberingtypelistbox.hxx
@@ -21,6 +21,7 @@
 
 #include <memory>
 #include <vcl/lstbox.hxx>
+#include <vcl/weld.hxx>
 #include <swdllapi.h>
 #include <o3tl/typed_flags_set.hxx>
 #include <editeng/svxenum.hxx>
@@ -57,6 +58,20 @@ public:
     bool          SelectNumberingType(SvxNumType nType);
 };
 
+class SW_DLLPUBLIC NumberingTypeListBox
+{
+    std::unique_ptr<weld::ComboBoxText> m_xWidget;
+    std::unique_ptr<SwNumberingTypeListBox_Impl> m_xImpl;
+
+public:
+    NumberingTypeListBox(weld::ComboBoxText* pWidget);
+    ~NumberingTypeListBox();
+
+    void          Reload(SwInsertNumTypes nTypeFlags);
+    SvxNumType    GetSelectedNumberingType();
+    bool          SelectNumberingType(SvxNumType nType);
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx
index 31f7c5de9cc4..b55ddb5a983e 100644
--- a/sw/source/uibase/misc/numberingtypelistbox.cxx
+++ b/sw/source/uibase/misc/numberingtypelistbox.cxx
@@ -184,4 +184,122 @@ bool    SwNumberingTypeListBox::SelectNumberingType(SvxNumType nType)
     return LISTBOX_ENTRY_NOTFOUND != nPos;
 }
 
+NumberingTypeListBox::NumberingTypeListBox(weld::ComboBoxText* pWidget)
+    : m_xWidget(pWidget)
+    , m_xImpl(new SwNumberingTypeListBox_Impl)
+{
+    uno::Reference<uno::XComponentContext>          xContext( ::comphelper::getProcessComponentContext() );
+    uno::Reference<text::XDefaultNumberingProvider> xDefNum = text::DefaultNumberingProvider::create(xContext);
+    m_xImpl->xInfo.set(xDefNum, uno::UNO_QUERY);
+}
+
+NumberingTypeListBox::~NumberingTypeListBox()
+{
+}
+
+void NumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags)
+{
+    m_xWidget->clear();
+    uno::Sequence<sal_Int16> aTypes;
+    const sal_Int16* pTypes = nullptr;
+    if (nTypeFlags & SwInsertNumTypes::Extended)
+    {
+        if (m_xImpl->xInfo.is())
+        {
+            aTypes = m_xImpl->xInfo->getSupportedNumberingTypes();
+            pTypes = aTypes.getConstArray();
+        }
+    }
+
+    for(size_t i = 0; i < SvxNumberingTypeTable::Count(); i++)
+    {
+        sal_IntPtr nValue = SvxNumberingTypeTable::GetValue(i);
+        bool bInsert = true;
+        int nPos = -1;
+        switch(nValue)
+        {
+            case  style::NumberingType::NUMBER_NONE:
+                bInsert = bool(nTypeFlags & SwInsertNumTypes::NoNumbering);
+                nPos = 0;
+
+                break;
+            case  style::NumberingType::CHAR_SPECIAL:
+                bInsert = bool(nTypeFlags & SwInsertNumTypes::Bullet);
+
+                break;
+            case  style::NumberingType::PAGE_DESCRIPTOR:
+                bInsert = bool(nTypeFlags & SwInsertNumTypes::PageStyleNumbering);
+
+                break;
+            case  style::NumberingType::BITMAP:
+                bInsert = bool(nTypeFlags & SwInsertNumTypes::Bitmap );
+
+                break;
+            case  style::NumberingType::BITMAP | LINK_TOKEN:
+                bInsert = false;
+
+                break;
+            default:
+                if (nValue >  style::NumberingType::CHARS_LOWER_LETTER_N)
+                {
+                    // Insert only if offered by i18n framework per configuration.
+                    bInsert = false;
+                    if (pTypes)
+                    {
+                        for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+                        {
+                            if (pTypes[nType] == nValue)
+                            {
+                                bInsert = true;
+                                break;  // for
+                            }
+                        }
+                    }
+                }
+        }
+        if (bInsert)
+        {
+            m_xWidget->insert(nPos, OUString::number(nValue), SvxNumberingTypeTable::GetString(i));
+        }
+    }
+    if (nTypeFlags & SwInsertNumTypes::Extended)
+    {
+        if (pTypes)
+        {
+            for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
+            {
+                sal_Int16 nCurrent = pTypes[nType];
+                if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
+                {
+                    if (m_xWidget->find_id(OUString::number(nCurrent)) == -1)
+                    {
+                        m_xWidget->insert(-1, OUString::number(nCurrent), m_xImpl->xInfo->getNumberingIdentifier(nCurrent));
+                    }
+                }
+            }
+        }
+        m_xWidget->set_active(0);
+    }
+}
+
+SvxNumType NumberingTypeListBox::GetSelectedNumberingType()
+{
+    SvxNumType nRet = SVX_NUM_CHARS_UPPER_LETTER;
+    int nSelPos = m_xWidget->get_active();
+    if (nSelPos != -1)
+        nRet = static_cast<SvxNumType>(m_xWidget->get_id(nSelPos).toInt32());
+#if OSL_DEBUG_LEVEL > 0
+    else
+        OSL_FAIL("NumberingTypeListBox not selected");
+#endif
+    return nRet;
+}
+
+bool NumberingTypeListBox::SelectNumberingType(SvxNumType nType)
+{
+    int nPos = m_xWidget->find_id(OUString::number(nType));
+    m_xWidget->set_active(nPos);
+    return nPos != -1;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/linenumbering.ui b/sw/uiconfig/swriter/ui/linenumbering.ui
index 28047802320e..d2bdafc7c27b 100644
--- a/sw/uiconfig/swriter/ui/linenumbering.ui
+++ b/sw/uiconfig/swriter/ui/linenumbering.ui
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkAdjustment" id="intervaladjustment">
     <property name="lower">1</property>
     <property name="upper">1000</property>
@@ -16,26 +15,6 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkListStore" id="positionstore">
-    <columns>
-      <!-- column-name positions -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes" context="linenumbering|positionstore">Left</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="linenumbering|positionstore">Right</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="linenumbering|positionstore">Inner</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" context="linenumbering|positionstore">Outer</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkAdjustment" id="spacingadjustment">
     <property name="upper">9999</property>
     <property name="value">0.5</property>
@@ -46,6 +25,9 @@
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="linenumbering|LineNumberingDialog">Line Numbering</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 internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -61,6 +43,7 @@
                 <property name="label">gtk-ok</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
@@ -158,10 +141,10 @@
                               <object class="GtkLabel" id="characterstyle">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
                                 <property name="label" translatable="yes" context="linenumbering|characterstyle">Character style:</property>
                                 <property name="use_underline">True</property>
                                 <property name="mnemonic_widget">styledropdown</property>
+                                <property name="xalign">0</property>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
@@ -172,8 +155,8 @@
                               <object class="GtkLabel" id="format">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
                                 <property name="label" translatable="yes" context="linenumbering|format">Format:</property>
+                                <property name="xalign">0</property>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
@@ -184,10 +167,10 @@
                               <object class="GtkLabel" id="position">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
                                 <property name="label" translatable="yes" context="linenumbering|position">Position:</property>
                                 <property name="use_underline">True</property>
                                 <property name="mnemonic_widget">positiondropdown</property>
+                                <property name="xalign">0</property>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
@@ -198,10 +181,10 @@
                               <object class="GtkLabel" id="spacing">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
                                 <property name="label" translatable="yes" context="linenumbering|spacing">Spacing:</property>
                                 <property name="use_underline">True</property>
-                                <property name="mnemonic_widget">spacingspin:0.00cm</property>
+                                <property name="mnemonic_widget">spacingspin</property>
+                                <property name="xalign">0</property>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
@@ -212,10 +195,10 @@
                               <object class="GtkLabel" id="interval">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
                                 <property name="label" translatable="yes" context="linenumbering|interval">Interval:</property>
                                 <property name="use_underline">True</property>
                                 <property name="mnemonic_widget">intervalspin</property>
+                                <property name="xalign">0</property>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
@@ -223,7 +206,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkComboBox" id="styledropdown">
+                              <object class="GtkComboBoxText" id="styledropdown">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="hexpand">True</property>
@@ -235,11 +218,10 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="swlo-SwNumberingTypeListBox" id="formatdropdown">
+                              <object class="GtkComboBoxText" id="formatdropdown">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="hexpand">True</property>
-                                <property name="type">16</property>
                               </object>
                               <packing>
                                 <property name="left_attach">1</property>
@@ -248,11 +230,16 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkComboBox" id="positiondropdown">
+                              <object class="GtkComboBoxText" id="positiondropdown">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="hexpand">True</property>
-                                <property name="model">positionstore</property>
+                                <items>
+                                  <item translatable="yes" context="linenumbering|positionstore">Left</item>
+                                  <item translatable="yes" context="linenumbering|positionstore">Right</item>
+                                  <item translatable="yes" context="linenumbering|positionstore">Inner</item>
+                                  <item translatable="yes" context="linenumbering|positionstore">Outer</item>
+                                </items>
                               </object>
                               <packing>
                                 <property name="left_attach">1</property>
@@ -261,7 +248,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkSpinButton" id="spacingspin:0.00cm">
+                              <object class="GtkSpinButton" id="spacingspin">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="halign">start</property>
@@ -295,8 +282,8 @@
                                   <object class="GtkLabel" id="intervallines">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="xalign">0</property>
                                     <property name="label" translatable="yes" context="linenumbering|intervallines">lines</property>
+                                    <property name="xalign">0</property>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
@@ -359,10 +346,10 @@
                                   <object class="GtkLabel" id="text">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="xalign">0</property>
                                     <property name="label" translatable="yes" context="linenumbering|text">Text:</property>
                                     <property name="use_underline">True</property>
                                     <property name="mnemonic_widget">textentry</property>
+                                    <property name="xalign">0</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">0</property>
@@ -373,10 +360,10 @@
                                   <object class="GtkLabel" id="every">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="xalign">0</property>
                                     <property name="label" translatable="yes" context="linenumbering|every">Every:</property>
                                     <property name="use_underline">True</property>
                                     <property name="mnemonic_widget">linesspin</property>
+                                    <property name="xalign">0</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">0</property>
@@ -387,6 +374,7 @@
                                   <object class="GtkEntry" id="textentry">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
+                                    <property name="activates_default">True</property>
                                     <property name="width_chars">3</property>
                                   </object>
                                   <packing>
@@ -399,8 +387,8 @@
                                   <object class="GtkLabel" id="lines">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
-                                    <property name="xalign">0</property>
                                     <property name="label" translatable="yes" context="linenumbering|lines">lines</property>
+                                    <property name="xalign">0</property>
                                   </object>
                                   <packing>
                                     <property name="left_attach">2</property>
@@ -568,5 +556,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 637f5651d66b..6a31861bce43 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -310,6 +310,11 @@ public:
         m_xWidget->SetAccessibleName(rName);
     }
 
+    virtual OUString get_accessible_name() const override
+    {
+        return m_xWidget->GetAccessibleName();
+    }
+
     virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
     {
         assert(!m_aFocusInHdl.IsSet());
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 081efc63bffb..ebb5dfdde8a3 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1332,7 +1332,14 @@ public:
         AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
         if (!pAtkObject)
             return;
-        atk_object_set_description(pAtkObject, OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
+        atk_object_set_name(pAtkObject, OUStringToOString(rName, RTL_TEXTENCODING_UTF8).getStr());
+    }
+
+    virtual OUString get_accessible_name() const override
+    {
+        AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
+        const char* pStr = pAtkObject ? atk_object_get_name(pAtkObject) : nullptr;
+        return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
     }
 
     virtual weld::Container* weld_parent() const override;


More information about the Libreoffice-commits mailing list