sw/qa/extras/uiwriter/uiwriter.cxx              |   35 ++++++++++++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx   |    4 +-
 test/user-template/user/autocorr/acor_en-GB.dat |binary
 3 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit db999ddee7a890390f66d7e34906066c8bf178da
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Mar 8 14:13:39 2021 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Mar 9 17:42:04 2021 +0100

    tdf#140674 sw change tracking: fix :emoji: replacement
    
    Regression from commit 2951c96bcb673a260a09e2c6eb92ca0f99bf0c18
    (tdf#83419 sw change tracking: clean-up autocorrect).
    
    Note: only :snowman: -> ☃ was added to the test autocorrect
    file acor_en-GB.dat.
    
    Change-Id: Ic3013e969ab937a5f9e5b6d1a6fac2f533b541f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112166
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 9c2719f99638..c39659fa9bab 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -399,6 +399,7 @@ public:
     void testSpellOnlineParameter();
     void testRedlineAutoCorrect();
     void testRedlineAutoCorrect2();
+    void testEmojiAutoCorrect();
 #if HAVE_FEATURE_PDFIUM
     void testInsertPdf();
 #endif
@@ -631,6 +632,7 @@ public:
     CPPUNIT_TEST(testSpellOnlineParameter);
     CPPUNIT_TEST(testRedlineAutoCorrect);
     CPPUNIT_TEST(testRedlineAutoCorrect2);
+    CPPUNIT_TEST(testEmojiAutoCorrect);
 #if HAVE_FEATURE_PDFIUM
     CPPUNIT_TEST(testInsertPdf);
 #endif
@@ -7771,6 +7773,39 @@ void SwUiWriterTest::testRedlineAutoCorrect2()
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
+void SwUiWriterTest::testEmojiAutoCorrect()
+{
+    SwDoc* pDoc = createDoc("redline-autocorrect2.fodt");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+    // Emoji replacement (:snowman: -> ☃)
+
+    // without change tracking
+    CPPUNIT_ASSERT(!(pWrtShell->GetRedlineFlags() & RedlineFlags::On));
+    SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
+    pWrtShell->Insert(":snowman");
+    pWrtShell->AutoCorrect(corr, ':');
+    sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    OUString sReplaced = u"☃Lorem,";
+    nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+    CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+
+    // with change tracking (showing redlines)
+    RedlineFlags const nMode(pWrtShell->GetRedlineFlags() | RedlineFlags::On);
+    CPPUNIT_ASSERT(nMode & (RedlineFlags::ShowDelete | 
RedlineFlags::ShowInsert));
+    pWrtShell->SetRedlineFlags(nMode);
+    CPPUNIT_ASSERT(nMode & RedlineFlags::On);
+    CPPUNIT_ASSERT(nMode & RedlineFlags::ShowDelete);
+
+    pWrtShell->Insert(":snowman");
+    pWrtShell->AutoCorrect(corr, ':');
+    sReplaced = u"☃☃Lorem,";
+    nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+
+    // tdf#140674 This was ":snowman:" instead of autocorrect
+    CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+}
+
 void SwUiWriterTest::testTdf108423()
 {
     SwDoc* pDoc = createDoc();
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index d694fff83154..8f8688702a18 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2555,7 +2555,7 @@ SwRedlineTable::size_type 
DocumentRedlineManager::GetRedlinePos( const SwNode& r
     // #TODO - add 'SwExtraRedlineTable' also ?
 }
 
-bool DocumentRedlineManager::HasRedline( const SwPaM& rPam, RedlineType nType, 
bool bStartOrEndInRange ) const // xxx
+bool DocumentRedlineManager::HasRedline( const SwPaM& rPam, RedlineType nType, 
bool bStartOrEndInRange ) const
 {
     SwPosition currentStart(*rPam.Start());
     SwPosition currentEnd(*rPam.End());
@@ -2576,7 +2576,7 @@ bool DocumentRedlineManager::HasRedline( const SwPaM& 
rPam, RedlineType nType, b
         if ( currentStart < *pTmp->End() && *pTmp->Start() <= currentEnd &&
              // starting or ending within the range
              ( !bStartOrEndInRange ||
-                 ( currentStart <= *pTmp->Start() || *pTmp->End() <= 
currentEnd ) ) )
+                 ( currentStart < *pTmp->Start() || *pTmp->End() < currentEnd 
) ) )
         {
             return true;
         }
diff --git a/test/user-template/user/autocorr/acor_en-GB.dat 
b/test/user-template/user/autocorr/acor_en-GB.dat
index b74f1834caac..ae2f12db59d8 100644
Binary files a/test/user-template/user/autocorr/acor_en-GB.dat and 
b/test/user-template/user/autocorr/acor_en-GB.dat differ
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to