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

Caolán McNamara caolanm at redhat.com
Thu Jan 11 15:54:18 UTC 2018


 sw/source/filter/html/htmltab.cxx |   53 ++++++++++++++++++++++++++++++++------
 sw/source/filter/html/swhtml.hxx  |    2 +
 2 files changed, 47 insertions(+), 8 deletions(-)

New commits:
commit 710cf469bf0e43a021fc1a24a80745bc602368ef
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 11 10:37:56 2018 +0000

    ofz#5235 Bad-cast
    
    Change-Id: I041f09f37941a92ccee3f0ebf9e5a950dee0c52f
    Reviewed-on: https://gerrit.libreoffice.org/47747
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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>


More information about the Libreoffice-commits mailing list