[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa sw/source

Henry Castro hcastro at collabora.com
Fri Feb 9 16:46:53 UTC 2018


 sw/qa/extras/tiledrendering/tiledrendering.cxx |   27 +++++++++++++++++++++++++
 sw/source/core/doc/docredln.cxx                |   12 ++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 27fa442a86d4ffdad08feebc1841a79f7d1ce5a4
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Jan 24 15:11:00 2018 -0400

    sw lok: include the field name in the description of the redline
    
    In tiled rendering case, when the text node is a field,
    the description shows incorrect characters
    
    Change-Id: I1e3a456b6e2a19a7629b58a8a6ae77e2090a06a1
    Reviewed-on: https://gerrit.libreoffice.org/48538
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/48723
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 226874291be6..089537b6dc0c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -38,6 +38,7 @@
 #include <sfx2/dispatch.hxx>
 #include <redline.hxx>
 #include <IDocumentRedlineAccess.hxx>
+#include <flddat.hxx>
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
 
@@ -93,6 +94,7 @@ public:
     void testDocumentRepair();
     void testPageHeader();
     void testPageFooter();
+    void testRedlineField();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -142,6 +144,7 @@ public:
     CPPUNIT_TEST(testDocumentRepair);
     CPPUNIT_TEST(testPageHeader);
     CPPUNIT_TEST(testPageFooter);
+    CPPUNIT_TEST(testRedlineField);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2009,6 +2012,30 @@ void SwTiledRenderingTest::testPageFooter()
 }
 
 
+void SwTiledRenderingTest::testRedlineField()
+{
+    // Load a document.
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+    SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+
+    // Turn on track changes and type "x".
+    uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
+    xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+
+    SwDateTimeField aDate(static_cast<SwDateTimeFieldType*>(pWrtShell->GetFieldType(0, RES_DATETIMEFLD)));
+    //aDate->SetDateTime(::DateTime(::DateTime::SYSTEM));
+    pWrtShell->Insert(aDate);
+
+    // Get the redline just created
+    const SwRedlineTable& rTable = pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size());
+    SwRangeRedline* pRedline = rTable[0];
+    CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 0803609ae963..2d24fe55fdbd 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -57,6 +57,7 @@
 #include <comcore.hrc>
 #include <unoport.hxx>
 #include <wrtsh.hxx>
+#include <txtfld.hxx>
 
 #include "flowfrm.hxx"
 
@@ -1777,9 +1778,18 @@ OUString SwRangeRedline::GetDescr()
         bDeletePaM = true;
     }
 
+    OUString sDescr = 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();
+        }
+    }
+
     // replace $1 in description by description of the redlines text
     const OUString aTmpStr = SW_RESSTR(STR_START_QUOTE)
-        + ShortenString(pPaM->GetText(), nUndoStringLength, SW_RESSTR(STR_LDOTS))
+        + ShortenString(sDescr, nUndoStringLength, SW_RESSTR(STR_LDOTS))
         + SW_RESSTR(STR_END_QUOTE);
 
     SwRewriter aRewriter;


More information about the Libreoffice-commits mailing list