summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-11-09 22:37:11 +0100
committerLuboš Luňák <l.lunak@collabora.com>2014-11-14 13:27:27 +0100
commit390b6e5cf66363275ac693bfc37ead8508412c86 (patch)
treef157dbe5f5290845d4c59094d593755356e5b6ea
parentf679e32f892d7ac198d511d53b524d7059ff42fc (diff)
speed up SwDoc::IsInHeaderFooter() by using SwFrmFmtAnchorMap
Now that it's possible to quickly find anchored objects for a node, it's actually faster to check the node hiearchy rather than layout. Conflicts: sw/source/core/doc/doclay.cxx Change-Id: I5f93d5af32c744f1773535e5ec8537334d1ff58a
-rw-r--r--sw/source/core/doc/doclay.cxx45
1 files changed, 23 insertions, 22 deletions
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index f15e0c884bf7..95a220b7ada0 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -2167,44 +2167,42 @@ void SwDoc::SetAllUniqueFlyNames()
bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const
{
- // If there's a Layout, use it!
// That can also be a Fly in a Fly in the Header.
// Is also used by sw3io, to determine if a Redline object is
// in the Header or Footer.
// Because Redlines are also attached to Start and EndNoden,
// the Index must not necessarily be from a ContentNode.
SwNode* pNd = &rIdx.GetNode();
- if( pNd->IsCntntNode() && mpCurrentView )//swmod 071029//swmod 071225
- {
- const SwFrm *pFrm = pNd->GetCntntNode()->getLayoutFrm( GetCurrentLayout() );
- if( pFrm )
- {
- const SwFrm *pUp = pFrm->GetUpper();
- while ( pUp && !pUp->IsHeaderFrm() && !pUp->IsFooterFrm() )
- {
- if ( pUp->IsFlyFrm() )
- pUp = ((SwFlyFrm*)pUp)->GetAnchorFrm();
- pUp = pUp->GetUpper();
- }
- if ( pUp )
- return true;
-
- return false;
- }
- }
-
-
const SwNode* pFlyNd = pNd->FindFlyStartNode();
while( pFlyNd )
{
// get up by using the Anchor
+#if OSL_DEBUG_LEVEL > 0
+ std::list<const SwFrmFmt*> checkFmts;
sal_uInt16 n;
for( n = 0; n < GetSpzFrmFmts()->size(); ++n )
{
const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[ n ];
const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
if( pIdx && pFlyNd == &pIdx->GetNode() )
+ checkFmts.push_back( pFmt );
+ }
+#endif
+ SwFrmFmtAnchorMap::const_iterator_pair range = GetFrmFmtAnchorMap()->equal_range( SwNodeIndex( *pFlyNd ));
+ SwFrmFmtAnchorMap::const_iterator it;
+ for( it = range.first;
+ it != range.second;
+ ++it )
+ {
+ const SwFrmFmt* pFmt = it->second;
+ const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
+ if( pIdx && pFlyNd == &pIdx->GetNode() )
{
+#if OSL_DEBUG_LEVEL > 0
+ std::list<const SwFrmFmt*>::iterator checkPos = std::find( checkFmts.begin(), checkFmts.end(), pFmt );
+ assert( checkPos != checkFmts.end());
+ checkFmts.erase( checkPos );
+#endif
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
if ((FLY_AT_PAGE == rAnchor.GetAnchorId()) ||
!rAnchor.GetCntntAnchor() )
@@ -2217,11 +2215,14 @@ bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const
break;
}
}
- if( n >= GetSpzFrmFmts()->size() )
+ if( it == range.second )
{
OSL_ENSURE( mbInReading, "Found a FlySection but not a Format!" );
return false;
}
+#if OSL_DEBUG_LEVEL > 0
+ assert( checkFmts.empty());
+#endif
}
return 0 != pNd->FindHeaderStartNode() ||