Kaydet (Commit) 8a798ef5 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Caolán McNamara

Some minor MM related refactoring

Refactors some code of SwFEShell::Paste and
SwDBManager::MergeDocuments to make it more readable.

Change-Id: Ifd78d6a44fa78eaf1f4fca63f4bbd3ee43ca129d
Reviewed-on: https://gerrit.libreoffice.org/10965Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 01e5ff37
......@@ -681,7 +681,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
// If there are table formulas in the area, then display the table first
// so that the table formula can calculate a new value first
// (individual boxes in the area are retrieved via the layout)
SwFieldType* pTblFldTyp = GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_TABLEFLD );
SwFieldType* pTblFldTyp = GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_TABLEFLD );
SwTableNode *pDestNd, *pSrcNd = aCpyPam.GetNode().GetTableNode();
if( !pSrcNd ) // TabellenNode ?
......@@ -1077,19 +1077,12 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i )
{
bool bInsWithFmt = true;
const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i];
if( bInsWithFmt )
{
SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )
{
aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 );
}
else
continue;
GetDoc()->getIDocumentLayoutAccess().CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
}
SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
if ( FLY_AT_PAGE != aAnchor.GetAnchorId() )
continue;
aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 );
GetDoc()->getIDocumentLayoutAccess().CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
}
}
}
......
......@@ -2897,17 +2897,12 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
}
}
if(nDocNo == 1 || bPageStylesWithHeaderFooter)
{
pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), true );
}
if(nDocNo > 1)
{
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
}
else
{
pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
}
sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt();
OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
bool para_added = false;
......@@ -2915,9 +2910,9 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
//#i51359# add a second paragraph in case there's only one
{
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false);
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
SwPosition aTestPos( aIdx );
SwCursor aTestCrsr( aTestPos, 0, false );
if ( !aTestCrsr.MovePara(fnParaNext, fnParaStart) )
{
//append a paragraph
pWorkDoc->getIDocumentContentOperations().AppendTxtNode( aTestPos );
......@@ -2950,7 +2945,7 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
#endif
//add the document info to the config item
// add the document info to the config item
SwDocMergeInfo aMergeInfo;
aMergeInfo.nStartPageInTarget = nPageCountBefore;
//#i72820# calculate layout to be able to find the correct page index
......@@ -2964,17 +2959,17 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
for( sal_uInt16 i = 0; i < 25; i++)
Application::Reschedule();
//restore the ole DBManager
// restore the old DBManager
pWorkDoc->SetDBManager( pWorkDBManager );
//now the temporary document should be closed
SfxObjectShellRef xDocSh(pWorkView->GetDocShell());
xDocSh->DoClose();
// close the temporary document
xWorkDocSh->DoClose();
nEndRow = pImpl->pMergeData->xResultSet->getRow();
++nDocNo;
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
//deselect all, go out of the frame and go to the beginning of the document
// deselect all, go out of the frame and go to the beginning of the document
Point aPt(LONG_MIN, LONG_MIN);
pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
if (pTargetShell->IsSelFrmMode())
......
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