diff options
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 21 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 11 |
3 files changed, 15 insertions, 19 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 8a382e1b19d0..c8b88c241796 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1660,7 +1660,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 066f62580303..70bda8ca87ff 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -932,7 +932,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 @@ -973,7 +973,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" ); @@ -985,18 +984,6 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu OUString 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 ) ); @@ -1154,10 +1141,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->getIDocumentLayoutAccess().CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); } } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index c6f48fef5eb7..4a0740829142 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -979,6 +979,12 @@ bool SwDBManager::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 ) ) static_cast<CreateMonitor*>( pProgressDlg )->SetTotalCount( nDocCount ); @@ -1125,10 +1131,13 @@ bool SwDBManager::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) |