LCOV - code coverage report
Current view: top level - sc/source/ui/view - printfun.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1108 1681 65.9 %
Date: 2014-11-03 Functions: 51 62 82.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : 
      23             : #include "printfun.hxx"
      24             : 
      25             : #include <svx/svxids.hrc>
      26             : #include <editeng/adjustitem.hxx>
      27             : #include <editeng/boxitem.hxx>
      28             : #include <editeng/brushitem.hxx>
      29             : #include <svtools/colorcfg.hxx>
      30             : #include <editeng/editstat.hxx>
      31             : #include <svx/fmview.hxx>
      32             : #include <editeng/frmdiritem.hxx>
      33             : #include <editeng/lrspitem.hxx>
      34             : #include <editeng/paperinf.hxx>
      35             : #include <editeng/pbinitem.hxx>
      36             : #include <editeng/shaditem.hxx>
      37             : #include <editeng/sizeitem.hxx>
      38             : #include <svx/svdpagv.hxx>
      39             : #include <editeng/ulspitem.hxx>
      40             : #include <sfx2/app.hxx>
      41             : #include <sfx2/printer.hxx>
      42             : #include <tools/multisel.hxx>
      43             : #include <sfx2/docfile.hxx>
      44             : #include <tools/urlobj.hxx>
      45             : #include <svx/xoutbmp.hxx>
      46             : 
      47             : #include "editutil.hxx"
      48             : #include "docsh.hxx"
      49             : #include "output.hxx"
      50             : #include "viewdata.hxx"
      51             : #include "viewopti.hxx"
      52             : #include "stlpool.hxx"
      53             : #include "pagepar.hxx"
      54             : #include "attrib.hxx"
      55             : #include "patattr.hxx"
      56             : #include "docpool.hxx"
      57             : #include "dociter.hxx"
      58             : #include "formulacell.hxx"
      59             : #include "drawutil.hxx"
      60             : #include "globstr.hrc"
      61             : #include "scresid.hxx"
      62             : #include "sc.hrc"
      63             : #include "pagedata.hxx"
      64             : #include "printopt.hxx"
      65             : #include "prevloc.hxx"
      66             : #include "scmod.hxx"
      67             : #include "drwlayer.hxx"
      68             : #include "fillinfo.hxx"
      69             : #include "postit.hxx"
      70             : 
      71             : #include <vcl/lineinfo.hxx>
      72             : 
      73             : #include <boost/scoped_ptr.hpp>
      74             : #include <com/sun/star/document/XDocumentProperties.hpp>
      75             : 
      76             : #define ZOOM_MIN    10
      77             : 
      78             : #define GET_BOOL(set,which)   static_cast<const SfxBoolItem&>((set)->Get((which))).GetValue()
      79             : #define GET_USHORT(set,which) static_cast<const SfxUInt16Item&>((set)->Get((which))).GetValue()
      80             : #define GET_SHOW(set,which)   ( VOBJ_MODE_SHOW == ScVObjMode( static_cast<const ScViewObjectModeItem&>((set)->Get((which))).GetValue()) )
      81             : 
      82         644 : ScPageRowEntry::ScPageRowEntry(const ScPageRowEntry& r)
      83             : {
      84         644 :     nStartRow = r.nStartRow;
      85         644 :     nEndRow   = r.nEndRow;
      86         644 :     nPagesX   = r.nPagesX;
      87         644 :     if (r.pHidden && nPagesX)
      88             :     {
      89           0 :         pHidden = new bool[nPagesX];
      90           0 :         memcpy( pHidden, r.pHidden, nPagesX * sizeof(bool) );
      91             :     }
      92             :     else
      93         644 :         pHidden = NULL;
      94         644 : }
      95             : 
      96           0 : const ScPageRowEntry& ScPageRowEntry::operator=(const ScPageRowEntry& r)
      97             : {
      98           0 :     delete[] pHidden;
      99             : 
     100           0 :     nStartRow = r.nStartRow;
     101           0 :     nEndRow   = r.nEndRow;
     102           0 :     nPagesX   = r.nPagesX;
     103           0 :     if (r.pHidden && nPagesX)
     104             :     {
     105           0 :         pHidden = new bool[nPagesX];
     106           0 :         memcpy( pHidden, r.pHidden, nPagesX * sizeof(bool) );
     107             :     }
     108             :     else
     109           0 :         pHidden = NULL;
     110             : 
     111           0 :     return *this;
     112             : }
     113             : 
     114         158 : void ScPageRowEntry::SetPagesX(size_t nNew)
     115             : {
     116         158 :     if (pHidden)
     117             :     {
     118             :         OSL_FAIL("SetPagesX nicht nach SetHidden");
     119           0 :         delete[] pHidden;
     120           0 :         pHidden = NULL;
     121             :     }
     122         158 :     nPagesX = nNew;
     123         158 : }
     124             : 
     125           0 : void ScPageRowEntry::SetHidden(size_t nX)
     126             : {
     127           0 :     if ( nX < nPagesX )
     128             :     {
     129           0 :         if ( nX+1 == nPagesX )  // last page?
     130           0 :             --nPagesX;
     131             :         else
     132             :         {
     133           0 :             if (!pHidden)
     134             :             {
     135           0 :                 pHidden = new bool[nPagesX];
     136           0 :                 memset( pHidden, false, nPagesX * sizeof(bool) );
     137             :             }
     138           0 :             pHidden[nX] = true;
     139             :         }
     140             :     }
     141           0 : }
     142             : 
     143         108 : bool ScPageRowEntry::IsHidden(size_t nX) const
     144             : {
     145         108 :     return nX>=nPagesX || ( pHidden && pHidden[nX] );       //! inline?
     146             : }
     147             : 
     148          52 : size_t ScPageRowEntry::CountVisible() const
     149             : {
     150          52 :     if ( pHidden )
     151             :     {
     152           0 :         size_t nVis = 0;
     153           0 :         for (size_t i=0; i<nPagesX; i++)
     154           0 :             if (!pHidden[i])
     155           0 :                 ++nVis;
     156           0 :         return nVis;
     157             :     }
     158             :     else
     159          52 :         return nPagesX;
     160             : }
     161             : 
     162       13104 : static long lcl_LineTotal(const ::editeng::SvxBorderLine* pLine)
     163             : {
     164       13104 :     return pLine ? ( pLine->GetScaledWidth() ) : 0;
     165             : }
     166             : 
     167         696 : void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
     168             : {
     169         696 :     pDocShell->UpdatePendingRowHeights( nPrintTab );
     170         696 :     pDoc = &pDocShell->GetDocument();
     171             : 
     172         696 :     SfxPrinter* pDocPrinter = pDoc->GetPrinter();   // use the printer, even for preview
     173         696 :     if (pDocPrinter)
     174         696 :         aOldPrinterMode = pDocPrinter->GetMapMode();
     175             : 
     176             :     //  unified MapMode for all calls (e.g. Repaint!!!)
     177             :     //  else, EditEngine outputs different text heights
     178         696 :     pDev->SetMapMode(MAP_PIXEL);
     179             : 
     180         696 :     pBorderItem = NULL;
     181         696 :     pBackgroundItem = NULL;
     182         696 :     pShadowItem = NULL;
     183             : 
     184         696 :     pEditEngine = NULL;
     185         696 :     pEditDefaults = NULL;
     186             : 
     187         696 :     ScStyleSheetPool* pStylePool    = pDoc->GetStyleSheetPool();
     188             :     SfxStyleSheetBase* pStyleSheet  = pStylePool->Find(
     189             :                                             pDoc->GetPageStyle( nPrintTab ),
     190         696 :                                             SFX_STYLE_FAMILY_PAGE );
     191         696 :     if (pStyleSheet)
     192         696 :         pParamSet = &pStyleSheet->GetItemSet();
     193             :     else
     194             :     {
     195             :         OSL_FAIL("Seitenvorlage nicht gefunden" );
     196           0 :         pParamSet = NULL;
     197             :     }
     198             : 
     199         696 :     if (!bState)
     200         608 :         nZoom = 100;
     201         696 :     nManualZoom = 100;
     202         696 :     bClearWin = false;
     203         696 :     bUseStyleColor = false;
     204         696 :     bIsRender = false;
     205             : 
     206         696 :     InitParam(pOptions);
     207             : 
     208         696 :     pPageData = NULL;       // wird nur zur Initialisierung gebraucht
     209         696 : }
     210             : 
     211         556 : ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
     212             :                             long nPage, long nDocP, const ScRange* pArea,
     213             :                             const ScPrintOptions* pOptions,
     214             :                             ScPageBreakData* pData )
     215             :     :   pDocShell           ( pShell ),
     216             :         pPrinter            ( pNewPrinter ),
     217             :         pDrawView           ( NULL ),
     218             :         nPrintTab           ( nTab ),
     219             :         nPageStart          ( nPage ),
     220             :         nDocPages           ( nDocP ),
     221             :         pUserArea           ( pArea ),
     222             :         bState              ( false ),
     223             :         bSourceRangeValid   ( false ),
     224             :         bPrintCurrentTable  ( false ),
     225             :         bMultiArea          ( false ),
     226             :         mbHasPrintRange(true),
     227             :         nTabPages           ( 0 ),
     228             :         nTotalPages         ( 0 ),
     229             :         nPagesX(0),
     230             :         nPagesY(0),
     231             :         nTotalY(0),
     232         556 :         pPageData           ( pData )
     233             : {
     234         556 :     pDev = pPrinter;
     235         556 :     aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM );
     236         556 :     Construct( pOptions );
     237         556 : }
     238             : 
     239          52 : ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
     240             :                             long nPage, long nDocP, const ScRange* pArea,
     241             :                             const ScPrintOptions* pOptions )
     242             :     :   pDocShell           ( pShell ),
     243             :         pPrinter            ( NULL ),
     244             :         pDrawView           ( NULL ),
     245             :         nPrintTab           ( nTab ),
     246             :         nPageStart          ( nPage ),
     247             :         nDocPages           ( nDocP ),
     248             :         pUserArea           ( pArea ),
     249             :         bState              ( false ),
     250             :         bSourceRangeValid   ( false ),
     251             :         bPrintCurrentTable  ( false ),
     252             :         bMultiArea          ( false ),
     253             :         mbHasPrintRange(true),
     254             :         nTabPages           ( 0 ),
     255             :         nTotalPages         ( 0 ),
     256             :         nPagesX(0),
     257             :         nPagesY(0),
     258             :         nTotalY(0),
     259          52 :         pPageData           ( NULL )
     260             : {
     261          52 :     pDev = pOutDev;
     262          52 :     Construct( pOptions );
     263          52 : }
     264             : 
     265          88 : ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
     266             :                              const ScPrintState& rState, const ScPrintOptions* pOptions )
     267             :     :   pDocShell           ( pShell ),
     268             :         pPrinter            ( NULL ),
     269             :         pDrawView           ( NULL ),
     270             :         pUserArea           ( NULL ),
     271             :         bSourceRangeValid   ( false ),
     272             :         bPrintCurrentTable  ( false ),
     273             :         bMultiArea          ( false ),
     274             :         mbHasPrintRange(true),
     275             :         nPagesX(0),
     276             :         nPagesY(0),
     277             :         nTotalY(0),
     278          88 :         pPageData           ( NULL )
     279             : {
     280          88 :     pDev = pOutDev;
     281             : 
     282          88 :     nPrintTab   = rState.nPrintTab;
     283          88 :     nStartCol   = rState.nStartCol;
     284          88 :     nStartRow   = rState.nStartRow;
     285          88 :     nEndCol     = rState.nEndCol;
     286          88 :     nEndRow     = rState.nEndRow;
     287          88 :     nZoom       = rState.nZoom;
     288          88 :     nPagesX     = rState.nPagesX;
     289          88 :     nPagesY     = rState.nPagesY;
     290          88 :     nTabPages   = rState.nTabPages;
     291          88 :     nTotalPages = rState.nTotalPages;
     292          88 :     nPageStart  = rState.nPageStart;
     293          88 :     nDocPages   = rState.nDocPages;
     294          88 :     bState      = true;
     295             : 
     296          88 :     Construct( pOptions );
     297          88 : }
     298             : 
     299          52 : void ScPrintFunc::GetPrintState( ScPrintState& rState )
     300             : {
     301          52 :     rState.nPrintTab    = nPrintTab;
     302          52 :     rState.nStartCol    = nStartCol;
     303          52 :     rState.nStartRow    = nStartRow;
     304          52 :     rState.nEndCol      = nEndCol;
     305          52 :     rState.nEndRow      = nEndRow;
     306          52 :     rState.nZoom        = nZoom;
     307          52 :     rState.nPagesX      = nPagesX;
     308          52 :     rState.nPagesY      = nPagesY;
     309          52 :     rState.nTabPages    = nTabPages;
     310          52 :     rState.nTotalPages  = nTotalPages;
     311          52 :     rState.nPageStart   = nPageStart;
     312          52 :     rState.nDocPages    = nDocPages;
     313          52 : }
     314             : 
     315           0 : bool ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const
     316             : {
     317           0 :     rRange = aLastSourceRange;
     318           0 :     return bSourceRangeValid;
     319             : }
     320             : 
     321           2 : void ScPrintFunc::FillPageData()
     322             : {
     323           2 :     if (pPageData)
     324             :     {
     325           2 :         sal_uInt16 nCount = sal::static_int_cast<sal_uInt16>( pPageData->GetCount() );
     326           2 :         ScPrintRangeData& rData = pPageData->GetData(nCount);       // count up
     327             : 
     328             :         rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab,
     329           2 :                                         nEndCol, nEndRow, nPrintTab ) );
     330             :         // #i123672#
     331           2 :         if(maPageEndX.empty())
     332             :         {
     333             :             OSL_ENSURE(false, "vector access error for maPageEndX (!)");
     334             :         }
     335             :         else
     336             :         {
     337           2 :             rData.SetPagesX( nPagesX, &maPageEndX[0]);
     338             :         }
     339             : 
     340             :         // #i123672#
     341           2 :         if(maPageEndY.empty())
     342             :         {
     343             :             OSL_ENSURE(false, "vector access error for maPageEndY (!)");
     344             :         }
     345             :         else
     346             :         {
     347           2 :             rData.SetPagesY( nTotalY, &maPageEndY[0]);
     348             :         }
     349             : 
     350             :         //  Settings
     351           2 :         rData.SetTopDown( aTableParam.bTopDown );
     352           2 :         rData.SetAutomatic( !aAreaParam.bPrintArea );
     353             :     }
     354           2 : }
     355             : 
     356        1392 : ScPrintFunc::~ScPrintFunc()
     357             : {
     358         696 :     delete pEditDefaults;
     359         696 :     delete pEditEngine;
     360             : 
     361             :     //  Printer settings are now restored from outside
     362             : 
     363             :     //  For DrawingLayer/Charts, the MapMode of the printer (RefDevice) must always be correct
     364         696 :     SfxPrinter* pDocPrinter = pDoc->GetPrinter();   // use Preview also for the printer
     365         696 :     if (pDocPrinter)
     366         696 :         pDocPrinter->SetMapMode(aOldPrinterMode);
     367         696 : }
     368             : 
     369         108 : void ScPrintFunc::SetDrawView( FmFormView* pNew )
     370             : {
     371         108 :     pDrawView = pNew;
     372         108 : }
     373             : 
     374          78 : static void lcl_HidePrint( ScTableInfo& rTabInfo, SCCOL nX1, SCCOL nX2 )
     375             : {
     376         470 :     for (SCSIZE nArrY=1; nArrY+1<rTabInfo.mnArrCount; nArrY++)
     377             :     {
     378         392 :         RowInfo* pThisRowInfo = &rTabInfo.mpRowInfo[nArrY];
     379        1772 :         for (SCCOL nX=nX1; nX<=nX2; nX++)
     380             :         {
     381        1380 :             const CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1];
     382        1380 :             if (!rCellInfo.bEmptyCellText)
     383         150 :                 if (static_cast<const ScProtectionAttr&>(rCellInfo.pPatternAttr->
     384         150 :                             GetItem(ATTR_PROTECTION, rCellInfo.pConditionSet)).GetHidePrint())
     385             :                 {
     386           0 :                     pThisRowInfo->pCellInfo[nX+1].maCell.clear();
     387           0 :                     pThisRowInfo->pCellInfo[nX+1].bEmptyCellText = true;
     388             :                 }
     389             :         }
     390             :     }
     391          78 : }
     392             : 
     393             : //          output to Device (static)
     394             : //
     395             : //      us used for:
     396             : //      -   Clipboard/Bitmap
     397             : //      -   Ole-Object (DocShell::Draw)
     398             : //      -   Preview of templates
     399             : 
     400          12 : void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPrintFactor */,
     401             :                             const Rectangle& rBound, ScViewData* pViewData, bool bMetaFile )
     402             : {
     403             :     //! evaluate nPrintFactor !!!
     404             : 
     405          12 :     SCTAB nTab = 0;
     406          12 :     if (pViewData)
     407          12 :         nTab = pViewData->GetTabNo();
     408             : 
     409             :     bool bDoGrid, bNullVal, bFormula;
     410          12 :     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     411          12 :     SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
     412          12 :     if (pStyleSheet)
     413             :     {
     414          12 :         SfxItemSet& rSet = pStyleSheet->GetItemSet();
     415          12 :         bDoGrid  = static_cast<const SfxBoolItem&>(rSet.Get(ATTR_PAGE_GRID)).GetValue();
     416          12 :         bNullVal = static_cast<const SfxBoolItem&>(rSet.Get(ATTR_PAGE_NULLVALS)).GetValue();
     417          12 :         bFormula = static_cast<const SfxBoolItem&>(rSet.Get(ATTR_PAGE_FORMULAS)).GetValue();
     418             :     }
     419             :     else
     420             :     {
     421           0 :         const ScViewOptions& rOpt = pDoc->GetViewOptions();
     422           0 :         bDoGrid  = rOpt.GetOption(VOPT_GRID);
     423           0 :         bNullVal = rOpt.GetOption(VOPT_NULLVALS);
     424           0 :         bFormula = rOpt.GetOption(VOPT_FORMULAS);
     425             :     }
     426             : 
     427          12 :     MapMode aMode = pDev->GetMapMode();
     428             : 
     429          12 :     Rectangle aRect = rBound;
     430             : 
     431          12 :     if (aRect.Right() < aRect.Left() || aRect.Bottom() < aRect.Top())
     432           0 :         aRect = Rectangle( Point(), pDev->GetOutputSize() );
     433             : 
     434          12 :     SCCOL nX1 = 0;
     435          12 :     SCROW nY1 = 0;
     436          12 :     SCCOL nX2 = OLE_STD_CELLS_X - 1;
     437          12 :     SCROW nY2 = OLE_STD_CELLS_Y - 1;
     438          12 :     if (bMetaFile)
     439             :     {
     440          12 :         ScRange aRange = pDoc->GetRange( nTab, rBound );
     441          12 :         nX1 = aRange.aStart.Col();
     442          12 :         nY1 = aRange.aStart.Row();
     443          12 :         nX2 = aRange.aEnd.Col();
     444          12 :         nY2 = aRange.aEnd.Row();
     445             :     }
     446           0 :     else if (pViewData)
     447             :     {
     448           0 :         ScSplitPos eWhich = pViewData->GetActivePart();
     449           0 :         ScHSplitPos eHWhich = WhichH(eWhich);
     450           0 :         ScVSplitPos eVWhich = WhichV(eWhich);
     451           0 :         nX1 = pViewData->GetPosX(eHWhich);
     452           0 :         nY1 = pViewData->GetPosY(eVWhich);
     453           0 :         nX2 = nX1 + pViewData->VisibleCellsX(eHWhich);
     454           0 :         if (nX2>nX1) --nX2;
     455           0 :         nY2 = nY1 + pViewData->VisibleCellsY(eVWhich);
     456           0 :         if (nY2>nY1) --nY2;
     457             :     }
     458             : 
     459          12 :     if (nX1 > MAXCOL) nX1 = MAXCOL;
     460          12 :     if (nX2 > MAXCOL) nX2 = MAXCOL;
     461          12 :     if (nY1 > MAXROW) nY1 = MAXROW;
     462          12 :     if (nY2 > MAXROW) nY2 = MAXROW;
     463             : 
     464          12 :     long nDevSizeX = aRect.Right()-aRect.Left()+1;
     465          12 :     long nDevSizeY = aRect.Bottom()-aRect.Top()+1;
     466             : 
     467          12 :     Rectangle aLines;
     468          12 :     ScRange aRange( nX1,nY1,nTab, nX2,nY2,nTab );
     469             : 
     470          12 :     long nTwipsSizeX = 0;
     471          60 :     for (SCCOL i=nX1; i<=nX2; i++)
     472          48 :         nTwipsSizeX += pDoc->GetColWidth( i, nTab );
     473          12 :     long nTwipsSizeY = (long) pDoc->GetRowHeight( nY1, nY2, nTab );
     474             : 
     475             :     //  if no lines, still space for the outline frame (20 Twips = 1pt)
     476             :     //  (HasLines initalizes aLines to 0,0,0,0)
     477          12 :     nTwipsSizeX += aLines.Left() + std::max( aLines.Right(), 20L );
     478          12 :     nTwipsSizeY += aLines.Top() +  std::max( aLines.Bottom(), 20L );
     479             : 
     480          12 :     double nScaleX = (double) nDevSizeX / nTwipsSizeX;
     481          12 :     double nScaleY = (double) nDevSizeY / nTwipsSizeY;
     482             : 
     483             :                             //!     hand over Flag at FillInfo !!!!!
     484          12 :     ScRange aERange;
     485          12 :     bool bEmbed = pDoc->IsEmbedded();
     486          12 :     if (bEmbed)
     487             :     {
     488           0 :         pDoc->GetEmbedded(aERange);
     489           0 :         pDoc->ResetEmbedded();
     490             :     }
     491             : 
     492             :     //  Assemble data
     493             : 
     494          24 :     ScTableInfo aTabInfo;
     495             :     pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
     496          12 :                                         nScaleX, nScaleY, false, bFormula );
     497          12 :     lcl_HidePrint( aTabInfo, nX1, nX2 );
     498             : 
     499          12 :     if (bEmbed)
     500           0 :         pDoc->SetEmbedded(aERange);
     501             : 
     502          12 :     long nScrX = aRect.Left();
     503          12 :     long nScrY = aRect.Top();
     504             : 
     505             :     //  If no lines, still leave space for grid lines
     506             :     //  (would be elseways cut away)
     507          12 :     long nAddX = (long)( aLines.Left() * nScaleX );
     508          12 :     nScrX += ( nAddX ? nAddX : 1 );
     509          12 :     long nAddY = (long)( aLines.Top() * nScaleY );
     510          12 :     nScrY += ( nAddY ? nAddY : 1 );
     511             : 
     512             :     ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nTab,
     513          24 :                                 nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
     514          12 :     aOutputData.SetMetaFileMode(bMetaFile);
     515          12 :     aOutputData.SetShowNullValues(bNullVal);
     516          12 :     aOutputData.SetShowFormulas(bFormula);
     517             : 
     518             :     // #114135#
     519          12 :     ScDrawLayer* pModel = pDoc->GetDrawLayer();
     520          24 :     boost::scoped_ptr<FmFormView> pDrawView;
     521             : 
     522          12 :     if( pModel )
     523             :     {
     524          12 :         pDrawView.reset(new FmFormView( pModel, pDev ));
     525          12 :         pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
     526          12 :         pDrawView->SetPrintPreview( true );
     527          12 :         aOutputData.SetDrawView( pDrawView.get() );
     528             :     }
     529             : 
     530             :     //! SetUseStyleColor ??
     531             : 
     532          12 :     if ( bMetaFile && pDev->GetOutDevType() == OUTDEV_VIRDEV )
     533          12 :         aOutputData.SetSnapPixel();
     534             : 
     535          12 :     Point aLogStart = pDev->PixelToLogic( Point(nScrX,nScrY), MAP_100TH_MM );
     536          12 :     long nLogStX = aLogStart.X();
     537          12 :     long nLogStY = aLogStart.Y();
     538             : 
     539             :     //!     nZoom for GetFont in OutputData ???
     540             : 
     541          12 :     if (!bMetaFile && pViewData)
     542           0 :         pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
     543             : 
     544             :     // #i72502#
     545          12 :     const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
     546          12 :     aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
     547             : 
     548          12 :     if (!bMetaFile && pViewData)
     549           0 :         pDev->SetMapMode(aMode);
     550             : 
     551          12 :     aOutputData.DrawBackground();
     552          12 :     aOutputData.DrawShadow();
     553          12 :     aOutputData.DrawFrame();
     554          12 :     aOutputData.DrawStrings();
     555             : 
     556          12 :     if (!bMetaFile && pViewData)
     557           0 :         pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
     558             : 
     559          12 :     aOutputData.DrawEdit(!bMetaFile);
     560             : 
     561          12 :     if (bDoGrid)
     562             :     {
     563           0 :         if (!bMetaFile && pViewData)
     564           0 :             pDev->SetMapMode(aMode);
     565             : 
     566           0 :         aOutputData.DrawGrid( true, false );    // no page breaks
     567             : 
     568           0 :         pDev->SetLineColor( COL_BLACK );
     569             : 
     570           0 :         Size aOne = pDev->PixelToLogic( Size(1,1) );
     571           0 :         if (bMetaFile)
     572           0 :             aOne = Size(1,1);   // compatible with DrawGrid
     573           0 :         long nRight = nScrX + aOutputData.GetScrW() - aOne.Width();
     574           0 :         long nBottom = nScrY + aOutputData.GetScrH() - aOne.Height();
     575             : 
     576           0 :         bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
     577             : 
     578             :         // extra line at the left edge for left-to-right, right for right-to-left
     579           0 :         if ( bLayoutRTL )
     580           0 :             pDev->DrawLine( Point(nRight,nScrY), Point(nRight,nBottom) );
     581             :         else
     582           0 :             pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX,nBottom) );
     583             :         // extra line at the top in both cases
     584           0 :         pDev->DrawLine( Point(nScrX,nScrY), Point(nRight,nScrY) );
     585             :     }
     586             : 
     587             :     // #i72502#
     588          12 :     aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
     589          12 :     aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
     590          24 :     aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
     591          12 : }
     592             : 
     593             : //          Printing
     594             : 
     595        1392 : static void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet )
     596             : {
     597             :     //  nDistance must be initialized differently before
     598             : 
     599        1392 :     if ( pHFSet == NULL )
     600             :     {
     601           0 :         rParam.bEnable  = false;
     602           0 :         rParam.pBorder  = NULL;
     603           0 :         rParam.pBack    = NULL;
     604           0 :         rParam.pShadow  = NULL;
     605             :     }
     606             :     else
     607             :     {
     608        1392 :         rParam.bEnable  = static_cast<const SfxBoolItem&>( pHFSet->Get(ATTR_PAGE_ON)).GetValue();
     609        1392 :         rParam.bDynamic = static_cast<const SfxBoolItem&>( pHFSet->Get(ATTR_PAGE_DYNAMIC)).GetValue();
     610        1392 :         rParam.bShared  = static_cast<const SfxBoolItem&>( pHFSet->Get(ATTR_PAGE_SHARED)).GetValue();
     611        1392 :         rParam.nHeight  = static_cast<const SvxSizeItem&>( pHFSet->Get(ATTR_PAGE_SIZE)).GetSize().Height();
     612        1392 :         const SvxLRSpaceItem* pHFLR = &static_cast<const SvxLRSpaceItem&>(pHFSet->Get(ATTR_LRSPACE));
     613             :         long nTmp;
     614        1392 :         nTmp = pHFLR->GetLeft();
     615        1392 :         rParam.nLeft = nTmp < 0 ? 0 : sal_uInt16(nTmp);
     616        1392 :         nTmp = pHFLR->GetRight();
     617        1392 :         rParam.nRight = nTmp < 0 ? 0 : sal_uInt16(nTmp);
     618        1392 :         rParam.pBorder  = static_cast<const SvxBoxItem*>   (&pHFSet->Get(ATTR_BORDER));
     619        1392 :         rParam.pBack    = static_cast<const SvxBrushItem*> (&pHFSet->Get(ATTR_BACKGROUND));
     620        1392 :         rParam.pShadow  = static_cast<const SvxShadowItem*>(&pHFSet->Get(ATTR_SHADOW));
     621             : 
     622             : //   now back in the dialog:
     623             : //      rParam.nHeight += rParam.nDistance;             // not in the dialog any more ???
     624             : 
     625        1392 :         if (rParam.pBorder)
     626        1392 :             rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
     627        1392 :                               lcl_LineTotal( rParam.pBorder->GetBottom() );
     628             : 
     629        1392 :         rParam.nManHeight = rParam.nHeight;
     630             :     }
     631             : 
     632        1392 :     if (!rParam.bEnable)
     633           8 :         rParam.nHeight = 0;
     634        1392 : }
     635             : 
     636             : //  bNew = TRUE:    search for used part of the document
     637             : //  bNew = FALSE:   only limit whole lines/columns
     638             : 
     639         692 : bool ScPrintFunc::AdjustPrintArea( bool bNew )
     640             : {
     641         692 :     SCCOL nOldEndCol = nEndCol; // only important for !bNew
     642         692 :     SCROW nOldEndRow = nEndRow;
     643         692 :     bool bChangeCol = true;         // at bNew both are being adjusted
     644         692 :     bool bChangeRow = true;
     645             : 
     646         692 :     bool bNotes = aTableParam.bNotes;
     647         692 :     if ( bNew )
     648             :     {
     649         624 :         nStartCol = 0;
     650         624 :         nStartRow = 0;
     651         624 :         if (!pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ))
     652         564 :             return false;   // nix
     653             :     }
     654             :     else
     655             :     {
     656          68 :         bool bFound = true;
     657          68 :         bChangeCol = ( nStartCol == 0 && nEndCol == MAXCOL );
     658          68 :         bChangeRow = ( nStartRow == 0 && nEndRow == MAXROW );
     659          68 :         bool bForcedChangeRow = false;
     660             : 
     661             :         // #i53558# Crop entire column of old row limit to real print area with
     662             :         // some fuzzyness.
     663          68 :         if (!bChangeRow && nStartRow == 0)
     664             :         {
     665             :             SCROW nPAEndRow;
     666          68 :             bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nPAEndRow, bNotes );
     667             :             // Say we don't want to print more than ~1000 empty rows, which are
     668             :             // about 14 pages intentionally left blank..
     669          68 :             const SCROW nFuzzy = 23*42;
     670          68 :             if (nPAEndRow + nFuzzy < nEndRow)
     671             :             {
     672           0 :                 bForcedChangeRow = true;
     673           0 :                 nEndRow = nPAEndRow;
     674             :             }
     675             :             else
     676          68 :                 bFound = true;  // user seems to _want_ to print some empty rows
     677             :         }
     678             :         // TODO: in case we extend the number of columns we may have to do the
     679             :         // same for horizontal cropping.
     680             : 
     681          68 :         if ( bChangeCol && bChangeRow )
     682           0 :             bFound = pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes );
     683          68 :         else if ( bChangeCol )
     684           0 :             bFound = pDoc->GetPrintAreaHor( nPrintTab, nStartRow, nEndRow, nEndCol, bNotes );
     685          68 :         else if ( bChangeRow )
     686           0 :             bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nEndRow, bNotes );
     687             : 
     688          68 :         if (!bFound)
     689           0 :             return false;   // empty
     690             : 
     691          68 :         if (bForcedChangeRow)
     692           0 :             bChangeRow = true;
     693             :     }
     694             : 
     695             :     pDoc->ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab,
     696         128 :                         false );      // no Refresh, incl. Attrs
     697             : 
     698         128 :     if ( bChangeCol )
     699             :     {
     700          60 :         OutputDevice* pRefDev = pDoc->GetPrinter();     // use the printer also for Preview
     701          60 :         pRefDev->SetMapMode( MAP_PIXEL );               // important for GetNeededSize
     702             : 
     703             :         pDoc->ExtendPrintArea( pRefDev,
     704          60 :                             nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow );
     705             :         //  changing nEndCol
     706             :     }
     707             : 
     708         256 :     if ( nEndCol < MAXCOL && pDoc->HasAttrib(
     709         128 :                     nEndCol,nStartRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_RIGHT ) )
     710           0 :         ++nEndCol;
     711         256 :     if ( nEndRow < MAXROW && pDoc->HasAttrib(
     712         128 :                     nStartCol,nEndRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_DOWN ) )
     713           0 :         ++nEndRow;
     714             : 
     715         128 :     if (!bChangeCol) nEndCol = nOldEndCol;
     716         128 :     if (!bChangeRow) nEndRow = nOldEndRow;
     717             : 
     718         128 :     return true;
     719             : }
     720             : 
     721        9216 : long ScPrintFunc::TextHeight( const EditTextObject* pObject )
     722             : {
     723        9216 :     if (!pObject)
     724        1044 :         return 0;
     725             : 
     726        8172 :     pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
     727             : 
     728        8172 :     return (long) pEditEngine->GetTextHeight();
     729             : }
     730             : 
     731             : //  nZoom must be set !!!
     732             : //  and the respective Twip-MapMode configured
     733             : 
     734        1440 : void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam )
     735             : {
     736             :     OSL_ENSURE( aPageSize.Width(), "UpdateHFHeight ohne aPageSize");
     737             : 
     738        1440 :     if (rParam.bEnable && rParam.bDynamic)
     739             :     {
     740             :         //  calculate nHeight from content
     741             : 
     742        1428 :         MakeEditEngine();
     743        1428 :         long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin -
     744        1428 :                                 rParam.nLeft - rParam.nRight ) * 100 / nZoom;
     745        1428 :         if (rParam.pBorder)
     746        2856 :             nPaperWidth -= ( rParam.pBorder->GetDistance(BOX_LINE_LEFT) +
     747        4284 :                              rParam.pBorder->GetDistance(BOX_LINE_RIGHT) +
     748        2856 :                              lcl_LineTotal(rParam.pBorder->GetLeft()) +
     749        2856 :                              lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom;
     750             : 
     751        1428 :         if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
     752           0 :             nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SHADOW_LEFT) +
     753           0 :                              rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT) ) * 100L / nZoom;
     754             : 
     755        1428 :         pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) );
     756             : 
     757        1428 :         long nMaxHeight = 0;
     758        1428 :         if ( rParam.pLeft )
     759             :         {
     760        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) );
     761        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) );
     762        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) );
     763             :         }
     764        1428 :         if ( rParam.pRight )
     765             :         {
     766        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) );
     767        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) );
     768        1428 :             nMaxHeight = std::max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) );
     769             :         }
     770             : 
     771        1428 :         rParam.nHeight = nMaxHeight + rParam.nDistance;
     772        1428 :         if (rParam.pBorder)
     773        2856 :             rParam.nHeight += rParam.pBorder->GetDistance(BOX_LINE_TOP) +
     774        4284 :                               rParam.pBorder->GetDistance(BOX_LINE_BOTTOM) +
     775        1428 :                               lcl_LineTotal( rParam.pBorder->GetTop() ) +
     776        1428 :                               lcl_LineTotal( rParam.pBorder->GetBottom() );
     777        1428 :         if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
     778           0 :             rParam.nHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
     779           0 :                               rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
     780             : 
     781        1428 :         if (rParam.nHeight < rParam.nManHeight)
     782        1428 :             rParam.nHeight = rParam.nManHeight;         // configured minimum
     783             :     }
     784        1440 : }
     785             : 
     786         696 : void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
     787             : {
     788         696 :     if (!pParamSet)
     789         696 :         return;
     790             : 
     791             :                                 // TabPage "Page"
     792         696 :     const SvxLRSpaceItem* pLRItem = static_cast<const SvxLRSpaceItem*>( &pParamSet->Get( ATTR_LRSPACE ) );
     793             :     long nTmp;
     794         696 :     nTmp = pLRItem->GetLeft();
     795         696 :     nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
     796         696 :     nTmp = pLRItem->GetRight();
     797         696 :     nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp);
     798         696 :     const SvxULSpaceItem* pULItem = static_cast<const SvxULSpaceItem*>( &pParamSet->Get( ATTR_ULSPACE ) );
     799         696 :     nTopMargin    = pULItem->GetUpper();
     800         696 :     nBottomMargin = pULItem->GetLower();
     801             : 
     802         696 :     const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>( &pParamSet->Get( ATTR_PAGE ) );
     803         696 :     nPageUsage          = pPageItem->GetPageUsage();
     804         696 :     bLandscape          = pPageItem->IsLandscape();
     805         696 :     aFieldData.eNumType = pPageItem->GetNumType();
     806             : 
     807         696 :     bCenterHor = static_cast<const SfxBoolItem&>( pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue();
     808         696 :     bCenterVer = static_cast<const SfxBoolItem&>( pParamSet->Get(ATTR_PAGE_VERCENTER)).GetValue();
     809             : 
     810         696 :     aPageSize = static_cast<const SvxSizeItem&>( pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
     811         696 :     if ( !aPageSize.Width() || !aPageSize.Height() )
     812             :     {
     813             :         OSL_FAIL("PageSize Null ?!?!?");
     814           0 :         aPageSize = SvxPaperInfo::GetPaperSize( PAPER_A4 );
     815             :     }
     816             : 
     817         696 :     pBorderItem     = static_cast<const SvxBoxItem*>   (&pParamSet->Get(ATTR_BORDER) );
     818         696 :     pBackgroundItem = static_cast<const SvxBrushItem*> (&pParamSet->Get(ATTR_BACKGROUND) );
     819         696 :     pShadowItem     = static_cast<const SvxShadowItem*>(&pParamSet->Get(ATTR_SHADOW) );
     820             : 
     821             :                                 // TabPage "Headline"
     822             : 
     823         696 :     aHdr.pLeft      = static_cast<const ScPageHFItem*>( &pParamSet->Get(ATTR_PAGE_HEADERLEFT) );      // Content
     824         696 :     aHdr.pRight     = static_cast<const ScPageHFItem*>( &pParamSet->Get(ATTR_PAGE_HEADERRIGHT) );
     825             : 
     826             :     const SvxSetItem* pHeaderSetItem;
     827         696 :     const SfxItemSet* pHeaderSet = NULL;
     828         696 :     if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, false,
     829         696 :                             (const SfxPoolItem**)&pHeaderSetItem ) == SfxItemState::SET )
     830             :     {
     831         696 :         pHeaderSet = &pHeaderSetItem->GetItemSet();
     832             :                                                         // Headline has space below
     833         696 :         aHdr.nDistance  = static_cast<const SvxULSpaceItem&>(pHeaderSet->Get(ATTR_ULSPACE)).GetLower();
     834             :     }
     835         696 :     lcl_FillHFParam( aHdr, pHeaderSet );
     836             : 
     837             :                                 // TabPage "Footline"
     838             : 
     839         696 :     aFtr.pLeft      = static_cast<const ScPageHFItem*>( &pParamSet->Get(ATTR_PAGE_FOOTERLEFT) );      // Content
     840         696 :     aFtr.pRight     = static_cast<const ScPageHFItem*>( &pParamSet->Get(ATTR_PAGE_FOOTERRIGHT) );
     841             : 
     842             :     const SvxSetItem* pFooterSetItem;
     843         696 :     const SfxItemSet* pFooterSet = NULL;
     844         696 :     if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, false,
     845         696 :                             (const SfxPoolItem**)&pFooterSetItem ) == SfxItemState::SET )
     846             :     {
     847         696 :         pFooterSet = &pFooterSetItem->GetItemSet();
     848             :                                                         // Footline has space above
     849         696 :         aFtr.nDistance  = static_cast<const SvxULSpaceItem&>(pFooterSet->Get(ATTR_ULSPACE)).GetUpper();
     850             :     }
     851         696 :     lcl_FillHFParam( aFtr, pFooterSet );
     852             : 
     853             :     // Compile Table-/Area-Params from single Items
     854             : 
     855             :     // TabPage "Table"
     856             : 
     857         696 :     const SfxUInt16Item*     pScaleItem          = NULL;
     858         696 :     const ScPageScaleToItem* pScaleToItem        = NULL;
     859         696 :     const SfxUInt16Item*     pScaleToPagesItem   = NULL;
     860             :     SfxItemState             eState;
     861             : 
     862             :     eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, false,
     863         696 :                                       (const SfxPoolItem**)&pScaleItem );
     864         696 :     if ( SfxItemState::DEFAULT == eState )
     865             :         pScaleItem = static_cast<const SfxUInt16Item*>(
     866         692 :                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALE ));
     867             : 
     868             :     eState = pParamSet->GetItemState( ATTR_PAGE_SCALETO, false,
     869         696 :                                       (const SfxPoolItem**)&pScaleToItem );
     870         696 :     if ( SfxItemState::DEFAULT == eState )
     871             :         pScaleToItem = static_cast<const ScPageScaleToItem*>(
     872         696 :                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETO ));
     873             : 
     874             :     eState = pParamSet->GetItemState( ATTR_PAGE_SCALETOPAGES, false,
     875         696 :                                       (const SfxPoolItem**)&pScaleToPagesItem );
     876         696 :     if ( SfxItemState::DEFAULT == eState )
     877             :         pScaleToPagesItem = static_cast<const SfxUInt16Item*>(
     878         696 :                     &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETOPAGES ));
     879             : 
     880             :     OSL_ENSURE( pScaleItem && pScaleToItem && pScaleToPagesItem, "Missing ScaleItem! :-/" );
     881             : 
     882         696 :     aTableParam.bCellContent    = true;
     883         696 :     aTableParam.bNotes          = GET_BOOL(pParamSet,ATTR_PAGE_NOTES);
     884         696 :     aTableParam.bGrid           = GET_BOOL(pParamSet,ATTR_PAGE_GRID);
     885         696 :     aTableParam.bHeaders        = GET_BOOL(pParamSet,ATTR_PAGE_HEADERS);
     886         696 :     aTableParam.bFormulas       = GET_BOOL(pParamSet,ATTR_PAGE_FORMULAS);
     887         696 :     aTableParam.bNullVals       = GET_BOOL(pParamSet,ATTR_PAGE_NULLVALS);
     888         696 :     aTableParam.bCharts         = GET_SHOW(pParamSet,ATTR_PAGE_CHARTS);
     889         696 :     aTableParam.bObjects        = GET_SHOW(pParamSet,ATTR_PAGE_OBJECTS);
     890         696 :     aTableParam.bDrawings       = GET_SHOW(pParamSet,ATTR_PAGE_DRAWINGS);
     891         696 :     aTableParam.bTopDown        = GET_BOOL(pParamSet,ATTR_PAGE_TOPDOWN);
     892         696 :     aTableParam.bLeftRight      = !aTableParam.bLeftRight;
     893         696 :     aTableParam.nFirstPageNo    = GET_USHORT(pParamSet,ATTR_PAGE_FIRSTPAGENO);
     894         696 :     if (!aTableParam.nFirstPageNo)
     895          28 :         aTableParam.nFirstPageNo = (sal_uInt16) nPageStart;     // from previous table
     896             : 
     897         696 :     if ( pScaleItem && pScaleToItem && pScaleToPagesItem )
     898             :     {
     899         696 :         sal_uInt16  nScaleAll     = pScaleItem->GetValue();
     900         696 :         sal_uInt16  nScaleToPages = pScaleToPagesItem->GetValue();
     901             : 
     902         696 :         aTableParam.bScaleNone      = (nScaleAll     == 100);
     903         696 :         aTableParam.bScaleAll       = (nScaleAll      > 0  );
     904         696 :         aTableParam.bScaleTo        = pScaleToItem->IsValid();
     905         696 :         aTableParam.bScalePageNum   = (nScaleToPages  > 0  );
     906         696 :         aTableParam.nScaleAll       = nScaleAll;
     907         696 :         aTableParam.nScaleWidth     = pScaleToItem->GetWidth();
     908         696 :         aTableParam.nScaleHeight    = pScaleToItem->GetHeight();
     909         696 :         aTableParam.nScalePageNum   = nScaleToPages;
     910             :     }
     911             :     else
     912             :     {
     913           0 :         aTableParam.bScaleNone      = true;
     914           0 :         aTableParam.bScaleAll       = false;
     915           0 :         aTableParam.bScaleTo        = false;
     916           0 :         aTableParam.bScalePageNum   = false;
     917           0 :         aTableParam.nScaleAll       = 0;
     918           0 :         aTableParam.nScaleWidth     = 0;
     919           0 :         aTableParam.nScaleHeight    = 0;
     920           0 :         aTableParam.nScalePageNum   = 0;
     921             :     }
     922             : 
     923             :     //  skip empty pages only if options with that flag are passed
     924         696 :     aTableParam.bSkipEmpty = pOptions && pOptions->GetSkipEmpty();
     925         696 :     if ( pPageData )
     926           2 :         aTableParam.bSkipEmpty = false;
     927             :     // If pPageData is set, only the breaks are interesting for the
     928             :     // pagebreak preview, empty pages are not addressed separately.
     929             : 
     930         696 :     aTableParam.bForceBreaks = pOptions && pOptions->GetForceBreaks();
     931             : 
     932             :     // TabPage "Parts":
     933             : 
     934             :     //! walk throuch all PrintAreas of the table !!!
     935         696 :     const ScRange*  pPrintArea = pDoc->GetPrintRange( nPrintTab, 0 );
     936         696 :     const ScRange*  pRepeatCol = pDoc->GetRepeatColRange( nPrintTab );
     937         696 :     const ScRange*  pRepeatRow = pDoc->GetRepeatRowRange( nPrintTab );
     938             : 
     939             :     //  ignoring ATTR_PAGE_PRINTTABLES
     940             : 
     941         696 :     bool bHasPrintRange = pDoc->HasPrintRange();
     942         696 :     sal_uInt16 nPrintRangeCount = pDoc->GetPrintRangeCount(nPrintTab);
     943         696 :     bool bPrintEntireSheet = pDoc->IsPrintEntireSheet(nPrintTab);
     944             : 
     945         696 :     if (!bPrintEntireSheet && !nPrintRangeCount)
     946           0 :         mbHasPrintRange = false;
     947             : 
     948         696 :     if ( pUserArea )                // UserArea (selection) has prority
     949             :     {
     950             :         bPrintCurrentTable    =
     951           0 :         aAreaParam.bPrintArea = true;                   // Selection
     952           0 :         aAreaParam.aPrintArea = *pUserArea;
     953             : 
     954             :         //  The table-query is already in DocShell::Print, here always
     955           0 :         aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
     956           0 :         aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
     957             :     }
     958         696 :     else if (bHasPrintRange)
     959             :     {
     960         696 :         if ( pPrintArea )                               // at least one set?
     961             :         {
     962             :             bPrintCurrentTable    =
     963           4 :             aAreaParam.bPrintArea = true;
     964           4 :             aAreaParam.aPrintArea = *pPrintArea;
     965             : 
     966           4 :             bMultiArea = nPrintRangeCount > 1;
     967             :         }
     968             :         else
     969             :         {
     970             :             // do not print hidden sheets with "Print entire sheet" flag
     971         692 :             bPrintCurrentTable = pDoc->IsPrintEntireSheet( nPrintTab ) && pDoc->IsVisible( nPrintTab );
     972         692 :             aAreaParam.bPrintArea = !bPrintCurrentTable;    // otherwise the table is always counted
     973             :         }
     974             :     }
     975             :     else
     976             :     {
     977             :         //  don't print hidden tables if there's no print range defined there
     978           0 :         if ( pDoc->IsVisible( nPrintTab ) )
     979             :         {
     980           0 :             aAreaParam.bPrintArea = false;
     981           0 :             bPrintCurrentTable = true;
     982             :         }
     983             :         else
     984             :         {
     985           0 :             aAreaParam.bPrintArea = true;   // otherwise the table is always counted
     986           0 :             bPrintCurrentTable = false;
     987             :         }
     988             :     }
     989             : 
     990         696 :     if ( pRepeatCol )
     991             :     {
     992           2 :         aAreaParam.bRepeatCol = true;
     993           2 :         aAreaParam.aRepeatCol = *pRepeatCol;
     994           2 :         nRepeatStartCol = pRepeatCol->aStart.Col();
     995           2 :         nRepeatEndCol   = pRepeatCol->aEnd  .Col();
     996             :     }
     997             :     else
     998             :     {
     999         694 :         aAreaParam.bRepeatCol = false;
    1000         694 :         nRepeatStartCol = nRepeatEndCol = SCCOL_REPEAT_NONE;
    1001             :     }
    1002             : 
    1003         696 :     if ( pRepeatRow )
    1004             :     {
    1005          10 :         aAreaParam.bRepeatRow = true;
    1006          10 :         aAreaParam.aRepeatRow = *pRepeatRow;
    1007          10 :         nRepeatStartRow = pRepeatRow->aStart.Row();
    1008          10 :         nRepeatEndRow   = pRepeatRow->aEnd  .Row();
    1009             :     }
    1010             :     else
    1011             :     {
    1012         686 :         aAreaParam.bRepeatRow = false;
    1013         686 :         nRepeatStartRow = nRepeatEndRow = SCROW_REPEAT_NONE;
    1014             :     }
    1015             : 
    1016             :             //  Split pages
    1017             : 
    1018         696 :     if (!bState)
    1019             :     {
    1020         608 :         nTabPages = CountPages();                                   // also calculates zoom
    1021         608 :         nTotalPages = nTabPages;
    1022         608 :         nTotalPages += CountNotePages();
    1023             :     }
    1024             :     else
    1025             :     {
    1026          88 :         CalcPages();            // search breaks only
    1027          88 :         CountNotePages();       // Count notes, even if number of pages is already known
    1028             :     }
    1029             : 
    1030         696 :     if (nDocPages)
    1031         108 :         aFieldData.nTotalPages = nDocPages;
    1032             :     else
    1033         588 :         aFieldData.nTotalPages = nTotalPages;
    1034             : 
    1035         696 :     SetDateTime( Date( Date::SYSTEM ), tools::Time( tools::Time::SYSTEM ) );
    1036             : 
    1037         696 :     if( pDocShell->getDocProperties()->getTitle().getLength() != 0 )
    1038           8 :         aFieldData.aTitle = pDocShell->getDocProperties()->getTitle();
    1039             :     else
    1040         688 :         aFieldData.aTitle = pDocShell->GetTitle();
    1041             : 
    1042         696 :     const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
    1043         696 :     aFieldData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
    1044         696 :     if ( !aFieldData.aLongDocName.isEmpty() )
    1045         548 :         aFieldData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
    1046             :     else
    1047         148 :         aFieldData.aShortDocName = aFieldData.aLongDocName = aFieldData.aTitle;
    1048             : 
    1049             :     //  Printer settings (Orientation, Paper) at DoPrint
    1050             : }
    1051             : 
    1052           0 : Size ScPrintFunc::GetDataSize() const
    1053             : {
    1054           0 :     Size aSize = aPageSize;
    1055           0 :     aSize.Width()  -= nLeftMargin + nRightMargin;
    1056           0 :     aSize.Height() -= nTopMargin + nBottomMargin;
    1057           0 :     aSize.Height() -= aHdr.nHeight + aFtr.nHeight;
    1058           0 :     return aSize;
    1059             : }
    1060             : 
    1061           0 : void ScPrintFunc::GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr )
    1062             : {
    1063           0 :     rPhysSize = aPageSize;
    1064           0 :     rPhysSize.Width()  -= nLeftMargin + nRightMargin;
    1065           0 :     rPhysSize.Height() -= nTopMargin + nBottomMargin;
    1066             : 
    1067           0 :     rDocHdr = aHdr.nHeight;
    1068           0 :     rDocFtr = aFtr.nHeight;
    1069           0 : }
    1070             : 
    1071         804 : void ScPrintFunc::SetDateTime( const Date& rDate, const tools::Time& rTime )
    1072             : {
    1073         804 :     aFieldData.aDate = rDate;
    1074         804 :     aFieldData.aTime = rTime;
    1075         804 : }
    1076             : 
    1077           0 : static void lcl_DrawGraphic( const Graphic &rGraphic, OutputDevice *pOut,
    1078             :                       const Rectangle &rGrf, const Rectangle &rOut )
    1079             : {
    1080           0 :     const bool bNotInside = !rOut.IsInside( rGrf );
    1081           0 :     if ( bNotInside )
    1082             :     {
    1083           0 :         pOut->Push();
    1084           0 :         pOut->IntersectClipRegion( rOut );
    1085             :     }
    1086             : 
    1087           0 :     ((Graphic&)rGraphic).Draw( pOut, rGrf.TopLeft(), rGrf.GetSize() );
    1088             : 
    1089           0 :     if ( bNotInside )
    1090           0 :         pOut->Pop();
    1091           0 : }
    1092             : 
    1093           0 : static void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, OutputDevice* pRefDev,
    1094             :                         const Rectangle &rOrg, const Rectangle &rOut,
    1095             :                         OUString const & referer )
    1096             : {
    1097           0 :     Size aGrfSize(0,0);
    1098           0 :     const Graphic *pGraphic = rBrush.GetGraphic(referer);
    1099             :     SvxGraphicPosition ePos;
    1100           0 :     if ( pGraphic && pGraphic->IsSupportedGraphic() )
    1101             :     {
    1102           0 :         const MapMode aMapMM( MAP_100TH_MM );
    1103           0 :         if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
    1104           0 :             aGrfSize = pRefDev->PixelToLogic( pGraphic->GetPrefSize(), aMapMM );
    1105             :         else
    1106             :             aGrfSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
    1107           0 :                                     pGraphic->GetPrefMapMode(), aMapMM );
    1108           0 :         ePos = rBrush.GetGraphicPos();
    1109             :     }
    1110             :     else
    1111           0 :         ePos = GPOS_NONE;
    1112             : 
    1113           0 :     Point aPos;
    1114           0 :     Size aDrawSize = aGrfSize;
    1115             : 
    1116           0 :     bool bDraw = true;
    1117           0 :     switch ( ePos )
    1118             :     {
    1119           0 :         case GPOS_LT: aPos = rOrg.TopLeft();
    1120           0 :                       break;
    1121           0 :         case GPOS_MT: aPos.Y() = rOrg.Top();
    1122           0 :                       aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
    1123           0 :                       break;
    1124           0 :         case GPOS_RT: aPos.Y() = rOrg.Top();
    1125           0 :                       aPos.X() = rOrg.Right() - aGrfSize.Width();
    1126           0 :                       break;
    1127             : 
    1128           0 :         case GPOS_LM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
    1129           0 :                       aPos.X() = rOrg.Left();
    1130           0 :                       break;
    1131           0 :         case GPOS_MM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
    1132           0 :                       aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
    1133           0 :                       break;
    1134           0 :         case GPOS_RM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
    1135           0 :                       aPos.X() = rOrg.Right() - aGrfSize.Width();
    1136           0 :                       break;
    1137             : 
    1138           0 :         case GPOS_LB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
    1139           0 :                       aPos.X() = rOrg.Left();
    1140           0 :                       break;
    1141           0 :         case GPOS_MB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
    1142           0 :                       aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
    1143           0 :                       break;
    1144           0 :         case GPOS_RB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
    1145           0 :                       aPos.X() = rOrg.Right() - aGrfSize.Width();
    1146           0 :                       break;
    1147             : 
    1148             :         case GPOS_AREA:
    1149           0 :                       aPos = rOrg.TopLeft();
    1150           0 :                       aDrawSize = rOrg.GetSize();
    1151           0 :                       break;
    1152             :         case GPOS_TILED:
    1153             :                     {
    1154             :                         //  use GraphicObject::DrawTiled instead of an own loop
    1155             :                         //  (pixel rounding is handled correctly, and a very small bitmap
    1156             :                         //  is duplicated into a bigger one for better performance)
    1157             : 
    1158           0 :                         GraphicObject aObject( *pGraphic );
    1159             : 
    1160           0 :                         if( pOut->GetPDFWriter() &&
    1161           0 :                             (aObject.GetType() == GRAPHIC_BITMAP || aObject.GetType() == GRAPHIC_DEFAULT) )
    1162             :                         {
    1163             :                             // For PDF export, every draw
    1164             :                             // operation for bitmaps takes a noticeable
    1165             :                             // amount of place (~50 characters). Thus,
    1166             :                             // optimize between tile bitmap size and
    1167             :                             // number of drawing operations here.
    1168             :                             //
    1169             :                             //                  A_out
    1170             :                             // n_chars = k1 *  ---------- + k2 * A_bitmap
    1171             :                             //                  A_bitmap
    1172             :                             //
    1173             :                             // minimum n_chars is obtained for (derive for
    1174             :                             // A_bitmap, set to 0, take positive
    1175             :                             // solution):
    1176             :                             //                   k1
    1177             :                             // A_bitmap = Sqrt( ---- A_out )
    1178             :                             //                   k2
    1179             :                             //
    1180             :                             // where k1 is the number of chars per draw
    1181             :                             // operation, and k2 is the number of chars
    1182             :                             // per bitmap pixel. This is approximately 50
    1183             :                             // and 7 for current PDF writer, respectively.
    1184             : 
    1185           0 :                             const double    k1( 50 );
    1186           0 :                             const double    k2( 7 );
    1187           0 :                             const Size      aSize( rOrg.GetSize() );
    1188           0 :                             const double    Abitmap( k1/k2 * aSize.Width()*aSize.Height() );
    1189             : 
    1190             :                             aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0),
    1191             :                                                NULL, GRFMGR_DRAW_STANDARD,
    1192           0 :                                                ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) );
    1193             :                         }
    1194             :                         else
    1195             :                         {
    1196           0 :                             aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0) );
    1197             :                         }
    1198             : 
    1199           0 :                         bDraw = false;
    1200             :                     }
    1201           0 :                     break;
    1202             : 
    1203             :         case GPOS_NONE:
    1204           0 :                       bDraw = false;
    1205           0 :                       break;
    1206             : 
    1207             :         default: OSL_ENSURE( !pOut, "new Graphic position?" );
    1208             :     }
    1209           0 :     Rectangle aGrf( aPos,aDrawSize );
    1210           0 :     if ( bDraw && aGrf.IsOver( rOut ) )
    1211             :     {
    1212           0 :         lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut );
    1213             :     }
    1214           0 : }
    1215             : 
    1216             : //  Rahmen wird nach innen gezeichnet
    1217             : 
    1218         198 : void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
    1219             :                                 const SvxBoxItem* pBorderData, const SvxBrushItem* pBackground,
    1220             :                                 const SvxShadowItem* pShadow )
    1221             : {
    1222             :     //!     direkte Ausgabe aus SvxBoxItem !!!
    1223             : 
    1224         198 :     if (pBorderData)
    1225         396 :         if ( !pBorderData->GetTop() && !pBorderData->GetBottom() && !pBorderData->GetLeft() &&
    1226         198 :                                         !pBorderData->GetRight() )
    1227         198 :             pBorderData = NULL;
    1228             : 
    1229         198 :     if (!pBorderData && !pBackground && !pShadow)
    1230           0 :         return;                                     // nichts zu tun
    1231             : 
    1232         198 :     long nLeft   = 0;
    1233         198 :     long nRight  = 0;
    1234         198 :     long nTop    = 0;
    1235         198 :     long nBottom = 0;
    1236             : 
    1237             :     //  aFrameRect - ouside around frame, without shadow
    1238         198 :     if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
    1239             :     {
    1240           0 :         nLeft   += (long) ( pShadow->CalcShadowSpace(SHADOW_LEFT)   * nScaleX );
    1241           0 :         nRight  += (long) ( pShadow->CalcShadowSpace(SHADOW_RIGHT)  * nScaleX );
    1242           0 :         nTop    += (long) ( pShadow->CalcShadowSpace(SHADOW_TOP)    * nScaleY );
    1243           0 :         nBottom += (long) ( pShadow->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY );
    1244             :     }
    1245             :     Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop),
    1246         198 :                           Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) );
    1247             : 
    1248             :     //  center of frame, to paint lines through OutputData
    1249         198 :     if (pBorderData)
    1250             :     {
    1251           0 :         nLeft   += (long) ( lcl_LineTotal(pBorderData->GetLeft())   * nScaleX / 2 );
    1252           0 :         nRight  += (long) ( lcl_LineTotal(pBorderData->GetRight())  * nScaleX / 2 );
    1253           0 :         nTop    += (long) ( lcl_LineTotal(pBorderData->GetTop())    * nScaleY / 2 );
    1254           0 :         nBottom += (long) ( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 );
    1255             :     }
    1256         198 :     long nEffHeight = nScrH - nTop - nBottom;
    1257         198 :     long nEffWidth = nScrW - nLeft - nRight;
    1258         198 :     if (nEffHeight<=0 || nEffWidth<=0)
    1259           0 :         return;                                         // enmpty
    1260             : 
    1261         198 :     if ( pBackground )
    1262             :     {
    1263         198 :         if (pBackground->GetGraphicPos() != GPOS_NONE)
    1264             :         {
    1265             :             OutputDevice* pRefDev;
    1266           0 :             if ( bIsRender )
    1267           0 :                 pRefDev = pDev;                 // don't use printer for PDF
    1268             :             else
    1269           0 :                 pRefDev = pDoc->GetPrinter();   // use printer also for preview
    1270           0 :             OUString referer;
    1271           0 :             if (pDocShell->HasName()) {
    1272           0 :                 referer = pDocShell->GetMedium()->GetName();
    1273             :             }
    1274           0 :             lcl_DrawGraphic( *pBackground, pDev, pRefDev, aFrameRect, aFrameRect, referer );
    1275             :         }
    1276             :         else
    1277             :         {
    1278         198 :             pDev->SetFillColor(pBackground->GetColor());
    1279         198 :             pDev->SetLineColor();
    1280         198 :             pDev->DrawRect(aFrameRect);
    1281             :         }
    1282             :     }
    1283             : 
    1284         198 :     if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
    1285             :     {
    1286           0 :         pDev->SetFillColor(pShadow->GetColor());
    1287           0 :         pDev->SetLineColor();
    1288           0 :         long nShadowX = (long) ( pShadow->GetWidth() * nScaleX );
    1289           0 :         long nShadowY = (long) ( pShadow->GetWidth() * nScaleY );
    1290           0 :         switch (pShadow->GetLocation())
    1291             :         {
    1292             :             case SVX_SHADOW_TOPLEFT:
    1293             :                 pDev->DrawRect( Rectangle(
    1294           0 :                         aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
    1295           0 :                         aFrameRect.Right()-nShadowX, aFrameRect.Top() ) );
    1296             :                 pDev->DrawRect( Rectangle(
    1297           0 :                         aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
    1298           0 :                         aFrameRect.Left(), aFrameRect.Bottom()-nShadowY ) );
    1299           0 :                 break;
    1300             :             case SVX_SHADOW_TOPRIGHT:
    1301             :                 pDev->DrawRect( Rectangle(
    1302           0 :                         aFrameRect.Left()+nShadowX, aFrameRect.Top()-nShadowY,
    1303           0 :                         aFrameRect.Right()+nShadowX, aFrameRect.Top() ) );
    1304             :                 pDev->DrawRect( Rectangle(
    1305           0 :                         aFrameRect.Right(), aFrameRect.Top()-nShadowY,
    1306           0 :                         aFrameRect.Right()+nShadowX, aFrameRect.Bottom()-nShadowY ) );
    1307           0 :                 break;
    1308             :             case SVX_SHADOW_BOTTOMLEFT:
    1309             :                 pDev->DrawRect( Rectangle(
    1310           0 :                         aFrameRect.Left()-nShadowX, aFrameRect.Bottom(),
    1311           0 :                         aFrameRect.Right()-nShadowX, aFrameRect.Bottom()+nShadowY ) );
    1312             :                 pDev->DrawRect( Rectangle(
    1313           0 :                         aFrameRect.Left()-nShadowX, aFrameRect.Top()+nShadowY,
    1314           0 :                         aFrameRect.Left(), aFrameRect.Bottom()+nShadowY ) );
    1315           0 :                 break;
    1316             :             case SVX_SHADOW_BOTTOMRIGHT:
    1317             :                 pDev->DrawRect( Rectangle(
    1318           0 :                         aFrameRect.Left()+nShadowX, aFrameRect.Bottom(),
    1319           0 :                         aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
    1320             :                 pDev->DrawRect( Rectangle(
    1321           0 :                         aFrameRect.Right(), aFrameRect.Top()+nShadowY,
    1322           0 :                         aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
    1323           0 :                 break;
    1324             :             default:
    1325             :             {
    1326             :                 // added to avoid warnings
    1327             :             }
    1328             :         }
    1329             :     }
    1330             : 
    1331         198 :     if (pBorderData)
    1332             :     {
    1333           0 :         boost::scoped_ptr<ScDocument> pBorderDoc(new ScDocument( SCDOCMODE_UNDO ));
    1334           0 :         pBorderDoc->InitUndo( pDoc, 0,0, true,true );
    1335           0 :         if (pBorderData)
    1336           0 :             pBorderDoc->ApplyAttr( 0,0,0, *pBorderData );
    1337             : 
    1338           0 :         ScTableInfo aTabInfo;
    1339             :         pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0,
    1340           0 :                                             nScaleX, nScaleY, false, false );
    1341             :         OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0");
    1342             : 
    1343           0 :         aTabInfo.mpRowInfo[1].nHeight = (sal_uInt16) nEffHeight;
    1344           0 :         aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth =
    1345           0 :             aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = (sal_uInt16) nEffWidth;
    1346             : 
    1347             :         ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc.get(), 0,
    1348           0 :                                     nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY );
    1349           0 :         aOutputData.SetUseStyleColor( bUseStyleColor );
    1350             : 
    1351           0 :         if (pBorderData)
    1352           0 :             aOutputData.DrawFrame();
    1353             :     }
    1354             : }
    1355             : 
    1356          12 : void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY )
    1357             : {
    1358          12 :     bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
    1359          12 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    1360             : 
    1361          12 :     Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    1362          12 :     long nOneX = aOnePixel.Width();
    1363          12 :     long nOneY = aOnePixel.Height();
    1364             :     SCCOL nCol;
    1365             : 
    1366          12 :     long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
    1367          12 :     long nEndY = nScrY + nHeight - nOneY;
    1368             : 
    1369          12 :     long nPosX = nScrX;
    1370          12 :     if ( bLayoutRTL )
    1371             :     {
    1372           0 :         for (nCol=nX1; nCol<=nX2; nCol++)
    1373           0 :             nPosX += (long)( pDoc->GetColWidth( nCol, nPrintTab ) * nScaleX );
    1374             :     }
    1375             :     else
    1376          12 :         nPosX -= nOneX;
    1377          12 :     long nPosY = nScrY - nOneY;
    1378          12 :     OUString aText;
    1379             : 
    1380          24 :     for (nCol=nX1; nCol<=nX2; nCol++)
    1381             :     {
    1382          12 :         sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
    1383          12 :         if (nDocW)
    1384             :         {
    1385          12 :             long nWidth = (long) (nDocW * nScaleX);
    1386          12 :             long nEndX = nPosX + nWidth * nLayoutSign;
    1387             : 
    1388          12 :             pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
    1389             : 
    1390          12 :             aText = ::ScColToAlpha( nCol);
    1391          12 :             long nTextWidth = pDev->GetTextWidth(aText);
    1392          12 :             long nTextHeight = pDev->GetTextHeight();
    1393          12 :             long nAddX = ( nWidth  - nTextWidth  ) / 2;
    1394          12 :             long nAddY = ( nHeight - nTextHeight ) / 2;
    1395          12 :             long nTextPosX = nPosX+nAddX;
    1396          12 :             if ( bLayoutRTL )
    1397           0 :                 nTextPosX -= nWidth;
    1398          12 :             pDev->DrawText( Point( nTextPosX,nPosY+nAddY ), aText );
    1399             : 
    1400          12 :             nPosX = nEndX;
    1401             :         }
    1402          12 :     }
    1403          12 : }
    1404             : 
    1405          12 : void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY )
    1406             : {
    1407          12 :     Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    1408          12 :     long nOneX = aOnePixel.Width();
    1409          12 :     long nOneY = aOnePixel.Height();
    1410             : 
    1411          12 :     bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
    1412             : 
    1413          12 :     long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
    1414          12 :     long nEndX = nScrX + nWidth;
    1415          12 :     long nPosX = nScrX;
    1416          12 :     if ( !bLayoutRTL )
    1417             :     {
    1418          12 :         nEndX -= nOneX;
    1419          12 :         nPosX -= nOneX;
    1420             :     }
    1421          12 :     long nPosY = nScrY - nOneY;
    1422          12 :     OUString aText;
    1423             : 
    1424          24 :     for (SCROW nRow=nY1; nRow<=nY2; nRow++)
    1425             :     {
    1426          12 :         sal_uInt16 nDocH = pDoc->GetRowHeight( nRow, nPrintTab );
    1427          12 :         if (nDocH)
    1428             :         {
    1429          12 :             long nHeight = (long) (nDocH * nScaleY);
    1430          12 :             long nEndY = nPosY + nHeight;
    1431             : 
    1432          12 :             pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
    1433             : 
    1434          12 :             aText = OUString::number( nRow+1 );
    1435          12 :             long nTextWidth = pDev->GetTextWidth(aText);
    1436          12 :             long nTextHeight = pDev->GetTextHeight();
    1437          12 :             long nAddX = ( nWidth  - nTextWidth  ) / 2;
    1438          12 :             long nAddY = ( nHeight - nTextHeight ) / 2;
    1439          12 :             pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText );
    1440             : 
    1441          12 :             nPosY = nEndY;
    1442             :         }
    1443          12 :     }
    1444          12 : }
    1445             : 
    1446           4 : void ScPrintFunc::LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
    1447             :                                 bool bRepCol, ScPreviewLocationData& rLocationData )
    1448             : {
    1449           4 :     Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    1450           4 :     long nOneX = aOnePixel.Width();
    1451           4 :     long nOneY = aOnePixel.Height();
    1452             : 
    1453           4 :     long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
    1454           4 :     long nEndY = nScrY + nHeight - nOneY;
    1455             : 
    1456           4 :     long nPosX = nScrX - nOneX;
    1457           8 :     for (SCCOL nCol=nX1; nCol<=nX2; nCol++)
    1458             :     {
    1459           4 :         sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
    1460           4 :         if (nDocW)
    1461           4 :             nPosX += (long) (nDocW * nScaleX);
    1462             :     }
    1463           4 :     Rectangle aCellRect( nScrX, nScrY, nPosX, nEndY );
    1464           4 :     rLocationData.AddColHeaders( aCellRect, nX1, nX2, bRepCol );
    1465           4 : }
    1466             : 
    1467           4 : void ScPrintFunc::LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
    1468             :                                 bool bRepRow, ScPreviewLocationData& rLocationData )
    1469             : {
    1470           4 :     Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    1471           4 :     long nOneX = aOnePixel.Width();
    1472           4 :     long nOneY = aOnePixel.Height();
    1473             : 
    1474           4 :     bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
    1475             : 
    1476           4 :     long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
    1477           4 :     long nEndX = nScrX + nWidth;
    1478           4 :     if ( !bLayoutRTL )
    1479           4 :         nEndX -= nOneX;
    1480             : 
    1481           4 :     long nPosY = nScrY - nOneY;
    1482           4 :     nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
    1483           4 :     Rectangle aCellRect( nScrX, nScrY, nEndX, nPosY );
    1484           4 :     rLocationData.AddRowHeaders( aCellRect, nY1, nY2, bRepRow );
    1485           4 : }
    1486             : 
    1487          42 : void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
    1488             :                                 long nScrX, long nScrY, bool bRepCol, bool bRepRow,
    1489             :                                 ScPreviewLocationData& rLocationData )
    1490             : {
    1491             :     //  get MapMode for drawing objects (same MapMode as in ScOutputData::PrintDrawingLayer)
    1492             : 
    1493          42 :     Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
    1494          42 :     long nLogStX = aLogPos.X();
    1495          42 :     long nLogStY = aLogPos.Y();
    1496             : 
    1497             :     SCCOL nCol;
    1498          42 :     Point aTwipOffset;
    1499          42 :     for (nCol=0; nCol<nX1; nCol++)
    1500           0 :         aTwipOffset.X() -= pDoc->GetColWidth( nCol, nPrintTab );
    1501          42 :     aTwipOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab );
    1502             : 
    1503          42 :     Point aMMOffset( aTwipOffset );
    1504          42 :     aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
    1505          42 :     aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
    1506          42 :     aMMOffset += Point( nLogStX, nLogStY );
    1507          42 :     MapMode aDrawMapMode( MAP_100TH_MM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() );
    1508             : 
    1509             :     //  get pixel rectangle
    1510             : 
    1511          42 :     Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    1512          42 :     long nOneX = aOnePixel.Width();
    1513          42 :     long nOneY = aOnePixel.Height();
    1514             : 
    1515          42 :     long nPosX = nScrX - nOneX;
    1516          94 :     for (nCol=nX1; nCol<=nX2; nCol++)
    1517             :     {
    1518          52 :         sal_uInt16 nDocW = pDoc->GetColWidth( nCol, nPrintTab );
    1519          52 :         if (nDocW)
    1520          52 :             nPosX += (long) (nDocW * nScaleX);
    1521             :     }
    1522             : 
    1523          42 :     long nPosY = nScrY - nOneY;
    1524          42 :     nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
    1525          42 :     Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY );
    1526             :     rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ),
    1527          42 :                                 bRepCol, bRepRow, aDrawMapMode );
    1528          42 : }
    1529             : 
    1530          66 : void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
    1531             :                                 long nScrX, long nScrY,
    1532             :                                 bool bShLeft, bool bShTop, bool bShRight, bool bShBottom )
    1533             : {
    1534             :     // #i47547# nothing to do if the end of the print area is before the end of
    1535             :     // the repeat columns/rows (don't use negative size for ScOutputData)
    1536          66 :     if ( nX2 < nX1 || nY2 < nY1 )
    1537          66 :         return;
    1538             : 
    1539             :                             //!     hand over Flag at FillInfo  !!!!!
    1540          66 :     ScRange aERange;
    1541          66 :     bool bEmbed = pDoc->IsEmbedded();
    1542          66 :     if (bEmbed)
    1543             :     {
    1544           0 :         pDoc->GetEmbedded(aERange);
    1545           0 :         pDoc->ResetEmbedded();
    1546             :     }
    1547             : 
    1548          66 :     Point aPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
    1549          66 :     long nLogStX = aPos.X();
    1550          66 :     long nLogStY = aPos.Y();
    1551             : 
    1552             :                     //  Assemble data
    1553             : 
    1554          66 :     ScTableInfo aTabInfo;
    1555             :     pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab,
    1556          66 :                                         nScaleX, nScaleY, true, aTableParam.bFormulas );
    1557          66 :     lcl_HidePrint( aTabInfo, nX1, nX2 );
    1558             : 
    1559          66 :     if (bEmbed)
    1560           0 :         pDoc->SetEmbedded(aERange);
    1561             : 
    1562             :     ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nPrintTab,
    1563         132 :                                 nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
    1564             : 
    1565             :     // #114135#
    1566          66 :     aOutputData.SetDrawView( pDrawView );
    1567             : 
    1568             :     // test if all paint parts are hidden, then a paint is not necessary at all
    1569          66 :     const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
    1570          66 :     const bool bHideAllDrawingLayer( pDrawView && pDrawView->getHideOle() && pDrawView->getHideChart()
    1571          66 :             && pDrawView->getHideDraw() && pDrawView->getHideFormControl() );
    1572             : 
    1573          66 :     if(!bHideAllDrawingLayer)
    1574             :     {
    1575          66 :         pDev->SetMapMode(aLogicMode);
    1576             :         //  don's set Clipping here (Mapmode is being moved)
    1577             : 
    1578             :         // #i72502#
    1579          66 :         aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
    1580             :     }
    1581             : 
    1582          66 :     pDev->SetMapMode(aOffsetMode);
    1583             : 
    1584          66 :     aOutputData.SetShowFormulas( aTableParam.bFormulas );
    1585          66 :     aOutputData.SetShowNullValues( aTableParam.bNullVals );
    1586          66 :     aOutputData.SetUseStyleColor( bUseStyleColor );
    1587             : 
    1588          66 :     Color aGridColor( COL_BLACK );
    1589          66 :     if ( bUseStyleColor )
    1590          66 :         aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
    1591          66 :     aOutputData.SetGridColor( aGridColor );
    1592             : 
    1593          66 :     if ( !pPrinter )
    1594             :     {
    1595          66 :         OutputDevice* pRefDev = pDoc->GetPrinter();     // use the printer also for Preview
    1596          66 :         Fraction aPrintFrac( nZoom, 100 );              // without nManualZoom
    1597             :         //  MapMode, as it would arrive at the printer:
    1598          66 :         pRefDev->SetMapMode( MapMode( MAP_100TH_MM, Point(), aPrintFrac, aPrintFrac ) );
    1599             : 
    1600             :         //  when rendering (PDF), don't use printer as ref device, but printer's MapMode
    1601             :         //  has to be set anyway, as charts still use it (#106409#)
    1602          66 :         if ( !bIsRender )
    1603          66 :             aOutputData.SetRefDevice( pRefDev );
    1604             :     }
    1605             : 
    1606          66 :     if( aTableParam.bCellContent )
    1607          66 :         aOutputData.DrawBackground();
    1608             : 
    1609             :     pDev->SetClipRegion(vcl::Region(Rectangle(
    1610          66 :                 aPos, Size(aOutputData.GetScrW(), aOutputData.GetScrH()))));
    1611          66 :     pDev->SetClipRegion();
    1612             : 
    1613          66 :     if( aTableParam.bCellContent )
    1614             :     {
    1615          66 :         aOutputData.DrawExtraShadow( bShLeft, bShTop, bShRight, bShBottom );
    1616          66 :         aOutputData.DrawFrame();
    1617          66 :         aOutputData.DrawStrings();
    1618          66 :         aOutputData.DrawEdit(false);
    1619             :     }
    1620             : 
    1621          66 :     if (aTableParam.bGrid)
    1622           0 :         aOutputData.DrawGrid( true, false );    // no page breaks
    1623             : 
    1624          66 :     aOutputData.AddPDFNotes();      // has no effect if not rendering PDF with notes enabled
    1625             : 
    1626             :     // test if all paint parts are hidden, then a paint is not necessary at all
    1627          66 :     if(!bHideAllDrawingLayer)
    1628             :     {
    1629             :         // #i72502#
    1630          66 :         aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
    1631             :     }
    1632             : 
    1633             :     // #i72502#
    1634          66 :     aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
    1635         132 :     aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
    1636             : }
    1637             : 
    1638         108 : bool ScPrintFunc::IsMirror( long nPageNo )          // Mirror margins?
    1639             : {
    1640         108 :     SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
    1641         108 :     return ( eUsage == SVX_PAGE_MIRROR && (nPageNo & 1) );
    1642             : }
    1643             : 
    1644         216 : bool ScPrintFunc::IsLeft( long nPageNo )            // left foot notes?
    1645             : {
    1646         216 :     SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
    1647             :     bool bLeft;
    1648         216 :     if (eUsage == SVX_PAGE_LEFT)
    1649           0 :         bLeft = true;
    1650         216 :     else if (eUsage == SVX_PAGE_RIGHT)
    1651           0 :         bLeft = false;
    1652             :     else
    1653         216 :         bLeft = (nPageNo & 1) != 0;
    1654         216 :     return bLeft;
    1655             : }
    1656             : 
    1657         108 : void ScPrintFunc::MakeTableString()
    1658             : {
    1659         108 :     OUString aTmp;
    1660         108 :     pDoc->GetName(nPrintTab, aTmp);
    1661         108 :     aFieldData.aTabName = aTmp;
    1662         108 : }
    1663             : 
    1664        1644 : void ScPrintFunc::MakeEditEngine()
    1665             : {
    1666        1644 :     if (!pEditEngine)
    1667             :     {
    1668             :         //  can't use document's edit engine pool here,
    1669             :         //  because pool must have twips as default metric
    1670         692 :         pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), true );
    1671             : 
    1672         692 :         pEditEngine->EnableUndo(false);
    1673             :         //fdo#45869 we want text to be positioned as it would be for the the
    1674             :         //high dpi printed output, not as would be ideal for the 96dpi preview
    1675             :         //window itself
    1676         692 :         pEditEngine->SetRefDevice(pPrinter ? pPrinter : pDoc->GetRefDevice());
    1677             :         pEditEngine->SetWordDelimiters(
    1678         692 :                 ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
    1679         692 :         pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS );
    1680         692 :         pDoc->ApplyAsianEditSettings( *pEditEngine );
    1681         692 :         pEditEngine->EnableAutoColor( bUseStyleColor );
    1682             : 
    1683             :         //  Default-Set for alignment
    1684         692 :         pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
    1685             : 
    1686         692 :         const ScPatternAttr& rPattern = static_cast<const ScPatternAttr&>(pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN));
    1687         692 :         rPattern.FillEditItemSet( pEditDefaults );
    1688             :         //  FillEditItemSet adjusts font height to 1/100th mm,
    1689             :         //  but for header/footer twips is needed, as in the PatternAttr:
    1690         692 :         pEditDefaults->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
    1691         692 :         pEditDefaults->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
    1692         692 :         pEditDefaults->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
    1693             :         //  dont use font color, because background color is not used
    1694             :         //! there's no way to set the background for note pages
    1695         692 :         pEditDefaults->ClearItem( EE_CHAR_COLOR );
    1696         692 :         if (ScGlobal::IsSystemRTL())
    1697           0 :             pEditDefaults->Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
    1698             :     }
    1699             : 
    1700        1644 :     pEditEngine->SetData( aFieldData );     // Set page count etc.
    1701        1644 : }
    1702             : 
    1703             : //  nStartY = logic
    1704         216 : void ScPrintFunc::PrintHF( long nPageNo, bool bHeader, long nStartY,
    1705             :                             bool bDoPrint, ScPreviewLocationData* pLocationData )
    1706             : {
    1707         216 :     const ScPrintHFParam& rParam = bHeader ? aHdr : aFtr;
    1708             : 
    1709         216 :     pDev->SetMapMode( aTwipMode );          // Head-/Footlines in Twips
    1710             : 
    1711         216 :     bool bLeft = IsLeft(nPageNo) && !rParam.bShared;
    1712         216 :     const ScPageHFItem* pHFItem = bLeft ? rParam.pLeft : rParam.pRight;
    1713             : 
    1714         216 :     long nLineStartX = aPageRect.Left()  + rParam.nLeft;
    1715         216 :     long nLineEndX   = aPageRect.Right() - rParam.nRight;
    1716         216 :     long nLineWidth  = nLineEndX - nLineStartX + 1;
    1717             : 
    1718             :     //  Edit-Engine
    1719             : 
    1720         216 :     Point aStart( nLineStartX, nStartY );
    1721         216 :     Size aPaperSize( nLineWidth, rParam.nHeight-rParam.nDistance );
    1722         216 :     if ( rParam.pBorder )
    1723             :     {
    1724         216 :         long nLeft = lcl_LineTotal( rParam.pBorder->GetLeft() ) + rParam.pBorder->GetDistance(BOX_LINE_LEFT);
    1725         216 :         long nTop = lcl_LineTotal( rParam.pBorder->GetTop() ) + rParam.pBorder->GetDistance(BOX_LINE_TOP);
    1726         216 :         aStart.X() += nLeft;
    1727         216 :         aStart.Y() += nTop;
    1728         216 :         aPaperSize.Width() -= nLeft + lcl_LineTotal( rParam.pBorder->GetRight() ) + rParam.pBorder->GetDistance(BOX_LINE_RIGHT);
    1729         216 :         aPaperSize.Height() -= nTop + lcl_LineTotal( rParam.pBorder->GetBottom() ) + rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
    1730             :     }
    1731             : 
    1732         216 :     if ( rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE )
    1733             :     {
    1734           0 :         long nLeft  = rParam.pShadow->CalcShadowSpace(SHADOW_LEFT);
    1735           0 :         long nTop   = rParam.pShadow->CalcShadowSpace(SHADOW_TOP);
    1736           0 :         aStart.X() += nLeft;
    1737           0 :         aStart.Y() += nTop;
    1738           0 :         aPaperSize.Width() -= nLeft + rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT);
    1739           0 :         aPaperSize.Height() -= nTop + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
    1740             :     }
    1741             : 
    1742         216 :     aFieldData.nPageNo = nPageNo+aTableParam.nFirstPageNo;
    1743         216 :     MakeEditEngine();
    1744             : 
    1745         216 :     pEditEngine->SetPaperSize(aPaperSize);
    1746             : 
    1747             :     //  Frame / Background
    1748             : 
    1749         216 :     Point aBorderStart( nLineStartX, nStartY );
    1750         216 :     Size aBorderSize( nLineWidth, rParam.nHeight-rParam.nDistance );
    1751         216 :     if ( rParam.bDynamic )
    1752             :     {
    1753             :         //  adjust here again, for even/odd head-/footlines
    1754             :         //  and probably other breaks by variable (page number etc.)
    1755             : 
    1756         216 :         long nMaxHeight = 0;
    1757         216 :         nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetLeftArea() ) );
    1758         216 :         nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetCenterArea() ) );
    1759         216 :         nMaxHeight = std::max( nMaxHeight, TextHeight( pHFItem->GetRightArea() ) );
    1760         216 :         if (rParam.pBorder)
    1761         432 :             nMaxHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
    1762         432 :                           lcl_LineTotal( rParam.pBorder->GetBottom() ) +
    1763         432 :                                     rParam.pBorder->GetDistance(BOX_LINE_TOP) +
    1764         432 :                                     rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
    1765         216 :         if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
    1766           0 :             nMaxHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
    1767           0 :                           rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
    1768             : 
    1769         216 :         if (nMaxHeight < rParam.nManHeight-rParam.nDistance)
    1770         216 :             nMaxHeight = rParam.nManHeight-rParam.nDistance;        // configured Minimum
    1771             : 
    1772         216 :         aBorderSize.Height() = nMaxHeight;
    1773             :     }
    1774             : 
    1775         216 :     if ( bDoPrint )
    1776             :     {
    1777         132 :         double nOldScaleX = nScaleX;
    1778         132 :         double nOldScaleY = nScaleY;
    1779         132 :         nScaleX = nScaleY = 1.0;            // output directly in Twips
    1780         528 :         DrawBorder( aBorderStart.X(), aBorderStart.Y(), aBorderSize.Width(), aBorderSize.Height(),
    1781         660 :                         rParam.pBorder, rParam.pBack, rParam.pShadow );
    1782         132 :         nScaleX = nOldScaleX;
    1783         132 :         nScaleY = nOldScaleY;
    1784             : 
    1785             :         //  Clipping for Text
    1786             : 
    1787         132 :         pDev->SetClipRegion(vcl::Region(Rectangle(aStart, aPaperSize)));
    1788             : 
    1789             :         //  left
    1790             : 
    1791         132 :         const EditTextObject* pObject = pHFItem->GetLeftArea();
    1792         132 :         if (pObject)
    1793             :         {
    1794         132 :             pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
    1795         132 :             pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
    1796         132 :             Point aDraw = aStart;
    1797         132 :             long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
    1798         132 :             if (nDif > 0)
    1799         132 :                 aDraw.Y() += nDif / 2;
    1800         132 :             pEditEngine->Draw( pDev, aDraw, 0 );
    1801             :         }
    1802             : 
    1803             :         //  center
    1804             : 
    1805         132 :         pObject = pHFItem->GetCenterArea();
    1806         132 :         if (pObject)
    1807             :         {
    1808         132 :             pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
    1809         132 :             pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
    1810         132 :             Point aDraw = aStart;
    1811         132 :             long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
    1812         132 :             if (nDif > 0)
    1813         132 :                 aDraw.Y() += nDif / 2;
    1814         132 :             pEditEngine->Draw( pDev, aDraw, 0 );
    1815             :         }
    1816             : 
    1817             :         //  right
    1818             : 
    1819         132 :         pObject = pHFItem->GetRightArea();
    1820         132 :         if (pObject)
    1821             :         {
    1822         132 :             pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
    1823         132 :             pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, false );
    1824         132 :             Point aDraw = aStart;
    1825         132 :             long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
    1826         132 :             if (nDif > 0)
    1827         132 :                 aDraw.Y() += nDif / 2;
    1828         132 :             pEditEngine->Draw( pDev, aDraw, 0 );
    1829             :         }
    1830             : 
    1831         132 :         pDev->SetClipRegion();
    1832             :     }
    1833             : 
    1834         216 :     if ( pLocationData )
    1835             :     {
    1836          84 :         Rectangle aHeaderRect( aBorderStart, aBorderSize );
    1837          84 :         pLocationData->AddHeaderFooter( aHeaderRect, bHeader, bLeft );
    1838             :     }
    1839         216 : }
    1840             : 
    1841           0 : long ScPrintFunc::DoNotes( long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData )
    1842             : {
    1843           0 :     if (bDoPrint)
    1844           0 :         pDev->SetMapMode(aTwipMode);
    1845             : 
    1846           0 :     MakeEditEngine();
    1847           0 :     pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
    1848           0 :     pEditEngine->SetDefaults( *pEditDefaults );
    1849             : 
    1850           0 :     vcl::Font aMarkFont;
    1851           0 :     ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
    1852           0 :     static_cast<const ScPatternAttr&>(pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont( aMarkFont, eColorMode );
    1853           0 :     pDev->SetFont( aMarkFont );
    1854           0 :     long nMarkLen = pDev->GetTextWidth(OUString("GW99999:"));
    1855             :     // without Space-Char, because it rarle arrives there
    1856             : 
    1857           0 :     Size aDataSize = aPageRect.GetSize();
    1858           0 :     if ( nMarkLen > aDataSize.Width() / 2 )     // everything much too small?
    1859           0 :         nMarkLen = aDataSize.Width() / 2;       // split the page appropriately
    1860           0 :     aDataSize.Width() -= nMarkLen;
    1861             : 
    1862           0 :     pEditEngine->SetPaperSize( aDataSize );
    1863           0 :     long nPosX = aPageRect.Left() + nMarkLen;
    1864           0 :     long nPosY = aPageRect.Top();
    1865             : 
    1866           0 :     long nCount = 0;
    1867           0 :     long nSize = aNotePosList.size();
    1868             :     bool bOk;
    1869           0 :     do
    1870             :     {
    1871           0 :         bOk = false;
    1872           0 :         if ( nNoteStart + nCount < nSize)
    1873             :         {
    1874           0 :             ScAddress &rPos = aNotePosList[ nNoteStart + nCount ];
    1875             : 
    1876           0 :             if( const ScPostIt* pNote = pDoc->GetNote( rPos ) )
    1877             :             {
    1878           0 :                 if(const EditTextObject *pEditText = pNote->GetEditTextObject())
    1879           0 :                     pEditEngine->SetText(*pEditText);
    1880           0 :                 long nTextHeight = pEditEngine->GetTextHeight();
    1881           0 :                 if ( nPosY + nTextHeight < aPageRect.Bottom() )
    1882             :                 {
    1883           0 :                     if (bDoPrint)
    1884             :                     {
    1885           0 :                         pEditEngine->Draw( pDev, Point( nPosX, nPosY ), 0 );
    1886             : 
    1887           0 :                         OUString aMarkStr(rPos.Format(SCA_VALID, pDoc, pDoc->GetAddressConvention()));
    1888           0 :                         aMarkStr += ":";
    1889             : 
    1890             :                         //  cell position also via EditEngine, for correct positioning
    1891           0 :                         pEditEngine->SetText(aMarkStr);
    1892           0 :                         pEditEngine->Draw( pDev, Point( aPageRect.Left(), nPosY ), 0 );
    1893             :                     }
    1894             : 
    1895           0 :                     if ( pLocationData )
    1896             :                     {
    1897           0 :                         Rectangle aTextRect( Point( nPosX, nPosY ), Size( aDataSize.Width(), nTextHeight ) );
    1898           0 :                         pLocationData->AddNoteText( aTextRect, rPos );
    1899           0 :                         Rectangle aMarkRect( Point( aPageRect.Left(), nPosY ), Size( nMarkLen, nTextHeight ) );
    1900           0 :                         pLocationData->AddNoteMark( aMarkRect, rPos );
    1901             :                     }
    1902             : 
    1903           0 :                     nPosY += nTextHeight;
    1904           0 :                     nPosY += 200;                   // Distance
    1905           0 :                     ++nCount;
    1906           0 :                     bOk = true;
    1907             :                 }
    1908             :             }
    1909             :         }
    1910             :     }
    1911             :     while (bOk);
    1912             : 
    1913           0 :     return nCount;
    1914             : }
    1915             : 
    1916         128 : long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData )
    1917             : {
    1918         128 :     if ( nNoteStart >= (long) aNotePosList.size() || !aTableParam.bNotes )
    1919         128 :         return 0;
    1920             : 
    1921           0 :     if ( bDoPrint && bClearWin )
    1922             :     {
    1923             :         //!  aggregate PrintPage !!!
    1924             : 
    1925           0 :         Color aBackgroundColor( COL_WHITE );
    1926           0 :         if ( bUseStyleColor )
    1927           0 :             aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
    1928             : 
    1929           0 :         pDev->SetMapMode(aOffsetMode);
    1930           0 :         pDev->SetLineColor();
    1931           0 :         pDev->SetFillColor(aBackgroundColor);
    1932             :         pDev->DrawRect(Rectangle(Point(),
    1933           0 :                 Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
    1934           0 :                      (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
    1935             :     }
    1936             : 
    1937             :     //      adjust aPageRect for left/right page
    1938             : 
    1939           0 :     Rectangle aTempRect = Rectangle( Point(), aPageSize );
    1940           0 :     if (IsMirror(nPageNo))
    1941             :     {
    1942           0 :         aPageRect.Left()  = ( aTempRect.Left()  + nRightMargin ) * 100 / nZoom;
    1943           0 :         aPageRect.Right() = ( aTempRect.Right() - nLeftMargin  ) * 100 / nZoom;
    1944             :     }
    1945             :     else
    1946             :     {
    1947           0 :         aPageRect.Left()  = ( aTempRect.Left()  + nLeftMargin  ) * 100 / nZoom;
    1948           0 :         aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
    1949             :     }
    1950             : 
    1951           0 :     if ( pPrinter && bDoPrint )
    1952             :     {
    1953             :         OSL_FAIL( "StartPage does not exist anymore" );
    1954             :     }
    1955             : 
    1956           0 :     if ( bDoPrint || pLocationData )
    1957             :     {
    1958             :         //  Head and foot lines
    1959             : 
    1960           0 :         if (aHdr.bEnable)
    1961             :         {
    1962           0 :             long nHeaderY = aPageRect.Top()-aHdr.nHeight;
    1963           0 :             PrintHF( nPageNo, true, nHeaderY, bDoPrint, pLocationData );
    1964             :         }
    1965           0 :         if (aFtr.bEnable)
    1966             :         {
    1967           0 :             long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
    1968           0 :             PrintHF( nPageNo, false, nFooterY, bDoPrint, pLocationData );
    1969             :         }
    1970             :     }
    1971             : 
    1972           0 :     long nCount = DoNotes( nNoteStart, bDoPrint, pLocationData );
    1973             : 
    1974           0 :     if ( pPrinter && bDoPrint )
    1975             :     {
    1976             :         OSL_FAIL( "EndPage does not exist anymore" );
    1977             :     }
    1978             : 
    1979           0 :     return nCount;
    1980             : }
    1981             : 
    1982         108 : void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
    1983             :                                 bool bDoPrint, ScPreviewLocationData* pLocationData )
    1984             : {
    1985         108 :     bool bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
    1986         108 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    1987             : 
    1988             :     //  nPageNo is the page number within all sheets of one "start page" setting
    1989             : 
    1990         108 :     if ( bClearWin && bDoPrint )
    1991             :     {
    1992             :         //  must exactly fit to painting the frame in preview.cxx !!!
    1993             : 
    1994          66 :         Color aBackgroundColor( COL_WHITE );
    1995          66 :         if ( bUseStyleColor )
    1996          66 :             aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
    1997             : 
    1998          66 :         pDev->SetMapMode(aOffsetMode);
    1999          66 :         pDev->SetLineColor();
    2000          66 :         pDev->SetFillColor(aBackgroundColor);
    2001             :         pDev->DrawRect(Rectangle(Point(),
    2002          66 :                 Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
    2003         132 :                      (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
    2004             :     }
    2005             : 
    2006             :     //      adjust aPageRect for left/right page
    2007             : 
    2008         108 :     Rectangle aTempRect = Rectangle( Point(), aPageSize );
    2009         108 :     if (IsMirror(nPageNo))
    2010             :     {
    2011           0 :         aPageRect.Left()  = ( aTempRect.Left()  + nRightMargin ) * 100 / nZoom;
    2012           0 :         aPageRect.Right() = ( aTempRect.Right() - nLeftMargin  ) * 100 / nZoom;
    2013             :     }
    2014             :     else
    2015             :     {
    2016         108 :         aPageRect.Left()  = ( aTempRect.Left()  + nLeftMargin  ) * 100 / nZoom;
    2017         108 :         aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
    2018             :     }
    2019             : 
    2020         108 :     if ( aAreaParam.bRepeatCol )
    2021           0 :         if ( nX1 > nRepeatStartCol && nX1 <= nRepeatEndCol )
    2022           0 :             nX1 = nRepeatEndCol + 1;
    2023         108 :     bool bDoRepCol = (aAreaParam.bRepeatCol && nX1 > nRepeatEndCol);
    2024         108 :     if ( aAreaParam.bRepeatRow )
    2025           0 :         if ( nY1 > nRepeatStartRow && nY1 <= nRepeatEndRow )
    2026           0 :             nY1 = nRepeatEndRow + 1;
    2027         108 :     bool bDoRepRow = (aAreaParam.bRepeatRow && nY1 > nRepeatEndRow);
    2028             : 
    2029             :     // use new object hide flags in SdrPaintView
    2030         108 :     if(pDrawView)
    2031             :     {
    2032         108 :         pDrawView->setHideOle(!aTableParam.bObjects);
    2033         108 :         pDrawView->setHideChart(!aTableParam.bCharts);
    2034         108 :         pDrawView->setHideDraw(!aTableParam.bDrawings);
    2035         108 :         pDrawView->setHideFormControl(!aTableParam.bDrawings);
    2036             :     }
    2037             : 
    2038         108 :     if ( pPrinter && bDoPrint )
    2039             :     {
    2040             :         OSL_FAIL( "StartPage does not exist anymore" );
    2041             :     }
    2042             : 
    2043             :     //  head and foot lines (without centering)
    2044             : 
    2045         108 :     if (aHdr.bEnable)
    2046             :     {
    2047         108 :         long nHeaderY = aPageRect.Top()-aHdr.nHeight;
    2048         108 :         PrintHF( nPageNo, true, nHeaderY, bDoPrint, pLocationData );
    2049             :     }
    2050         108 :     if (aFtr.bEnable)
    2051             :     {
    2052         108 :         long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
    2053         108 :         PrintHF( nPageNo, false, nFooterY, bDoPrint, pLocationData );
    2054             :     }
    2055             : 
    2056             :     //  Position ( margins / centering )
    2057             : 
    2058         108 :     long nLeftSpace = aPageRect.Left();     // Document-Twips
    2059         108 :     long nTopSpace  = aPageRect.Top();
    2060         108 :     if ( bCenterHor || bLayoutRTL )
    2061             :     {
    2062           0 :         long nDataWidth = 0;
    2063             :         SCCOL i;
    2064           0 :         for (i=nX1; i<=nX2; i++)
    2065           0 :             nDataWidth += pDoc->GetColWidth( i,nPrintTab );
    2066           0 :         if (bDoRepCol)
    2067           0 :             for (i=nRepeatStartCol; i<=nRepeatEndCol; i++)
    2068           0 :                 nDataWidth += pDoc->GetColWidth( i,nPrintTab );
    2069           0 :         if (aTableParam.bHeaders)
    2070           0 :             nDataWidth += (long) PRINT_HEADER_WIDTH;
    2071           0 :         if (pBorderItem)
    2072           0 :             nDataWidth += pBorderItem->GetDistance(BOX_LINE_LEFT) +
    2073           0 :                            pBorderItem->GetDistance(BOX_LINE_RIGHT);        //! Line width?
    2074           0 :         if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
    2075           0 :             nDataWidth += pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
    2076           0 :                            pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
    2077           0 :         if ( bCenterHor )
    2078             :         {
    2079           0 :             nLeftSpace += ( aPageRect.GetWidth() - nDataWidth ) / 2;        // LTR or RTL
    2080           0 :             if (pBorderItem)
    2081           0 :                 nLeftSpace -= lcl_LineTotal(pBorderItem->GetLeft());
    2082             :         }
    2083           0 :         else if ( bLayoutRTL )
    2084           0 :             nLeftSpace += aPageRect.GetWidth() - nDataWidth;                // align to the right edge of the page
    2085             :     }
    2086         108 :     if ( bCenterVer )
    2087             :     {
    2088           0 :         long nDataHeight = pDoc->GetRowHeight( nY1, nY2, nPrintTab);
    2089           0 :         if (bDoRepRow)
    2090             :             nDataHeight += pDoc->GetRowHeight( nRepeatStartRow,
    2091           0 :                     nRepeatEndRow, nPrintTab);
    2092           0 :         if (aTableParam.bHeaders)
    2093           0 :             nDataHeight += (long) PRINT_HEADER_HEIGHT;
    2094           0 :         if (pBorderItem)
    2095           0 :             nDataHeight += pBorderItem->GetDistance(BOX_LINE_TOP) +
    2096           0 :                            pBorderItem->GetDistance(BOX_LINE_BOTTOM);       //! Line width?
    2097           0 :         if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
    2098           0 :             nDataHeight += pShadowItem->CalcShadowSpace(SHADOW_TOP) +
    2099           0 :                            pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
    2100           0 :         nTopSpace += ( aPageRect.GetHeight() - nDataHeight ) / 2;
    2101           0 :         if (pBorderItem)
    2102           0 :             nTopSpace -= lcl_LineTotal(pBorderItem->GetTop());
    2103             :     }
    2104             : 
    2105             :     //  calculate sizes of the elements for partitioning
    2106             :     //  (header, repeat, data)
    2107             : 
    2108         108 :     long nHeaderWidth   = 0;
    2109         108 :     long nHeaderHeight  = 0;
    2110         108 :     long nRepeatWidth   = 0;
    2111         108 :     long nRepeatHeight  = 0;
    2112         108 :     long nContentWidth  = 0;        // scaled - not the same as nDataWidth above
    2113         108 :     long nContentHeight = 0;
    2114         108 :     if (aTableParam.bHeaders)
    2115             :     {
    2116          16 :         nHeaderWidth  = (long) (PRINT_HEADER_WIDTH * nScaleX);
    2117          16 :         nHeaderHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
    2118             :     }
    2119         108 :     if (bDoRepCol)
    2120           0 :         for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++)
    2121           0 :             nRepeatWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
    2122         108 :     if (bDoRepRow)
    2123             :         nRepeatHeight += pDoc->GetScaledRowHeight( nRepeatStartRow,
    2124           0 :                 nRepeatEndRow, nPrintTab, nScaleY);
    2125         236 :     for (SCCOL i=nX1; i<=nX2; i++)
    2126         128 :         nContentWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
    2127             :     nContentHeight += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab,
    2128         108 :             nScaleY);
    2129             : 
    2130             :     //  partition the page
    2131             : 
    2132         108 :     long nStartX = ((long) ( nLeftSpace * nScaleX ));
    2133         108 :     long nStartY = ((long) ( nTopSpace  * nScaleY ));
    2134         108 :     long nInnerStartX = nStartX;
    2135         108 :     long nInnerStartY = nStartY;
    2136         108 :     if (pBorderItem)
    2137             :     {
    2138         216 :         nInnerStartX += (long) ( ( lcl_LineTotal(pBorderItem->GetLeft()) +
    2139         216 :                                     pBorderItem->GetDistance(BOX_LINE_LEFT) ) * nScaleX );
    2140         216 :         nInnerStartY += (long) ( ( lcl_LineTotal(pBorderItem->GetTop()) +
    2141         216 :                                     pBorderItem->GetDistance(BOX_LINE_TOP) ) * nScaleY );
    2142             :     }
    2143         108 :     if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
    2144             :     {
    2145           0 :         nInnerStartX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_LEFT) * nScaleX );
    2146           0 :         nInnerStartY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_TOP) * nScaleY );
    2147             :     }
    2148             : 
    2149         108 :     if ( bLayoutRTL )
    2150             :     {
    2151             :         //  arrange elements starting from the right edge
    2152           0 :         nInnerStartX += nHeaderWidth + nRepeatWidth + nContentWidth;
    2153             : 
    2154             :         //  make rounding easier so the elements are really next to each other in preview
    2155           0 :         Size aOffsetOnePixel = pDev->PixelToLogic( Size(1,1), aOffsetMode );
    2156           0 :         long nOffsetOneX = aOffsetOnePixel.Width();
    2157           0 :         nInnerStartX += nOffsetOneX / 2;
    2158             :     }
    2159             : 
    2160         108 :     long nFrameStartX = nInnerStartX;
    2161         108 :     long nFrameStartY = nInnerStartY;
    2162             : 
    2163         108 :     long nRepStartX = nInnerStartX + nHeaderWidth * nLayoutSign;    // widths/heights are 0 if not used
    2164         108 :     long nRepStartY = nInnerStartY + nHeaderHeight;
    2165         108 :     long nDataX = nRepStartX + nRepeatWidth * nLayoutSign;
    2166         108 :     long nDataY = nRepStartY + nRepeatHeight;
    2167         108 :     long nEndX = nDataX + nContentWidth * nLayoutSign;
    2168         108 :     long nEndY = nDataY + nContentHeight;
    2169         108 :     long nFrameEndX = nEndX;
    2170         108 :     long nFrameEndY = nEndY;
    2171             : 
    2172         108 :     if ( bLayoutRTL )
    2173             :     {
    2174             :         //  each element's start position is its left edge
    2175             :         //! subtract one pixel less?
    2176           0 :         nInnerStartX -= nHeaderWidth;       // used for header
    2177           0 :         nRepStartX   -= nRepeatWidth;
    2178           0 :         nDataX       -= nContentWidth;
    2179             : 
    2180             :         //  continue right of the main elements again
    2181           0 :         nEndX += nHeaderWidth + nRepeatWidth + nContentWidth;
    2182             :     }
    2183             : 
    2184             :     //  Page frame / background
    2185             : 
    2186             :     //! adjust nEndX/Y
    2187             : 
    2188         108 :     long nBorderEndX = nEndX;
    2189         108 :     long nBorderEndY = nEndY;
    2190         108 :     if (pBorderItem)
    2191             :     {
    2192         216 :         nBorderEndX += (long) ( ( lcl_LineTotal(pBorderItem->GetRight()) +
    2193         216 :                                     pBorderItem->GetDistance(BOX_LINE_RIGHT) ) * nScaleX );
    2194         216 :         nBorderEndY += (long) ( ( lcl_LineTotal(pBorderItem->GetBottom()) +
    2195         216 :                                     pBorderItem->GetDistance(BOX_LINE_BOTTOM) ) * nScaleY );
    2196             :     }
    2197         108 :     if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
    2198             :     {
    2199           0 :         nBorderEndX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_RIGHT) * nScaleX );
    2200           0 :         nBorderEndY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY );
    2201             :     }
    2202             : 
    2203         108 :     if ( bDoPrint )
    2204             :     {
    2205          66 :         pDev->SetMapMode( aOffsetMode );
    2206             :         DrawBorder( nStartX, nStartY, nBorderEndX-nStartX, nBorderEndY-nStartY,
    2207          66 :                         pBorderItem, pBackgroundItem, pShadowItem );
    2208             : 
    2209          66 :         pDev->SetMapMode( aTwipMode );
    2210             :     }
    2211             : 
    2212         108 :     pDev->SetMapMode( aOffsetMode );
    2213             : 
    2214             :     //  Output repeating rows/columns
    2215             : 
    2216         108 :     if (bDoRepCol && bDoRepRow)
    2217             :     {
    2218           0 :         if ( bDoPrint )
    2219             :             PrintArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
    2220           0 :                             nRepStartX,nRepStartY, true, true, false, false );
    2221           0 :         if ( pLocationData )
    2222             :             LocateArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
    2223           0 :                             nRepStartX,nRepStartY, true, true, *pLocationData );
    2224             :     }
    2225         108 :     if (bDoRepCol)
    2226             :     {
    2227           0 :         if ( bDoPrint )
    2228             :             PrintArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY,
    2229           0 :                         true, !bDoRepRow, false, true );
    2230           0 :         if ( pLocationData )
    2231           0 :             LocateArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY, true, false, *pLocationData );
    2232             :     }
    2233         108 :     if (bDoRepRow)
    2234             :     {
    2235           0 :         if ( bDoPrint )
    2236             :             PrintArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY,
    2237           0 :                         !bDoRepCol, true, true, false );
    2238           0 :         if ( pLocationData )
    2239           0 :             LocateArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY, false, true, *pLocationData );
    2240             :     }
    2241             : 
    2242             :     //  output data
    2243             : 
    2244         108 :     if ( bDoPrint )
    2245          66 :         PrintArea( nX1,nY1, nX2,nY2, nDataX,nDataY, !bDoRepCol,!bDoRepRow, true, true );
    2246         108 :     if ( pLocationData )
    2247          42 :         LocateArea( nX1,nY1, nX2,nY2, nDataX,nDataY, false,false, *pLocationData );
    2248             : 
    2249             :     //  output column/row headers
    2250             :     //  after data (throug probably shadow)
    2251             : 
    2252         108 :     Color aGridColor( COL_BLACK );
    2253         108 :     if ( bUseStyleColor )
    2254         108 :         aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
    2255             : 
    2256         108 :     if (aTableParam.bHeaders)
    2257             :     {
    2258          16 :         if ( bDoPrint )
    2259             :         {
    2260          12 :             pDev->SetLineColor( aGridColor );
    2261          12 :             pDev->SetFillColor();
    2262          12 :             pDev->SetMapMode(aOffsetMode);
    2263             :         }
    2264             : 
    2265          16 :         ScPatternAttr aPattern( pDoc->GetPool() );
    2266          32 :         vcl::Font aFont;
    2267          16 :         ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
    2268          16 :         aPattern.GetFont( aFont, eColorMode, pDev );
    2269          16 :         pDev->SetFont( aFont );
    2270             : 
    2271          16 :         if (bDoRepCol)
    2272             :         {
    2273           0 :             if ( bDoPrint )
    2274           0 :                 PrintColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY );
    2275           0 :             if ( pLocationData )
    2276           0 :                 LocateColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY, true, *pLocationData );
    2277             :         }
    2278          16 :         if ( bDoPrint )
    2279          12 :             PrintColHdr( nX1,nX2, nDataX,nInnerStartY );
    2280          16 :         if ( pLocationData )
    2281           4 :             LocateColHdr( nX1,nX2, nDataX,nInnerStartY, false, *pLocationData );
    2282          16 :         if (bDoRepRow)
    2283             :         {
    2284           0 :             if ( bDoPrint )
    2285           0 :                 PrintRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY );
    2286           0 :             if ( pLocationData )
    2287           0 :                 LocateRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY, true, *pLocationData );
    2288             :         }
    2289          16 :         if ( bDoPrint )
    2290          12 :             PrintRowHdr( nY1,nY2, nInnerStartX,nDataY );
    2291          16 :         if ( pLocationData )
    2292          20 :             LocateRowHdr( nY1,nY2, nInnerStartX,nDataY, false, *pLocationData );
    2293             :     }
    2294             : 
    2295             :     //  simple frame
    2296             : 
    2297         108 :     if ( bDoPrint && ( aTableParam.bGrid || aTableParam.bHeaders ) )
    2298             :     {
    2299          12 :         Size aOnePixel = pDev->PixelToLogic(Size(1,1));
    2300          12 :         long nOneX = aOnePixel.Width();
    2301          12 :         long nOneY = aOnePixel.Height();
    2302             : 
    2303          12 :         long nLeftX   = nFrameStartX;
    2304          12 :         long nTopY    = nFrameStartY - nOneY;
    2305          12 :         long nRightX  = nFrameEndX;
    2306          12 :         long nBottomY = nFrameEndY - nOneY;
    2307          12 :         if ( !bLayoutRTL )
    2308             :         {
    2309          12 :             nLeftX   -= nOneX;
    2310          12 :             nRightX  -= nOneX;
    2311             :         }
    2312          12 :         pDev->SetMapMode(aOffsetMode);
    2313          12 :         pDev->SetLineColor( aGridColor );
    2314          12 :         pDev->SetFillColor();
    2315          12 :         pDev->DrawRect( Rectangle( nLeftX, nTopY, nRightX, nBottomY ) );
    2316             :         //  nEndX/Y without frame-adaption
    2317             :     }
    2318             : 
    2319         108 :     if ( pPrinter && bDoPrint )
    2320             :     {
    2321             :         OSL_FAIL( "EndPage does not exist anymore" );
    2322             :     }
    2323             : 
    2324         108 :     aLastSourceRange = ScRange( nX1, nY1, nPrintTab, nX2, nY2, nPrintTab );
    2325         108 :     bSourceRangeValid = true;
    2326         108 : }
    2327             : 
    2328         108 : void ScPrintFunc::SetOffset( const Point& rOfs )
    2329             : {
    2330         108 :     aSrcOffset = rOfs;
    2331         108 : }
    2332             : 
    2333         108 : void ScPrintFunc::SetManualZoom( sal_uInt16 nNewZoom )
    2334             : {
    2335         108 :     nManualZoom = nNewZoom;
    2336         108 : }
    2337             : 
    2338         108 : void ScPrintFunc::SetClearFlag( bool bFlag )
    2339             : {
    2340         108 :     bClearWin = bFlag;
    2341         108 : }
    2342             : 
    2343         108 : void ScPrintFunc::SetUseStyleColor( bool bFlag )
    2344             : {
    2345         108 :     bUseStyleColor = bFlag;
    2346         108 :     if (pEditEngine)
    2347         108 :         pEditEngine->EnableAutoColor( bUseStyleColor );
    2348         108 : }
    2349             : 
    2350           0 : void ScPrintFunc::SetRenderFlag( bool bFlag )
    2351             : {
    2352           0 :     bIsRender = bFlag;      // set when using XRenderable (PDF)
    2353           0 : }
    2354             : 
    2355           0 : void ScPrintFunc::SetExclusivelyDrawOleAndDrawObjects()
    2356             : {
    2357           0 :     aTableParam.bCellContent = false;
    2358           0 :     aTableParam.bNotes = false;
    2359           0 :     aTableParam.bGrid = false;
    2360           0 :     aTableParam.bHeaders = false;
    2361           0 :     aTableParam.bFormulas = false;
    2362           0 :     aTableParam.bNullVals = false;
    2363           0 : }
    2364             : 
    2365             : //  UpdatePages is only called from outside to set the breaks correctly for viewing
    2366             : //  - always without UserArea
    2367             : 
    2368         554 : bool ScPrintFunc::UpdatePages()
    2369             : {
    2370         554 :     if (!pParamSet)
    2371           0 :         return false;
    2372             : 
    2373             :     //  Zoom
    2374             : 
    2375         554 :     nZoom = 100;
    2376         554 :     if (aTableParam.bScalePageNum || aTableParam.bScaleTo)
    2377           0 :         nZoom = ZOOM_MIN;                       // correct for breaks
    2378         554 :     else if (aTableParam.bScaleAll)
    2379             :     {
    2380         554 :         nZoom = aTableParam.nScaleAll;
    2381         554 :         if ( nZoom <= ZOOM_MIN )
    2382           0 :             nZoom = ZOOM_MIN;
    2383             :     }
    2384             : 
    2385         554 :     OUString aName = pDoc->GetPageStyle( nPrintTab );
    2386         554 :     SCTAB nTabCount = pDoc->GetTableCount();
    2387        1130 :     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
    2388         576 :         if ( nTab==nPrintTab || pDoc->GetPageStyle(nTab)==aName )
    2389             :         {
    2390             :             //  Repeating rows/columns
    2391         568 :             pDoc->SetRepeatArea( nTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
    2392             : 
    2393             :             //  set breaks
    2394         568 :             ResetBreaks(nTab);
    2395         568 :             pDocShell->PostPaint(0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID);
    2396             :         }
    2397             : 
    2398         554 :     return true;
    2399             : }
    2400             : 
    2401         608 : long ScPrintFunc::CountPages()                          // sets also nPagesX, nPagesY
    2402             : {
    2403         608 :     bool bAreaOk = false;
    2404             : 
    2405         608 :     if (pDoc->HasTable( nPrintTab ))
    2406             :     {
    2407         608 :         if (aAreaParam.bPrintArea)                          // Specify print area?
    2408             :         {
    2409           4 :             if ( bPrintCurrentTable )
    2410             :             {
    2411           4 :                 ScRange& rRange = aAreaParam.aPrintArea;
    2412             : 
    2413             :                 //  Here, no comparison of the tables any more. Area is always valid for this table
    2414             :                 //  If comparison should be done here, the table of print ranges must be adjusted
    2415             :                 //  when inserting tables etc.!
    2416             : 
    2417           4 :                 nStartCol = rRange.aStart.Col();
    2418           4 :                 nStartRow = rRange.aStart.Row();
    2419           4 :                 nEndCol   = rRange.aEnd  .Col();
    2420           4 :                 nEndRow   = rRange.aEnd  .Row();
    2421           4 :                 bAreaOk   = AdjustPrintArea(false);         // limit
    2422             :             }
    2423             :             else
    2424           0 :                 bAreaOk = false;
    2425             :         }
    2426             :         else                                                // search from document
    2427         604 :             bAreaOk = AdjustPrintArea(true);
    2428             :     }
    2429             : 
    2430         608 :     if (bAreaOk)
    2431             :     {
    2432          64 :         long nPages = 0;
    2433             :         size_t nY;
    2434          64 :         if (bMultiArea)
    2435             :         {
    2436           0 :             sal_uInt16 nRCount = pDoc->GetPrintRangeCount( nPrintTab );
    2437           0 :             for (sal_uInt16 i=0; i<nRCount; i++)
    2438             :             {
    2439           0 :                 CalcZoom(i);
    2440           0 :                 if ( aTableParam.bSkipEmpty )
    2441           0 :                     for (nY=0; nY<nPagesY; nY++)
    2442             :                     {
    2443             :                         OSL_ENSURE(nY < maPageRows.size(), "vector access error for maPageRows (!)");
    2444           0 :                         nPages += maPageRows[nY].CountVisible();
    2445             :                     }
    2446             :                 else
    2447           0 :                     nPages += ((long) nPagesX) * nPagesY;
    2448           0 :                 if ( pPageData )
    2449           0 :                     FillPageData();
    2450             :             }
    2451             :         }
    2452             :         else
    2453             :         {
    2454          64 :             CalcZoom(RANGENO_NORANGE);                      // calculate Zoom
    2455          64 :             if ( aTableParam.bSkipEmpty )
    2456         104 :                 for (nY=0; nY<nPagesY; nY++)
    2457             :                 {
    2458             :                     OSL_ENSURE(nY < maPageRows.size(), "vector access error for maPageRows (!)");
    2459          52 :                     nPages += maPageRows[nY].CountVisible();
    2460             :                 }
    2461             :             else
    2462          12 :                 nPages += ((long) nPagesX) * nPagesY;
    2463          64 :             if ( pPageData )
    2464           2 :                 FillPageData();
    2465             :         }
    2466          64 :         return nPages;
    2467             :     }
    2468             :     else
    2469             :     {
    2470         544 :         nPagesX = nPagesY = nTotalY = 0;
    2471         544 :         return 0;
    2472             :     }
    2473             : }
    2474             : 
    2475         696 : long ScPrintFunc::CountNotePages()
    2476             : {
    2477         696 :     if ( !aTableParam.bNotes || !bPrintCurrentTable )
    2478         676 :         return 0;
    2479             : 
    2480          20 :     bool bError = false;
    2481          20 :     if (!aAreaParam.bPrintArea)
    2482          20 :         bError = !AdjustPrintArea(true);            // completely search in Doc
    2483             : 
    2484          20 :     sal_uInt16 nRepeats = 1;                            // how often go through it ?
    2485          20 :     if (bMultiArea)
    2486           0 :         nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
    2487          20 :     if (bError)
    2488          20 :         nRepeats = 0;
    2489             : 
    2490          20 :     for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
    2491             :     {
    2492           0 :         bool bDoThis = true;
    2493           0 :         if (bMultiArea)             // go through all Areas
    2494             :         {
    2495           0 :             const ScRange* pThisRange = pDoc->GetPrintRange( nPrintTab, nStep );
    2496           0 :             if ( pThisRange )
    2497             :             {
    2498           0 :                 nStartCol = pThisRange->aStart.Col();
    2499           0 :                 nStartRow = pThisRange->aStart.Row();
    2500           0 :                 nEndCol   = pThisRange->aEnd  .Col();
    2501           0 :                 nEndRow   = pThisRange->aEnd  .Row();
    2502           0 :                 bDoThis = AdjustPrintArea(false);
    2503             :             }
    2504             :         }
    2505             : 
    2506           0 :         if (bDoThis)
    2507             :         {
    2508           0 :             for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
    2509             :             {
    2510           0 :                 if (pDoc->HasColNotes(nCol, nPrintTab))
    2511             :                 {
    2512           0 :                     for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
    2513             :                         {
    2514           0 :                             if ( pDoc->HasNote(nCol, nRow, nPrintTab) )
    2515           0 :                                 aNotePosList.push_back( ScAddress( nCol, nRow, nPrintTab ) );
    2516             :                         }
    2517             :                 }
    2518             :             }
    2519             :         }
    2520             :     }
    2521             : 
    2522          20 :     long nPages = 0;
    2523          20 :     long nNoteNr = 0;
    2524             :     long nNoteAdd;
    2525          20 :     do
    2526             :     {
    2527          20 :         nNoteAdd = PrintNotes( nPages, nNoteNr, false, NULL );
    2528          20 :         if (nNoteAdd)
    2529             :         {
    2530           0 :             nNoteNr += nNoteAdd;
    2531           0 :             ++nPages;
    2532             :         }
    2533             :     }
    2534             :     while (nNoteAdd);
    2535             : 
    2536          20 :     return nPages;
    2537             : }
    2538             : 
    2539         828 : void ScPrintFunc::InitModes()               // set MapModes from  nZoom etc.
    2540             : {
    2541         828 :     aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
    2542             : 
    2543         828 :     long nEffZoom = nZoom * (long) nManualZoom;
    2544         828 :     nScaleX = nScaleY = HMM_PER_TWIPS;  // output in 1/100 mm
    2545             : 
    2546         828 :     Fraction aZoomFract( nEffZoom,10000 );
    2547         828 :     Fraction aHorFract = aZoomFract;
    2548             : 
    2549         828 :     if ( !pPrinter && !bIsRender )                          // adjust scale for preview
    2550             :     {
    2551         248 :         double nFact = pDocShell->GetOutputFactor();
    2552         248 :         aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 );
    2553             :     }
    2554             : 
    2555         828 :     aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract );
    2556             : 
    2557         828 :     Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
    2558         828 :     aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract );
    2559             : 
    2560         828 :     Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) );
    2561         828 :     aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract );
    2562         828 : }
    2563             : 
    2564           0 : void ScPrintFunc::ApplyPrintSettings()
    2565             : {
    2566           0 :     if ( pPrinter )
    2567             :     {
    2568             : 
    2569             :         //  Configure Printer to Printing
    2570             : 
    2571           0 :         Size aEnumSize = aPageSize;
    2572             : 
    2573           0 :         pPrinter->SetOrientation( bLandscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT );
    2574           0 :         if ( bLandscape )
    2575             :         {
    2576             :                 // landscape is always interpreted as a rotation by 90 degrees !
    2577             :                 // this leads to non WYSIWIG but at least it prints!
    2578             :                 // #i21775#
    2579           0 :                 long nTemp = aEnumSize.Width();
    2580           0 :                 aEnumSize.Width() = aEnumSize.Height();
    2581           0 :                 aEnumSize.Height() = nTemp;
    2582             :         }
    2583           0 :         Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MAP_TWIP, true );
    2584           0 :         sal_uInt16 nPaperBin = static_cast<const SvxPaperBinItem&>(pParamSet->Get(ATTR_PAGE_PAPERBIN)).GetValue();
    2585             : 
    2586           0 :         pPrinter->SetPaper( ePaper );
    2587           0 :         if ( PAPER_USER == ePaper )
    2588             :         {
    2589           0 :             MapMode aPrinterMode = pPrinter->GetMapMode();
    2590           0 :             MapMode aLocalMode( MAP_TWIP );
    2591           0 :             pPrinter->SetMapMode( aLocalMode );
    2592           0 :             pPrinter->SetPaperSizeUser( aEnumSize );
    2593           0 :             pPrinter->SetMapMode( aPrinterMode );
    2594             :         }
    2595             : 
    2596           0 :         pPrinter->SetPaperBin( nPaperBin );
    2597             :     }
    2598           0 : }
    2599             : 
    2600             : //  rPageRanges   = range for all tables
    2601             : //  nStartPage    = rPageRanges starts at nStartPage
    2602             : //  nDisplayStart = continuous number for displaying the page number
    2603             : 
    2604         108 : long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges,
    2605             :                                 long nStartPage, long nDisplayStart, bool bDoPrint,
    2606             :                                 ScPreviewLocationData* pLocationData )
    2607             : {
    2608             :     OSL_ENSURE(pDev,"Device == NULL");
    2609         108 :     if (!pParamSet)
    2610           0 :         return 0;
    2611             : 
    2612         108 :     if ( pPrinter && bDoPrint )
    2613           0 :         ApplyPrintSettings();
    2614             : 
    2615         108 :     InitModes();
    2616         108 :     if ( pLocationData )
    2617             :     {
    2618          42 :         pLocationData->SetCellMapMode( aOffsetMode );
    2619          42 :         pLocationData->SetPrintTab( nPrintTab );
    2620             :     }
    2621             : 
    2622         108 :     MakeTableString();
    2623             : 
    2624         108 :     long nPageNo = 0;
    2625         108 :     long nPrinted = 0;
    2626         108 :     long nEndPage = rPageRanges.GetTotalRange().Max();
    2627             : 
    2628         108 :     sal_uInt16 nRepeats = 1;
    2629         108 :     if (bMultiArea)
    2630           0 :         nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
    2631         216 :     for (sal_uInt16 nStep=0; nStep<nRepeats; nStep++)
    2632             :     {
    2633         108 :         if (bMultiArea)                     // replace area
    2634             :         {
    2635           0 :             CalcZoom(nStep);                // also sets nStartCol etc. new
    2636           0 :             InitModes();
    2637             :         }
    2638             : 
    2639             :         SCCOL nX1;
    2640             :         SCROW nY1;
    2641             :         SCCOL nX2;
    2642             :         SCROW nY2;
    2643             :         size_t nCountX;
    2644             :         size_t nCountY;
    2645             : 
    2646         108 :         if (aTableParam.bTopDown)                           // top-bottom
    2647             :         {
    2648         108 :             nX1 = nStartCol;
    2649         216 :             for (nCountX=0; nCountX<nPagesX; nCountX++)
    2650             :             {
    2651             :                 OSL_ENSURE(nCountX < maPageEndX.size(), "vector access error for maPageEndX (!)");
    2652         108 :                 nX2 = maPageEndX[nCountX];
    2653         216 :                 for (nCountY=0; nCountY<nPagesY; nCountY++)
    2654             :                 {
    2655             :                     OSL_ENSURE(nCountY < maPageRows.size(), "vector access error for maPageRows (!)");
    2656         108 :                     nY1 = maPageRows[nCountY].GetStartRow();
    2657         108 :                     nY2 = maPageRows[nCountY].GetEndRow();
    2658         108 :                     if ( !aTableParam.bSkipEmpty || !maPageRows[nCountY].IsHidden(nCountX) )
    2659             :                     {
    2660         108 :                         if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
    2661             :                         {
    2662             :                             PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
    2663         108 :                                         bDoPrint, pLocationData );
    2664         108 :                             ++nPrinted;
    2665             :                         }
    2666         108 :                         ++nPageNo;
    2667             :                     }
    2668             :                 }
    2669         108 :                 nX1 = nX2 + 1;
    2670             :             }
    2671             :         }
    2672             :         else                                                // left to right
    2673             :         {
    2674           0 :             for (nCountY=0; nCountY<nPagesY; nCountY++)
    2675             :             {
    2676             :                 OSL_ENSURE(nCountY < maPageRows.size(), "vector access error for maPageRows (!)");
    2677           0 :                 nY1 = maPageRows[nCountY].GetStartRow();
    2678           0 :                 nY2 = maPageRows[nCountY].GetEndRow();
    2679           0 :                 nX1 = nStartCol;
    2680           0 :                 for (nCountX=0; nCountX<nPagesX; nCountX++)
    2681             :                 {
    2682             :                     OSL_ENSURE(nCountX < maPageEndX.size(), "vector access error for maPageEndX (!)");
    2683           0 :                     nX2 = maPageEndX[nCountX];
    2684           0 :                     if ( !aTableParam.bSkipEmpty || !maPageRows[nCountY].IsHidden(nCountX) )
    2685             :                     {
    2686           0 :                         if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
    2687             :                         {
    2688             :                             PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
    2689           0 :                                         bDoPrint, pLocationData );
    2690           0 :                             ++nPrinted;
    2691             :                         }
    2692           0 :                         ++nPageNo;
    2693             :                     }
    2694           0 :                     nX1 = nX2 + 1;
    2695             :                 }
    2696             :             }
    2697             :         }
    2698             :     }
    2699             : 
    2700         108 :     aFieldData.aTabName = ScGlobal::GetRscString( STR_NOTES );
    2701             : 
    2702         108 :     long nNoteNr = 0;
    2703             :     long nNoteAdd;
    2704         108 :     do
    2705             :     {
    2706         108 :         if ( nPageNo+nStartPage <= nEndPage )
    2707             :         {
    2708         108 :             bool bPageSelected = rPageRanges.IsSelected( nPageNo+nStartPage+1 );
    2709         108 :             nNoteAdd = PrintNotes( nPageNo+nStartPage, nNoteNr, bDoPrint && bPageSelected,
    2710         216 :                                     ( bPageSelected ? pLocationData : NULL ) );
    2711         108 :             if ( nNoteAdd )
    2712             :             {
    2713           0 :                 nNoteNr += nNoteAdd;
    2714           0 :                 if (bPageSelected)
    2715             :                 {
    2716           0 :                     ++nPrinted;
    2717           0 :                     bSourceRangeValid = false;      // last page was no cell range
    2718             :                 }
    2719           0 :                 ++nPageNo;
    2720             :             }
    2721             :         }
    2722             :         else
    2723           0 :             nNoteAdd = 0;
    2724             :     }
    2725             :     while (nNoteAdd);
    2726             : 
    2727         108 :     if ( bMultiArea )
    2728           0 :         ResetBreaks(nPrintTab);                         //breaks correct for displaying
    2729             : 
    2730         108 :     return nPrinted;
    2731             : }
    2732             : 
    2733          64 : void ScPrintFunc::CalcZoom( sal_uInt16 nRangeNo )                       // calculate zoom
    2734             : {
    2735          64 :     sal_uInt16 nRCount = pDoc->GetPrintRangeCount( nPrintTab );
    2736          64 :     const ScRange* pThisRange = NULL;
    2737          64 :     if ( nRangeNo != RANGENO_NORANGE || nRangeNo < nRCount )
    2738           0 :         pThisRange = pDoc->GetPrintRange( nPrintTab, nRangeNo );
    2739          64 :     if ( pThisRange )
    2740             :     {
    2741           0 :         nStartCol = pThisRange->aStart.Col();
    2742           0 :         nStartRow = pThisRange->aStart.Row();
    2743           0 :         nEndCol   = pThisRange->aEnd  .Col();
    2744           0 :         nEndRow   = pThisRange->aEnd  .Row();
    2745             :     }
    2746             : 
    2747          64 :     if (!AdjustPrintArea(false))                        // empty
    2748             :     {
    2749           0 :         nZoom = 100;
    2750           0 :         nPagesX = nPagesY = nTotalY = 0;
    2751          64 :         return;
    2752             :     }
    2753             : 
    2754          64 :     pDoc->SetRepeatArea( nPrintTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
    2755             : 
    2756          64 :     if (aTableParam.bScalePageNum)
    2757             :     {
    2758           0 :         nZoom = 100;
    2759           0 :         sal_uInt16 nPagesToFit = aTableParam.nScalePageNum;
    2760             : 
    2761             :         // If manual breaks are forced, calculate minimum # pages required
    2762           0 :         if (aTableParam.bForceBreaks)
    2763             :         {
    2764           0 :              sal_uInt16 nMinPages = 0;
    2765           0 :              std::set<SCROW> aRowBreaks;
    2766           0 :              std::set<SCCOL> aColBreaks;
    2767           0 :              pDoc->GetAllRowBreaks(aRowBreaks, nPrintTab, false, true);
    2768           0 :              pDoc->GetAllColBreaks(aColBreaks, nPrintTab, false, true);
    2769           0 :              nMinPages = (aRowBreaks.size() + 1) * (aColBreaks.size() + 1);
    2770             : 
    2771             :              // #i54993# use min forced by breaks if it's > # pages in
    2772             :              // scale parameter to avoid bottoming out at <= ZOOM_MIN
    2773           0 :              nPagesToFit = nMinPages > nPagesToFit ? nMinPages : nPagesToFit;
    2774             :         }
    2775             : 
    2776           0 :         sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
    2777             :         while (true)
    2778             :         {
    2779           0 :             if (nZoom <= ZOOM_MIN)
    2780           0 :                 break;
    2781             : 
    2782           0 :             CalcPages();
    2783           0 :             bool bFitsPage = (nPagesX * nPagesY <= nPagesToFit);
    2784             : 
    2785           0 :             if (bFitsPage)
    2786             :             {
    2787           0 :                 if (nZoom == 100)
    2788             :                     // If it fits at 100%, it's good enough for me.
    2789           0 :                     break;
    2790             : 
    2791           0 :                 nLastFitZoom = nZoom;
    2792           0 :                 nZoom = (nLastNonFitZoom + nZoom) / 2;
    2793             : 
    2794           0 :                 if (nLastFitZoom == nZoom)
    2795             :                     // It converged.  Use this zoom level.
    2796           0 :                     break;
    2797             :             }
    2798             :             else
    2799             :             {
    2800           0 :                 if (nZoom - nLastFitZoom <= 1)
    2801             :                 {
    2802           0 :                     nZoom = nLastFitZoom;
    2803           0 :                     CalcPages();
    2804           0 :                     break;
    2805             :                 }
    2806             : 
    2807           0 :                 nLastNonFitZoom = nZoom;
    2808           0 :                 nZoom = (nLastFitZoom + nZoom) / 2;
    2809             :             }
    2810           0 :         }
    2811             :     }
    2812          64 :     else if (aTableParam.bScaleTo)
    2813             :     {
    2814           0 :         nZoom = 100;
    2815           0 :         sal_uInt16 nW = aTableParam.nScaleWidth;
    2816           0 :         sal_uInt16 nH = aTableParam.nScaleHeight;
    2817             : 
    2818             :         // If manual breaks are forced, calculate minimum # pages required
    2819           0 :         if (aTableParam.bForceBreaks)
    2820             :         {
    2821           0 :              sal_uInt16 nMinPagesW = 0, nMinPagesH = 0;
    2822           0 :              std::set<SCROW> aRowBreaks;
    2823           0 :              std::set<SCCOL> aColBreaks;
    2824           0 :              pDoc->GetAllRowBreaks(aRowBreaks, nPrintTab, false, true);
    2825           0 :              pDoc->GetAllColBreaks(aColBreaks, nPrintTab, false, true);
    2826           0 :              nMinPagesW = aColBreaks.size() + 1;
    2827           0 :              nMinPagesH = aRowBreaks.size() + 1;
    2828             : 
    2829             :              // #i54993# use min forced by breaks if it's > # pages in
    2830             :              // scale parameters to avoid bottoming out at <= ZOOM_MIN
    2831           0 :              nW = nMinPagesW > nW ? nMinPagesW : nW;
    2832           0 :              nH = nMinPagesH > nH ? nMinPagesH : nH;
    2833             :         }
    2834             : 
    2835           0 :         sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
    2836             :         while (true)
    2837             :         {
    2838           0 :             if (nZoom <= ZOOM_MIN)
    2839           0 :                 break;
    2840             : 
    2841           0 :             CalcPages();
    2842           0 :             bool bFitsPage = ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH)));
    2843             : 
    2844           0 :             if (bFitsPage)
    2845             :             {
    2846           0 :                 if (nZoom == 100)
    2847             :                     // If it fits at 100%, it's good enough for me.
    2848           0 :                     break;
    2849             : 
    2850           0 :                 nLastFitZoom = nZoom;
    2851           0 :                 nZoom = (nLastNonFitZoom + nZoom) / 2;
    2852             : 
    2853           0 :                 if (nLastFitZoom == nZoom)
    2854             :                     // It converged.  Use this zoom level.
    2855           0 :                     break;
    2856             :             }
    2857             :             else
    2858             :             {
    2859           0 :                 if (nZoom - nLastFitZoom <= 1)
    2860             :                 {
    2861           0 :                     nZoom = nLastFitZoom;
    2862           0 :                     CalcPages();
    2863           0 :                     break;
    2864             :                 }
    2865             : 
    2866           0 :                 nLastNonFitZoom = nZoom;
    2867           0 :                 nZoom = (nLastFitZoom + nZoom) / 2;
    2868             :             }
    2869           0 :         }
    2870             :     }
    2871          64 :     else if (aTableParam.bScaleAll)
    2872             :     {
    2873          64 :         nZoom = aTableParam.nScaleAll;
    2874          64 :         if ( nZoom <= ZOOM_MIN )
    2875           0 :             nZoom = ZOOM_MIN;
    2876          64 :         CalcPages();
    2877             :     }
    2878             :     else
    2879             :     {
    2880             :         OSL_ENSURE( aTableParam.bScaleNone, "kein Scale-Flag gesetzt" );
    2881           0 :         nZoom = 100;
    2882           0 :         CalcPages();
    2883             :     }
    2884             : }
    2885             : 
    2886         720 : Size ScPrintFunc::GetDocPageSize()
    2887             : {
    2888             :                         // Adjust height of head/foot line
    2889             : 
    2890         720 :     InitModes();                            // initialize aTwipMode from nZoom
    2891         720 :     pDev->SetMapMode( aTwipMode );          // head/foot line in Twips
    2892         720 :     UpdateHFHeight( aHdr );
    2893         720 :     UpdateHFHeight( aFtr );
    2894             : 
    2895             :                         //  Page size in Document-Twips
    2896             :                         //  Calculating Left / Right also in PrintPage
    2897             : 
    2898         720 :     aPageRect = Rectangle( Point(), aPageSize );
    2899         720 :     aPageRect.Left()   = ( aPageRect.Left()   + nLeftMargin                  ) * 100 / nZoom;
    2900         720 :     aPageRect.Right()  = ( aPageRect.Right()  - nRightMargin                 ) * 100 / nZoom;
    2901         720 :     aPageRect.Top()    = ( aPageRect.Top()    + nTopMargin    ) * 100 / nZoom + aHdr.nHeight;
    2902         720 :     aPageRect.Bottom() = ( aPageRect.Bottom() - nBottomMargin ) * 100 / nZoom - aFtr.nHeight;
    2903             : 
    2904         720 :     Size aDocPageSize = aPageRect.GetSize();
    2905         720 :     if (aTableParam.bHeaders)
    2906             :     {
    2907          20 :         aDocPageSize.Width()  -= (long) PRINT_HEADER_WIDTH;
    2908          20 :         aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT;
    2909             :     }
    2910         720 :     if (pBorderItem)
    2911             :     {
    2912        2160 :         aDocPageSize.Width()  -= lcl_LineTotal(pBorderItem->GetLeft()) +
    2913        1440 :                                  lcl_LineTotal(pBorderItem->GetRight()) +
    2914        1440 :                                  pBorderItem->GetDistance(BOX_LINE_LEFT) +
    2915        2160 :                                  pBorderItem->GetDistance(BOX_LINE_RIGHT);
    2916        2160 :         aDocPageSize.Height() -= lcl_LineTotal(pBorderItem->GetTop()) +
    2917        1440 :                                  lcl_LineTotal(pBorderItem->GetBottom()) +
    2918        1440 :                                  pBorderItem->GetDistance(BOX_LINE_TOP) +
    2919        2160 :                                  pBorderItem->GetDistance(BOX_LINE_BOTTOM);
    2920             :     }
    2921         720 :     if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
    2922             :     {
    2923           0 :         aDocPageSize.Width()  -= pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
    2924           0 :                                  pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
    2925           0 :         aDocPageSize.Height() -= pShadowItem->CalcShadowSpace(SHADOW_TOP) +
    2926           0 :                                  pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
    2927             :     }
    2928         720 :     return aDocPageSize;
    2929             : }
    2930             : 
    2931         568 : void ScPrintFunc::ResetBreaks( SCTAB nTab )         // Set Breaks correctly for view
    2932             : {
    2933         568 :     pDoc->SetPageSize( nTab, GetDocPageSize() );
    2934         568 :     pDoc->UpdatePageBreaks( nTab, NULL );
    2935         568 : }
    2936             : 
    2937         140 : static void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry,
    2938             :                     SCCOL nStartCol, const std::vector< SCCOL >& rPageEndX )
    2939             : {
    2940         140 :     size_t nPagesX   = rPageRowEntry.GetPagesX();
    2941         140 :     SCROW nStartRow = rPageRowEntry.GetStartRow();
    2942         140 :     SCROW nEndRow   = rPageRowEntry.GetEndRow();
    2943             : 
    2944         140 :     bool bLeftIsEmpty = false;
    2945         140 :     ScRange aTempRange;
    2946         140 :     Rectangle aTempRect = pDoc->GetMMRect( 0,0, 0,0, 0 );
    2947             : 
    2948         280 :     for (size_t i=0; i<nPagesX; i++)
    2949             :     {
    2950             :         OSL_ENSURE(i < rPageEndX.size(), "vector access error for maPageEndX (!)");
    2951         140 :         SCCOL nEndCol = rPageEndX[i];
    2952         140 :         if ( pDoc->IsPrintEmpty( nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow,
    2953         140 :                                     bLeftIsEmpty, &aTempRange, &aTempRect ) )
    2954             :         {
    2955           0 :             rPageRowEntry.SetHidden(i);
    2956           0 :             bLeftIsEmpty = true;
    2957             :         }
    2958             :         else
    2959         140 :             bLeftIsEmpty = false;
    2960             : 
    2961         140 :         nStartCol = nEndCol+1;
    2962             :     }
    2963         140 : }
    2964             : 
    2965         152 : void ScPrintFunc::CalcPages()               // calculates aPageRect and pages from nZoom
    2966             : {
    2967             :     // #i123672# use dynamic mem to react on size changes
    2968         152 :     if (maPageEndX.size() < MAXCOL+1)
    2969             :     {
    2970         152 :         maPageEndX.resize(MAXCOL+1, SCCOL());
    2971             :     }
    2972             : 
    2973         152 :     pDoc->SetPageSize( nPrintTab, GetDocPageSize() );
    2974         152 :     if (aAreaParam.bPrintArea)
    2975             :     {
    2976           4 :         ScRange aRange( nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab );
    2977           4 :         pDoc->UpdatePageBreaks( nPrintTab, &aRange );
    2978             :     }
    2979             :     else
    2980             :     {
    2981         148 :         pDoc->UpdatePageBreaks( nPrintTab, NULL );      // else, end is marked
    2982             :     }
    2983             : 
    2984         152 :     const size_t nRealCnt = nEndRow-nStartRow+1;
    2985             : 
    2986             :     // #i123672# use dynamic mem to react on size changes
    2987         152 :     if (maPageEndY.size() < nRealCnt+1)
    2988             :     {
    2989         152 :         maPageEndY.resize(nRealCnt+1, SCROW());
    2990             :     }
    2991             : 
    2992             :     // #i123672# use dynamic mem to react on size changes
    2993         152 :     if (maPageRows.size() < nRealCnt+1)
    2994             :     {
    2995         152 :         maPageRows.resize(nRealCnt+1, ScPageRowEntry());
    2996             :     }
    2997             : 
    2998             :     //  Page alignment/splitting after breaks in Col/RowFlags
    2999             :     //  Of several breaks in a hidden area, only one counts.
    3000             : 
    3001         152 :     nPagesX = 0;
    3002         152 :     nPagesY = 0;
    3003         152 :     nTotalY = 0;
    3004             : 
    3005         152 :     bool bVisCol = false;
    3006         434 :     for (SCCOL i=nStartCol; i<=nEndCol; i++)
    3007             :     {
    3008         282 :         bool bHidden = pDoc->ColHidden(i, nPrintTab);
    3009         282 :         bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
    3010         282 :         if ( i>nStartCol && bVisCol && bPageBreak )
    3011             :         {
    3012             :             OSL_ENSURE(nPagesX < maPageEndX.size(), "vector access error for maPageEndX (!)");
    3013          10 :             maPageEndX[nPagesX] = i-1;
    3014          10 :             ++nPagesX;
    3015          10 :             bVisCol = false;
    3016             :         }
    3017         282 :         if (!bHidden)
    3018         282 :             bVisCol = true;
    3019             :     }
    3020         152 :     if (bVisCol)    // also at the end, no empty pages
    3021             :     {
    3022             :         OSL_ENSURE(nPagesX < maPageEndX.size(), "vector access error for maPageEndX (!)");
    3023         152 :         maPageEndX[nPagesX] = nEndCol;
    3024         152 :         ++nPagesX;
    3025             :     }
    3026             : 
    3027         152 :     bool bVisRow = false;
    3028         152 :     SCROW nPageStartRow = nStartRow;
    3029         152 :     SCROW nLastVisibleRow = -1;
    3030             : 
    3031         152 :     ::boost::scoped_ptr<ScRowBreakIterator> pRowBreakIter(pDoc->GetRowBreakIterator(nPrintTab));
    3032         152 :     SCROW nNextPageBreak = pRowBreakIter->first();
    3033         304 :     while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < nStartRow)
    3034             :         // Skip until the page break position is at the start row or greater.
    3035           0 :         nNextPageBreak = pRowBreakIter->next();
    3036             : 
    3037         644 :     for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
    3038             :     {
    3039         492 :         bool bPageBreak = (nNextPageBreak == nRow);
    3040         492 :         if (bPageBreak)
    3041           6 :             nNextPageBreak = pRowBreakIter->next();
    3042             : 
    3043         492 :         if (nRow > nStartRow && bVisRow && bPageBreak )
    3044             :         {
    3045             :             OSL_ENSURE(nTotalY < maPageEndY.size(), "vector access error for maPageEndY (!)");
    3046           6 :             maPageEndY[nTotalY] = nRow-1;
    3047           6 :             ++nTotalY;
    3048             : 
    3049           6 :             if ( !aTableParam.bSkipEmpty ||
    3050           0 :                     !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) )
    3051             :             {
    3052             :                 OSL_ENSURE(nPagesY < maPageRows.size(), "vector access error for maPageRows (!)");
    3053           6 :                 maPageRows[nPagesY].SetStartRow( nPageStartRow );
    3054           6 :                 maPageRows[nPagesY].SetEndRow( nRow-1 );
    3055           6 :                 maPageRows[nPagesY].SetPagesX( nPagesX );
    3056           6 :                 if (aTableParam.bSkipEmpty)
    3057           0 :                     lcl_SetHidden( pDoc, nPrintTab, maPageRows[nPagesY], nStartCol, maPageEndX );
    3058           6 :                 ++nPagesY;
    3059             :             }
    3060             : 
    3061           6 :             nPageStartRow = nRow;
    3062           6 :             bVisRow = false;
    3063             :         }
    3064             : 
    3065         492 :         if (nRow <= nLastVisibleRow)
    3066             :         {
    3067             :             // This row is still visible.  Don't bother calling RowHidden() to
    3068             :             // find out, for speed optimization.
    3069         340 :             bVisRow = true;
    3070         340 :             continue;
    3071             :         }
    3072             : 
    3073         152 :         SCROW nLastRow = -1;
    3074         152 :         if (!pDoc->RowHidden(nRow, nPrintTab, NULL, &nLastRow))
    3075             :         {
    3076         152 :             bVisRow = true;
    3077         152 :             nLastVisibleRow = nLastRow;
    3078             :         }
    3079             :         else
    3080             :             // skip all hidden rows.
    3081           0 :             nRow = nLastRow;
    3082             :     }
    3083             : 
    3084         152 :     if (bVisRow)
    3085             :     {
    3086             :         OSL_ENSURE(nTotalY < maPageEndY.size(), "vector access error for maPageEndY (!)");
    3087         152 :         maPageEndY[nTotalY] = nEndRow;
    3088         152 :         ++nTotalY;
    3089             : 
    3090         292 :         if ( !aTableParam.bSkipEmpty ||
    3091         140 :                 !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow ) )
    3092             :         {
    3093             :             OSL_ENSURE(nPagesY < maPageRows.size(), "vector access error for maPageRows (!)");
    3094         152 :             maPageRows[nPagesY].SetStartRow( nPageStartRow );
    3095         152 :             maPageRows[nPagesY].SetEndRow( nEndRow );
    3096         152 :             maPageRows[nPagesY].SetPagesX( nPagesX );
    3097         152 :             if (aTableParam.bSkipEmpty)
    3098         140 :                 lcl_SetHidden( pDoc, nPrintTab, maPageRows[nPagesY], nStartCol, maPageEndX );
    3099         152 :             ++nPagesY;
    3100             :         }
    3101         152 :     }
    3102         380 : }
    3103             : 
    3104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10