summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-11-08 09:41:02 +0100
committerLuboš Luňák <l.lunak@collabora.com>2014-11-09 19:45:12 +0100
commitbb00a0097900ae054401f7758a915047cfde4065 (patch)
tree324f08792f653d83bb740c9b9441862b0526ed84
parentf1fb3fae21d8e157978da4666eab15364ebb0660 (diff)
do not bother with nice unique names during mailmerge
When using a single document for all the generating MM documents, there can be a significant number of sections/etc. , enough to make searching them all in order to find a next nice unique name take a noticeable time. Since it's very unlikely anybody will ever care about nice names after mailmerge, just get some unique name in a fast way. Change-Id: Id6b8d39a67529984cb93bb369f2c6eab401f1799
-rw-r--r--sw/source/core/doc/docbm.cxx21
-rw-r--r--sw/source/core/doc/doclay.cxx9
-rw-r--r--sw/source/core/doc/docnum.cxx11
-rw-r--r--sw/source/core/doc/doctxm.cxx11
-rw-r--r--sw/source/core/docnode/ndsect.cxx11
-rw-r--r--sw/source/core/docnode/ndtbl.cxx9
-rw-r--r--sw/source/core/inc/MarkManager.hxx2
7 files changed, 63 insertions, 11 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 6c877dc331b1..22cef6b83fa1 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -52,6 +52,7 @@
#include <viscrs.hxx>
#include <edimp.hxx>
#include <stdio.h>
+#include <tools/datetimeutils.hxx>
using namespace ::boost;
using namespace ::sw::mark;
@@ -1069,6 +1070,14 @@ namespace sw { namespace mark
{
OSL_ENSURE(rName.getLength(),
"<MarkManager::getUniqueMarkName(..)> - a name should be proposed");
+ if( m_pDoc->IsInMailMerge())
+ {
+ OUString newName = rName + "MailMergeMark"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( m_vAllMarks.size() + 1 );
+ return newName;
+ }
+
if ( findMark(rName) == getAllMarksEnd() )
{
return rName;
@@ -1076,13 +1085,9 @@ namespace sw { namespace mark
OUStringBuffer sBuf;
OUString sTmp;
- // try the name "<rName>XXX" (where XXX is a number starting from 1) unless there is
- // a unused name. Due to performance-reasons (especially in mailmerge-Szenarios) there
- // 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;
+ // Try the name "<rName>XXX", where XXX is a number. Start the number at the existing count rather than 1
+ // in order to increase the chance that already the first one will not exist.
+ sal_Int32 nCnt = m_vAllMarks.size() + 1;
while(nCnt < SAL_MAX_INT32)
{
sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear();
@@ -1092,8 +1097,6 @@ namespace sw { namespace mark
break;
}
}
- m_aMarkBasenameMapUniqueOffset[rName] = nCnt;
-
return sTmp;
}
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 288ba1fa0fa9..8f12b98d230a 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -94,6 +94,7 @@
#include <pagedesc.hxx>
#include <PostItMgr.hxx>
#include <comcore.hrc>
+#include <tools/datetimeutils.hxx>
#include <unoframe.hxx>
@@ -1287,6 +1288,14 @@ IMPL_STATIC_LINK( SwDoc, BackgroundDone, SvxBrushItem*, EMPTYARG )
static OUString lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId )
{
+ if( pDoc->IsInMailMerge())
+ {
+ OUString newName = "MailMergeFly"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( pDoc->GetSpzFrmFmts()->size() + 1 );
+ return newName;
+ }
+
ResId aId( nDefStrId, *pSwResMgr );
OUString aName( aId );
sal_Int32 nNmLen = aName.getLength();
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 1b078e2b152d..4cf931b8daba 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -55,6 +55,7 @@
#include <list.hxx>
#include <switerator.hxx>
#include <comphelper/string.hxx>
+#include <tools/datetimeutils.hxx>
#include <cstdlib>
#include <map>
@@ -2185,6 +2186,16 @@ sal_uInt16 SwDoc::MakeNumRule( const OUString &rName,
OUString SwDoc::GetUniqueNumRuleName( const OUString* pChkStr, bool bAutoNum ) const
{
+ if( IsInMailMerge())
+ {
+ OUString newName = "MailMergeNumRule"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( mpNumRuleTbl->size() + 1 );
+ if( pChkStr )
+ newName += *pChkStr;
+ return newName;
+ }
+
OUString aName;
if( bAutoNum )
{
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 5d89632afcca..d0c1441a740c 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -71,6 +71,7 @@
#include <switerator.hxx>
#include <ToxTextGenerator.hxx>
#include <ToxTabStopTokenHandler.hxx>
+#include <tools/datetimeutils.hxx>
#include <boost/make_shared.hpp>
@@ -609,6 +610,16 @@ const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp )
OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType,
const OUString& sChkStr ) const
{
+ if( IsInMailMerge())
+ {
+ OUString newName = "MailMergeTOX"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( mpSectionFmtTbl->size() + 1 );
+ if( !sChkStr.isEmpty())
+ newName += sChkStr;
+ return newName;
+ }
+
bool bUseChkStr = !sChkStr.isEmpty();
const OUString aName( rType.GetTypeName() );
const sal_Int32 nNmLen = aName.getLength();
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 993cd8ea7eb0..1178ef92f175 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -58,6 +58,7 @@
#include <txtfrm.hxx>
#include <boost/scoped_ptr.hpp>
#include <ndsect.hxx>
+#include <tools/datetimeutils.hxx>
// #i21457# - new implementation of local method <lcl_IsInSameTblBox(..)>.
// Method now determines the previous/next on its own. Thus, it can be controlled,
@@ -1380,6 +1381,16 @@ void SwSectionNode::NodesArrChgd()
OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const
{
+ if( IsInMailMerge())
+ {
+ OUString newName = "MailMergeSection"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( mpSectionFmtTbl->size() + 1 );
+ if( pChkStr )
+ newName += *pChkStr;
+ return newName;
+ }
+
const OUString aName( ResId( STR_REGION_DEFNAME, *pSwResMgr ) );
sal_uInt16 nNum = 0;
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 568493b5df00..8e5d2fd12bd0 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -94,6 +94,7 @@
#include <switerator.hxx>
#include <o3tl/numeric.hxx>
#include <boost/foreach.hpp>
+#include <tools/datetimeutils.hxx>
#ifdef DBG_UTIL
#define CHECK_TABLE(t) (t).CheckConsistency();
@@ -3861,6 +3862,14 @@ bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet )
OUString SwDoc::GetUniqueTblName() const
{
+ if( IsInMailMerge())
+ {
+ OUString newName = "MailMergeTable"
+ + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
+ + OUString::number( mpTblFrmFmtTbl->size() + 1 );
+ return newName;
+ }
+
ResId aId( STR_TABLE_DEFNAME, *pSwResMgr );
const OUString aName( aId );
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index ccd614e9d900..52fea0a07d91 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -27,7 +27,6 @@
namespace sw {
namespace mark {
- typedef boost::unordered_map<OUString, sal_Int32, OUStringHash> MarkBasenameMapUniqueOffset_t;
class MarkManager
: private ::boost::noncopyable
@@ -111,7 +110,6 @@ namespace sw {
container_t m_vFieldmarks;
boost::unordered_set<OUString, OUStringHash> m_aMarkNamesSet;
- mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset;
// container for annotation marks
container_t m_vAnnotationMarks;