From d08e41379d39a3b552c2c8a34fe1c4849bb80bc9 Mon Sep 17 00:00:00 2001 From: László Németh Date: Tue, 1 Dec 2020 15:12:54 +0100 Subject: tdf#66043 sw: fix spell checking of word with deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correct words were underlined as spelling mistakes, if they contained tracked deletions, related to the unwanted CH_TXTATR_INWORD characters (result of removing tracked deletions) at calling spell checking API functions. Fix it by checking the "invalid" words without CH_TXTATR_INWORD characters, too. Change-Id: I6d8a8d619a571dfb613991cb8cf67faab57de4c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106988 Tested-by: László Németh Reviewed-by: László Németh --- sw/qa/uitest/data/tdf66043.fodt | 35 +++++++++++++++++++++++++++++++ sw/qa/uitest/writer_tests4/spellDialog.py | 33 ++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 sw/qa/uitest/data/tdf66043.fodt (limited to 'sw/qa') diff --git a/sw/qa/uitest/data/tdf66043.fodt b/sw/qa/uitest/data/tdf66043.fodt new file mode 100644 index 000000000000..5fcdde71d4ae --- /dev/null +++ b/sw/qa/uitest/data/tdf66043.fodt @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + Unknown Author + 2020-12-01T12:49:53 + + o + + + + + + Unknown Author + 2020-12-01T12:50:00 + + a + + + + good baad eeend + + + + diff --git a/sw/qa/uitest/writer_tests4/spellDialog.py b/sw/qa/uitest/writer_tests4/spellDialog.py index e678afea53e9..3b9e4c31f3da 100644 --- a/sw/qa/uitest/writer_tests4/spellDialog.py +++ b/sw/qa/uitest/writer_tests4/spellDialog.py @@ -5,6 +5,8 @@ # import re +import org.libreoffice.unotest +import pathlib from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict @@ -12,6 +14,9 @@ from uitest.uihelper.common import get_state_as_dict from libreoffice.linguistic.linguservice import get_spellchecker from com.sun.star.lang import Locale +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + class SpellingAndGrammarDialog(UITestCase): def is_supported_locale(self, language, country): @@ -99,4 +104,30 @@ frog, dogg, catt""" output_text = document.Text.getString().replace('\r\n', '\n') self.assertTrue(re.match(self.TDF46852_REGEX, output_text)) - + + def test_tdf66043(self): + writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf66043.fodt")) + document = self.ui_test.get_component() + # Step 1: Initiate spellchecking, and make sure "Check grammar" is + # unchecked + spell_dialog = self.launch_dialog() + checkgrammar = spell_dialog.getChild('checkgrammar') + if get_state_as_dict(checkgrammar)['Selected'] == 'true': + checkgrammar.executeAction('CLICK', ()) + self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') + + # Step 2: Click on "Correct all" for each misspelling + # prompt until end of document is reached. + changeall = spell_dialog.getChild('changeall') + changeall.executeAction("CLICK", ()) + + xCloseBtn = spell_dialog.getChild("close") + xCloseBtn.executeAction("CLICK", tuple()) + + output_text = document.Text.getString().replace('\r\n', '\n') + # This was "gooodgood baaad eeend" ("goood" is a deletion, + # "good" is an insertion by fixing the first misspelling), + # but now "goood" is not a misspelling because it is accepted + # correctly without the redline containing a deleted "o" + self.assertTrue(output_text == 'goood baaadbaaed eeend') + -- cgit