From 458d56d9b35f2ecb2eea2589737079390b10ee26 Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Mon, 30 Jan 2012 11:35:42 +0100 Subject: fdo#35669: more robust references merging --- sw/source/core/fields/reffld.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 5f1aa3a7523d..05c3eda29e16 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -974,11 +974,13 @@ void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField ) GetFieldIdsFromDoc( rDoc, aDstIds ); // Define the mappings now - sal_uInt16 nMaxDstId = *aIds.end(); + sal_uInt16 nMaxDstId = -1; + if ( !aIds.empty() ) + nMaxDstId = *aIds.rbegin(); // Map all the src fields to their value + nMaxDstId for ( std::set::iterator pIt = aDstIds.begin(); pIt != aDstIds.end(); ++pIt ) - AddId( nMaxDstId++, *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 ); -- cgit