sw/source/uibase/dbui/dbmgr.cxx | 69 ++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 27 deletions(-)
New commits: commit 74458301569bc9c0e7619e68be85e716d7b6f9f7 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Tue Jul 1 21:31:35 2014 +0200 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.michael...@canonical.com> Tested-by: Björn Michaelsen <bjoern.michael...@canonical.com> diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 7b013a7..895ffc3 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 )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits