diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-11-09 15:30:08 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-14 13:27:18 +0100 |
commit | f679e32f892d7ac198d511d53b524d7059ff42fc (patch) | |
tree | 1dfea8a27f1a0caf5fd00787edeb45624a8b0f6f /sw/source/core/attr/swatrset.cxx | |
parent | 0bc4baf73ce11a777195a31c23496960f60f6dfb (diff) |
faster mapping from nodes to SwFrmFmt's anchored at them
The SwFrmFmtAnchorMap class provides reverse mapping
to SwFrmFmt::GetAnchor().GetCntntAnchor(), so that when code somewhere needs
to update SwFrmFmt's anchored at a position, it's not necessary to iterate
over all of them (which can be a large number e.g. with mail merge).
One special catch with the multimap of SwNodeIndex keys is that
the values of those keys change (whenever the node structure of the document
changes, indexes of nodes change as a result). This makes it impossible to use
any hashing container, as the hashes would change without the container
noticing, but multimap should work fine, as it just requires that the keys
remain sorted, and that is the case. Nevertheless, the old code in the two
converted places is intentionally left there in debug mode to verify the reverse
mapping is updated correctly.
I intentionally went with SwNodeIndex rather than SwPosition, as SwIndex
(the other component of SwPosition) was causing some trouble (see e.g. the
SwPosition comparison operator< , where two same positions are different if one
is registered and the other not) and it doesn't appear to be actually necessary.
Conflicts:
sw/inc/doc.hxx
sw/inc/frmfmt.hxx
sw/source/core/attr/swatrset.cxx
sw/source/core/doc/docnew.cxx
sw/source/core/inc/frmtool.hxx
sw/source/core/layout/atrfrm.cxx
sw/source/core/txtnode/ndtxt.cxx
Change-Id: I7f1768558f60155d4ba83c84aa7f9e34dc65ebf9
Diffstat (limited to 'sw/source/core/attr/swatrset.cxx')
-rw-r--r-- | sw/source/core/attr/swatrset.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index aa7ba15cff3b..4ca52ffd8f9c 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -25,6 +25,7 @@ #include <editeng/brushitem.hxx> #include <editeng/lineitem.hxx> #include <editeng/boxitem.hxx> +#include <fmtanchr.hxx> #include <fmtpdsc.hxx> #include <hintids.hxx> #include <istyleaccess.hxx> @@ -300,12 +301,15 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const } } + boost::scoped_ptr< SfxItemSet > tmpSet; + const SwPageDesc* pPgDesc; if( pSrcDoc != pDstDoc && SFX_ITEM_SET == GetItemState( RES_PAGEDESC, sal_False, &pItem ) && 0 != ( pPgDesc = ((SwFmtPageDesc*)pItem)->GetPageDesc()) ) { - SfxItemSet aTmpSet( *this ); + if( !tmpSet ) + tmpSet.reset( new SfxItemSet( *this )); SwPageDesc* pDstPgDesc = pDstDoc->FindPageDescByName(pPgDesc->GetName()); if( !pDstPgDesc ) @@ -315,20 +319,33 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const } SwFmtPageDesc aDesc( pDstPgDesc ); aDesc.SetNumOffset( ((SwFmtPageDesc*)pItem)->GetNumOffset() ); - aTmpSet.Put( aDesc ); + tmpSet->Put( aDesc ); + } + if( pSrcDoc != pDstDoc && SFX_ITEM_SET == GetItemState( RES_ANCHOR, false, &pItem ) + && static_cast< const SwFmtAnchor* >( pItem )->GetCntntAnchor() != NULL ) + { + if( !tmpSet ) + tmpSet.reset( new SfxItemSet( *this )); + // Anchors at any node position cannot be copied to another document, because the SwPosition + // would still point to the old document. It needs to be fixed up explicitly. + tmpSet->ClearItem( RES_ANCHOR ); + } + + if( tmpSet ) + { if( pCNd ) { // #i92811# if ( pNewListIdItem != 0 ) { - aTmpSet.Put( *pNewListIdItem ); + tmpSet->Put( *pNewListIdItem ); } - pCNd->SetAttr( aTmpSet ); + pCNd->SetAttr( *tmpSet ); } else { - pFmt->SetFmtAttr( aTmpSet ); + pFmt->SetFmtAttr( *tmpSet ); } } else if( pCNd ) |