[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - editeng/source sw/qa

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Sun Dec 29 11:47:52 UTC 2019


 editeng/source/misc/svxacorr.cxx   |    4 ++++
 sw/qa/extras/uiwriter/uiwriter.cxx |   30 ++++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

New commits:
commit 30d5b303f0dd300e200c1316feeef4a0ba022b04
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed Dec 25 18:07:11 2019 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Sun Dec 29 12:47:23 2019 +0100

    tdf#54409 fix AutoCorrect with Unicode quotation marks
    
    Now single or double typographical quotation marks don't
    break automatic correction of the quoted words.
    
    For example, ‘acn -> ‘can, acn’ -> can’, “acn” -> “can”.
    
    Change-Id: I7f895414be4c3bbc9a3914df83d93cf28b4311a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85812
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 0d52da4637b563c175cd21d04a639160441436ef)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85930
    Tested-by: Jenkins

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 1e5006d90484..fc89820415a5 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -177,6 +177,10 @@ static bool lcl_IsSymbolChar( CharClass const & rCC, const OUString& rTxt,
 
 static bool lcl_IsInAsciiArr( const sal_Char* pArr, const sal_Unicode c )
 {
+    // tdf#54409 check also typographical quotation marks in the case of skipped ASCII quotation marks
+    if ( 0x2018 <= c && c <= 0x201F && (pArr == sImplSttSkipChars || pArr == sImplEndSkipChars) )
+        return true;
+
     bool bRet = false;
     for( ; *pArr; ++pArr )
         if( *pArr == c )
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 5b29fdc371da..db3ae33167e2 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -360,6 +360,7 @@ public:
     void testTdf51223();
     void testTdf108423();
     void testTdf106164();
+    void testTdf54409();
     void testInconsistentBookmark();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
@@ -564,6 +565,7 @@ public:
     CPPUNIT_TEST(testInconsistentBookmark);
     CPPUNIT_TEST(testTdf108423);
     CPPUNIT_TEST(testTdf106164);
+    CPPUNIT_TEST(testTdf54409);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -6985,8 +6987,32 @@ void SwUiWriterTest::testTdf106164()
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
     sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
-    OUString sIApostrophe(u"We\u2019re ");
-    CPPUNIT_ASSERT_EQUAL(sIApostrophe, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+    OUString sReplaced(u"We\u2019re ");
+    CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+}
+
+void SwUiWriterTest::testTdf54409()
+{
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    // testing autocorrect of "tset -> "test with typographical double quotation mark U+201C
+    SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
+    pWrtShell->Insert(u"\u201Ctset");
+    const sal_Unicode cChar = ' ';
+    pWrtShell->AutoCorrect(corr, cChar);
+    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    OUString sReplaced(u"\u201Ctest ");
+    CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+    // testing autocorrect of test" -> test" with typographical double quotation mark U+201D
+    pWrtShell->Insert(u"and tset\u201D");
+    pWrtShell->AutoCorrect(corr, cChar);
+    OUString sReplaced2(sReplaced + u"and test\u201D ");
+    CPPUNIT_ASSERT_EQUAL(sReplaced2, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+    // testing autocorrect of "tset" -> "test" with typographical double quotation mark U+201C and U+201D
+    pWrtShell->Insert(u"\u201Ctset\u201D");
+    pWrtShell->AutoCorrect(corr, cChar);
+    OUString sReplaced3(sReplaced2 + u"\u201Ctest\u201D ");
+    CPPUNIT_ASSERT_EQUAL(sReplaced3, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);


More information about the Libreoffice-commits mailing list