sw/inc/swabstdlg.hxx                    |    3 ++
 sw/source/ui/dialog/swdlgfact.cxx       |   10 +++++++
 sw/source/ui/dialog/swdlgfact.hxx       |    2 +
 sw/source/ui/misc/pagenumberdlg.cxx     |   17 ++++++++++++
 sw/source/uibase/inc/pagenumberdlg.hxx  |    7 +++++
 sw/source/uibase/shells/textfld.cxx     |   16 +++++++++++
 sw/uiconfig/swriter/ui/pagenumberdlg.ui |   43 ++++++++++++++++++++++++++++++++
 7 files changed, 98 insertions(+)

New commits:
commit 0e73b0d9c3d812b2e4340ebfd12c3cb084f4ffb8
Author:     Justin Luth <[email protected]>
AuthorDate: Tue Apr 25 16:45:52 2023 -0400
Commit:     Justin Luth <[email protected]>
CommitDate: Thu May 18 17:54:51 2023 +0200

    tdf#86630 sw page number wizard: set page style numbering type
    
    This is a squashed commit - including
    commit d4cf5814146e375805df98eafba2baf321b9b005
        tdf#86630 sw page number wizard: cleanup numbering type patch
    and commit 0b35b7953507491fe1ebdead9ac6ce592bd9b674
        cid#1528191 Uninitialized scalar field
    
    Giving the user the opportunity to change the number type
    is rather important. Well, maybe not too critical since I
    assume that the default page number style is relatively accurate
    for each locale, and at least for English we always just
    use numbers for the page style.
    
    However, a wizard is the perfect place to expose such a setting,
    otherwise it is buried in page style settings - far from
    where anyone would look when inserting a page number.
    
    Change-Id: I9053504fa55d16ebf5424946b480cb044b79988c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151005
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>
     Reviewed-by: Miklos Vajna <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151899
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 534d422cb781..ae47d54053f4 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -19,6 +19,7 @@
 #ifndef INCLUDED_SW_INC_SWABSTDLG_HXX
 #define INCLUDED_SW_INC_SWABSTDLG_HXX
 
+#include <editeng/svxenum.hxx>
 #include <rtl/ustring.hxx>
 #include <sfx2/sfxdlg.hxx>
 #include <com/sun/star/uno/Reference.h>
@@ -237,6 +238,8 @@ protected:
 public:
     virtual int GetPageNumberPosition() const = 0;
     virtual int GetPageNumberAlignment() const = 0;
+    virtual SvxNumType GetPageNumberType() const = 0;
+    virtual void SetPageNumberType(SvxNumType nSet) = 0;
 };
 
 /**
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index ae224d00f78c..e9e20bf336da 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -642,6 +642,16 @@ int AbstractSwPageNumberDlg_Impl::GetPageNumberAlignment() 
const
     return m_xDlg->GetPageNumberAlignment();
 }
 
+SvxNumType AbstractSwPageNumberDlg_Impl::GetPageNumberType() const
+{
+    return m_xDlg->GetPageNumberType();
+}
+
+void AbstractSwPageNumberDlg_Impl::SetPageNumberType(SvxNumType nSet)
+{
+    m_xDlg->SetPageNumberType(nSet);
+}
+
 bool AbstractInsFootNoteDlg_Impl::IsEndNote()
 {
     return m_xDlg->IsEndNote();
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 929063a2dab5..39c8d1fc6f54 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -165,6 +165,8 @@ public:
     virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
     virtual int GetPageNumberPosition() const override;
     virtual int GetPageNumberAlignment() const override;
+    SvxNumType GetPageNumberType() const override;
+    void SetPageNumberType(SvxNumType nSet) override;
 };
 
 class AbstractGenericDialog_Impl : public VclAbstractDialog
diff --git a/sw/source/ui/misc/pagenumberdlg.cxx 
b/sw/source/ui/misc/pagenumberdlg.cxx
index b2634d68950e..9d2ad412840b 100644
--- a/sw/source/ui/misc/pagenumberdlg.cxx
+++ b/sw/source/ui/misc/pagenumberdlg.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <pagenumberdlg.hxx>
+#include <svx/SvxNumOptionsTabPageHelper.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/BitmapTools.hxx>
@@ -29,15 +30,20 @@ SwPageNumberDlg::SwPageNumberDlg(weld::Window* pParent)
     , m_xCancel(m_xBuilder->weld_button("cancel"))
     , m_xPageNumberPosition(m_xBuilder->weld_combo_box("positionCombo"))
     , m_xPageNumberAlignment(m_xBuilder->weld_combo_box("alignmentCombo"))
+    , m_xPageNumberTypeLB(new 
SvxPageNumberListBox(m_xBuilder->weld_combo_box("numfmtlb")))
     , m_xPreviewImage(m_xBuilder->weld_image("previewImage"))
     , m_aPageNumberPosition(1) // bottom
     , m_aPageNumberAlignment(1) // center
+    , m_nPageNumberType(SVX_NUM_CHARS_UPPER_LETTER)
 {
     m_xOk->connect_clicked(LINK(this, SwPageNumberDlg, OkHdl));
     m_xPageNumberPosition->connect_changed(LINK(this, SwPageNumberDlg, 
PositionSelectHdl));
     m_xPageNumberAlignment->connect_changed(LINK(this, SwPageNumberDlg, 
AlignmentSelectHdl));
     m_xPageNumberPosition->set_active(m_aPageNumberPosition);
     m_xPageNumberAlignment->set_active(m_aPageNumberAlignment);
+    
SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xPageNumberTypeLB->get_widget(),
+                                                 
::std::numeric_limits<sal_uInt16>::max());
+    m_xPageNumberTypeLB->connect_changed(LINK(this, SwPageNumberDlg, 
NumberTypeSelectHdl));
     updateImage();
 }
 
@@ -60,6 +66,17 @@ IMPL_LINK_NOARG(SwPageNumberDlg, AlignmentSelectHdl, 
weld::ComboBox&, void)
     updateImage();
 }
 
+IMPL_LINK_NOARG(SwPageNumberDlg, NumberTypeSelectHdl, weld::ComboBox&, void)
+{
+    m_nPageNumberType = m_xPageNumberTypeLB->get_active_id();
+}
+
+void SwPageNumberDlg::SetPageNumberType(SvxNumType nSet)
+{
+    m_nPageNumberType = nSet;
+    m_xPageNumberTypeLB->set_active_id(nSet);
+}
+
 void SwPageNumberDlg::updateImage()
 {
     int nBackgroundWidth = 75;
diff --git a/sw/source/uibase/inc/pagenumberdlg.hxx 
b/sw/source/uibase/inc/pagenumberdlg.hxx
index 23a3c1423462..9e3adff871a7 100644
--- a/sw/source/uibase/inc/pagenumberdlg.hxx
+++ b/sw/source/uibase/inc/pagenumberdlg.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <sfx2/basedlgs.hxx>
+#include <svx/pagenumberlistbox.hxx>
 
 class SwWrtShell;
 
@@ -30,15 +31,19 @@ class SwPageNumberDlg : public SfxDialogController
     std::unique_ptr<weld::Button> m_xCancel;
     std::unique_ptr<weld::ComboBox> m_xPageNumberPosition;
     std::unique_ptr<weld::ComboBox> m_xPageNumberAlignment;
+    std::unique_ptr<SvxPageNumberListBox> m_xPageNumberTypeLB;
+
     std::unique_ptr<weld::Image> m_xPreviewImage;
 
     int m_aPageNumberPosition;
     int m_aPageNumberAlignment;
+    SvxNumType m_nPageNumberType;
 
     DECL_LINK(OkHdl, weld::Button&, void);
     DECL_LINK(CancelHdl, weld::Button&, void);
     DECL_LINK(PositionSelectHdl, weld::ComboBox&, void);
     DECL_LINK(AlignmentSelectHdl, weld::ComboBox&, void);
+    DECL_LINK(NumberTypeSelectHdl, weld::ComboBox&, void);
 
     void updateImage();
 
@@ -46,6 +51,8 @@ public:
     SwPageNumberDlg(weld::Window* pParent);
     int GetPageNumberPosition() const { return m_aPageNumberPosition; }
     int GetPageNumberAlignment() const { return m_aPageNumberAlignment; }
+    SvxNumType GetPageNumberType() const { return m_nPageNumberType; }
+    void SetPageNumberType(SvxNumType nSet);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/textfld.cxx 
b/sw/source/uibase/shells/textfld.cxx
index 878f37387baf..f9d091cce3cf 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -61,6 +61,7 @@
 #include <IDocumentUndoRedo.hxx>
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
+#include <svx/pageitem.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <IMark.hxx>
 #include <officecfg/Office/Compatibility.hxx>
@@ -1027,6 +1028,12 @@ FIELD_INSERT:
         VclPtr<AbstractSwPageNumberDlg> pDlg(
                 pFact->CreateSwPageNumberDlg(GetView().GetFrameWeld()));
         auto pShell = GetShellPtr();
+
+        const SvxPageItem* pPageItem;
+        rSh.GetView().GetDispatcher().QueryState(SID_ATTR_PAGE, pPageItem);
+        if (pPageItem)
+            pDlg->SetPageNumberType(pPageItem->GetNumType());
+
         pDlg->StartExecuteAsync([pShell, &rSh, pDlg](int nResult) {
             if ( nResult == RET_OK )
             {
@@ -1042,6 +1049,15 @@ FIELD_INSERT:
                 sal_uInt16 nPageNumberPosition = bFooter ?
                     FN_INSERT_PAGEFOOTER : FN_INSERT_PAGEHEADER;
                 SfxBoolItem aItem(FN_PARAM_1, true);
+
+                SvxPageItem aPageItem(SID_ATTR_PAGE);
+                aPageItem.SetNumType(pDlg->GetPageNumberType());
+                rSh.GetView().GetDispatcher().ExecuteList(SID_ATTR_PAGE,
+                                                          SfxCallMode::API | 
SfxCallMode::SYNCHRON,
+                                                          { &aPageItem });
+
+
+
                 rSh.GetView().GetDispatcher().ExecuteList(
                     nPageNumberPosition,
                     SfxCallMode::API | SfxCallMode::SYNCHRON,
diff --git a/sw/uiconfig/swriter/ui/pagenumberdlg.ui 
b/sw/uiconfig/swriter/ui/pagenumberdlg.ui
index 4f46767d9491..3063e42ac4ac 100644
--- a/sw/uiconfig/swriter/ui/pagenumberdlg.ui
+++ b/sw/uiconfig/swriter/ui/pagenumberdlg.ui
@@ -152,6 +152,49 @@
                     <property name="position">3</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="numfmtLabel">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="margin-top">6</property>
+                    <property name="label" translatable="yes" 
context="pagenumberdlg|numfmtLabel">Page numbers:</property>
+                    <property name="use-underline">True</property>
+                    <property name="mnemonic-widget">numfmtlb</property>
+                    <accessibility>
+                      <relation type="label-for" target="numfmtlb"/>
+                    </accessibility>
+                    <child internal-child="accessible">
+                      <object class="AtkObject" id="numfmtLabel-atkobject">
+                        <property name="AtkObject::accessible-name" 
translatable="yes" context="pagenumberdlg|alignmentLabel-atkobject">Number 
format</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBoxText" id="numfmtlb">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <accessibility>
+                      <relation type="labelled-by" target="numfmtLabel"/>
+                    </accessibility>
+                    <child internal-child="accessible">
+                      <object class="AtkObject" id="numfmtlb-atkobject">
+                        <property name="AtkObject::accessible-description" 
translatable="yes" context="numberingoptionspage|extended_tip|numfmtlb">Select 
a numbering scheme for the page numbering.</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">5</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>

Reply via email to