LCOV - code coverage report
Current view: top level - sc/source/ui/inc - printfun.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 21 100.0 %
Date: 2015-06-13 12:38:46 Functions: 19 19 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SC_SOURCE_UI_INC_PRINTFUN_HXX
      21             : #define INCLUDED_SC_SOURCE_UI_INC_PRINTFUN_HXX
      22             : 
      23             : #include "pagepar.hxx"
      24             : #include "editutil.hxx"
      25             : 
      26             : #include <vcl/print.hxx>
      27             : 
      28             : class SfxPrinter;
      29             : class ScDocShell;
      30             : class ScDocument;
      31             : class ScViewData;
      32             : class SfxItemSet;
      33             : class ScPageHFItem;
      34             : class EditTextObject;
      35             : class MultiSelection;
      36             : class ScHeaderEditEngine;
      37             : class ScPageBreakData;
      38             : class ScPreviewLocationData;
      39             : class ScPrintOptions;
      40             : class SvxBoxItem;
      41             : class SvxBrushItem;
      42             : class SvxShadowItem;
      43             : class FmFormView;
      44             : 
      45             : #define RANGENO_NORANGE             USHRT_MAX
      46             : 
      47             : #define PRINT_HEADER_WIDTH          (1.0 * TWIPS_PER_CM)
      48             : #define PRINT_HEADER_HEIGHT         (12.8 * TWIPS_PER_POINT)
      49             : 
      50             :                                             // Settings for headers/footers
      51             : struct ScPrintHFParam
      52             : {
      53             :     bool                bEnable;
      54             :     bool                bDynamic;
      55             :     bool                bShared;
      56             :     long                nHeight;            // in total (height + distance + frames)
      57             :     long                nManHeight;         // set size (min when dynamic)
      58             :     sal_uInt16          nDistance;
      59             :     sal_uInt16          nLeft;              // edges
      60             :     sal_uInt16          nRight;
      61             :     const ScPageHFItem* pLeft;
      62             :     const ScPageHFItem* pRight;
      63             :     const SvxBoxItem*   pBorder;
      64             :     const SvxBrushItem* pBack;
      65             :     const SvxShadowItem* pShadow;
      66             : };
      67             : 
      68             : struct ScPrintState                         //  Save Variables from ScPrintFunc
      69             : {
      70             :     SCTAB   nPrintTab;
      71             :     SCCOL   nStartCol;
      72             :     SCROW   nStartRow;
      73             :     SCCOL   nEndCol;
      74             :     SCROW   nEndRow;
      75             :     sal_uInt16  nZoom;
      76             :     size_t  nPagesX;
      77             :     size_t  nPagesY;
      78             :     long    nTabPages;
      79             :     long    nTotalPages;
      80             :     long    nPageStart;
      81             :     long    nDocPages;
      82           8 :     ScPrintState()
      83             :         : nPrintTab(0)
      84             :         , nStartCol(0)
      85             :         , nStartRow(0)
      86             :         , nEndCol(0)
      87             :         , nEndRow(0)
      88             :         , nZoom(0)
      89             :         , nPagesX(0)
      90             :         , nPagesY(0)
      91             :         , nTabPages(0)
      92             :         , nTotalPages(0)
      93             :         , nPageStart(0)
      94           8 :         , nDocPages(0)
      95             :     {
      96           8 :     }
      97             : };
      98             : 
      99             : class ScPageRowEntry
     100             : {
     101             : private:
     102             :     SCROW   nStartRow;
     103             :     SCROW   nEndRow;
     104             :     size_t  nPagesX;
     105             :     bool*   pHidden;
     106             :     //!     Cache Number of really visible?
     107             : 
     108             : public:
     109          65 :             ScPageRowEntry()    { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
     110         365 :             ~ScPageRowEntry()   { delete[] pHidden; }
     111             : 
     112             :             ScPageRowEntry(const ScPageRowEntry& r);
     113             :     const ScPageRowEntry& operator=(const ScPageRowEntry& r);
     114             : 
     115         102 :     SCROW   GetStartRow() const     { return nStartRow; }
     116         102 :     SCROW   GetEndRow() const       { return nEndRow; }
     117          59 :     size_t  GetPagesX() const       { return nPagesX; }
     118          68 :     void    SetStartRow(SCROW n)    { nStartRow = n; }
     119          68 :     void    SetEndRow(SCROW n)      { nEndRow = n; }
     120             : 
     121             :     void    SetPagesX(size_t nNew);
     122             :     void    SetHidden(size_t nX);
     123             :     bool    IsHidden(size_t nX) const;
     124             : 
     125             :     size_t  CountVisible() const;
     126             : };
     127             : 
     128             : class ScPrintFunc
     129             : {
     130             : private:
     131             :     ScDocShell*         pDocShell;
     132             :     ScDocument*         pDoc;
     133             :     VclPtr<SfxPrinter>   pPrinter;
     134             :     VclPtr<OutputDevice> pDev;
     135             :     FmFormView*         pDrawView;
     136             : 
     137             :     MapMode             aOldPrinterMode;    //  MapMode before the call
     138             : 
     139             :     Point               aSrcOffset;         //  Paper-1/100 mm
     140             :     Point               aOffset;            //  scaled by a factor of page size
     141             :     sal_uInt16          nManualZoom;        //  Zoom in Preview (percent)
     142             :     bool                bClearWin;          //  Clear output before
     143             :     bool                bUseStyleColor;
     144             :     bool                bIsRender;
     145             : 
     146             :     SCTAB               nPrintTab;
     147             :     long                nPageStart;         //  Offset for the first page
     148             :     long                nDocPages;          //  Number of Pages in Document
     149             : 
     150             :     const ScRange*      pUserArea;          //  Selection, if set in dialog
     151             : 
     152             :     const SfxItemSet*   pParamSet;          //  Selected template
     153             :     bool                bState;             // created from State-struct
     154             : 
     155             :                                             //  Parameter from template:
     156             :     sal_uInt16          nLeftMargin;
     157             :     sal_uInt16          nTopMargin;
     158             :     sal_uInt16          nRightMargin;
     159             :     sal_uInt16          nBottomMargin;
     160             :     bool                bCenterHor;
     161             :     bool                bCenterVer;
     162             :     bool                bLandscape;
     163             :     bool                bSourceRangeValid;
     164             : 
     165             :     sal_uInt16              nPageUsage;
     166             :     Size                aPageSize;          // Printer Twips
     167             :     const SvxBoxItem*   pBorderItem;
     168             :     const SvxBrushItem* pBackgroundItem;
     169             :     const SvxShadowItem* pShadowItem;
     170             : 
     171             :     ScRange             aLastSourceRange;
     172             :     ScPrintHFParam      aHdr;
     173             :     ScPrintHFParam      aFtr;
     174             :     ScPageTableParam    aTableParam;
     175             :     ScPageAreaParam     aAreaParam;
     176             : 
     177             :                                             // Calculated values:
     178             :     sal_uInt16          nZoom;
     179             :     bool                bPrintCurrentTable;
     180             :     bool                bMultiArea;
     181             :     bool                mbHasPrintRange;
     182             :     long                nTabPages;
     183             :     long                nTotalPages;
     184             : 
     185             :     Rectangle           aPageRect;          // Document Twips
     186             : 
     187             :     MapMode             aLogicMode;         // Set in DoPrint
     188             :     MapMode             aOffsetMode;
     189             :     MapMode             aTwipMode;
     190             :     double              nScaleX;
     191             :     double              nScaleY;
     192             : 
     193             :     SCCOL               nRepeatStartCol;
     194             :     SCCOL               nRepeatEndCol;
     195             :     SCROW               nRepeatStartRow;
     196             :     SCROW               nRepeatEndRow;
     197             : 
     198             :     SCCOL               nStartCol;
     199             :     SCROW               nStartRow;
     200             :     SCCOL               nEndCol;
     201             :     SCROW               nEndRow;
     202             : 
     203             :     std::vector< SCCOL >            maPageEndX;
     204             :     std::vector< SCROW >            maPageEndY;
     205             :     std::vector< ScPageRowEntry>    maPageRows;
     206             : 
     207             :     size_t              nPagesX;
     208             :     size_t              nPagesY;
     209             :     size_t              nTotalY;
     210             : 
     211             :     ScHeaderEditEngine* pEditEngine;
     212             :     SfxItemSet*         pEditDefaults;
     213             : 
     214             :     ScHeaderFieldData   aFieldData;
     215             : 
     216             :     std::vector<ScAddress> aNotePosList;        // The order of notes
     217             : 
     218             :     ScPageBreakData*    pPageData;          // for recording the breaks etc.
     219             : 
     220             : public:
     221             :                     ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
     222             :                                  long nPage = 0, long nDocP = 0,
     223             :                                  const ScRange* pArea = NULL,
     224             :                                  const ScPrintOptions* pOptions = NULL,
     225             :                                  ScPageBreakData* pData = NULL );
     226             : 
     227             :                     // ctors for device other than printer - for preview and pdf:
     228             : 
     229             :                     ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
     230             :                                  long nPage = 0, long nDocP = 0,
     231             :                                  const ScRange* pArea = NULL,
     232             :                                  const ScPrintOptions* pOptions = NULL );
     233             : 
     234             :                     ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
     235             :                                  const ScPrintState& rState,
     236             :                                  const ScPrintOptions* pOptions );
     237             : 
     238             :                     ~ScPrintFunc();
     239             : 
     240             :     static void     DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
     241             :                                 const Rectangle& rBound, ScViewData* pViewData, bool bMetaFile );
     242             : 
     243             :     void            SetDrawView( FmFormView* pNew );
     244             : 
     245             :     void            SetOffset( const Point& rOfs );
     246             :     void            SetManualZoom( sal_uInt16 nNewZoom );
     247             :     void            SetDateTime( const Date& rDate, const tools::Time& rTime );
     248             : 
     249             :     void            SetClearFlag( bool bFlag );
     250             :     void            SetUseStyleColor( bool bFlag );
     251             :     void            SetRenderFlag( bool bFlag );
     252             : 
     253             :     void            SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
     254             : 
     255             :     bool            UpdatePages();
     256             : 
     257             :     void            ApplyPrintSettings();       // Already called from DoPrint()
     258             :     long            DoPrint( const MultiSelection& rPageRanges,
     259             :                                 long nStartPage, long nDisplayStart, bool bDoPrint,
     260             :                                 ScPreviewLocationData* pLocationData );
     261             : 
     262             :                     // Query values - immediately
     263             : 
     264          59 :     Size            GetPageSize() const { return aPageSize; }
     265             :     Size            GetDataSize() const;
     266             :     void            GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
     267          16 :     long            GetFirstPageNo() const  { return aTableParam.nFirstPageNo; }
     268             : 
     269             :                     // Query last value - after DoPrint!!
     270             : 
     271             :     double          GetScaleX() const { return nScaleX; }
     272             :     double          GetScaleY() const { return nScaleY; }
     273          16 :     long            GetTotalPages() const { return nTotalPages; }
     274          43 :     sal_uInt16          GetZoom() const { return nZoom; }
     275             : 
     276             :     void            ResetBreaks( SCTAB nTab );
     277             : 
     278             :     void            GetPrintState( ScPrintState& rState );
     279             :     bool            GetLastSourceRange( ScRange& rRange ) const;
     280          43 :     sal_uInt16      GetLeftMargin() const{return nLeftMargin;}
     281          43 :     sal_uInt16      GetRightMargin() const{return nRightMargin;}
     282          43 :     sal_uInt16      GetTopMargin() const{return nTopMargin;}
     283          43 :     sal_uInt16      GetBottomMargin() const{return nBottomMargin;}
     284             :     void            SetLeftMargin(sal_uInt16 nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
     285             :     void            SetRightMargin(sal_uInt16 nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
     286             :     void            SetTopMargin(sal_uInt16 nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
     287             :     void            SetBottomMargin(sal_uInt16 nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
     288          86 :     ScPrintHFParam  GetHeader(){return aHdr;}
     289          86 :     ScPrintHFParam  GetFooter(){return aFtr;}
     290             : 
     291          16 :     bool HasPrintRange() const { return mbHasPrintRange;}
     292             : 
     293             : private:
     294             :     void            Construct( const ScPrintOptions* pOptions );
     295             :     void            InitParam( const ScPrintOptions* pOptions );
     296             :     void            CalcZoom( sal_uInt16 nRangeNo );
     297             :     void            CalcPages();
     298             :     long            CountPages();
     299             :     long            CountNotePages();
     300             : 
     301             :     bool            AdjustPrintArea( bool bNew );
     302             : 
     303             :     Size            GetDocPageSize();
     304             : 
     305             :     long            TextHeight( const EditTextObject* pObject );
     306             :     void            MakeEditEngine();
     307             :     void            UpdateHFHeight( ScPrintHFParam& rParam );
     308             : 
     309             :     void            InitModes();
     310             : 
     311             :     bool            IsLeft( long nPageNo );
     312             :     bool            IsMirror( long nPageNo );
     313             :     void            ReplaceFields( long nPageNo );      // changes Text in pEditEngine
     314             :     void            MakeTableString();                  // sets aTableStr
     315             : 
     316             :     void            PrintPage( long nPageNo,
     317             :                                     SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
     318             :                                     bool bDoPrint, ScPreviewLocationData* pLocationData );
     319             :     void            PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
     320             :                                     long nScrX, long nScrY,
     321             :                                     bool bShLeft, bool bShTop, bool bShRight, bool bShBottom );
     322             :     void            LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
     323             :                                     long nScrX, long nScrY, bool bRepCol, bool bRepRow,
     324             :                                     ScPreviewLocationData& rLocationData );
     325             :     void            PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
     326             :     void            PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
     327             :     void            LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
     328             :                                 bool bRepCol, ScPreviewLocationData& rLocationData );
     329             :     void            LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
     330             :                                 bool bRepRow, ScPreviewLocationData& rLocationData );
     331             :     void            PrintHF( long nPageNo, bool bHeader, long nStartY,
     332             :                                     bool bDoPrint, ScPreviewLocationData* pLocationData );
     333             : 
     334             :     long            PrintNotes( long nPageNo, long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData );
     335             :     long            DoNotes( long nNoteStart, bool bDoPrint, ScPreviewLocationData* pLocationData );
     336             : 
     337             :     void            DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
     338             :                                     const SvxBoxItem* pBorderData,
     339             :                                     const SvxBrushItem* pBackground,
     340             :                                     const SvxShadowItem* pShadow );
     341             : 
     342             :     void            FillPageData();
     343             : };
     344             : 
     345             : #endif
     346             : 
     347             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11