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

Szymon Kłos szymon.klos at collabora.com
Fri May 5 07:55:05 UTC 2017


 sw/qa/extras/uiwriter/data/autotext-dotm.dotm |binary
 sw/qa/extras/uiwriter/uiwriter.cxx            |   18 ++++++++++++++++++
 sw/source/filter/docx/swdocxreader.cxx        |    7 ++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 3a654934be5581a22c50e72999ebf91ce37d0504
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Thu May 4 11:57:20 2017 +0200

    AutoText: fix dotm support
    
    + dotm files don't contain additional empty paragraphs
      at the end of AutoText entry
    + added test for dotm import
    
    Change-Id: I336145dcf8a5dd69aa9ed82318a0f05a6f62596c
    Reviewed-on: https://gerrit.libreoffice.org/37230
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/37233
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sw/qa/extras/uiwriter/data/autotext-dotm.dotm b/sw/qa/extras/uiwriter/data/autotext-dotm.dotm
new file mode 100644
index 000000000000..4909296d2117
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/autotext-dotm.dotm differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 69b0a1eabeb3..e298c322f690 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -118,6 +118,7 @@ public:
     void testExportRTF();
     void testDOCXAutoTextEmpty();
     void testDOCXAutoTextMultiple();
+    void testDOTMAutoText();
     void testTdf67238();
     void testFdo75110();
     void testFdo75898();
@@ -237,6 +238,7 @@ public:
     CPPUNIT_TEST(testExportRTF);
     CPPUNIT_TEST(testDOCXAutoTextEmpty);
     CPPUNIT_TEST(testDOCXAutoTextMultiple);
+    CPPUNIT_TEST(testDOTMAutoText);
     CPPUNIT_TEST(testTdf67238);
     CPPUNIT_TEST(testFdo75110);
     CPPUNIT_TEST(testFdo75898);
@@ -780,6 +782,22 @@ void SwUiWriterTest::testDOCXAutoTextMultiple()
     CPPUNIT_ASSERT_EQUAL(OUString("complex"), rLastNode.GetTextNode()->GetText());
 }
 
+void SwUiWriterTest::testDOTMAutoText()
+{
+    // this is dotm file difference is that in the dotm
+    // there are no empty paragraphs at the end of each entry
+    SwTextBlocks* pGlossary = readDOCXAutotext("autotext-dotm.dotm");
+
+    SwDoc* pDoc = pGlossary->GetDoc();
+    CPPUNIT_ASSERT(pDoc != nullptr);
+
+    // check if content is correct
+    SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent());
+    SwNodeIndex aStart(*aDocEnd.GetNode().StartOfSectionNode(), 1);
+    SwNode& rNode = aStart.GetNode();
+    CPPUNIT_ASSERT_EQUAL(OUString("paragraph"), rNode.GetTextNode()->GetText());
+}
+
 void SwUiWriterTest::testFdo74981()
 {
     // create a document with an input field
diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx
index 7558b4dfba10..8939e4922b02 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -33,6 +33,7 @@
 #include <ndtxt.hxx>
 #include <poolfmt.hxx>
 #include <svl/urihelper.hxx>
+#include <doc.hxx>
 #include <swerror.h>
 #include <tools/ref.hxx>
 #include <unotxdoc.hxx>
@@ -139,7 +140,11 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
             aPam.SetMark();
             {
                 SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
-                rIdx = aStart.GetNode().EndOfSectionIndex() - 2;
+                rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
+                // don't add extra empty text node if exist (.dotx but not .dotm)
+                if( rIdx.GetNode().GetTextNode() &&
+                    rIdx.GetNode().GetTextNode()->GetText().isEmpty() )
+                    rIdx = aStart.GetNode().EndOfSectionIndex() - 2;
                 if( ( nullptr == ( pCNd = rIdx.GetNode().GetContentNode() ) ) )
                 {
                     ++rIdx;


More information about the Libreoffice-commits mailing list