summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2014-06-23 08:43:08 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2014-09-30 09:47:49 +0200
commit05ff9aafeb3f68fa0f70f8b14571bdec789628a6 (patch)
treecee7e770a2e2e493d8b697cdb958e6e2ca2501c0
parentcbbcb3b4d9c58cbb49112bd1a49f894d8986cb05 (diff)
Save debug mail merge documents
This saves the first three mail merge documents, the source and the corresponding working documents. For convenience all saved document URIs printed to the console. Change-Id: Ice86bf59fc519cfab170ff0956559dc9373d5a26 Reviewed-on: https://gerrit.libreoffice.org/9860 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 212dce21b62a4cfb85406bebe54ee07545516e21) Conflicts: sw/source/uibase/dbui/dbmgr.cxx
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 926237d0591e..271f17d2ea38 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -2679,10 +2679,41 @@ uno::Reference<XResultSet> SwNewDBMgr::createCursor(const OUString& _sDataSource
}
+#ifdef DBG_UTIL
+
+#define MAX_DOC_DUMP 3
+
+static void lcl_SaveDoc( SfxObjectShell *xTargetDocShell,
+ const char *name, int no = 0 )
+{
+ boost::scoped_ptr< utl::TempFile > aTempFile;
+ String sExt( ".odt" );
+ String basename = OUString::createFromAscii( name );
+ if (no > 0 )
+ basename += OUString::number(no) + "-";
+ aTempFile.reset( new utl::TempFile( basename, true, &sExt ) );
+ OSL_ENSURE( aTempFile.get(), "Temporary file not available" );
+ INetURLObject aTempFileURL( aTempFile->GetURL() );
+ SfxMedium* pDstMed = new SfxMedium(
+ aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
+ STREAM_STD_READWRITE );
+ xTargetDocShell->DoSaveAs( *pDstMed );
+ xTargetDocShell->DoSaveCompleted( pDstMed );
+ if( xTargetDocShell->GetError() )
+ SAL_WARN( "sw.mailmerge", "Error saving: " << aTempFile->GetURL() );
+ else
+ SAL_INFO( "sw.mailmerge", "Saved doc as: " << aTempFile->GetURL() );
+}
+#endif
+
// merge all data into one resulting document and return the number of merged documents
sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
SwView& rSourceView )
{
+#ifdef DBG_UTIL
+ lcl_SaveDoc( rSourceView.GetDocShell(), "MergeSource" );
+#endif
+
// check the availability of all data in the config item
uno::Reference< XResultSet> xResultSet = rMMConfig.GetResultSet();
if(!xResultSet.is())
@@ -2745,6 +2776,9 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
// create a target docshell to put the merged document into
SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) );
xTargetDocShell->DoInitNew( 0 );
+#ifdef DBG_UTIL
+ lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
+#endif
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
//the created window has to be located at the same position as the source window
@@ -2803,6 +2837,11 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
{
xWorkDocSh = rSourceView.GetDocShell()->GetDoc()->CreateCopy(true);
}
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
+#endif
+
//create a ViewFrame
SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::LoadHiddenDocument( *xWorkDocSh, 0 )->GetViewShell() );
SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
@@ -2890,6 +2929,11 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
pWorkDoc->AppendTxtNode( aTestPos );
}
}
+
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
+#endif
pTargetShell->Paste( rWorkShell.GetDoc(), sal_True );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
@@ -2897,6 +2941,11 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
pTargetShell->CalcLayout();
pTargetShell->ConvertFieldsToText();
}
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
+#endif
+
//add the document info to the config item
SwDocMergeInfo aMergeInfo;
aMergeInfo.nStartPageInTarget = nPageCountBefore;