cui/source/tabpages/numpages.cxx | 2 sw/qa/uitest/writer_tests7/tdf144439.py | 111 ++++++++++++++++++++++++++++++++ sw/source/ui/misc/outline.cxx | 7 -- 3 files changed, 115 insertions(+), 5 deletions(-)
New commits: commit a913789e2f59bd38fd7c2f5e6325846f4365b696 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Fri Sep 24 15:57:07 2021 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Oct 5 10:19:15 2021 +0200 tdf#144439: generate list format string on level change Changed values for included upper levels should cause generation of new list format string. Same applies to outlines editing. Change-Id: I90e19d6b5169f68c83ae3e55ec41b9016623d8ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122590 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123073 diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index 8c14c9607fe1..5cad832dba79 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -1616,6 +1616,8 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void) { SvxNumberFormat aNumFmt(pActNum->GetLevel(e)); aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), int(e + 1))) ); + // Set the same prefix/suffix to generate list format with changed IncludedUpperLevels + aNumFmt.SetListFormat(aNumFmt.GetPrefix(), aNumFmt.GetSuffix(), e); pActNum->SetLevel(e, aNumFmt); } nMask <<= 1; diff --git a/sw/qa/uitest/writer_tests7/tdf144439.py b/sw/qa/uitest/writer_tests7/tdf144439.py new file mode 100644 index 000000000000..21992c1cb859 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf144439.py @@ -0,0 +1,111 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import type_text, select_by_text, select_pos, get_state_as_dict + +class tdf144439(UITestCase): + + def test_tdf144439_list(self): + self.ui_test.create_doc_in_start_center("writer") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + # Enter some text + type_text(xWriterEdit, "List item") + # Apply numbering + self.xUITest.executeCommand(".uno:DefaultNumbering") + # Increase level up to 2 + self.xUITest.executeCommand(".uno:IncrementIndent") + + self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") + # Select custom tab + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") + + # Select numbering + xNumFmt = xDialog.getChild("numfmtlb") + select_by_text(xNumFmt, "1, 2, 3, ...") + + # Increase number of sublevels to show + xSubLevels = xDialog.getChild("sublevels") + xSubLevels.executeAction("UP", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + document = self.ui_test.get_component() + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "List item") + self.assertEqual(Para1.getPropertyValue("ListLabelString"), "1.1.") + + self.ui_test.close_doc() + + def test_tdf144439_outline(self): + self.ui_test.create_doc_in_start_center("writer") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + # Enter some text + type_text(xWriterEdit, "Outline2") + # Apply outline level 2 (as a style) + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%202&FamilyName:string=ParagraphStyles") + + self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") + # Select level "2" + xDialog = self.xUITest.getTopFocusWindow() + xLevel = xDialog.getChild("level") + xLevel2 = xLevel.getChild("1") + xLevel2.executeAction("SELECT", tuple()) + self.assertEqual("2", get_state_as_dict(xLevel)['SelectEntryText']) + + # Select custom tab + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Select numbering + xNumFmt = xDialog.getChild("numbering") + select_by_text(xNumFmt, "1, 2, 3, ...") + + # Increase number of sublevels to show + xSubLevels = xDialog.getChild("sublevelsnf") + xSubLevels.executeAction("UP", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + document = self.ui_test.get_component() + Paragraphs = document.Text.createEnumeration() + Para1 = Paragraphs.nextElement() + self.assertEqual(Para1.String, "Outline2") + # Well, this looks strange, but we asked to show 1 & 2 levels and 1st is without numbering + self.assertEqual(Para1.getPropertyValue("ListLabelString"), ".1") + + self.ui_test.execute_dialog_through_command(".uno:ChapterNumberingDialog") + # Select level "1" + xDialog = self.xUITest.getTopFocusWindow() + xLevel = xDialog.getChild("level") + xLevel2 = xLevel.getChild("0") + xLevel2.executeAction("SELECT", tuple()) + self.assertEqual("1", get_state_as_dict(xLevel)['SelectEntryText']) + + # Select custom tab + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Select numbering + xNumFmt = xDialog.getChild("numbering") + select_by_text(xNumFmt, "1, 2, 3, ...") + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + self.assertEqual(Para1.String, "Outline2") + self.assertEqual(Para1.getPropertyValue("ListLabelString"), "1.1") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx index ebac78812a6c..fd8bb3d2736a 100644 --- a/sw/source/ui/misc/outline.cxx +++ b/sw/source/ui/misc/outline.cxx @@ -561,11 +561,8 @@ IMPL_LINK(SwOutlineSettingsTabPage, ToggleComplete, weld::SpinButton&, rEdit, vo SwNumFormat aNumFormat(pNumRule->Get(i)); aNumFormat.SetIncludeUpperLevels( std::min( static_cast<sal_uInt8>(rEdit.get_value()), static_cast<sal_uInt8>(i + 1)) ); - if (aNumFormat.HasListFormat()) - { - aNumFormat.SetListFormat(); // clear custom format - m_xAllLevelNF->set_min(1); - } + // Set the same prefix/suffix to generate list format with changed IncludedUpperLevels + aNumFormat.SetListFormat(aNumFormat.GetPrefix(), aNumFormat.GetSuffix(), i); pNumRule->Set(i, aNumFormat); } nMask <<= 1;