diff options
author | Serge Krot <Serge.Krot@cib.de> | 2019-05-27 14:37:27 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2019-05-28 00:08:38 +0200 |
commit | 37103a3f008c13dee21d55c8da9e6af807b1997c (patch) | |
tree | 3dcf2fae679d4974da89022a4e84ad6066192b69 /sw | |
parent | 651cb3049ca250780715b8875bc206f344cc134c (diff) |
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@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/mailmerge/data/tdf125522.odt | bin | 0 -> 9794 bytes | |||
-rw-r--r-- | sw/qa/extras/mailmerge/mailmerge.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 28 |
3 files changed, 49 insertions, 3 deletions
diff --git a/sw/qa/extras/mailmerge/data/tdf125522.odt b/sw/qa/extras/mailmerge/data/tdf125522.odt Binary files differnew file mode 100644 index 000000000000..265d8fca7615 --- /dev/null +++ b/sw/qa/extras/mailmerge/data/tdf125522.odt 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(); + } } } |