diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-11-08 09:41:02 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-14 13:26:48 +0100 |
commit | 0e8534395c3ba0d328a14525d145ff3e75b1457d (patch) | |
tree | 0052d8fa0f9cfede91ce73bb5f18c562667e5263 | |
parent | 4ca3a96ff8b5c05aa8a4e48000a1ee485a59707a (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.
Conflicts:
sw/source/core/doc/docbm.cxx
sw/source/core/doc/doclay.cxx
sw/source/core/doc/docnum.cxx
sw/source/core/doc/doctxm.cxx
sw/source/core/docnode/ndsect.cxx
sw/source/core/inc/MarkManager.hxx
Change-Id: Id6b8d39a67529984cb93bb369f2c6eab401f1799
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/doc/doclay.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/doc/docnum.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/docnode/ndsect.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/inc/MarkManager.hxx | 2 |
7 files changed, 61 insertions, 12 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index ab8319998cfd..5a52a3e4db31 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -47,6 +47,7 @@ #include <unocrsr.hxx> #include <viscrs.hxx> #include <stdio.h> +#include <tools/datetimeutils.hxx> using namespace ::std; @@ -839,25 +840,27 @@ namespace sw { namespace mark OSL_ENSURE(!rName.isEmpty(), "<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_aMarkNamesSet.size() + 1 ); + return newName; + } if(!hasMark(rName)) return rName; + 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_aMarkNamesSet.size() + 1; while(nCnt < SAL_MAX_INT32) { sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear(); nCnt++; if(!hasMark(sTmp)) break; } - m_aMarkBasenameMapUniqueOffset[rName] = nCnt; - return sTmp; } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 2da20a1546d4..f15e0c884bf7 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -88,6 +88,7 @@ #include <pagedesc.hxx> #include <PostItMgr.hxx> #include <comcore.hrc> // STR ResIds +#include <tools/datetimeutils.hxx> #include <unoframe.hxx> @@ -1907,6 +1908,14 @@ IMPL_STATIC_LINK( SwDoc, BackgroundDone, SvxBrushItem*, EMPTYARG ) static String 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 ); String aName( aId ); xub_StrLen nNmLen = aName.Len(); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 038f01eea263..3eb149031dad 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -52,6 +52,7 @@ #include <listfunc.hxx> #include <switerator.hxx> #include <comphelper/string.hxx> +#include <tools/datetimeutils.hxx> #include <map> @@ -2215,6 +2216,15 @@ sal_uInt16 SwDoc::MakeNumRule( const String &rName, String SwDoc::GetUniqueNumRuleName( const String* 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; + } String aName; if( bAutoNum ) { diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 6498585a79fb..d69796f6f399 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -63,6 +63,7 @@ #include <editsh.hxx> #include <scriptinfo.hxx> #include <switerator.hxx> +#include <tools/datetimeutils.hxx> using namespace ::com::sun::star; @@ -608,6 +609,15 @@ const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp ) String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, const String* pChkStr ) const { + if( IsInMailMerge()) + { + OUString newName = "MailMergeTOX" + + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US ) + + OUString::number( mpSectionFmtTbl->size() + 1 ); + if( pChkStr ) + newName += *pChkStr; + return newName; + } sal_uInt16 n; const SwSectionNode* pSectNd; const SwSection* pSect; diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index c6ae2921a821..2148a6c36068 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -54,7 +54,7 @@ // #i27138# #include <viewsh.hxx> #include <txtfrm.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, @@ -1386,6 +1386,16 @@ void SwSectionNode::NodesArrChgd() String SwDoc::GetUniqueSectionName( const String* 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; + } + ResId aId( STR_REGION_DEFNAME, *pSwResMgr ); String aName( aId ); xub_StrLen nNmLen = aName.Len(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 92f17bf60689..f0f37ae14be2 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -86,6 +86,7 @@ #include <fldupde.hxx> #include <switerator.hxx> #include <boost/foreach.hpp> +#include <tools/datetimeutils.hxx> #ifdef DBG_UTIL #define CHECK_TABLE(t) (t).CheckConsistency(); @@ -3882,6 +3883,14 @@ sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet String 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 ); String aName( aId ); xub_StrLen nNmLen = aName.Len(); diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx index e5f08b342c27..42f3bb367f47 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 @@ -88,7 +87,6 @@ namespace sw { container_t m_vBookmarks; container_t m_vFieldmarks; boost::unordered_set<OUString, OUStringHash> m_aMarkNamesSet; - mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset; SwDoc * const m_pDoc; }; } // namespace mark |