[Libreoffice-commits] core.git: sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 23 11:11:38 UTC 2019


 sw/qa/core/macros-test.cxx         |    6 ++++--
 sw/qa/core/uwriter.cxx             |    2 ++
 sw/qa/extras/uiwriter/uiwriter.cxx |    4 +++-
 sw/source/core/crsr/pam.cxx        |    4 ++++
 sw/source/core/doc/docredln.cxx    |   10 +++++-----
 5 files changed, 18 insertions(+), 8 deletions(-)

New commits:
commit 2e636ee01e32208387ca77c4edadf6929063158a
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Oct 22 16:51:45 2019 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Oct 23 13:10:02 2019 +0200

    sw: let's insert some paragraph break character in SwPaM::GetText()
    
    There are just 3 callers of this; 2 redline-related ones should both use
    DenoteSpecialCharacters() anyway and SwEditWin::FlushInBuffer()
    would probably be surprised to find any of the other CH_TXTATR in the
    string, so assume there's something limiting the cursor selection in
    that case.
    
    Change-Id: I83dcdc2b6734b6db22404d1c9b3adc9362451e9b
    Reviewed-on: https://gerrit.libreoffice.org/81343
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 739b24afbf5c..58ea47a0449d 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -503,7 +503,8 @@ void SwMacrosTest::testFindReplace()
             opts, false, SwDocPositions::Curr, SwDocPositions::End, bCancel, FindRanges::InBody);
     CPPUNIT_ASSERT(bFound);
     CPPUNIT_ASSERT(pPaM->HasMark());
-    CPPUNIT_ASSERT_EQUAL(OUString(), pPaM->GetText());
+    CPPUNIT_ASSERT(pPaM->GetPoint()->nNode != pPaM->GetMark()->nNode);
+    CPPUNIT_ASSERT_EQUAL(OUString(OUStringLiteral1(CH_TXTATR_NEWLINE)), pPaM->GetText());
 
     // now do another Find, inside the selection from the first Find
 //    opts.searchFlags = 71680;
@@ -511,7 +512,8 @@ void SwMacrosTest::testFindReplace()
             opts, false, SwDocPositions::Curr, SwDocPositions::End, bCancel, FindRanges::InSel);
     CPPUNIT_ASSERT(bFound);
     CPPUNIT_ASSERT(pPaM->HasMark());
-    CPPUNIT_ASSERT_EQUAL(OUString(), pPaM->GetText());
+    CPPUNIT_ASSERT(pPaM->GetPoint()->nNode != pPaM->GetMark()->nNode);
+    CPPUNIT_ASSERT_EQUAL(OUString(OUStringLiteral1(CH_TXTATR_NEWLINE)), pPaM->GetText());
 
     rIDCO.ReplaceRange(*pPaM, " ", true);
 
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 62756392113f..575baa3c32ee 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1547,6 +1547,8 @@ void SwDocTest::testTransliterate()
 
     m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPaM.GetPoint());
     m_pDoc->getIDocumentContentOperations().InsertString(aPaM, "one (two) three");
+    aPaM.SetMark();
+    aPaM.GetMark()->nContent = 0;
     CPPUNIT_ASSERT_EQUAL(OUString("One (Two) Three"),
             translitTest(*m_pDoc, aPaM,
                 TransliterationFlags::TITLE_CASE));
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index ff50b080f79a..7bdd081dce2f 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -2456,7 +2456,7 @@ void SwUiWriterTest::testTdf72788()
         pCursor->Move(fnMoveBackward);
     }
     //Check the text selection
-    CPPUNIT_ASSERT_EQUAL(OUString("is textmore"), pCursor->GetText());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"is text" + OUStringLiteral1(CH_TXTATR_NEWLINE) + u"more"), pCursor->GetText());
     //Apply a *Bold* attribute to selection
     SvxWeightItem aWeightItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT);
     rIDCO.InsertPoolItem(*pCursor, aWeightItem);
@@ -3523,7 +3523,9 @@ void SwUiWriterTest::testTdf83798()
     SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
     pCursor->SetMark();
     pCursor->Move(fnMoveForward, GoInNode);
+    pCursor->Move(fnMoveBackward, GoInContent);
     CPPUNIT_ASSERT_EQUAL(OUString("Table of Contents"), pCursor->GetText());
+    pCursor->Move(fnMoveForward, GoInContent);
     pCursor->DeleteMark();
     pCursor->SetMark();
     pCursor->Move(fnMoveForward, GoInContent);
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index ebef14e1ca3b..437864f6df56 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -1021,6 +1021,10 @@ OUString SwPaM::GetText() const
 
         if (pTextNode != nullptr)
         {
+            if (!bIsStartNode)
+            {
+                aResult.append(CH_TXTATR_NEWLINE); // use newline for para break
+            }
             const OUString& aTmpStr = pTextNode->GetText();
 
             if (bIsStartNode || bIsEndNode)
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index c6a3e694e210..7c68046324a7 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1788,19 +1788,19 @@ OUString SwRangeRedline::GetDescr()
         bDeletePaM = true;
     }
 
-    OUString sDescr = pPaM->GetText();
+    OUString sDescr = DenoteSpecialCharacters(pPaM->GetText());
     if (const SwTextNode *pTextNode = pPaM->GetNode().GetTextNode())
     {
         if (const SwTextAttr* pTextAttr = pTextNode->GetFieldTextAttrAt(pPaM->GetPoint()->nContent.GetIndex() - 1, true ))
         {
-            sDescr = pTextAttr->GetFormatField().GetField()->GetFieldName();
+            sDescr = SwResId(STR_START_QUOTE)
+                + pTextAttr->GetFormatField().GetField()->GetFieldName()
+                + SwResId(STR_END_QUOTE);
         }
     }
 
     // replace $1 in description by description of the redlines text
-    const OUString aTmpStr = SwResId(STR_START_QUOTE)
-        + ShortenString(sDescr, nUndoStringLength, SwResId(STR_LDOTS))
-        + SwResId(STR_END_QUOTE);
+    const OUString aTmpStr = ShortenString(sDescr, nUndoStringLength, SwResId(STR_LDOTS));
 
     SwRewriter aRewriter;
     aRewriter.AddRule(UndoArg1, aTmpStr);


More information about the Libreoffice-commits mailing list