LCOV - code coverage report
Current view: top level - sc/source/ui/view - printfun.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1050 1661 63.2 %
Date: 2012-08-25 Functions: 47 60 78.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 777 2164 35.9 %

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

Generated by: LCOV version 1.10