ofz#43310 don't try and delete prior header/footer contents
If a duplicate appears, just hide the prior ones.
FWIW our own html export only exports a single header/footer as far as I
can see.
Change-Id: I5df28f7215ed49ce4a13add990716edcc7f2c72c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131329
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/qa/core/data/html/pass/ofz43310-1.html b/sw/qa/core/data/html/pass/ofz43310-1.html
new file mode 100644
index 0000000..e84d1cc
--- /dev/null
+++ b/sw/qa/core/data/html/pass/ofz43310-1.html
Binary files differ
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index c684f0a..d5de707 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -194,7 +194,11 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
}
else
{
// Create a new node at the beginning of the section
// Our own html export only exports one "header" at most (and one "footer")
// Create a new node at the beginning of the section if a duplicate arises
// and hide the original header/footers content by putting it into a hidden
// document-level section
SwNodeIndex aSttIdx( rContentStIdx, 1 );
pCNd = m_xDoc->GetNodes().MakeTextNode( aSttIdx,
m_pCSS1Parser->GetTextCollFromPool(RES_POOLCOLL_TEXT));
@@ -205,13 +209,11 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
const SwStartNode *pStNd =
static_cast<const SwStartNode *>( &rContentStIdx.GetNode() );
aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex() - 1;
aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex();
if (!PendingTableInPaM(aDelPam))
{
m_xDoc->getIDocumentContentOperations().DeleteRange(aDelPam);
m_xDoc->getIDocumentContentOperations().DelFullPara(aDelPam);
}
SwSectionData aSection(SectionType::Content, m_xDoc->GetUniqueSectionName());
if (SwSection* pOldContent = m_xDoc->InsertSwSection(aDelPam, aSection, nullptr, nullptr, false))
pOldContent->SetHidden(true);
// update page style
for( size_t i=0; i < m_xDoc->GetPageDescCnt(); i++ )
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index dad2219..d5cde19 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -5248,23 +5248,4 @@ std::shared_ptr<HTMLTable> SwHTMLParser::BuildTable(SvxAdjust eParentAdjust,
return xRetTable;
}
bool SwHTMLParser::PendingTableInPaM(SwPaM& rPam) const
{
bool bRet = false;
for (const auto& a : m_aTables)
{
const SwTable *pTable = a->GetSwTable();
if (!pTable)
continue;
const SwTableNode* pTableNode = pTable->GetTableNode();
if (!pTableNode)
continue;
SwNodeIndex aTableNodeIndex(*pTableNode);
bRet = (aTableNodeIndex >= rPam.Start()->nNode && aTableNodeIndex <= rPam.End()->nNode);
if (bRet)
break;
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index a0b7143..346e612 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -874,8 +874,6 @@ private:
bool HasCurrentParaFlys( bool bNoSurroundOnly = false,
bool bSurroundOnly = false ) const;
bool PendingTableInPaM(SwPaM& rPam) const;
class TableDepthGuard
{
private: