sw/inc/doc.hxx | 4 ++++ sw/source/core/doc/DocumentLayoutManager.cxx | 2 +- sw/source/core/doc/docnew.cxx | 1 + sw/source/uibase/dbui/dbmgr.cxx | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-)
New commits: commit 997055f50db39557425c9da58bcd3f01a8584676 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 31 10:22:28 2014 +0100 SwDBManager::MergeMailFiles: set unique fly names at the end of the merge When generating a unique fly name, we have to iterate over all the existing flys to find out what's the first not used one, so doing this for every new fly inserted by mail merge is O(n^2). During import, we already skip this and only do it once at the end of the import, which is O(n). Fix the performance problem by skipping the unique fly name generating when we produce a combined mail merge document as well, and just generate them once the mail merge is complete. For a test document having 12 text frames and 2000 mail merge records, the times for css::text::MailMerge::execute() is 9m37.330s -> 8m18.811s. Change-Id: Idfa8e9fe3acc93f1138f5bb12c2419c1492f8ff1 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3bbf546..eb1a240 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -372,6 +372,7 @@ private: frames need deletion. */ bool mbCopyIsMove : 1; //< TRUE: Copy is a hidden Move. bool mbInReading : 1; //< TRUE: Document is in the process of being read. + bool mbInMailMerge : 1; //< TRUE: Document is in the process of being written by mail merge. bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary. bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX. bool mbInLoadAsynchron : 1; //< TRUE: Document is in the process of being loaded asynchronously. @@ -1016,6 +1017,9 @@ public: bool IsInReading() const { return mbInReading; } void SetInReading( bool bNew ) { mbInReading = bNew; } + bool IsInMailMerge() const { return mbInMailMerge; } + void SetInMailMerge( bool bNew ) { mbInMailMerge = bNew; } + bool IsClipBoard() const { return mbClipBoard; } // N.B.: must be called right after constructor! (@see GetXmlIdRegistry) void SetClipBoard( bool bNew ) { mbClipBoard = bNew; } diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 19b07cb..63146ac 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -412,7 +412,7 @@ SwFrmFmt *DocumentLayoutManager::CopyLayoutFmt( if( !m_rSwdoc.IsCopyIsMove() || &m_rSwdoc != pSrcDoc ) { - if( m_rSwdoc.IsInReading() ) + if( m_rSwdoc.IsInReading() || m_rSwdoc.IsInMailMerge() ) pDest->SetName( OUString() ); else { diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 227dcc7..a8405d5 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -262,6 +262,7 @@ SwDoc::SwDoc() mbDtor(false), mbCopyIsMove(false), mbInReading(false), + mbInMailMerge(false), mbInXMLImport(false), mbUpdateTOX(false), mbInLoadAsynchron(false), diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 141f9a2..6f17f51 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -941,6 +941,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() ); pTargetShell = pTargetView->GetWrtShellPtr(); pTargetDoc = pTargetShell->GetDoc(); + pTargetDoc->SetInMailMerge(true); //copy the styles from the source to the target document pTargetView->GetDocShell()->_LoadStyles( *pSourceDocSh, true ); @@ -1267,6 +1268,13 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, } } while( !bCancel && (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord())); + if (rMergeDescriptor.bCreateSingleFile) + { + // sw::DocumentLayoutManager::CopyLayoutFmt() did not generate + // unique fly names, do it here once. + pTargetDoc->SetInMailMerge(false); + pTargetDoc->SetAllUniqueFlyNames(); + } for( sal_uInt16 i = 0; i < 25; i++) Application::Reschedule(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits