tdf#150408: Implement UI for "Legal" numbering

Change-Id: I16849a2d823539040ecb91416b5214d25851950a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154287
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx
index dd1dfba..d693b9e 100644
--- a/cui/source/inc/numpages.hxx
+++ b/cui/source/inc/numpages.hxx
@@ -235,6 +235,7 @@ class SvxNumOptionsTabPage : public SfxTabPage
    std::unique_ptr<weld::MetricSpinButton> m_xBulRelSizeMF;
    std::unique_ptr<weld::Label> m_xAllLevelFT;
    std::unique_ptr<weld::SpinButton> m_xAllLevelNF;
    std::unique_ptr<weld::CheckButton> m_xIsLegalCB;
    std::unique_ptr<weld::Label> m_xStartFT;
    std::unique_ptr<weld::SpinButton> m_xStartED;
    std::unique_ptr<weld::Label> m_xBulletFT;
@@ -273,6 +274,7 @@ class SvxNumOptionsTabPage : public SfxTabPage
    DECL_LINK(EditModifyHdl_Impl, weld::Entry&, void);
    DECL_LINK(SpinModifyHdl_Impl, weld::SpinButton&, void);
    DECL_LINK(AllLevelHdl_Impl, weld::SpinButton&, void);
    DECL_LINK(IsLegalHdl_Impl, weld::Toggleable&, void);
    DECL_LINK(OrientHdl_Impl, weld::ComboBox&, void);
    DECL_LINK(SameLevelHdl_Impl, weld::Toggleable&, void);
    DECL_LINK(BulColorHdl_Impl, ColorListBox&, void);
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 2179ad2..45ee580 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -1037,6 +1037,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC
    , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT))
    , m_xAllLevelFT(m_xBuilder->weld_label("sublevelsft"))
    , m_xAllLevelNF(m_xBuilder->weld_spin_button("sublevels"))
    , m_xIsLegalCB(m_xBuilder->weld_check_button("islegal"))
    , m_xStartFT(m_xBuilder->weld_label("startatft"))
    , m_xStartED(m_xBuilder->weld_spin_button("startat"))
    , m_xBulletFT(m_xBuilder->weld_label("bulletft"))
@@ -1074,6 +1075,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC
    m_xPrefixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    m_xSuffixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
    m_xAllLevelNF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
    m_xIsLegalCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, IsLegalHdl_Impl));
    m_xOrientLB->connect_changed(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
    m_xSameLevelCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
    m_xBulRelSizeMF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
@@ -1271,6 +1273,7 @@ void    SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
    bool bAllLevel = bContinuous && !bHTMLMode;
    m_xAllLevelFT->set_visible(bAllLevel);
    m_xAllLevelNF->set_visible(bAllLevel);
    m_xIsLegalCB->set_visible(bAllLevel);

    m_xAllLevelsFrame->set_visible(bContinuous);

@@ -1334,6 +1337,8 @@ void SvxNumOptionsTabPage::InitControls()
    bool bSameBulColor  = true;
    bool bSameBulRelSize= true;

    TriState isLegal = TRISTATE_INDET;

    const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
    OUString sFirstCharFmt;
    sal_Int16 eFirstOrient = text::VertOrientation::NONE;
@@ -1358,6 +1363,7 @@ void SvxNumOptionsTabPage::InitControls()
                eFirstOrient = aNumFmtArr[i]->GetVertOrient();
                if(bShowBitmap)
                    aFirstSize = aNumFmtArr[i]->GetGraphicSize();
                isLegal = aNumFmtArr[i]->GetIsLegal() ? TRISTATE_TRUE : TRISTATE_FALSE;
            }
            if( i > nLvl)
            {
@@ -1367,6 +1373,8 @@ void SvxNumOptionsTabPage::InitControls()
                bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
                bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
                bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
                if (aNumFmtArr[i]->GetIsLegal() != aNumFmtArr[nLvl]->GetIsLegal())
                    isLegal = TRISTATE_INDET;
                bSameCharFmt    &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName();
                bSameVOrient    &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
                if(bShowBitmap && bSameSize)
@@ -1439,6 +1447,9 @@ void SvxNumOptionsTabPage::InitControls()
        m_xAllLevelNF->set_text("");
    }

    m_xIsLegalCB->set_state(isLegal);
    m_xIsLegalCB->set_sensitive(!m_xSameLevelCB->get_active());

    if(bBullRelSize)
    {
        if(bSameBulRelSize)
@@ -1518,6 +1529,7 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType )
    bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
    m_xAllLevelFT->set_visible(bAllLevel);
    m_xAllLevelNF->set_visible(bAllLevel);
    m_xIsLegalCB->set_visible(bAllLevel);

    m_xStartFT->set_visible(!(bBullet||bBitmap));
    m_xStartED->set_visible(!(bBullet||bBitmap));
@@ -1627,6 +1639,21 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void)
    SetModified();
}

IMPL_LINK(SvxNumOptionsTabPage, IsLegalHdl_Impl, weld::Toggleable&, rBox, void)
{
    bool bSet = rBox.get_active();
    for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    {
        if (nActNumLvl & (sal_uInt16(1) << i))
        {
            SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
            aNumFmt.SetIsLegal(bSet);
            pActNum->SetLevel(i, aNumFmt);
        }
    }
    SetModified();
}

IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void)
{
    OUString sSelectStyle;
diff --git a/cui/uiconfig/ui/numberingoptionspage.ui b/cui/uiconfig/ui/numberingoptionspage.ui
index adb0ea9..82ea810 100644
--- a/cui/uiconfig/ui/numberingoptionspage.ui
+++ b/cui/uiconfig/ui/numberingoptionspage.ui
@@ -209,6 +209,25 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkCheckButton" id="islegal">
                        <property name="label" translatable="yes" context="numberingoptionspage|islegal">All sublevels Arabic</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">False</property>
                        <property name="use_underline">True</property>
                        <property name="draw_indicator">True</property>
                        <child internal-child="accessible">
                          <object class="AtkObject" id="islegal-atkobject">
                            <property name="AtkObject::accessible-description" translatable="yes" context="numberingoptionspage|extended_tip|islegal">Use Arabic numerals for all sublevels ("Legal" numbering).</property>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">8</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkSpinButton" id="startat">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
@@ -266,7 +285,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">11</property>
                        <property name="top_attach">12</property>
                      </packing>
                    </child>
                    <child>
@@ -280,7 +299,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">12</property>
                        <property name="top_attach">13</property>
                      </packing>
                    </child>
                    <child>
@@ -299,7 +318,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">12</property>
                        <property name="top_attach">13</property>
                      </packing>
                    </child>
                    <child>
@@ -314,7 +333,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">13</property>
                        <property name="top_attach">14</property>
                      </packing>
                    </child>
                    <child>
@@ -333,7 +352,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">13</property>
                        <property name="top_attach">14</property>
                      </packing>
                    </child>
                    <child>
@@ -352,7 +371,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">14</property>
                        <property name="top_attach">15</property>
                      </packing>
                    </child>
                    <child>
@@ -366,7 +385,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">15</property>
                        <property name="top_attach">16</property>
                      </packing>
                    </child>
                    <child>
@@ -393,7 +412,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">15</property>
                        <property name="top_attach">16</property>
                      </packing>
                    </child>
                    <child>
@@ -416,7 +435,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">11</property>
                        <property name="top_attach">12</property>
                      </packing>
                    </child>
                    <child>
@@ -488,7 +507,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">9</property>
                        <property name="top_attach">10</property>
                      </packing>
                    </child>
                    <child>
@@ -501,7 +520,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">8</property>
                        <property name="top_attach">9</property>
                      </packing>
                    </child>
                    <child>
@@ -518,7 +537,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">10</property>
                        <property name="top_attach">11</property>
                      </packing>
                    </child>
                    <child>
@@ -535,7 +554,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">9</property>
                        <property name="top_attach">10</property>
                      </packing>
                    </child>
                    <child>
@@ -549,7 +568,7 @@
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">10</property>
                        <property name="top_attach">11</property>
                      </packing>
                    </child>
                    <child>