summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2012-01-26 15:30:01 +0100
committerMichael Stahl <mstahl@redhat.com>2012-01-30 22:23:22 +0100
commitd3294590d6c15205cc0a176e96ef04f2816079cd (patch)
tree2b19965cbcca7b996b3856cfd70d956919996f14
parent6594688df45cb491042470c4ae5289c47192994a (diff)
fdo#35669: properly merge ref fields in master documents
(cherry picked from commit 5e51960dede5015b862df05b7b16f02884647889) Signed-off-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/source/core/fields/reffld.cxx37
1 files changed, 22 insertions, 15 deletions
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 98111d0850f6..c15c542be50d 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -972,6 +972,26 @@ void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField )
{
GetFieldIdsFromDoc( rDestDoc, aIds );
GetFieldIdsFromDoc( rDoc, aDstIds );
+
+ // Define the mappings now
+ sal_uInt16 nMaxDstId = *aIds.end();
+
+ // Map all the src fields to their value + nMaxDstId
+ for ( std::set<sal_uInt16>::iterator pIt = aDstIds.begin(); pIt != aDstIds.end(); ++pIt )
+ AddId( nMaxDstId++, *pIt );
+
+ // Change the Sequence number of all the SetExp fields in the destination document
+ SwFieldType* pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false );
+ if( pType )
+ {
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
+ for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
+ if( pF->GetTxtFld() )
+ {
+ sal_uInt16 n = ((SwSetExpField*)pF->GetFld())->GetSeqNumber( );
+ ((SwSetExpField*)pF->GetFld())->SetSeqNumber( sequencedIds[ n ] );
+ }
+ }
}
else
{
@@ -1030,21 +1050,8 @@ void _RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld,
AddId( n, nSeqNo );
rFld.SetSeqNo( n );
- // und noch die Felder oder Fuss-/EndNote auf die neue
- // Id umsetzen
- if( bField )
- {
- SwFieldType* pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false );
- if( pType )
- {
- SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
- for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
- if( pF->GetTxtFld() && nSeqNo ==
- ((SwSetExpField*)pF->GetFld())->GetSeqNumber() )
- ((SwSetExpField*)pF->GetFld())->SetSeqNumber( n );
- }
- }
- else
+ // und noch die Fuss-/EndNote auf die neue Id umsetzen
+ if( !bField )
{
SwTxtFtn* pFtnIdx;
for( sal_uInt16 i = 0, nCnt = rDoc.GetFtnIdxs().Count(); i < nCnt; ++i )