editeng/source/misc/swafopt.cxx | 2 officecfg/registry/schema/org/openoffice/Office/Writer.xcs | 2 sw/qa/uitest/data/tdf156165.odt |binary sw/qa/uitest/writer_tests/tdf156165.py | 80 +++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-)
New commits: commit e50ec4d8ddca5dfe6a4f329298c0bae4edc5e41c Author: Baole Fang <baole.f...@gmail.com> AuthorDate: Thu Jul 6 12:03:31 2023 -0400 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Wed Aug 2 00:36:44 2023 +0200 tdf#156165: Fix replace custom styles while typing Originally, Replace Custom Styles changes styles to text body by entering BuiltText. Since styles change to text body is removed from BuiltTest, it is converted independently. Now, conversion is applied even during typing because m_aFlags.bChgUserColl is true (its default value) during typing. Therefore, its default value is changed to false. Change-Id: I8ce067b311922b5e1bdcd84036229c369b50a977 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154144 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit e26aeb882dd236adf19679d5df9b7ba5da1ed226) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155043 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/editeng/source/misc/swafopt.cxx b/editeng/source/misc/swafopt.cxx index f6de4098d2e4..f5f79a45be97 100644 --- a/editeng/source/misc/swafopt.cxx +++ b/editeng/source/misc/swafopt.cxx @@ -27,7 +27,6 @@ SvxSwAutoFormatFlags::SvxSwAutoFormatFlags() bAutoCorrect = bCapitalStartSentence = bCapitalStartWord = - bChgUserColl = bChgEnumNum = bAddNonBrkSpace = bChgOrdinalNumber = @@ -42,6 +41,7 @@ SvxSwAutoFormatFlags::SvxSwAutoFormatFlags() bAFormatByInpDelSpacesAtSttEnd = bAFormatByInpDelSpacesBetweenLines = true; + bChgUserColl = bReplaceStyles = bDelEmptyNode = bWithRedlining = diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs index 0f684bb2eea9..cfa36e974ca8 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs @@ -4235,7 +4235,7 @@ <desc>Specifies whether user-defined styles applied in the document are replaced by predefined text document styles.</desc> <label>Replace user-defined styles</label> </info> - <value>true</value> + <value>false</value> </prop> <prop oor:name="CombineParagraphs" oor:type="xs:boolean" oor:nillable="false"> <!-- UIHints: Tools AutoCorrect/AutoFormat Options Combine single line paragraphs if length greater --> diff --git a/sw/qa/uitest/data/tdf156165.odt b/sw/qa/uitest/data/tdf156165.odt new file mode 100644 index 000000000000..aabcfef91499 Binary files /dev/null and b/sw/qa/uitest/data/tdf156165.odt differ diff --git a/sw/qa/uitest/writer_tests/tdf156165.py b/sw/qa/uitest/writer_tests/tdf156165.py new file mode 100644 index 000000000000..69d1928bb8ce --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf156165.py @@ -0,0 +1,80 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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 get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +from time import sleep + +class tdf156165(UITestCase): + + def test_tdf156165(self): + with self.ui_test.load_file(get_url_for_data_file("tdf156165.odt")): + xMainWindow = self.xUITest.getTopFocusWindow() + writer_edit = xMainWindow.getChild("writer_edit") + style=xMainWindow.getChild('applystyle') + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + options=xDialog.getChild('list') + checkbox=options.getChild("16") + self.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox)["Text"]) + + # Replace Custom Styles is default to be false + self.assertEqual("false", get_state_as_dict(checkbox)["IsChecked"]) + + # Replace Custom Styles when applying manully with it disabled, should not change style + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.xUITest.executeCommand(".uno:AutoFormatApply") + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") + + # Replace Custom Styles when typing with it disabled, should not change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + options=xDialog.getChild('list') + checkbox=options.getChild("16") + self.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox)["Text"]) + + # set Replace Custom Styles to True + checkbox.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(checkbox)["IsChecked"]) + + # Replace Custom Styles when applying manully with it enabled, should change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.xUITest.executeCommand(".uno:AutoFormatApply") + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "Body Text") + + # Replace Custom Styles when typing with it enabled, should not change style + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"})) + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + sleep(1) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line + writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"})) + self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: