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
...@@ -1077,22 +1077,15 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames ) ...@@ -1077,22 +1077,15 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i ) for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i )
{ {
bool bInsWithFmt = true;
const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i]; const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i];
if( bInsWithFmt )
{
SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) if ( FLY_AT_PAGE != aAnchor.GetAnchorId() )
{
aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 );
}
else
continue; continue;
aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 );
GetDoc()->getIDocumentLayoutAccess().CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); GetDoc()->getIDocumentLayoutAccess().CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
} }
} }
} }
}
FOREACHPAM_END() FOREACHPAM_END()
} }
......
...@@ -2897,17 +2897,12 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, ...@@ -2897,17 +2897,12 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
} }
} }
if(nDocNo == 1 || bPageStylesWithHeaderFooter) if(nDocNo == 1 || bPageStylesWithHeaderFooter)
{
pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), true ); pTargetView->GetDocShell()->_LoadStyles( *rSourceView.GetDocShell(), true );
}
if(nDocNo > 1) if(nDocNo > 1)
{
pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo ); pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo );
}
else else
{
pTargetShell->SetPageStyle(sModifiedStartingPageDesc); pTargetShell->SetPageStyle(sModifiedStartingPageDesc);
}
sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt(); sal_uInt16 nPageCountBefore = pTargetShell->GetPageCnt();
OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended"); OSL_ENSURE(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended");
bool para_added = false; bool para_added = false;
...@@ -2916,8 +2911,8 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, ...@@ -2916,8 +2911,8 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
{ {
SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 ); SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 );
SwPosition aTestPos( aIdx ); SwPosition aTestPos( aIdx );
SwCursor aTestCrsr(aTestPos,0,false); SwCursor aTestCrsr( aTestPos, 0, false );
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart)) if ( !aTestCrsr.MovePara(fnParaNext, fnParaStart) )
{ {
//append a paragraph //append a paragraph
pWorkDoc->getIDocumentContentOperations().AppendTxtNode( aTestPos ); pWorkDoc->getIDocumentContentOperations().AppendTxtNode( aTestPos );
...@@ -2950,7 +2945,7 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, ...@@ -2950,7 +2945,7 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
lcl_SaveDoc( xTargetDocShell, "MergeDoc" ); lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
#endif #endif
//add the document info to the config item // add the document info to the config item
SwDocMergeInfo aMergeInfo; SwDocMergeInfo aMergeInfo;
aMergeInfo.nStartPageInTarget = nPageCountBefore; aMergeInfo.nStartPageInTarget = nPageCountBefore;
//#i72820# calculate layout to be able to find the correct page index //#i72820# calculate layout to be able to find the correct page index
...@@ -2964,17 +2959,17 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, ...@@ -2964,17 +2959,17 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
for( sal_uInt16 i = 0; i < 25; i++) for( sal_uInt16 i = 0; i < 25; i++)
Application::Reschedule(); Application::Reschedule();
//restore the ole DBManager // restore the old DBManager
pWorkDoc->SetDBManager( pWorkDBManager ); pWorkDoc->SetDBManager( pWorkDBManager );
//now the temporary document should be closed // close the temporary document
SfxObjectShellRef xDocSh(pWorkView->GetDocShell()); xWorkDocSh->DoClose();
xDocSh->DoClose();
nEndRow = pImpl->pMergeData->xResultSet->getRow(); nEndRow = pImpl->pMergeData->xResultSet->getRow();
++nDocNo; ++nDocNo;
} while( !bCancel && } while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord())); (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); Point aPt(LONG_MIN, LONG_MIN);
pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME); pTargetShell->SelectObj(aPt, SW_LEAVE_FRAME);
if (pTargetShell->IsSelFrmMode()) 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