[Libreoffice-commits] .: sw/source
Ivan Timofeev
ivantimofeev at kemper.freedesktop.org
Wed Nov 2 11:00:19 PDT 2011
sw/source/core/doc/doc.cxx | 95 +++++++--------------------------------------
1 file changed, 15 insertions(+), 80 deletions(-)
New commits:
commit 0847d1cb9868396cbcdf59b1a389dc88bcd5b71e
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Mon Oct 31 11:59:07 2011 +0400
simplify determination of pages to print
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index c512862..b3d9472 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1253,92 +1253,27 @@ void SwDoc::CalculatePagesForPrinting(
// #i103700# printing selections should not allow for automatic inserting empty pages
bool bPrintEmptyPages = bPrintSelection ? false : rOptions.IsPrintEmptyPages( bIsPDFExport );
- Range aPages( 1, nDocPageCount );
-
- MultiSelection aMulti( aPages );
- aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
- aMulti.Select( aPages );
-
- const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
- const SwFrm *pEndPage = pStPage;
-
- sal_uInt16 nFirstPageNo = 0;
- sal_uInt16 nLastPageNo = 0;
-
- for( sal_uInt16 i = 1; i <= (sal_uInt16)aPages.Max(); ++i )
- {
- if( i < (sal_uInt16)aPages.Min() )
- {
- if( !pStPage->GetNext() )
- break;
- pStPage = (SwPageFrm*)pStPage->GetNext();
- pEndPage= pStPage;
- }
- else if( i == (sal_uInt16)aPages.Min() )
- {
- nFirstPageNo = i;
- nLastPageNo = nFirstPageNo;
- if( !pStPage->GetNext() || (i == (sal_uInt16)aPages.Max()) )
- break;
- pEndPage = pStPage->GetNext();
- }
- else if( i > (sal_uInt16)aPages.Min() )
- {
- nLastPageNo = i;
- if( !pEndPage->GetNext() || (i == (sal_uInt16)aPages.Max()) )
- break;
- pEndPage = pEndPage->GetNext();
- }
- }
+ std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
+ std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
+ rValidPages.clear();
- OSL_ENSURE( nFirstPageNo, "first page not found! Should not happen!" );
- if (nFirstPageNo)
+ sal_Int32 nPageNum = 1;
+ const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
+ while (pStPage && nPageNum <= nDocPageCount)
{
-// HACK: Hier muss von der MultiSelection noch eine akzeptable Moeglichkeit
-// geschaffen werden, alle Seiten von Seite x an zu deselektieren.
-// Z.B. durch SetTotalRange ....
+ const bool bPrintThisPage =
+ ( (bPrintRightPages && pStPage->OnRightPage()) ||
+ (bPrintLeftPages && !pStPage->OnRightPage()) ) &&
+ ( bPrintEmptyPages || pStPage->Frm().Height() );
-// aMulti.Select( Range( nLastPageNo+1, SELECTION_MAX ), sal_False );
- MultiSelection aTmpMulti( Range( 1, nLastPageNo ) );
- long nTmpIdx = aMulti.FirstSelected();
- static long nEndOfSelection = SFX_ENDOFSELECTION;
- while ( nEndOfSelection != nTmpIdx && nTmpIdx <= long(nLastPageNo) )
+ if (bPrintThisPage)
{
- aTmpMulti.Select( nTmpIdx );
- nTmpIdx = aMulti.NextSelected();
+ rValidPages.insert( nPageNum );
+ rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
}
- aMulti = aTmpMulti;
-// Ende des HACKs
-
- sal_uInt16 nPageNo = nFirstPageNo;
-
- std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
- std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
- rValidPages.clear();
- while ( pStPage )
- {
- const sal_Bool bRightPg = pStPage->OnRightPage();
- if ( aMulti.IsSelected( nPageNo ) &&
- ( (bRightPg && bPrintRightPages) ||
- (!bRightPg && bPrintLeftPages) ) )
- {
- // Feature - Print empty pages
- if ( bPrintEmptyPages || pStPage->Frm().Height() )
- {
- rValidPages.insert( nPageNo );
- rPrinterPaperTrays[ nPageNo ] = lcl_GetPaperBin( pStPage );
- }
- }
- if ( pStPage == pEndPage )
- {
- pStPage = 0;
- }
- else
- { ++nPageNo;
- pStPage = (SwPageFrm*)pStPage->GetNext();
- }
- }
+ ++nPageNum;
+ pStPage = (SwPageFrm*)pStPage->GetNext();
}
More information about the Libreoffice-commits
mailing list