Kaydet (Commit) 74458301 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Björn Michaelsen

Add debug documents to SwDBManager::MergeMailFiles

Just like the debug documents in SwDBManager::MergeDocuments.

Change-Id: I275575853c80d4e19d6df5ba9d8dc689353d7c85
Reviewed-on: https://gerrit.libreoffice.org/10970Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 3b9361a9
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment