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.kaganski@collabora.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)) \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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:
|
||||
@@ -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:
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user