[Libreoffice-commits] core.git: sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Tue Jun 24 08:40:08 PDT 2014
sw/source/uibase/dbui/dbmgr.cxx | 49 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
New commits:
commit 212dce21b62a4cfb85406bebe54ee07545516e21
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Mon Jun 23 08:43:08 2014 +0200
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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 5565ef6..852879d 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2655,10 +2655,41 @@ uno::Reference<XResultSet> SwDBManager::createCursor(const OUString& _sDataSourc
return xResultSet;
}
+#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;
+ OUString sExt( ".odt" );
+ OUString 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 SwDBManager::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())
@@ -2721,6 +2752,9 @@ sal_Int32 SwDBManager::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
@@ -2777,6 +2811,11 @@ sal_Int32 SwDBManager::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();
@@ -2864,6 +2903,11 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
pWorkDoc->AppendTxtNode( aTestPos );
}
}
+
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
+#endif
pTargetShell->Paste( rWorkShell.GetDoc(), true );
//convert fields in page styles (header/footer - has to be done after the first document has been pasted
if(1 == nDocNo)
@@ -2871,6 +2915,11 @@ sal_Int32 SwDBManager::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;
More information about the Libreoffice-commits
mailing list