editeng/source/misc/svxacorr.cxx                          |   11 ++-
 solenv/gbuild/UITest.mk                                   |    2 
 sw/Module_sw.mk                                           |    1 
 sw/UITest_writer_tests8.mk                                |   20 +++++++
 sw/qa/uitest/writer_tests8/tdf156243.py                   |   39 ++++++++++++++
 sw/qa/uitest/writer_tests8_data/registrymodifications.xcu |   12 ++++
 6 files changed, 79 insertions(+), 6 deletions(-)

New commits:
commit b6e273aaaf597b60f78c1dd3db8676eea958a9f5
Author:     Matt K <matt...@gmail.com>
AuthorDate: Thu Nov 23 21:47:34 2023 -0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Nov 25 12:41:49 2023 +0100

    tdf#156243 Fix off-by-one bug for autocorrect
    
    This change removes the "-1" from the code
    that applies the autocorrection so that the entire
    string to be autocorrected is replaced, instead
    of leaving off the last character.  Also,
    the starting character of the string is
    preserved (i.e. non-bold if changing to bold)
    by adding 1 to the start position; this is
    for the case when the user cancels the
    autocorrect dialog.
    
    Change-Id: Ibe500a1ba0ca5b12ec9c918b51353074b8dd12ec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154685
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 094ee2130f67..4c4b6883f247 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -833,37 +833,38 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& 
rDoc, const OUString& rT
         // of an empty hint in SetAttr which would be removed by Delete
         // (fdo#62536, AUTOFMT in Writer)
         rDoc.Delete( nEndPos, nEndPos + 1 );
-        rDoc.Delete( nFndPos, nFndPos + 1 );
+
         // Span the Attribute over the area
         // the end.
         if( '*' == cInsChar )           // Bold
         {
             SvxWeightItem aSvxWeightItem( WEIGHT_BOLD, SID_ATTR_CHAR_WEIGHT );
-            rDoc.SetAttr( nFndPos, nEndPos - 1,
+            rDoc.SetAttr( nFndPos + 1, nEndPos,
                           SID_ATTR_CHAR_WEIGHT,
                           aSvxWeightItem);
         }
         else if( '/' == cInsChar )           // Italic
         {
             SvxPostureItem aSvxPostureItem( ITALIC_NORMAL, 
SID_ATTR_CHAR_POSTURE );
-            rDoc.SetAttr( nFndPos, nEndPos - 1,
+            rDoc.SetAttr( nFndPos + 1, nEndPos,
                           SID_ATTR_CHAR_POSTURE,
                           aSvxPostureItem);
         }
         else if( '-' == cInsChar )           // Strikeout
         {
             SvxCrossedOutItem aSvxCrossedOutItem( STRIKEOUT_SINGLE, 
SID_ATTR_CHAR_STRIKEOUT );
-            rDoc.SetAttr( nFndPos, nEndPos - 1,
+            rDoc.SetAttr( nFndPos + 1, nEndPos,
                           SID_ATTR_CHAR_STRIKEOUT,
                           aSvxCrossedOutItem);
         }
         else                            // Underline
         {
             SvxUnderlineItem aSvxUnderlineItem( LINESTYLE_SINGLE, 
SID_ATTR_CHAR_UNDERLINE );
-            rDoc.SetAttr( nFndPos, nEndPos - 1,
+            rDoc.SetAttr( nFndPos + 1, nEndPos,
                           SID_ATTR_CHAR_UNDERLINE,
                           aSvxUnderlineItem);
         }
+        rDoc.Delete( nFndPos, nFndPos + 1 );
     }
 
     return -1 != nFndPos;
diff --git a/solenv/gbuild/UITest.mk b/solenv/gbuild/UITest.mk
index 5859b9e56de4..65bc37c1d1bf 100644
--- a/solenv/gbuild/UITest.mk
+++ b/solenv/gbuild/UITest.mk
@@ -64,7 +64,7 @@ else
                $(if $(gb_UITest__interactive),, \
                    rm -fr $@.core && mkdir -p $(dir $(call 
gb_UITest_get_target,$*))user/ && mkdir $@.core && cd $@.core && ) \
                $(if $(gb_UITest_use_config), \
-                   cp $(gb_UITest_use_config) $(dir $(call 
gb_UITest_get_target,$*))user/. && ) \
+                   cp $(gb_UITest_use_config) $(dir $(call 
gb_UITest_get_target,$*))user/user && ) \
                $(call gb_CppunitTest_coredumpctl_setup,$@) \
                ($(gb_UITest_PRECOMMAND) \
                $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 9ef1c80c84f7..22cea818178a 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -212,6 +212,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\
        UITest_writer_tests5 \
        UITest_writer_tests6 \
        UITest_writer_tests7 \
+       UITest_writer_tests8 \
        UITest_sw_table \
        UITest_sw_chart \
        UITest_sw_fieldDialog \
diff --git a/sw/UITest_writer_tests8.mk b/sw/UITest_writer_tests8.mk
new file mode 100644
index 000000000000..a33fdedbe255
--- /dev/null
+++ b/sw/UITest_writer_tests8.mk
@@ -0,0 +1,20 @@
+# 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/.
+#
+
+$(eval $(call  gb_UITest_UITest,writer_tests8))
+
+$(eval $(call gb_UITest_add_modules,writer_tests8,$(SRCDIR)/sw/qa/uitest,\
+       writer_tests8/ \
+))
+
+$(eval $(call gb_UITest_set_defs,writer_tests8, \
+    TDOC="$(SRCDIR)/sw/qa/uitest/data" \
+))
+
+$(eval $(call 
gb_UITest_use_configuration,writer_tests8,$(SRCDIR)/sw/qa/uitest/writer_tests8_data/registrymodifications.xcu))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/qa/uitest/writer_tests8/tdf156243.py 
b/sw/qa/uitest/writer_tests8/tdf156243.py
new file mode 100644
index 000000000000..fc4eecffdb7c
--- /dev/null
+++ b/sw/qa/uitest/writer_tests8/tdf156243.py
@@ -0,0 +1,39 @@
+# -*- 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
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import type_text
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf156243(UITestCase):
+
+   def test_tdf156243_Autocorrect_dialog(self):
+        with self.ui_test.create_doc_in_start_center("writer") as document:
+            xWriterDoc = self.xUITest.getTopFocusWindow()
+            xWriterEdit = xWriterDoc.getChild("writer_edit")
+            type_text(xWriterEdit, "*ab*")
+            with 
self.ui_test.execute_dialog_through_command(".uno:AutoFormatRedlineApply", 
close_button="close") as xAutoFmt:
+                xAcceptAll = xAutoFmt.getChild("acceptall")
+                xAcceptAll.executeAction("CLICK", tuple())
+            xWriterEdit.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"SHIFT+LEFT"}))
+            with 
self.ui_test.execute_dialog_through_command(".uno:FontDialog", 
close_button="cancel") as xDialog:
+                xTabs = xDialog.getChild("tabcontrol")
+                select_pos(xTabs, "0")
+                xweststylelbcjk = xDialog.getChild("cbWestStyle")
+                self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], 
"Bold")
+            self.xUITest.executeCommand(".uno:GoLeft")
+            with 
self.ui_test.execute_dialog_through_command(".uno:FontDialog", 
close_button="cancel") as xDialog:
+                xTabs = xDialog.getChild("tabcontrol")
+                select_pos(xTabs, "0")
+                xweststylelbcjk = xDialog.getChild("cbWestStyle")
+                self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], 
"Bold")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/writer_tests8_data/registrymodifications.xcu 
b/sw/qa/uitest/writer_tests8_data/registrymodifications.xcu
new file mode 100755
index 000000000000..1d5be49fdcd6
--- /dev/null
+++ b/sw/qa/uitest/writer_tests8_data/registrymodifications.xcu
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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/.
+ *
+-->
+<oor:items xmlns:oor="http://openoffice.org/2001/registry"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+<item 
oor:path="/org.openoffice.Office.Writer/AutoFunction/Format/Option"><prop 
oor:name="ChangeUnderlineWeight" oor:op="fuse"><value>true</value></prop></item>
+</oor:items>

Reply via email to