[Libreoffice-commits] core.git: 2 commits - sw/source
Luboš Luňák
l.lunak at collabora.com
Sun Nov 9 14:01:03 PST 2014
sw/source/core/doc/doclay.cxx | 44 +++++++++++++++++++-------------------
sw/source/core/layout/frmtool.cxx | 2 +
2 files changed, 25 insertions(+), 21 deletions(-)
New commits:
commit 167a0383f0064372ad36d08f6318385adaacc6dc
Author: Luboš Luňák <l.lunak at collabora.com>
Date: Sun Nov 9 22:59:41 2014 +0100
avoid unused argument warning
Change-Id: Ib67b804423b521407710f8319cb89977e44494cc
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 8f714b5..a3dc23f 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1014,6 +1014,8 @@ void AppendObjs( const SwFrmFmts *pTbl, sal_uLong nIndex,
checkFmts.push_back( pFmt );
}
}
+#else
+ (void)pTbl;
#endif
SwFrmFmtAnchorMap::const_iterator_pair range = doc->GetFrmFmtAnchorMap()->equal_range( SwNodeIndex( doc->GetNodes(), nIndex ));
for( std::multimap< SwNodeIndex, SwFrmFmt* >::const_iterator it = range.first;
commit bb95f7e6f7c9b1281875e6d729b66b6018794ee0
Author: Luboš Luňák <l.lunak at collabora.com>
Date: Sun Nov 9 22:37:11 2014 +0100
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.
Change-Id: I5f93d5af32c744f1773535e5ec8537334d1ff58a
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 8f12b98..4bc37a0 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -1512,43 +1512,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() && getIDocumentLayoutAccess().GetCurrentViewShell() )
- {
- const SwFrm *pFrm = pNd->GetCntntNode()->getLayoutFrm( getIDocumentLayoutAccess().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() )
@@ -1561,11 +1560,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() ||
More information about the Libreoffice-commits
mailing list