summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-04-11 20:57:49 +0100
committerFridrich Strba <fridrich@documentfoundation.org>2013-04-13 10:05:37 +0000
commit1b1fe71be534fb05a11f741375e47f552e7a8914 (patch)
tree6b3dbf56f8caf08ed42bf80b76851c55a2f47afa
parent0ac18f7d54f22c0c0d40cc4b1cfe6059ef0b56c5 (diff)
Resolves: fdo#48039 use same algorithm for assigning get/set replacement ids
i.e. use the same algorithm for assigning replacement ids for both get and set exp fields. Otherwise, consider for ex. 1. fields exists with ids of 1 and 2 in master document 2. a field exists with id of 1 in subdocument and must be reassigned a new id to not collide with the pre existing master ids In get orig algorithm assigned first unused slot of master to subdocument field i.e. 0 unused in master, so subdocument:1 converted to master:0 In set orig algorithm sorted all used master slots and assigned largest used id plus 1 (therefore unused) to subdocument field i.e. largest id used in master is 2, so subdocument:1 converted to master:3 so get can't find set and error's out with: Error: Reference source not found Change-Id: Ie8758dc22cf8deeeeff079532284e57eeaf4a9bd (cherry picked from commit 74d942fb2396a268adfcc915e75b8b32fae851dc) Reviewed-on: https://gerrit.libreoffice.org/3347 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sw/source/core/fields/reffld.cxx13
1 files changed, 4 insertions, 9 deletions
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 79b076b6e72c..71b1902eac8c 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1007,14 +1007,9 @@ void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField )
GetFieldIdsFromDoc( rDestDoc, aIds );
GetFieldIdsFromDoc( rDoc, aDstIds );
- // Define the mappings now
- sal_uInt16 nMaxDstId = -1;
- if ( !aIds.empty() )
- nMaxDstId = *aIds.rbegin();
-
- // Map all the src fields to their value + nMaxDstId
+ // Map all the new src fields to the next available unused id
for ( std::set<sal_uInt16>::iterator pIt = aDstIds.begin(); pIt != aDstIds.end(); ++pIt )
- AddId( ++nMaxDstId, *pIt );
+ AddId( GetFirstUnusedId(aIds), *pIt );
// Change the Sequence number of all the SetExp fields in the destination document
SwFieldType* pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false );
@@ -1037,9 +1032,9 @@ void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField )
bInit = sal_True;
}
-/// Get the lowest unused ID in the passed set.
+/// Get the lowest number unused in the passed set.
/// @param[in] rIds The set of used ID numbers.
-/// @returns The lowest unused ID.
+/// @returns The lowest number unused by the passed set
sal_uInt16 _RefIdsMap::GetFirstUnusedId( std::set<sal_uInt16> &rIds )
{
sal_uInt16 num(0);