summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2013-12-26 23:15:24 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2014-08-20 09:40:42 +0200
commitdbb1d7c5603affbf65b84077f02450f1be9f9c6d (patch)
tree915f444bdc883a3a32ccaf813c5e26e2aa459cd7 /sw/source
parent43d96f279a8f7626bcc145ff1938d02f85ff0791 (diff)
Copy mail merge source instead of loading
Currently a mail merge loads the styles from the source document and also loads the original source per mail merge dataset. The new code is based on the MergeDocuments function and swaps the loading with an internal document copy to improve mail merge throughtput. For a mail merge with 99 datasets and a two pages document, callgrind shows an improvement from routhly 44 to 31 billion inclusive instructions for the single SwXMailMerge::execute call. Reviewed-on: https://gerrit.libreoffice.org/7433 Tested-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 8d11531565d746dd6a7938c4f3536ad34698092d) Conflicts: sw/source/ui/dbui/dbmgr.cxx Change-Id: I6929ba371f81c3ea1f26ea3a25e7751bc53256e3
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx32
1 files changed, 14 insertions, 18 deletions
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index d94838c5b2d1..70a853248917 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -870,11 +870,8 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
pSfxDispatcher->Execute( pSourceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
if( !pSourceDocSh->IsModified() )
{
- SfxMedium* pOrig = pSourceDocSh->GetMedium();
- String sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
- const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
- sSourceDocumentURL, ::aEmptyStr );
- const SfxFilter* pStoreToFilter = pSfxFlt;
+ const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
+ pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyStr );
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const String* pStoreToFilterOptions = 0;
@@ -923,14 +920,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
pTargetShell = pTargetView->GetWrtShellPtr();
//copy the styles from the source to the target document
- SwgReaderOption aOpt;
- aOpt.SetTxtFmts( sal_True );
- aOpt.SetFrmFmts( sal_True );
- aOpt.SetPageDescs( sal_True );
- aOpt.SetNumRules( sal_True );
- aOpt.SetMerge( sal_False );
- pTargetView->GetDocShell()->LoadStylesFromFile(
- sSourceDocumentURL, aOpt, sal_True );
+ pTargetView->GetDocShell()->_LoadStyles( *pSourceDocSh, sal_True );
//determine the page style and number used at the start of the source document
pSourceShell->SttEndDoc(sal_True);
nStartingPageNo = pSourceShell->GetVirtPageNum();
@@ -1027,13 +1017,19 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
for (sal_uInt16 i = 0; i < 10; i++)
Application::Reschedule();
- // Create and save new document
// The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here
- SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
- SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ );
- pWorkMed->SetFilter( pSfxFlt );
+ SfxObjectShellLock xWorkDocSh;
+ // copy the source document
+ if( 1 == nDocNo && (bAsSingleFile || rMergeDescriptor.bCreateSingleFile) )
+ {
+ uno::Reference< util::XCloneable > xClone( pSourceDocSh->GetModel(), uno::UNO_QUERY);
+ uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY);
+ SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId()));
+ xWorkDocSh = pWorkModel->GetDocShell();
+ }
+ else
+ xWorkDocSh = pSourceDocSh->GetDoc()->CreateCopy( true );
- if (xWorkDocSh->DoLoad(pWorkMed))
{
//create a view frame for the document
SfxViewFrame* pWorkFrame = SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 );