[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 3 08:58:20 UTC 2020


 sw/qa/uitest/data/tdf66043.fodt           |   35 ++++++++++++++++++++++++++++++
 sw/qa/uitest/writer_tests4/spellDialog.py |   33 +++++++++++++++++++++++++++-
 sw/source/core/txtnode/txtedt.cxx         |   15 ++++++++++--
 3 files changed, 79 insertions(+), 4 deletions(-)

New commits:
commit b4707a331d8f28c87e3e48709937da1260ace596
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Dec 1 15:12:54 2020 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Dec 3 09:57:48 2020 +0100

    tdf#66043 sw: fix spell checking of word with deletion
    
    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 <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit d08e41379d39a3b552c2c8a34fe1c4849bb80bc9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107097
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <office:styles>
+  <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+  <style:default-style style:family="paragraph">
+   <style:text-properties fo:language="en" fo:country="US"/>
+  </style:default-style>
+ </office:styles>
+  <office:body>
+    <office:text>
+      <text:tracked-changes>
+        <text:changed-region xml:id="ct94277392414656" text:id="ct94277392414656">
+          <text:deletion>
+            <office:change-info>
+              <dc:creator>Unknown Author</dc:creator>
+              <dc:date>2020-12-01T12:49:53</dc:date>
+            </office:change-info>
+            <text:p text:style-name="P1">o</text:p>
+          </text:deletion>
+        </text:changed-region>
+        <text:changed-region xml:id="ct94277392490096" text:id="ct94277392490096">
+          <text:deletion>
+            <office:change-info>
+              <dc:creator>Unknown Author</dc:creator>
+              <dc:date>2020-12-01T12:50:00</dc:date>
+            </office:change-info>
+            <text:p text:style-name="P1">a</text:p>
+          </text:deletion>
+        </text:changed-region>
+      </text:tracked-changes>
+      <text:p text:style-name="P1">goo<text:change text:change-id="ct94277392414656"/>d baa<text:change text:change-id="ct94277392490096"/>d eeend</text:p>
+    </office:text>
+  </office:body>
+</office:document>
+
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')
+
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index ba47a0021b73..cc66f68ed23e 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1022,7 +1022,12 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs)
                 }
                 if( pArgs->xSpellAlt.is() )
                 {
-                    if (IsSymbolAt(aScanner.GetBegin()))
+                    if ( IsSymbolAt(aScanner.GetBegin()) ||
+                        // redlines can leave "in word" character within word,
+                        // we must remove them before spell checking
+                        // to avoid false alarm
+                        ( bRestoreString && pArgs->xSpeller->isValid( rWord.replaceAll(OUStringChar(CH_TXTATR_INWORD), ""),
+                            static_cast<sal_uInt16>(eActLang), Sequence< PropertyValue >() ) ) )
                     {
                         pArgs->xSpellAlt = nullptr;
                     }
@@ -1324,8 +1329,12 @@ SwRect SwTextFrame::AutoSpell_(SwTextNode & rNode, sal_Int32 nActPos)
             {
                 // check for: bAlter => xHyphWord.is()
                 OSL_ENSURE(!bSpell || xSpell.is(), "NULL pointer");
-
-                if( !xSpell->isValid( rWord, static_cast<sal_uInt16>(eActLang), Sequence< PropertyValue >() ) )
+                if( !xSpell->isValid( rWord, static_cast<sal_uInt16>(eActLang), Sequence< PropertyValue >() ) &&
+                    // redlines can leave "in word" character within word,
+                    // we must remove them before spell checking
+                    // to avoid false alarm
+                    (!bRestoreString || !xSpell->isValid( rWord.replaceAll(OUStringChar(CH_TXTATR_INWORD), ""),
+                            static_cast<sal_uInt16>(eActLang), Sequence< PropertyValue >() ) ) )
                 {
                     sal_Int32 nSmartTagStt = nBegin;
                     sal_Int32 nDummy = 1;


More information about the Libreoffice-commits mailing list