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() ||