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

Generated by: LCOV version 1.10