2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* $RCSfile: viewpg.cxx,v $
|
|
|
|
* $Revision: 1.31 $
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 15:26:00 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 21:03:00 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2009-08-19 07:32:06 +00:00
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2000-10-25 11:07:02 +00:00
|
|
|
#include <hintids.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <vcl/window.hxx>
|
2009-08-19 07:32:06 +00:00
|
|
|
#include <vcl/oldprintadaptor.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <sfx2/printer.hxx>
|
|
|
|
#include <sfx2/progress.hxx>
|
|
|
|
#include <pvprtdat.hxx>
|
2000-10-25 11:07:02 +00:00
|
|
|
#include <viewsh.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
#include <rootfrm.hxx>
|
|
|
|
#include <viewimp.hxx>
|
|
|
|
#include <viewopt.hxx>
|
|
|
|
#include <swprtopt.hxx> // SwPrtOptions
|
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <ptqueue.hxx>
|
|
|
|
#include <swregion.hxx>
|
|
|
|
#include <hints.hxx>
|
|
|
|
#include <fntcache.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2000-10-25 11:07:02 +00:00
|
|
|
#ifndef _STATSTR_HRC
|
|
|
|
#include <statstr.hrc> // Text fuer SfxProgress
|
|
|
|
#endif
|
|
|
|
#ifndef _COMCORE_HRC
|
|
|
|
#include <comcore.hrc>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-08-14 15:58:59 +00:00
|
|
|
#include <IDocumentFieldsAccess.hxx>
|
|
|
|
#include <IDocumentDeviceAccess.hxx>
|
|
|
|
|
2009-08-19 07:32:06 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// OD 12.12.2002 #103492#
|
|
|
|
SwPagePreviewLayout* ViewShell::PagePreviewLayout()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
return Imp()->PagePreviewLayout();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2002-05-29 14:06:25 +00:00
|
|
|
void ViewShell::ShowPreViewSelection( sal_uInt16 nSelPage )
|
|
|
|
{
|
|
|
|
Imp()->InvalidateAccessiblePreViewSelection( nSelPage );
|
|
|
|
}
|
2002-12-06 15:26:55 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
/** adjust view options for page preview
|
2002-12-06 15:26:55 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
OD 09.01.2003 #i6467#
|
2002-12-06 15:26:55 +00:00
|
|
|
*/
|
2003-03-27 14:45:43 +00:00
|
|
|
void ViewShell::AdjustOptionsForPagePreview( const SwPrtOptions &_rPrintOptions )
|
2002-12-06 15:26:55 +00:00
|
|
|
{
|
|
|
|
if ( !IsPreView() )
|
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
ASSERT( false, "view shell doesn't belongs to a page preview - no adjustment of its view options");
|
|
|
|
return;
|
2002-12-02 06:55:21 +00:00
|
|
|
}
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
PrepareForPrint( _rPrintOptions );
|
2002-12-02 06:55:21 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
return;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2003-05-28 11:52:48 +00:00
|
|
|
// output print preview on printer
|
|
|
|
// OD 05.05.2003 #i14016# - consider empty pages on calculation of scaling
|
|
|
|
// and on calculation of paint offset.
|
2000-09-18 23:08:29 +00:00
|
|
|
void ViewShell::PrintPreViewPage( SwPrtOptions& rOptions,
|
|
|
|
USHORT nRowCol, SfxProgress& rProgress,
|
|
|
|
const SwPagePreViewPrtData* pPrtData )
|
|
|
|
{
|
|
|
|
if( !rOptions.aMulti.GetSelectCount() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// wenn kein Drucker vorhanden ist, wird nicht gedruckt
|
2006-08-14 15:58:59 +00:00
|
|
|
SfxPrinter* pPrt = getIDocumentDeviceAccess()->getPrinter(false);
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pPrt || !pPrt->GetName().Len() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// schoen waers gewesen !!! const MultiSelection& rMulti = rOptions.aMulti;
|
|
|
|
MultiSelection aMulti( rOptions.aMulti );
|
|
|
|
Range aPages( aMulti.FirstSelected(), aMulti.LastSelected() );
|
|
|
|
if ( aPages.Max() > USHRT_MAX )
|
|
|
|
aPages.Max() = USHRT_MAX;
|
|
|
|
|
|
|
|
ASSERT( aPages.Min() > 0,
|
|
|
|
"Seite 0 Drucken?" );
|
|
|
|
ASSERT( aPages.Min() <= aPages.Max(),
|
|
|
|
"MinSeite groesser MaxSeite." );
|
|
|
|
|
|
|
|
// eine neue Shell fuer den Printer erzeugen
|
2000-10-25 11:07:02 +00:00
|
|
|
ViewShell aShell( *this, 0 );
|
2003-06-12 06:39:51 +00:00
|
|
|
if ( &GetRefDev() == pPrt )
|
|
|
|
aShell.mpTmpRef = new SfxPrinter( *pPrt );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SET_CURR_SHELL( &aShell );
|
|
|
|
|
|
|
|
aShell.PrepareForPrint( rOptions );
|
|
|
|
|
|
|
|
// gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits
|
|
|
|
// ausgeblendet sind.
|
|
|
|
int bHiddenFlds = FALSE;
|
|
|
|
SwFieldType* pFldType = 0;
|
|
|
|
if ( GetViewOptions()->IsShowHiddenPara() )
|
|
|
|
{
|
2006-08-14 15:58:59 +00:00
|
|
|
pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD );
|
2000-09-18 23:08:29 +00:00
|
|
|
bHiddenFlds = 0 != pFldType->GetDepends();
|
|
|
|
if( bHiddenFlds )
|
|
|
|
{
|
|
|
|
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
|
|
|
|
pFldType->Modify( &aHnt, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seiten fuers Drucken formatieren
|
|
|
|
aShell.CalcPagesForPrint( (USHORT)aPages.Max(), &rProgress );
|
|
|
|
|
|
|
|
USHORT nCopyCnt = rOptions.bCollate ? rOptions.nCopyCount : 1;
|
|
|
|
BOOL bStartJob = FALSE;
|
|
|
|
|
2005-12-21 14:10:47 +00:00
|
|
|
const bool bPrintEmptyPages = rOptions.IsPrintEmptyPages();
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
for ( USHORT nCnt = 0; nCnt < nCopyCnt; nCnt++ )
|
|
|
|
{
|
2002-05-29 13:34:14 +00:00
|
|
|
if( rOptions.IsPrintSingleJobs() && rOptions.GetJobName().Len() &&
|
2000-09-18 23:08:29 +00:00
|
|
|
( bStartJob || rOptions.bJobStartet ) )
|
|
|
|
{
|
2009-06-11 17:26:10 +00:00
|
|
|
#ifdef TL_NOT_NOW /*TLPDF*/
|
2000-09-18 23:08:29 +00:00
|
|
|
pPrt->EndJob();
|
2009-06-11 17:26:10 +00:00
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
rOptions.bJobStartet = TRUE;
|
|
|
|
|
|
|
|
// Reschedule statt Yield, da Yield keine Events abarbeitet
|
|
|
|
// und es sonst eine Endlosschleife gibt.
|
|
|
|
while( pPrt->IsPrinting() )
|
|
|
|
rProgress.Reschedule();
|
|
|
|
|
|
|
|
rOptions.MakeNextJobName();
|
2009-06-11 17:26:10 +00:00
|
|
|
#ifdef TL_NOT_NOW /*TLPDF*/
|
|
|
|
// bStartJob = pPrt->StartJob( rOptions.GetJobName() );
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const SwPageFrm *pStPage = (SwPageFrm*)GetLayout()->Lower();
|
|
|
|
const SwFrm *pEndPage = pStPage;
|
2003-12-01 16:24:59 +00:00
|
|
|
USHORT i;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-12-01 16:24:59 +00:00
|
|
|
for( i = 1; pStPage && i < (USHORT)aPages.Min(); ++i )
|
2000-09-18 23:08:29 +00:00
|
|
|
pStPage = (SwPageFrm*)pStPage->GetNext();
|
|
|
|
|
|
|
|
if( !pStPage ) // dann wars das
|
|
|
|
{
|
|
|
|
if( bHiddenFlds )
|
|
|
|
{
|
|
|
|
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
|
|
|
|
pFldType->Modify( &aHnt, 0);
|
|
|
|
CalcPagesForPrint( (USHORT)aPages.Max() );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unsere SttPage haben wir, dann die EndPage suchen
|
|
|
|
USHORT nFirstPageNo = i;
|
|
|
|
USHORT nLastPageNo = i;
|
|
|
|
USHORT nPageNo = 1;
|
|
|
|
|
|
|
|
pEndPage = pStPage;
|
|
|
|
|
|
|
|
if( pStPage->GetNext() && (i != (USHORT)aPages.Max()) )
|
|
|
|
{
|
|
|
|
pEndPage = pEndPage->GetNext();
|
|
|
|
for( ++i,++nLastPageNo;
|
|
|
|
pEndPage->GetNext() && i < (USHORT)aPages.Max(); ++i )
|
|
|
|
{
|
|
|
|
pEndPage = pEndPage->GetNext();
|
|
|
|
++nLastPageNo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rOptions.bPrintReverse )
|
|
|
|
{
|
|
|
|
const SwFrm *pTmp = pStPage;
|
|
|
|
pStPage = (SwPageFrm*)pEndPage;
|
|
|
|
pEndPage = pTmp;
|
|
|
|
nPageNo = nLastPageNo;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nPageNo = nFirstPageNo;
|
|
|
|
|
|
|
|
// ein Array fuer die Seiten anlegen, die auf eine Drucker-Seite
|
|
|
|
// gedruckt werden sollen.
|
|
|
|
BYTE nRow = BYTE(nRowCol >> 8), nCol = BYTE(nRowCol & 0xff);
|
|
|
|
USHORT nPages = nRow * nCol;
|
|
|
|
SwPageFrm** aPageArr = new SwPageFrm* [ nPages ];
|
|
|
|
memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages );
|
|
|
|
USHORT nCntPage = 0;
|
|
|
|
|
|
|
|
SwTwips nCalcW = 0, nCalcH = 0, nMaxRowSz = 0, nMaxColSz = 0;
|
|
|
|
|
|
|
|
MapMode aOld( pPrt->GetMapMode() );
|
|
|
|
MapMode aMapMode( MAP_TWIP );
|
|
|
|
Size aPrtSize( pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), aMapMode ));
|
|
|
|
if( pPrtData )
|
|
|
|
{
|
|
|
|
aPrtSize.Width() -= pPrtData->GetLeftSpace() +
|
|
|
|
pPrtData->GetRightSpace() +
|
|
|
|
( pPrtData->GetHorzSpace() * (nCol - 1));
|
|
|
|
aPrtSize.Height() -= pPrtData->GetTopSpace() +
|
|
|
|
pPrtData->GetBottomSpace() +
|
|
|
|
( pPrtData->GetVertSpace() * (nRow - 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
aMulti.Select( Range( nLastPageNo+1, USHRT_MAX ), FALSE );
|
|
|
|
USHORT nSelCount = USHORT((aMulti.GetSelectCount()+nPages-1) / nPages);
|
2007-09-27 08:42:55 +00:00
|
|
|
nSelCount = nSelCount * nCopyCnt;
|
2000-09-18 23:08:29 +00:00
|
|
|
USHORT nPrintCount = 1;
|
|
|
|
|
|
|
|
const XubString aTmp( SW_RES( STR_STATSTR_PRINT ) );
|
|
|
|
rProgress.SetText( aTmp );
|
|
|
|
//HACK, damit die Anzeige nicht durcheinander kommt:
|
|
|
|
rProgress.SetState( 1, nSelCount );
|
|
|
|
rProgress.SetText( aTmp );
|
|
|
|
bStartJob = TRUE;
|
|
|
|
|
|
|
|
while( pStPage )
|
|
|
|
{
|
|
|
|
// Mag der Anwender noch ?
|
|
|
|
rProgress.Reschedule();
|
|
|
|
|
|
|
|
if ( !pPrt->IsJobActive() )
|
|
|
|
break;
|
|
|
|
|
2005-12-21 14:10:47 +00:00
|
|
|
// --> FME 2005-12-12 #b6354161# Feature - Print empty pages
|
2007-11-07 11:19:36 +00:00
|
|
|
// --> OD 2007-10-22 #i79738# - correct condition:
|
|
|
|
// always consider, if page is selected for print.
|
|
|
|
if( aMulti.IsSelected( nPageNo ) &&
|
|
|
|
( bPrintEmptyPages || !pStPage->IsEmptyPage() ) )
|
2005-12-21 14:10:47 +00:00
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( rOptions.bPrintReverse )
|
|
|
|
aPageArr[ nPages - ++nCntPage ] = (SwPageFrm*)pStPage;
|
|
|
|
else
|
|
|
|
aPageArr[ nCntPage++ ] = (SwPageFrm*)pStPage;
|
|
|
|
|
2003-05-28 11:52:48 +00:00
|
|
|
// OD 05.05.2003 #i14016# - consider empty pages on calculation
|
|
|
|
// of page size, used for calculation of scaling.
|
|
|
|
Size aPageSize;
|
|
|
|
if ( pStPage->IsEmptyPage() )
|
|
|
|
{
|
|
|
|
if ( pStPage->GetPhyPageNum() % 2 == 0 )
|
|
|
|
aPageSize = pStPage->GetPrev()->Frm().SSize();
|
|
|
|
else
|
|
|
|
aPageSize = pStPage->GetNext()->Frm().SSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aPageSize = pStPage->Frm().SSize();
|
|
|
|
}
|
|
|
|
nCalcW += aPageSize.Width();
|
|
|
|
if( nCalcH < aPageSize.Height() )
|
|
|
|
nCalcH = aPageSize.Height();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( 0 == (nCntPage % nCol ) || // neue Zeile
|
|
|
|
nCntPage == nPages || pStPage == pEndPage )
|
|
|
|
{
|
|
|
|
// sollte die Seite nicht gefuellt sein, so erweiter
|
|
|
|
// anhand der letzen Seite. Dadurch hat auch die
|
|
|
|
// letze Seite die richtigen Spalten/Reihen.
|
|
|
|
// BUG: 17695
|
|
|
|
if( pStPage == pEndPage && nCntPage != nPages )
|
|
|
|
{
|
|
|
|
// dann Werte mit der letzen Seite auffuellen
|
|
|
|
if( nCntPage < nCol )
|
2003-05-28 11:52:48 +00:00
|
|
|
nCalcW += aPageSize.Width() * (nCol - nCntPage);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
BYTE nRows = (BYTE) ( nCntPage / nCol + 1 );
|
|
|
|
if( nRows < nRow )
|
|
|
|
nCalcH += ( nRow - nRows ) * nCalcH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nMaxColSz < nCalcW )
|
|
|
|
nMaxColSz = nCalcW;
|
|
|
|
nCalcW = 0;
|
|
|
|
nMaxRowSz += nCalcH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nCntPage == nPages || pStPage == pEndPage )
|
|
|
|
{
|
|
|
|
// den MapMode einstellen
|
|
|
|
aMapMode.SetOrigin( Point() );
|
|
|
|
{
|
|
|
|
Fraction aScX( aPrtSize.Width(), nMaxColSz );
|
|
|
|
Fraction aScY( aPrtSize.Height(), nMaxRowSz );
|
|
|
|
|
|
|
|
{
|
|
|
|
if( aScX < aScY )
|
|
|
|
aScY = aScX;
|
|
|
|
|
|
|
|
// fuer Drawing, damit diese ihre Objecte vernuenftig Painten
|
|
|
|
// koennen, auf "glatte" Prozentwerte setzen
|
|
|
|
aScY *= Fraction( 1000, 1 );
|
|
|
|
long nTmp = (long)aScY;
|
|
|
|
if( 1 < nTmp )
|
|
|
|
--nTmp;
|
|
|
|
else
|
|
|
|
nTmp = 1;
|
|
|
|
aScY = Fraction( nTmp, 1000 );
|
|
|
|
aScX = aScY;
|
|
|
|
}
|
|
|
|
|
|
|
|
aMapMode.SetScaleY( aScY );
|
|
|
|
aMapMode.SetScaleX( aScX );
|
|
|
|
}
|
|
|
|
|
|
|
|
Point aPrtOff( pPrt->PixelToLogic(
|
|
|
|
pPrt->GetPageOffsetPixel(), aMapMode ) );
|
|
|
|
long nPageHeight = (nMaxRowSz / nRow);
|
|
|
|
|
|
|
|
// dann kann das drucken losgehen
|
|
|
|
rProgress.SetState( nPrintCount++, nSelCount );
|
|
|
|
|
2009-06-11 17:26:10 +00:00
|
|
|
#ifdef TL_NOT_NOW /*TLPDF*/
|
2000-09-18 23:08:29 +00:00
|
|
|
pPrt->StartPage();
|
2009-06-11 17:26:10 +00:00
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
Point aCalcPt;
|
|
|
|
SwPageFrm** ppTmpPg = aPageArr;
|
|
|
|
|
|
|
|
// ist das Array nicht vollsteandig gefuellt ?
|
|
|
|
if( rOptions.bPrintReverse && nCntPage != nPages )
|
|
|
|
{
|
|
|
|
// beim Rueckwaertsdruck alle Seiten nach vorne
|
|
|
|
// verschieben!
|
|
|
|
memmove( ppTmpPg, ppTmpPg + (nPages - nCntPage),
|
|
|
|
nCntPage * sizeof( SwPageFrm*) );
|
|
|
|
aPageArr[ nCntPage ] = 0; // Endekennung
|
|
|
|
}
|
|
|
|
|
|
|
|
long nHOffs = 0, nVOffs = 0, nXStt = 0;
|
|
|
|
if( pPrtData )
|
|
|
|
{
|
|
|
|
const Fraction& rScaleX = aMapMode.GetScaleX();
|
|
|
|
const Fraction& rScaleY = aMapMode.GetScaleY();
|
|
|
|
Fraction aF( pPrtData->GetTopSpace(), 1 );
|
|
|
|
aCalcPt.Y() = aF /= rScaleY;
|
|
|
|
aF = Fraction( pPrtData->GetLeftSpace(), 1 );
|
|
|
|
nXStt = aF /= rScaleX;
|
|
|
|
aF = Fraction( pPrtData->GetVertSpace(), 1 );
|
|
|
|
nVOffs = aF /= rScaleY;
|
|
|
|
aF = Fraction( pPrtData->GetHorzSpace(), 1 );
|
|
|
|
nHOffs = aF /= rScaleX;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BYTE nR = 0; *ppTmpPg && nR < nRow; ++nR )
|
|
|
|
{
|
|
|
|
aCalcPt.X() = nXStt;
|
|
|
|
for( BYTE nC = 0; *ppTmpPg && nC < nCol; ++nC )
|
|
|
|
{
|
|
|
|
aShell.Imp()->SetFirstVisPageInvalid();
|
|
|
|
aShell.aVisArea = (*ppTmpPg)->Frm();
|
|
|
|
|
|
|
|
Point aPos( aCalcPt );
|
|
|
|
aPos -= aShell.aVisArea.Pos();
|
|
|
|
aPos -= aPrtOff;
|
|
|
|
aMapMode.SetOrigin( aPos );
|
|
|
|
pPrt->SetMapMode( aMapMode );
|
|
|
|
(*ppTmpPg)->GetUpper()->Paint( (*ppTmpPg)->Frm() );
|
2003-05-28 11:52:48 +00:00
|
|
|
// OD 05.05.2003 #i14016# - consider empty pages
|
|
|
|
// on calculation of the paint offset for the next page.
|
|
|
|
aCalcPt.X() += nHOffs;
|
|
|
|
if ( (*ppTmpPg)->IsEmptyPage() )
|
|
|
|
{
|
|
|
|
if ( (*ppTmpPg)->GetPhyPageNum() % 2 == 0 )
|
|
|
|
aCalcPt.X() += (*ppTmpPg)->GetPrev()->Frm().SSize().Width();
|
|
|
|
else
|
|
|
|
aCalcPt.X() += (*ppTmpPg)->GetNext()->Frm().SSize().Width();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aCalcPt.X() += (*ppTmpPg)->Frm().Width();
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
++ppTmpPg;
|
|
|
|
}
|
|
|
|
aCalcPt.Y() += nVOffs + nPageHeight;
|
|
|
|
}
|
2009-06-11 17:26:10 +00:00
|
|
|
#ifdef TL_NOT_NOW /*TLPDF*/
|
2000-09-18 23:08:29 +00:00
|
|
|
pPrt->EndPage();
|
2009-06-11 17:26:10 +00:00
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
SwPaintQueue::Repaint();
|
|
|
|
|
|
|
|
memset( aPageArr, 0, sizeof( SwPageFrm* ) * nPages );
|
2009-08-07 14:42:45 +00:00
|
|
|
nCntPage = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
nMaxRowSz = nMaxColSz = nCalcH = nCalcW = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pStPage == pEndPage )
|
|
|
|
pStPage = 0;
|
|
|
|
else if( rOptions.bPrintReverse )
|
|
|
|
{
|
|
|
|
--nPageNo;
|
|
|
|
pStPage = (SwPageFrm*)pStPage->GetPrev();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++nPageNo;
|
|
|
|
pStPage = (SwPageFrm*)pStPage->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPrt->SetMapMode( aOld );
|
|
|
|
|
|
|
|
if( bHiddenFlds )
|
|
|
|
{
|
|
|
|
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
|
|
|
|
pFldType->Modify( &aHnt, 0);
|
|
|
|
CalcPagesForPrint( (USHORT)aPages.Max() );
|
|
|
|
}
|
2002-05-13 11:14:05 +00:00
|
|
|
delete[] aPageArr;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( bStartJob )
|
|
|
|
rOptions.bJobStartet = TRUE;
|
|
|
|
}
|
|
|
|
pFntCache->Flush();
|
|
|
|
}
|
|
|
|
|
2009-08-14 13:56:56 +00:00
|
|
|
|
2003-05-28 11:52:48 +00:00
|
|
|
// print brochure
|
|
|
|
// OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling
|
|
|
|
// for a page to be printed.
|
2009-08-07 14:42:45 +00:00
|
|
|
void ViewShell::PrintProspect(
|
2009-08-31 08:59:41 +00:00
|
|
|
OutputDevice *pOutDev,
|
|
|
|
const SwPrintData &rPrintData,
|
2009-08-14 13:56:56 +00:00
|
|
|
sal_Int32 nRenderer // the index in the vector of prospect pages to be printed
|
|
|
|
)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1;
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
DBG_ASSERT( 0 <= nRenderer && nRenderer < nMaxRenderer, "nRenderer out of bounds");
|
|
|
|
#endif
|
2009-08-07 14:42:45 +00:00
|
|
|
Printer *pPrinter = dynamic_cast< Printer * >(pOutDev);
|
2009-09-01 17:48:55 +00:00
|
|
|
if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
|
2000-09-18 23:08:29 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
// save settings of OutputDevice (should be done always since the
|
2009-08-07 14:42:45 +00:00
|
|
|
// output device is now provided by a call from outside the Writer)
|
|
|
|
pPrinter->Push();
|
|
|
|
|
|
|
|
std::pair< sal_Int32, sal_Int32 > rPagesToPrint =
|
2009-08-27 12:29:52 +00:00
|
|
|
rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ];
|
2009-09-01 16:31:53 +00:00
|
|
|
// const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ?
|
|
|
|
// rPagesToPrint.first : rPagesToPrint.second);
|
2009-08-07 14:42:45 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2009-08-27 12:29:52 +00:00
|
|
|
DBG_ASSERT( rPagesToPrint.first == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" );
|
|
|
|
DBG_ASSERT( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" );
|
2009-08-07 14:42:45 +00:00
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// eine neue Shell fuer den Printer erzeugen
|
2009-08-07 14:42:45 +00:00
|
|
|
ViewShell aShell( *this, 0, pPrinter );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SET_CURR_SHELL( &aShell );
|
|
|
|
|
2009-08-14 13:56:56 +00:00
|
|
|
aShell.PrepareForPrint( rPrintData );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-09-01 15:16:12 +00:00
|
|
|
#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount!
|
2000-09-18 23:08:29 +00:00
|
|
|
// gibt es versteckte Absatzfelder, unnoetig wenn die Absaetze bereits
|
|
|
|
// ausgeblendet sind.
|
|
|
|
int bHiddenFlds = FALSE;
|
|
|
|
SwFieldType* pFldType = 0;
|
|
|
|
if ( GetViewOptions()->IsShowHiddenPara() )
|
|
|
|
{
|
2006-08-14 15:58:59 +00:00
|
|
|
pFldType = getIDocumentFieldsAccess()->GetSysFldType( RES_HIDDENPARAFLD );
|
2000-09-18 23:08:29 +00:00
|
|
|
bHiddenFlds = 0 != pFldType->GetDepends();
|
|
|
|
if( bHiddenFlds )
|
|
|
|
{
|
|
|
|
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
|
|
|
|
pFldType->Modify( &aHnt, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seiten fuers Drucken formatieren
|
2009-09-03 15:12:37 +00:00
|
|
|
aShell.CalcPagesForPrint( nPageMax, 0 );
|
2009-09-01 15:16:12 +00:00
|
|
|
#endif // TL_NOT_NOW // TLPDF
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
MapMode aMapMode( MAP_TWIP );
|
|
|
|
Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
SwTwips nMaxRowSz, nMaxColSz;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
const SwPageFrm *pStPage = 0;
|
|
|
|
const SwPageFrm *pNxtPage = 0;
|
|
|
|
const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames();
|
|
|
|
if (rPagesToPrint.first > 0)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.first ) );
|
|
|
|
DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
|
|
|
|
pStPage = aIt->second;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2009-08-31 08:59:41 +00:00
|
|
|
if (rPagesToPrint.second > 0)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( rPagesToPrint.second ) );
|
|
|
|
DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
|
|
|
|
pNxtPage = aIt->second;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
// OD 05.05.2003 #i14016# - consider empty pages on calculation
|
|
|
|
// of page size, used for calculation of scaling.
|
|
|
|
Size aSttPageSize;
|
|
|
|
if ( pStPage )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
if ( pStPage->IsEmptyPage() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
if ( pStPage->GetPhyPageNum() % 2 == 0 )
|
|
|
|
aSttPageSize = pStPage->GetPrev()->Frm().SSize();
|
|
|
|
else
|
|
|
|
aSttPageSize = pStPage->GetNext()->Frm().SSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSttPageSize = pStPage->Frm().SSize();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-31 08:59:41 +00:00
|
|
|
Size aNxtPageSize;
|
|
|
|
if ( pNxtPage )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
if ( pNxtPage->IsEmptyPage() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
if ( pNxtPage->GetPhyPageNum() % 2 == 0 )
|
|
|
|
aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize();
|
|
|
|
else
|
|
|
|
aNxtPageSize = pNxtPage->GetNext()->Frm().SSize();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2009-08-31 08:59:41 +00:00
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
aNxtPageSize = pNxtPage->Frm().SSize();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2009-08-31 08:59:41 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
if( !pStPage )
|
|
|
|
{
|
|
|
|
nMaxColSz = 2 * aNxtPageSize.Width();
|
|
|
|
nMaxRowSz = aNxtPageSize.Height();
|
|
|
|
}
|
|
|
|
else if( !pNxtPage )
|
|
|
|
{
|
|
|
|
nMaxColSz = 2 * aSttPageSize.Width();
|
|
|
|
nMaxRowSz = aSttPageSize.Height();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nMaxColSz = aNxtPageSize.Width() + aSttPageSize.Width();
|
|
|
|
nMaxRowSz = Max( aNxtPageSize.Height(), aSttPageSize.Height() );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
// den MapMode einstellen
|
|
|
|
aMapMode.SetOrigin( Point() );
|
|
|
|
{
|
|
|
|
Fraction aScX( aPrtSize.Width(), nMaxColSz );
|
|
|
|
Fraction aScY( aPrtSize.Height(), nMaxRowSz );
|
|
|
|
if( aScX < aScY )
|
|
|
|
aScY = aScX;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
{
|
2009-08-31 08:59:41 +00:00
|
|
|
// fuer Drawing, damit diese ihre Objecte vernuenftig Painten
|
|
|
|
// koennen, auf "glatte" Prozentwerte setzen
|
|
|
|
aScY *= Fraction( 1000, 1 );
|
|
|
|
long nTmp = (long)aScY;
|
|
|
|
if( 1 < nTmp )
|
|
|
|
--nTmp;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2009-08-31 08:59:41 +00:00
|
|
|
nTmp = 1;
|
|
|
|
aScY = Fraction( nTmp, 1000 );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
aMapMode.SetScaleY( aScY );
|
|
|
|
aMapMode.SetScaleX( aScY );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) ); /* TLPDF */
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
// calculate start point for equal border on all sides
|
|
|
|
Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2,
|
|
|
|
(aTmpPrtSize.Height() - nMaxRowSz) / 2 );
|
|
|
|
for( int nC = 0; nC < 2; ++nC )
|
|
|
|
{
|
|
|
|
if( pStPage )
|
|
|
|
{
|
|
|
|
aShell.Imp()->SetFirstVisPageInvalid();
|
|
|
|
aShell.aVisArea = pStPage->Frm();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
Point aPos( aSttPt );
|
|
|
|
aPos -= aShell.aVisArea.Pos();
|
2009-08-10 09:55:47 +00:00
|
|
|
// TLPDF aPos -= aPrtOff;
|
2009-08-31 08:59:41 +00:00
|
|
|
aMapMode.SetOrigin( aPos );
|
|
|
|
pPrinter->SetMapMode( aMapMode );
|
|
|
|
pStPage->GetUpper()->Paint( pStPage->Frm() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
pStPage = pNxtPage;
|
|
|
|
aSttPt.X() += aTmpPrtSize.Width() / 2;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2009-08-31 08:59:41 +00:00
|
|
|
SwPaintQueue::Repaint();
|
|
|
|
|
2009-09-01 15:16:12 +00:00
|
|
|
#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount!
|
2009-08-31 08:59:41 +00:00
|
|
|
if( bHiddenFlds )
|
|
|
|
{
|
|
|
|
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
|
|
|
|
pFldType->Modify( &aHnt, 0);
|
2009-09-03 15:12:37 +00:00
|
|
|
CalcPagesForPrint( nPageMax );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2009-09-01 15:16:12 +00:00
|
|
|
#endif // TL_NOT_NOW // TLPDF
|
2000-09-18 23:08:29 +00:00
|
|
|
pFntCache->Flush();
|
2009-08-07 14:42:45 +00:00
|
|
|
|
|
|
|
// restore settings of OutputDevice (should be done always now since the
|
|
|
|
// output device is now provided by a call from outside the Writer)
|
|
|
|
pPrinter->Pop();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2009-08-07 14:42:45 +00:00
|
|
|
|
|
|
|
|