sw/source/ui/chrdlg/numpara.cxx | 59 +++++++++++++++++++++++++++++ sw/source/uibase/inc/numpara.hxx | 3 + sw/uiconfig/swriter/ui/numparapage.ui | 68 +++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 3 deletions(-)
New commits: commit d6851533713850b311c5c8121d91dc96ab94286c Author: Justin Luth <jl...@mail.com> AuthorDate: Tue Feb 28 20:43:27 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Mar 1 21:43:10 2023 +0000 tdf#62032 sw: let paragraph UI set List Level In order for this to be at all useful, we need to be slightly confusing to the user by equating both of Outline Level's "Body Text" and "1" with List Level 1. So, while outline levels can be "turned off" with "Body Text", a user cannot "turn off" a list level, even though the listbox has the choice "same as outline level". The way to turn off the list is to pick "No List" in the other list box. That situation (Outline = Body Text, ListLevel = 1) is the default situation, and so if we don't make that connection, then the whole intention of STRONGLY advocating for keeping the two values in sync will be lost. Note that both selecting "No list" or changing list level in a style does not have immediate effect. It only applies when the style is assigned, not modified. (I assume this is because of internal auto-styles which are not being updated when the underlying style changes?) [Because of this "strangeness" a follow-up commit will make this an experimental feature.] Change-Id: Ib6a47b3265ccf71f45a43ce6f10b780b995c231d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148027 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx index fbe38e773eaa..7392a3f06d21 100644 --- a/sw/source/ui/chrdlg/numpara.cxx +++ b/sw/source/ui/chrdlg/numpara.cxx @@ -45,6 +45,8 @@ SwParagraphNumTabPage::SwParagraphNumTabPage(weld::Container* pPage, weld::Dialo , m_xNumberStyleBX(m_xBuilder->weld_widget("boxNUMBER_STYLE")) , m_xNumberStyleLB(m_xBuilder->weld_combo_box("comboLB_NUMBER_STYLE")) , m_xEditNumStyleBtn(m_xBuilder->weld_button("editnumstyle")) + , m_xListLvBX(m_xBuilder->weld_widget("boxLIST_LEVEL")) + , m_xListLvLB(m_xBuilder->weld_combo_box("comboLB_LIST_LEVEL")) , m_xNewStartCB(m_xBuilder->weld_check_button("checkCB_NEW_START")) , m_xNewStartBX(m_xBuilder->weld_widget("boxNEW_START")) , m_xNewStartNumberCB(m_xBuilder->weld_check_button("checkCB_NUMBER_NEW_START")) @@ -105,6 +107,32 @@ bool SwParagraphNumTabPage::FillItemSet( SfxItemSet* rSet ) pOutlineLv->SetValue( aOutlineLv ); rSet->Put(std::move(pOutlineLv)); m_bModified = true; + + // Does List Level need to be set to be the same as Outline Level? + if (!m_xListLvLB->get_active() && m_xListLvBX->get_visible() + && !m_xListLvLB->get_value_changed_from_saved()) + { + sal_Int16 nListLevel = std::max<sal_Int16>(1, aOutlineLv); + --nListLevel; // Outline Level is 1 based. List Level is zero based. + rSet->Put(SfxInt16Item(RES_PARATR_LIST_LEVEL, nListLevel)); + } + } + } + + if (m_xListLvLB->get_value_changed_from_saved()) + { + if (m_xListLvBX->get_visible() && GetOldItem(*rSet, RES_PARATR_LIST_LEVEL)) + { + sal_Int16 nListLevel = m_xListLvLB->get_active(); + // Does List Level need to be set to be the same as Outline Level? + if (!nListLevel) + { + nListLevel = std::max<sal_Int16>(1, m_xOutlineLvLB->get_active()); + } + --nListLevel; // List Level is zero based, but both listboxes are 1-based. + + rSet->Put(SfxInt16Item(RES_PARATR_LIST_LEVEL, nListLevel)); + m_bModified = true; } } @@ -152,6 +180,7 @@ void SwParagraphNumTabPage::ChangesApplied() { m_xOutlineLvLB->save_value(); m_xNumberStyleLB->save_value(); + m_xListLvLB->save_value(); m_xNewStartCB->save_state(); m_xNewStartNumberCB->save_state(); m_xCountParaCB->save_state(); @@ -165,9 +194,10 @@ void SwParagraphNumTabPage::Reset(const SfxItemSet* rSet) SfxItemState eItemState = rSet->GetItemState( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) ); + sal_Int16 nOutlineLv = 1; // 0 is Text Body, 1 is level 1 if( eItemState >= SfxItemState::DEFAULT ) { - sal_Int16 nOutlineLv = rSet->Get( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) ).GetValue(); + nOutlineLv = rSet->Get( GetWhich(SID_ATTR_PARA_OUTLINE_LEVEL) ).GetValue(); m_xOutlineLvLB->set_active(nOutlineLv) ; } else @@ -176,6 +206,26 @@ void SwParagraphNumTabPage::Reset(const SfxItemSet* rSet) } m_xOutlineLvLB->save_value(); + eItemState = rSet->GetItemState(RES_PARATR_LIST_LEVEL); + if (eItemState >= SfxItemState::DEFAULT) + { + sal_Int16 nListLevel = rSet->Get(RES_PARATR_LIST_LEVEL).GetValue(); // 0 is level 1 + // Although listLevel doesn't have outline's "Text Body" level, treat it the same as level 1 + // so that if the outline level is either 0 or 1, it is considered equal to list level 1. + // This is a rather crucial discrepancy - otherwise the user will rarely see + // list level using the special "Same as outline level, + // and the highly desirable state of keeping the two in sync will rarely be achieved. + if ((!nOutlineLv && !nListLevel) || nListLevel == nOutlineLv - 1) + m_xListLvLB->set_active(0); // highly encourage using "Same as outline level" + else + m_xListLvLB->set_active(nListLevel + 1); + } + else + { + m_xListLvBX->hide(); + } + m_xListLvLB->save_value(); + eItemState = rSet->GetItemState( GetWhich(SID_ATTR_PARA_NUMRULE) ); if( eItemState >= SfxItemState::DEFAULT ) @@ -268,6 +318,7 @@ void SwParagraphNumTabPage::DisableNumbering() { m_xNumberStyleBX->set_sensitive(false); m_xNumberStyleBX->set_tooltip_text( SwResId(STR_OUTLINENUMBERING_DISABLED) ); + m_xListLvBX->set_sensitive(false); } void SwParagraphNumTabPage::EnableNewStart() @@ -297,9 +348,15 @@ IMPL_LINK_NOARG(SwParagraphNumTabPage, EditNumStyleSelectHdl_Impl, weld::ComboBo int numSelectPos = m_xNumberStyleLB->get_active(); // 0 is "None" and -1 is unselected state and a "pseudo" is uneditable "Chapter Numbering" if (numSelectPos == 0 || numSelectPos == -1 || m_xNumberStyleLB->get_active_id() == "pseudo") + { m_xEditNumStyleBtn->set_sensitive(false); + m_xListLvBX->set_sensitive(false); + } else + { m_xEditNumStyleBtn->set_sensitive(true); + m_xListLvBX->set_sensitive(true); + } } IMPL_LINK_NOARG(SwParagraphNumTabPage, EditNumStyleHdl_Impl, weld::Button&, void) diff --git a/sw/source/uibase/inc/numpara.hxx b/sw/source/uibase/inc/numpara.hxx index 3c34e05d5a49..f6da0b9f7174 100644 --- a/sw/source/uibase/inc/numpara.hxx +++ b/sw/source/uibase/inc/numpara.hxx @@ -38,6 +38,9 @@ class SwParagraphNumTabPage final : public SfxTabPage std::unique_ptr<weld::ComboBox> m_xNumberStyleLB; std::unique_ptr<weld::Button> m_xEditNumStyleBtn; + std::unique_ptr<weld::Widget> m_xListLvBX; + std::unique_ptr<weld::ComboBox> m_xListLvLB; + std::unique_ptr<weld::CheckButton> m_xNewStartCB; std::unique_ptr<weld::Widget> m_xNewStartBX; std::unique_ptr<weld::CheckButton> m_xNewStartNumberCB; diff --git a/sw/uiconfig/swriter/ui/numparapage.ui b/sw/uiconfig/swriter/ui/numparapage.ui index 474c74e671aa..fb6d0d8d0438 100644 --- a/sw/uiconfig/swriter/ui/numparapage.ui +++ b/sw/uiconfig/swriter/ui/numparapage.ui @@ -192,6 +192,68 @@ <property name="position">0</property> </packing> </child> + <child> + <object class="GtkBox" id="boxLIST_LEVEL"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <child> + <object class="GtkLabel" id="labelFT_LIST_LEVEL"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="numparapagedlg|labelFT_LIST_LEVEL">List level:</property> + <property name="xalign">0</property> + <accessibility> + <relation type="label-for" target="comboLB_LIST_LEVEL"/> + </accessibility> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="comboLB_LIST_LEVEL"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Assigned List Level</property> + <items> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Same as outline level</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 1</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 2</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 3</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 4</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 5</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 6</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 7</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 8</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 9</item> + <item translatable="yes" context="numparapage|comboLB_LIST_LEVEL">Level 10</item> + </items> + <accessibility> + <relation type="labelled-by" target="labelFT_LIST_LEVEL"/> + </accessibility> + <child internal-child="accessible"> + <object class="AtkObject" id="comboLB_LIST_LEVEL-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="numparapage|extended_tip|comboLB_LIST_LEVEL">Assigns a list level from 1 to 10 to the selected paragraphs or Paragraph Style.</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">6</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkCheckButton" id="checkCB_NEW_START"> <property name="label" translatable="yes" context="numparapage|checkCB_NEW_START">R_estart numbering at this paragraph</property> @@ -212,7 +274,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">3</property> </packing> </child> <child> @@ -281,7 +343,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">4</property> </packing> </child> </object> @@ -452,6 +514,7 @@ <widgets> <widget name="labelFT_OUTLINE_LEVEL"/> <widget name="labelFT_NUMBER_STYLE"/> + <widget name="labelFT_LIST_LEVEL"/> <widget name="box4"/> <widget name="box3"/> </widgets> @@ -460,6 +523,7 @@ <widgets> <widget name="comboLB_OUTLINE_LEVEL"/> <widget name="boxSubNumber_Style"/> + <widget name="comboLB_LIST_LEVEL"/> </widgets> </object> </interface>