summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2014-07-01 21:31:35 +0200
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2014-09-10 11:07:20 +0000
commit74458301569bc9c0e7619e68be85e716d7b6f9f7 (patch)
tree47f833dae929f737fef68167add548152628ed8a
parent3b9361a930d62430044ea0b746f4b5751dbb8d88 (diff)
Add debug documents to SwDBManager::MergeMailFiles
Just like the debug documents in SwDBManager::MergeDocuments. Change-Id: I275575853c80d4e19d6df5ba9d8dc689353d7c85 Reviewed-on: https://gerrit.libreoffice.org/10970 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx69
1 files changed, 42 insertions, 27 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 7b013a7cf678..895ffc3029d6 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -809,6 +809,33 @@ static void lcl_RemoveSectionLinks( SwWrtShell& rWorkShell )
rWorkShell.SetLabelDoc( false );
}
+#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
+
bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
const SwMergeDescriptor& rMergeDescriptor)
{
@@ -902,6 +929,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// create a target docshell to put the merged document into
xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
xTargetDocShell->DoInitNew( 0 );
+#ifdef DBG_UTIL
+ lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
+#endif
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
@@ -1012,6 +1042,10 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here
// copy the source document
SfxObjectShellLock xWorkDocSh = pSourceDocSh->GetDoc()->CreateCopy( true );
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
+#endif
{
//create a view frame for the document
@@ -1072,10 +1106,18 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
else
pTargetPageDesc = pTargetShell->FindPageDescByName( sModifiedStartingPageDesc );
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
+#endif
pTargetDoc->Append( *(rWorkShell.GetDoc()), nStartingPageNo, pTargetPageDesc, nDocNo == 1 );
// #i72820# calculate layout to be able to find the correct page index
pTargetShell->CalcLayout();
+#ifdef DBG_UTIL
+ if ( nDocNo <= MAX_DOC_DUMP )
+ lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
+#endif
}
else
{
@@ -2628,33 +2670,6 @@ 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 )