summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-11 10:37:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-01-11 16:53:47 +0100
commit710cf469bf0e43a021fc1a24a80745bc602368ef (patch)
tree8c0236cfa6d0974fdc70f0d670c5f56bc3e03670
parentdd51c589774a88010d78530fc6d152a9af98f095 (diff)
ofz#5235 Bad-cast
Change-Id: I041f09f37941a92ccee3f0ebf9e5a950dee0c52f Reviewed-on: https://gerrit.libreoffice.org/47747 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/filter/html/htmltab.cxx53
-rw-r--r--sw/source/filter/html/swhtml.hxx2
2 files changed, 47 insertions, 8 deletions
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index dbe5a5b7429b..74a2c0951c98 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -5033,19 +5033,13 @@ namespace
};
}
-void SwHTMLParser::DeleteSection(SwStartNode* pSttNd)
+void SwHTMLParser::ClearFootnotesInRange(const SwNodeIndex& rMkNdIdx, const SwNodeIndex& rPtNdIdx)
{
- //if section to be deleted contains a pending m_pMarquee, it will be deleted
- //so clear m_pMarquee pointer if that's the case
- SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr;
- FrameDeleteWatch aWatch(pObjectFormat);
-
//similarly for footnotes
if (m_pFootEndNoteImpl)
{
- SwNodeIndex aSttIdx(*pSttNd), aEndIdx(*pSttNd->EndOfSectionNode());
m_pFootEndNoteImpl->aTextFootnotes.erase(std::remove_if(m_pFootEndNoteImpl->aTextFootnotes.begin(),
- m_pFootEndNoteImpl->aTextFootnotes.end(), IndexInRange(aSttIdx, aEndIdx)), m_pFootEndNoteImpl->aTextFootnotes.end());
+ m_pFootEndNoteImpl->aTextFootnotes.end(), IndexInRange(rMkNdIdx, rPtNdIdx)), m_pFootEndNoteImpl->aTextFootnotes.end());
if (m_pFootEndNoteImpl->aTextFootnotes.empty())
{
delete m_pFootEndNoteImpl;
@@ -5053,6 +5047,49 @@ void SwHTMLParser::DeleteSection(SwStartNode* pSttNd)
}
}
+ //follow DelFlyInRange pattern here
+ const bool bDelFwrd = rMkNdIdx.GetIndex() <= rPtNdIdx.GetIndex();
+
+ SwDoc* pDoc = rMkNdIdx.GetNode().GetDoc();
+ SwFrameFormats& rTable = *pDoc->GetSpzFrameFormats();
+ for ( auto i = rTable.size(); i; )
+ {
+ SwFrameFormat *pFormat = rTable[--i];
+ const SwFormatAnchor &rAnch = pFormat->GetAnchor();
+ SwPosition const*const pAPos = rAnch.GetContentAnchor();
+ if (pAPos &&
+ ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA) ||
+ (rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)) &&
+ ( bDelFwrd
+ ? rMkNdIdx < pAPos->nNode && pAPos->nNode <= rPtNdIdx
+ : rPtNdIdx <= pAPos->nNode && pAPos->nNode < rMkNdIdx ))
+ {
+ if( rPtNdIdx != pAPos->nNode )
+ {
+ // If the Fly is deleted, all Flys in its content have to be deleted too.
+ const SwFormatContent &rContent = pFormat->GetContent();
+ // But only fly formats own their content, not draw formats.
+ if (rContent.GetContentIdx() && pFormat->Which() == RES_FLYFRMFMT)
+ {
+ ClearFootnotesInRange(*rContent.GetContentIdx(),
+ SwNodeIndex(*rContent.GetContentIdx()->GetNode().EndOfSectionNode()));
+ }
+ }
+ }
+ }
+}
+
+void SwHTMLParser::DeleteSection(SwStartNode* pSttNd)
+{
+ //if section to be deleted contains a pending m_pMarquee, it will be deleted
+ //so clear m_pMarquee pointer if that's the case
+ SwFrameFormat* pObjectFormat = m_pMarquee ? ::FindFrameFormat(m_pMarquee) : nullptr;
+ FrameDeleteWatch aWatch(pObjectFormat);
+
+ //similarly for footnotes
+ SwNodeIndex aSttIdx(*pSttNd), aEndIdx(*pSttNd->EndOfSectionNode());
+ ClearFootnotesInRange(aSttIdx, aEndIdx);
+
m_xDoc->getIDocumentContentOperations().DeleteSection(pSttNd);
if (pObjectFormat)
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index c86150510428..cd43c8f3f065 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -663,6 +663,8 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
// tags realized via character styles
void NewCharFormat( HtmlTokenId nToken );
+ void ClearFootnotesInRange(const SwNodeIndex& rSttIdx, const SwNodeIndex& rEndIdx);
+
void DeleteSection(SwStartNode* pSttNd);
// <SDFIELD>