summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-05-30 14:43:11 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-06-08 19:40:28 +0200
commit03fb5a1e09106674cb5ff00dc9a8b2600a32ba43 (patch)
treea139d6fa14bbe3baa48a0c972ba26fd226621d8a
parentd5d387893e125fb9073c5b48aff22132162832d1 (diff)
sw_redlinehide: SwTextFrame::DestroyImpl() needs to remove more
... footnotes for merged paragraphs. Change-Id: Ia32a2a776cb3a383f9ea0ecf51dcea872d6378be
-rw-r--r--sw/source/core/text/txtfrm.cxx64
1 files changed, 45 insertions, 19 deletions
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index c89fc3f90598..f405b30bc5ff 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -601,34 +601,60 @@ SwTextFrame::SwTextFrame(SwTextNode * const pNode, SwFrame* pSib )
mnFrameType = SwFrameType::Txt;
}
+static void RemoveFootnotesForNode(
+ SwTextFrame const& rTextFrame, SwTextNode const& rTextNode)
+{
+ const SwFootnoteIdxs &rFootnoteIdxs = rTextNode.GetDoc()->GetFootnoteIdxs();
+ size_t nPos = 0;
+ sal_uLong const nIndex = rTextNode.GetIndex();
+ rFootnoteIdxs.SeekEntry( rTextNode, &nPos );
+ if (nPos < rFootnoteIdxs.size())
+ {
+ while (nPos && &rTextNode == &(rFootnoteIdxs[ nPos ]->GetTextNode()))
+ --nPos;
+ if (nPos || &rTextNode != &(rFootnoteIdxs[ nPos ]->GetTextNode()))
+ ++nPos;
+ }
+ while (nPos < rFootnoteIdxs.size())
+ {
+ SwTextFootnote* pTextFootnote = rFootnoteIdxs[ nPos ];
+ if (pTextFootnote->GetTextNode().GetIndex() > nIndex)
+ break;
+ pTextFootnote->DelFrames( &rTextFrame );
+ ++nPos;
+ }
+}
+
void SwTextFrame::DestroyImpl()
{
// Remove associated SwParaPortion from s_pTextCache
ClearPara();
- const SwContentNode* pCNd;
- if( nullptr != ( pCNd = dynamic_cast<SwContentNode*>( GetRegisteredIn() ) ) &&
- !pCNd->GetDoc()->IsInDtor() && HasFootnote() )
+ assert(!GetDoc().IsInDtor()); // this shouldn't be happening with ViewShell owning layout
+ if (!GetDoc().IsInDtor() && HasFootnote())
{
- SwTextNode *pTextNd = GetTextNode();
- const SwFootnoteIdxs &rFootnoteIdxs = pCNd->GetDoc()->GetFootnoteIdxs();
- size_t nPos = 0;
- sal_uLong nIndex = pCNd->GetIndex();
- rFootnoteIdxs.SeekEntry( *pTextNd, &nPos );
- if( nPos < rFootnoteIdxs.size() )
+ if (m_pMergedPara)
{
- while( nPos && pTextNd == &(rFootnoteIdxs[ nPos ]->GetTextNode()) )
- --nPos;
- if( nPos || pTextNd != &(rFootnoteIdxs[ nPos ]->GetTextNode()) )
- ++nPos;
+ SwTextNode const* pNode(nullptr);
+ for (auto const& e : m_pMergedPara->extents)
+ {
+ if (e.pNode != pNode)
+ {
+ pNode = e.pNode;
+ // sw_redlinehide: not sure if it's necessary to check
+ // if the nodes are still alive here, which would require
+ // accessing WriterMultiListener::m_vDepends
+ RemoveFootnotesForNode(*this, *pNode);
+ }
+ }
}
- while( nPos < rFootnoteIdxs.size() )
+ else
{
- SwTextFootnote* pTextFootnote = rFootnoteIdxs[ nPos ];
- if( pTextFootnote->GetTextNode().GetIndex() > nIndex )
- break;
- pTextFootnote->DelFrames( this );
- ++nPos;
+ SwTextNode *const pNode(static_cast<SwTextNode*>(GetRegisteredIn()));
+ if (pNode)
+ {
+ RemoveFootnotesForNode(*this, *pNode);
+ }
}
}