Kaydet (Commit) 37103a3f authored tarafından Serge Krot's avatar Serge Krot Kaydeden (comit) Thorsten Behrens

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: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 651cb304
......@@ -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
......
......@@ -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();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment