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

Generated by: LCOV version 1.10