LCOV - code coverage report
Current view: top level - sw/inc - printdata.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 67 92 72.8 %
Date: 2015-06-13 12:38:46 Functions: 62 68 91.2 %
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             : #ifndef INCLUDED_SW_INC_PRINTDATA_HXX
      20             : #define INCLUDED_SW_INC_PRINTDATA_HXX
      21             : 
      22             : #include <sal/types.h>
      23             : #include <rtl/ustring.hxx>
      24             : #include <vcl/print.hxx>
      25             : #include <sfx2/objsh.hxx>
      26             : 
      27             : #include <boost/scoped_ptr.hpp>
      28             : 
      29             : #include <set>
      30             : #include <map>
      31             : #include <vector>
      32             : #include <utility>
      33             : 
      34             : class SwDoc;
      35             : class SwDocShell;
      36             : class _SetGetExpFields;
      37             : class SwViewOption;
      38             : class OutputDevice;
      39             : class SwViewOptionAdjust_Impl;
      40             : class SwViewShell;
      41             : class SfxViewShell;
      42             : 
      43             : // forward declarations
      44             : class SwPrintUIOptions;
      45             : class SwRenderData;
      46             : 
      47        3056 : class SwPrintData
      48             : {
      49             :     const SwPrintUIOptions *    m_pPrintUIOptions;  // not owner
      50             :     const SwRenderData *        m_pRenderData;      // not owner
      51             : 
      52             : public:
      53             : 
      54             :     bool bPrintGraphic, bPrintTable, bPrintDraw, bPrintControl, bPrintPageBackground,
      55             :              bPrintBlackFont,
      56             :              //#i81434# - printing of hidden text
      57             :              bPrintHiddenText, bPrintTextPlaceholder,
      58             :              bPrintLeftPages, bPrintRightPages, bPrintReverse, bPrintProspect,
      59             :              bPrintProspectRTL,
      60             :              bPrintSingleJobs, bPaperFromSetup,
      61             :              /// Print empty pages
      62             :              bPrintEmptyPages,
      63             : 
      64             :              /// #i56195# no field update while printing mail merge documents
      65             :              bUpdateFieldsInPrinting,
      66             :              bModified;
      67             : 
      68             :     sal_Int16           nPrintPostIts;
      69             :     OUString       sFaxName;
      70             : 
      71        3661 :     SwPrintData()
      72        3661 :     {
      73        3661 :         m_pPrintUIOptions       = NULL;
      74        3661 :         m_pRenderData        = NULL;
      75             : 
      76             :         bPrintGraphic           =
      77             :         bPrintTable             =
      78             :         bPrintDraw              =
      79             :         bPrintControl           =
      80             :         bPrintLeftPages         =
      81             :         bPrintRightPages        =
      82             :         bPrintPageBackground    =
      83             :         bPrintEmptyPages        =
      84        3661 :         bUpdateFieldsInPrinting = true;
      85             : 
      86             :         bPaperFromSetup         =
      87             :         bPrintReverse           =
      88             :         bPrintProspect          =
      89             :         bPrintProspectRTL       =
      90             :         bPrintSingleJobs        =
      91             :         bModified               =
      92             :         bPrintBlackFont         =
      93             :         bPrintHiddenText        =
      94        3661 :         bPrintTextPlaceholder   = false;
      95             : 
      96        3661 :         nPrintPostIts           = 0;
      97        3661 :     }
      98             : 
      99        6652 :     virtual ~SwPrintData() {}
     100             : 
     101           0 :     bool operator==(const SwPrintData& rData)const
     102             :     {
     103             :         return
     104           0 :         bPrintGraphic       ==   rData.bPrintGraphic        &&
     105           0 :         bPrintTable         ==   rData.bPrintTable          &&
     106           0 :         bPrintDraw          ==   rData.bPrintDraw           &&
     107           0 :         bPrintControl       ==   rData.bPrintControl        &&
     108           0 :         bPrintPageBackground==   rData.bPrintPageBackground &&
     109           0 :         bPrintBlackFont     ==   rData.bPrintBlackFont      &&
     110           0 :         bPrintLeftPages     ==   rData.bPrintLeftPages      &&
     111           0 :         bPrintRightPages    ==   rData.bPrintRightPages     &&
     112           0 :         bPrintReverse       ==   rData.bPrintReverse        &&
     113           0 :         bPrintProspect      ==   rData.bPrintProspect       &&
     114           0 :         bPrintProspectRTL   ==   rData.bPrintProspectRTL    &&
     115           0 :         bPrintSingleJobs    ==   rData.bPrintSingleJobs     &&
     116           0 :         bPaperFromSetup     ==   rData.bPaperFromSetup      &&
     117           0 :         bPrintEmptyPages    ==   rData.bPrintEmptyPages     &&
     118           0 :         bUpdateFieldsInPrinting == rData.bUpdateFieldsInPrinting &&
     119           0 :         nPrintPostIts       ==   rData.nPrintPostIts        &&
     120           0 :         sFaxName            ==   rData.sFaxName             &&
     121           0 :         bPrintHiddenText    ==   rData.bPrintHiddenText     &&
     122           0 :         bPrintTextPlaceholder   ==   rData.bPrintTextPlaceholder;
     123             :     }
     124             : 
     125             :     /** Note: in the context where this class is used the pointers should always be valid
     126             :        during the lifetime of this object */
     127             :     const SwPrintUIOptions &    GetPrintUIOptions() const       { return *m_pPrintUIOptions; }
     128           2 :     const SwRenderData &        GetRenderData() const           { return *m_pRenderData; }
     129           1 :     void  SetPrintUIOptions( const SwPrintUIOptions *pOpt )     { m_pPrintUIOptions = pOpt; }
     130           1 :     void  SetRenderData( const SwRenderData *pData )            { m_pRenderData = pData; }
     131             : 
     132          77 :     bool IsPrintGraphic() const             { return bPrintGraphic; }
     133          76 :     bool IsPrintTable() const               { return bPrintTable; }
     134          78 :     bool IsPrintDraw() const                { return bPrintDraw; }
     135          77 :     bool IsPrintControl() const             { return bPrintControl; }
     136          78 :     bool IsPrintLeftPage() const            { return bPrintLeftPages; }
     137          77 :     bool IsPrintRightPage() const           { return bPrintRightPages; }
     138          76 :     bool IsPrintReverse() const             { return bPrintReverse; }
     139          77 :     bool IsPaperFromSetup() const           { return bPaperFromSetup; }
     140          73 :     bool IsPrintEmptyPages() const          { return bPrintEmptyPages; }
     141          77 :     bool IsPrintProspect() const            { return bPrintProspect; }
     142          73 :     bool IsPrintProspectRTL() const         { return bPrintProspectRTL; }
     143          77 :     bool IsPrintPageBackground() const      { return bPrintPageBackground; }
     144          77 :     bool IsPrintBlackFont() const           { return bPrintBlackFont; }
     145          72 :     bool IsPrintSingleJobs() const          { return bPrintSingleJobs; }
     146          78 :     sal_Int16 GetPrintPostIts() const           { return nPrintPostIts; }
     147          76 :     const OUString GetFaxName() const      { return sFaxName; }
     148          73 :     bool IsPrintHiddenText() const          { return bPrintHiddenText; }
     149          73 :     bool IsPrintTextPlaceholder() const     { return bPrintTextPlaceholder; }
     150             : 
     151         287 :     void SetPrintGraphic( bool b )              { doSetModified(); bPrintGraphic = b; }
     152         287 :     void SetPrintTable( bool b )                { doSetModified(); bPrintTable = b; }
     153         287 :     void SetPrintDraw( bool b )                 { doSetModified(); bPrintDraw = b; }
     154         287 :     void SetPrintControl( bool b )              { doSetModified(); bPrintControl = b; }
     155         287 :     void SetPrintLeftPage( bool b )             { doSetModified(); bPrintLeftPages = b; }
     156         287 :     void SetPrintRightPage( bool b )            { doSetModified(); bPrintRightPages = b; }
     157         287 :     void SetPrintReverse( bool b )              { doSetModified(); bPrintReverse = b; }
     158         287 :     void SetPaperFromSetup( bool b )            { doSetModified(); bPaperFromSetup = b; }
     159         283 :     void SetPrintEmptyPages( bool b )           { doSetModified(); bPrintEmptyPages = b; }
     160         287 :     void SetPrintPostIts( sal_Int16 n )             { doSetModified(); nPrintPostIts = n; }
     161         287 :     void SetPrintProspect( bool b )             { doSetModified(); bPrintProspect = b; }
     162         277 :     void SetPrintProspect_RTL( bool b )         { doSetModified(); bPrintProspectRTL = b; }
     163         287 :     void SetPrintPageBackground( bool b )       { doSetModified(); bPrintPageBackground = b; }
     164         287 :     void SetPrintBlackFont( bool b )            { doSetModified(); bPrintBlackFont = b; }
     165         284 :     void SetPrintSingleJobs( bool b )           { doSetModified(); bPrintSingleJobs = b; }
     166         286 :     void SetFaxName( const OUString& rSet )    { sFaxName = rSet; }
     167         277 :     void SetPrintHiddenText( bool b )           { doSetModified(); bPrintHiddenText = b; }
     168         277 :     void SetPrintTextPlaceholder( bool b )      { doSetModified(); bPrintTextPlaceholder = b; }
     169             : 
     170        4830 :     virtual void doSetModified () { bModified = true;}
     171             : };
     172             : 
     173             : class SwPrintUIOptions : public vcl::PrinterOptionsHelper
     174             : {
     175             :     VclPtr< OutputDevice > m_pLast;
     176             :     const SwPrintData & m_rDefaultPrintData;
     177             : 
     178             : public:
     179             :     SwPrintUIOptions( sal_uInt16 nCurrentPage, bool bWeb, bool bSwSrcView, bool bHasSelection, bool bHasPostIts, const SwPrintData &rDefaultPrintData );
     180             :     virtual ~SwPrintUIOptions();
     181             : 
     182             :     bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
     183             : 
     184           2 :     bool IsPrintFormControls() const            { return getBoolValue( "PrintControls",        m_rDefaultPrintData.bPrintControl ); }
     185           2 :     bool IsPrintPageBackground() const          { return getBoolValue( "PrintPageBackground",  m_rDefaultPrintData.bPrintPageBackground ); }
     186           2 :     bool IsPrintProspect() const                { return getBoolValue( "PrintProspect",        m_rDefaultPrintData.bPrintProspect ); }
     187           2 :     bool IsPrintProspectRTL() const             { return getIntValue( "PrintProspectRTL",      m_rDefaultPrintData.bPrintProspectRTL ? 1 : 0 ) != 0; }
     188           2 :     bool IsPrintTextPlaceholders() const        { return getBoolValue( "PrintTextPlaceholder", m_rDefaultPrintData.bPrintTextPlaceholder ); }
     189           2 :     bool IsPrintHiddenText() const              { return getBoolValue( "PrintHiddenText",      m_rDefaultPrintData.bPrintHiddenText ); }
     190           2 :     bool IsPrintWithBlackTextColor() const      { return getBoolValue( "PrintBlackFonts",      m_rDefaultPrintData.bPrintBlackFont ); }
     191           2 :     sal_Int16 GetPrintPostItsType() const       { return static_cast< sal_Int16 >(getIntValue( "PrintAnnotationMode", m_rDefaultPrintData.nPrintPostIts )); }
     192           2 :     bool IsPaperFromSetup() const               { return getBoolValue( "PrintPaperFromSetup",  m_rDefaultPrintData.bPaperFromSetup ); }
     193             : 
     194             :     bool IsPrintLeftPages() const;
     195             :     bool IsPrintRightPages() const;
     196             :     bool IsPrintEmptyPages( bool bIsPDFExport ) const;
     197             :     bool IsPrintGraphics() const;
     198             :     bool IsPrintDrawings() const;
     199             : };
     200             : 
     201             : /** A class that stores temporary data that is needed for rendering the document.
     202             :    Usually this data is created when 'getRendererCount' is called and
     203             :    and it is used in the 'render' function of that same interface */
     204             : class SwRenderData
     205             : {
     206             :     /** pages valid for printing (according to the current settings)
     207             :      This set of pages does NOT depend on the 'PageRange' that is used as a printing option! */
     208             :     std::set< sal_Int32 >                       m_aValidPages;          ///< the set of possible pages (see StringRangeEnumerator::getRangesFromString )
     209             : 
     210             :     /// printer paper tray to use for each of the m_aValidPages above
     211             :     std::map< sal_Int32, sal_Int32 >            m_aPrinterPaperTrays;
     212             : 
     213             :     /** vector of pages and their order to be printed (duplicates and any order allowed!)
     214             :        (see 'render' in unotxdoc.cxx)
     215             :        negative entry indicates the page to be printed is from the post-it doc */
     216             :     std::vector< sal_Int32 >                    m_aPagesToPrint;
     217             : 
     218             :     /** for prospect printing: the pairs of pages to be printed together on a single prospect page.
     219             :        -1 indicates a half page to be left empty. */
     220             :     std::vector< std::pair< sal_Int32, sal_Int32 > >    m_aPagePairs;
     221             : 
     222             :     OUString               m_aPageRange;
     223             : 
     224             :     /** temp print document -- must live longer than m_pViewOptionAdjust!
     225             :        also this is a Lock and not a Ref because Ref does not delete the doc */
     226             :     SfxObjectShellLock m_xTempDocShell;
     227             : 
     228             :     /// the view options to be applied for printing
     229             :     ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
     230             : 
     231             :     ::boost::scoped_ptr<SwPrintData>    m_pPrtOptions;
     232             : 
     233             : public:
     234             : 
     235             :     // PostIt relevant data
     236             :     /// an array of "_SetGetExpField *" sorted by page and line numbers
     237             :     ::boost::scoped_ptr<_SetGetExpFields> m_pPostItFields;
     238             :     /// this contains a SwDoc with the post-it content
     239             :     ::boost::scoped_ptr<SwViewShell>      m_pPostItShell;
     240             : 
     241             : public:
     242             :     SwRenderData();
     243             :     ~SwRenderData();
     244             : 
     245           0 :     bool HasPostItData() const  { return m_pPostItShell != 0; }
     246             :     void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
     247             :     void DeletePostItData();
     248             : 
     249           0 :     SfxObjectShellLock const& GetTempDocShell() const { return m_xTempDocShell;}
     250             :     void SetTempDocShell(SfxObjectShellLock const&);
     251             : 
     252           2 :     bool IsViewOptionAdjust() const  { return m_pViewOptionAdjust != 0; }
     253             :     bool NeedNewViewOptionAdjust( const SwViewShell& ) const;
     254             :     void ViewOptionAdjustStart( SwViewShell &rSh, const SwViewOption &rViewOptions);
     255             :     void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
     256             :     void ViewOptionAdjustStop();
     257             :     void ViewOptionAdjustCrashPreventionKludge();
     258             : 
     259           1 :     bool HasSwPrtOptions() const    { return m_pPrtOptions != 0; }
     260           2 :     SwPrintData const*  GetSwPrtOptions() const { return m_pPrtOptions.get(); }
     261             :     void MakeSwPrtOptions( SwDocShell const*const pDocShell,
     262             :             SwPrintUIOptions const*const pOpt, bool const bIsPDFExport );
     263             : 
     264             :     typedef std::vector< std::pair< sal_Int32, sal_Int32 > >    PagePairsVec_t;
     265             : 
     266           2 :     std::set< sal_Int32 > &             GetValidPagesSet()          { return m_aValidPages; }
     267             :     const std::set< sal_Int32 > &       GetValidPagesSet() const    { return m_aValidPages; }
     268             : 
     269             :     /** a map for printer paper tray numbers to use for each document page
     270             :        a value of -1 for the tray means that there is no specific tray defined */
     271           2 :     std::map< sal_Int32, sal_Int32 >&        GetPrinterPaperTrays()          { return m_aPrinterPaperTrays; }
     272             :     const std::map< sal_Int32, sal_Int32 >&  GetPrinterPaperTrays() const    { return m_aPrinterPaperTrays; }
     273             : 
     274             :     /** used for 'normal' printing
     275             :        A page value of 0 as entry indicates that this page is not from the document but
     276             :        from the post-it document. (See also GetPostItStartFrame below) */
     277           5 :     std::vector< sal_Int32 > &          GetPagesToPrint()           { return m_aPagesToPrint; }
     278           2 :     const std::vector< sal_Int32 > &    GetPagesToPrint() const     { return m_aPagesToPrint; }
     279             : 
     280             :     /// used for prospect printing only
     281           0 :     PagePairsVec_t &                    GetPagePairsForProspectPrinting()           { return m_aPagePairs; }
     282           0 :     const PagePairsVec_t &              GetPagePairsForProspectPrinting() const     { return m_aPagePairs; }
     283             : 
     284           0 :     OUString   GetPageRange() const                            { return m_aPageRange; }
     285           1 :     void            SetPageRange( const OUString &rRange )     { m_aPageRange = rRange; }
     286             : };
     287             : 
     288             : /// last remnants of swprtopt.hxx:
     289             : #define POSTITS_NONE    0
     290             : #define POSTITS_ONLY    1
     291             : #define POSTITS_ENDDOC  2
     292             : #define POSTITS_ENDPAGE 3
     293             : #define POSTITS_INMARGINS 4
     294             : 
     295             : namespace sw {
     296             : 
     297             : void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb);
     298             : 
     299             : } ///< namespace sw
     300             : 
     301             : #endif // INCLUDED_SW_INC_PRINTDATA_HXX
     302             : 
     303             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11