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

Serge Krot (via logerrit) logerrit at kemper.freedesktop.org
Mon May 27 22:09:50 UTC 2019


 sw/qa/extras/mailmerge/data/tdf125522.odt |binary
 sw/qa/extras/mailmerge/mailmerge.cxx      |   24 ++++++++++++++++++++++++
 sw/source/core/doc/doc.cxx                |   28 +++++++++++++++++++++++++---
 3 files changed, 49 insertions(+), 3 deletions(-)

New commits:
commit 37103a3f008c13dee21d55c8da9e6af807b1997c
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Mon May 27 14:37:27 2019 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue May 28 00:08:38 2019 +0200

    tdf#125522: Mail merge: Hidden text frames are not completely removed
    
    Change-Id: I67550b325a0ac177ffbd52718234c2a0edf1154c
    Reviewed-on: https://gerrit.libreoffice.org/73033
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/qa/extras/mailmerge/data/tdf125522.odt b/sw/qa/extras/mailmerge/data/tdf125522.odt
new file mode 100644
index 000000000000..265d8fca7615
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/tdf125522.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index d4ef29e9e106..7e6e20967e27 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -933,6 +933,30 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf62364, "tdf62364.odt", "10-testing-addresses
     }
 }
 
+DECLARE_SHELL_MAILMERGE_TEST(tdf125522_shell, "tdf125522.odt", "10-testing-addresses.ods", "testing-addresses")
+{
+    // prepare unit test and run
+    executeMailMerge();
+
+    // reset currently opened layout of the original template,
+    // and create the layout of the document with 10 mails inside
+    dumpMMLayout();
+
+    // there should be no any text frame in output
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    const auto & rNodes = pTextDoc->GetDocShell()->GetDoc()->GetNodes();
+    for (sal_uLong nodeIndex = 0; nodeIndex<rNodes.Count(); nodeIndex++)
+    {
+        const SwNodePtr aNode = rNodes[nodeIndex];
+        if (aNode->StartOfSectionNode())
+        {
+            CPPUNIT_ASSERT(!aNode->StartOfSectionNode()->GetFlyFormat());
+        }
+    }
+}
+
 DECLARE_SHELL_MAILMERGE_TEST(testTd78611_shell, "tdf78611.odt", "10-testing-addresses.ods", "testing-addresses")
 {
     // prepare unit test and run
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 2da307cfd267..7828fba9e62c 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1438,12 +1438,30 @@ bool SwDoc::RemoveInvisibleContent()
         if ( pTextNd )
         {
             bool bRemoved = false;
-            SwPaM aPam(*pTextNd, 0, *pTextNd, pTextNd->GetText().getLength());
             if ( pTextNd->HasHiddenCharAttribute( true ) )
             {
                 bRemoved = true;
                 bRet = true;
-                RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
+
+                if (2 == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
+                {
+                    SwFrameFormat *const pFormat = pTextNd->StartOfSectionNode()->GetFlyFormat();
+                    if (nullptr != pFormat)
+                    {
+                        // remove hidden text frame
+                        getIDocumentLayoutAccess().DelLayoutFormat(pFormat);
+                    }
+                    else
+                    {
+                        // default, remove hidden paragraph
+                        RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
+                    }
+                }
+                else
+                {
+                    // default, remove hidden paragraph
+                    RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
+                }
             }
             else if ( pTextNd->HasHiddenCharAttribute( false ) )
             {
@@ -1455,7 +1473,11 @@ bool SwDoc::RemoveInvisibleContent()
             // Footnotes/Frames may have been removed, therefore we have
             // to reset n:
             if ( bRemoved )
-                n = aPam.GetPoint()->nNode.GetIndex();
+            {
+                // [n] has to be inside [0 .. GetNodes().Count()] range
+                if (n > GetNodes().Count())
+                    n = GetNodes().Count();
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list