summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2013-12-26 23:15:24 +0100
committerMichael Stahl <mstahl@redhat.com>2014-02-11 13:18:09 +0000
commit8d11531565d746dd6a7938c4f3536ad34698092d (patch)
tree2aff8a7c433a8f47c52b0faeda2e8f31de88eace
parente1f90846af87bed94da736236e2eaa10bddfdd7b (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. Change-Id: I6929ba371f81c3ea1f26ea3a25e7751bc53256e3 Reviewed-on: https://gerrit.libreoffice.org/7433 Tested-by: Michael Stahl <mstahl@redhat.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-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 e9e0319e909e..63d70d126f4b 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -869,11 +869,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();
- OUString sSourceDocumentURL(pOrig->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ));
- const SfxFilter* pSfxFlt = SwIoSystem::GetFileFilter(
- sSourceDocumentURL, ::aEmptyOUStr );
- const SfxFilter* pStoreToFilter = pSfxFlt;
+ const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
+ pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyOUStr );
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const OUString* pStoreToFilterOptions = 0;
@@ -922,14 +919,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();
@@ -1026,13 +1016,19 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
for (sal_uInt16 i = 0; i < 25; 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 );