summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2012-01-26 15:30:01 +0100
committerPetr Mladek <pmladek@suse.cz>2012-01-31 15:24:59 +0100
commit4632a18dae5e1770aa1da4ac55719a09c1ae461b (patch)
tree2dad4bee51c561a90d8385ca8dc360fea3ab4366
parent03e1564c1e306bcdcd6802d6ad09252e36cb51b5 (diff)
fdo#35669: properly merge ref fields in master documents
(cherry picked from commit 5e51960dede5015b862df05b7b16f02884647889) Signed-off-by: Michael Stahl <mstahl@redhat.com> Signed-off-by: Noel Power <nopower@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.cz>
-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 )