diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-10-20 22:05:51 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-11-14 13:25:10 +0100 |
commit | 57658e82c04d00fda60aaf9e22eb16cd1d6cfbb0 (patch) | |
tree | 51d791972581f5f84e760177ef403ae4fb482c6b | |
parent | 708cada5d76a26b6b2ac2885bf6b48f1205f1dd5 (diff) |
compute page offset for mailmerge based on source document rather than target
This removes another need for doing repeated and expensive layouts of the target
document.
Conflicts:
sw/inc/doc.hxx
sw/source/core/doc/docnew.cxx
sw/source/uibase/dbui/dbmgr.cxx
Change-Id: Id78bc3ccc71c17e42f858dc9660866b9c94dea3a
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 21 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbmgr.cxx | 13 |
3 files changed, 17 insertions, 19 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 0d01946d4c6c..86aae2817d6c 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -2078,7 +2078,7 @@ public: SfxObjectShell* CreateCopy(bool bCallInitNew) const; SwNodeIndex AppendDoc(const SwDoc& rSource, sal_uInt16 nStartPageNumber, - SwPageDesc* pTargetPageDesc, bool bDeletePrevious = false ); + SwPageDesc* pTargetPageDesc, bool bDeletePrevious = false, int physicalPageOffset = 0 ); /** * Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a7f714df09f5..112bdf59a62b 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -1157,7 +1157,7 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const // appends all pages of source SwDoc - based on SwFEShell::Paste( SwDoc* ) SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNumber, - SwPageDesc *const pTargetPageDesc, bool const bDeletePrevious) + SwPageDesc *const pTargetPageDesc, bool const bDeletePrevious, int pageOffset) { // GetEndOfExtras + 1 = StartOfContent == no content node! // @see IDocumentContentOperations::CopyRange @@ -1198,7 +1198,6 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu #endif SwWrtShell* pTargetShell = GetDocShell()->GetWrtShell(); - sal_uInt16 nPhysPageNumber = 0; if ( pTargetShell ) { #ifdef DBG_UTIL SAL_INFO( "sw.docappend", "Has target write shell" ); @@ -1210,18 +1209,6 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu String name = pTargetPageDesc->GetName(); pTargetShell->InsertPageBreak( &name, nStartPageNumber ); } - - // -1 for the page break + -1, becauce it's an offset - nPhysPageNumber = pTargetShell->GetPhyPageNum() - 2; - if (bDeletePrevious) - nPhysPageNumber--; - - // We always start on an odd physical page number - if (1 == nPhysPageNumber % 2) - nPhysPageNumber++; -#ifdef DBG_UTIL - SAL_INFO( "sw.docappend", "PPNo " << nPhysPageNumber ); -#endif } #ifdef DBG_UTIL SAL_INFO( "sw.docappend", "Nd: " << CNTNT_DOC( this ) ); @@ -1379,10 +1366,10 @@ else continue; #ifdef DBG_UTIL SAL_INFO( "sw.docappend", "PaAn: " << aAnchor.GetPageNum() - << " => " << aAnchor.GetPageNum() + nPhysPageNumber ); + << " => " << aAnchor.GetPageNum() + pageOffset ); #endif - if ( nPhysPageNumber ) - aAnchor.SetPageNum( aAnchor.GetPageNum() + nPhysPageNumber ); + if ( pageOffset != 0 ) + aAnchor.SetPageNum( aAnchor.GetPageNum() + pageOffset ); this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); } } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 329f5963819b..a612aa4d2467 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -1061,6 +1061,12 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, sal_Int32 nDocNo = 1; sal_Int32 nDocCount = 0; + // For single file mode, the number of pages in the target document so far, which is used + // by AppendDoc() to adjust position of page-bound objects. Getting this information directly + // from the target doc would require repeated layouts of the doc, which is expensive, but + // it can be manually computed from the source documents (for which we do layouts, so the page + // count is known, and there is a blank page between each of them in the target document). + int targetDocPageCount = 0; if( !IsMergeSilent() && bMergeShell && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) ) ((CreateMonitor*) pProgressDlg)->SetTotalCount( nDocCount ); @@ -1207,11 +1213,16 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) ) lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo ); + + if( targetDocPageCount % 2 == 1 ) + ++targetDocPageCount; // Docs always start on odd pages (so offset must be even). SwNodeIndex appendedDocStart = pTargetDoc->AppendDoc(*rWorkShell.GetDoc(), - nStartingPageNo, pTargetPageDesc, nDocNo == 1 ); + nStartingPageNo, pTargetPageDesc, nDocNo == 1, targetDocPageCount); // #i72820# calculate layout to be able to find the correct page index pTargetShell->CalcLayout(); + targetDocPageCount += rWorkShell.GetPageCnt(); + if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) ) lcl_SaveDoc( xTargetDocShell, "MergeDoc" ); if (bMergeShell) |