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

Generated by: LCOV version 1.10