Kaydet (Commit) 2fcf8923 authored tarafından Cor Nouws's avatar Cor Nouws Kaydeden (comit) Miklos Vajna

tdf#86397 Bookmark: no consecutive name numbering applied when copied

this partially changes behaviour introduced with commit bb00a009
but without the performace problems from the old code
thanks to kendy for helping

Change-Id: I5dab81b58262f67db1c70223c612636a8b8c90ee
üst 12c2bbc3
...@@ -1105,9 +1105,13 @@ namespace sw { namespace mark ...@@ -1105,9 +1105,13 @@ namespace sw { namespace mark
OUStringBuffer sBuf; OUStringBuffer sBuf;
OUString sTmp; OUString sTmp;
// Try the name "<rName>XXX", where XXX is a number. Start the number at the existing count rather than 1 // try the name "<rName>XXX" (where XXX is a number starting from 1) unless there is
// in order to increase the chance that already the first one will not exist. // a unused name. Due to performance-reasons (especially in mailmerge-Szenarios) there
sal_Int32 nCnt = m_vAllMarks.size() + 1; // is a map m_aMarkBasenameMapUniqueOffset which holds the next possible offset (XXX) for
// rName (so there is no need to test for nCnt-values smaller than the offset).
sal_Int32 nCnt = 1;
MarkBasenameMapUniqueOffset_t::const_iterator aIter = m_aMarkBasenameMapUniqueOffset.find(rName);
if(aIter != m_aMarkBasenameMapUniqueOffset.end()) nCnt = aIter->second;
while(nCnt < SAL_MAX_INT32) while(nCnt < SAL_MAX_INT32)
{ {
sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear(); sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear();
...@@ -1117,6 +1121,8 @@ namespace sw { namespace mark ...@@ -1117,6 +1121,8 @@ namespace sw { namespace mark
break; break;
} }
} }
m_aMarkBasenameMapUniqueOffset[rName] = nCnt;
return sTmp; return sTmp;
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
namespace sw { namespace sw {
namespace mark { namespace mark {
typedef std::unordered_map<OUString, sal_Int32, OUStringHash> MarkBasenameMapUniqueOffset_t;
class MarkManager class MarkManager
: private ::boost::noncopyable : private ::boost::noncopyable
...@@ -110,6 +111,7 @@ namespace sw { ...@@ -110,6 +111,7 @@ namespace sw {
container_t m_vFieldmarks; container_t m_vFieldmarks;
std::unordered_set<OUString, OUStringHash> m_aMarkNamesSet; std::unordered_set<OUString, OUStringHash> m_aMarkNamesSet;
mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset;
// container for annotation marks // container for annotation marks
container_t m_vAnnotationMarks; container_t m_vAnnotationMarks;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment