LCOV - code coverage report
Current view: top level - sc/source/filter/inc - pagesettings.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
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_FILTER_INC_PAGESETTINGS_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_PAGESETTINGS_HXX
      22             : 
      23             : #include "worksheethelper.hxx"
      24             : 
      25             : namespace oox { class PropertySet; }
      26             : namespace oox { namespace core { class Relations; } }
      27             : 
      28             : namespace oox {
      29             : namespace xls {
      30             : 
      31             : class HeaderFooterParser;
      32             : 
      33             : /** Holds page style data for a single sheet. */
      34         269 : struct PageSettingsModel
      35             : {
      36             :     OUString     maGraphicUrl;           /// URL of the graphic object.
      37             :     OUString     maBinSettPath;          /// Relation identifier of binary printer settings.
      38             :     OUString     maOddHeader;            /// Header string for odd pages.
      39             :     OUString     maOddFooter;            /// Footer string for odd pages.
      40             :     OUString     maEvenHeader;           /// Header string for even pages.
      41             :     OUString     maEvenFooter;           /// Footer string for even pages.
      42             :     OUString     maFirstHeader;          /// Header string for first page of the sheet.
      43             :     OUString     maFirstFooter;          /// Footer string for first page of the sheet.
      44             :     double              mfLeftMargin;           /// Margin between left edge of page and begin of sheet area.
      45             :     double              mfRightMargin;          /// Margin between end of sheet area and right edge of page.
      46             :     double              mfTopMargin;            /// Margin between top egde of page and begin of sheet area.
      47             :     double              mfBottomMargin;         /// Margin between end of sheet area and bottom edge of page.
      48             :     double              mfHeaderMargin;         /// Margin between top edge of page and begin of header.
      49             :     double              mfFooterMargin;         /// Margin between end of footer and bottom edge of page.
      50             :     sal_Int32           mnPaperSize;            /// Paper size (enumeration).
      51             :     sal_Int32           mnPaperWidth;           /// Paper width in twips
      52             :     sal_Int32           mnPaperHeight;          /// Paper height in twips
      53             :     sal_Int32           mnCopies;               /// Number of copies to print.
      54             :     sal_Int32           mnScale;                /// Page scale (zoom in percent).
      55             :     sal_Int32           mnFirstPage;            /// First page number.
      56             :     sal_Int32           mnFitToWidth;           /// Fit to number of pages in horizontal direction.
      57             :     sal_Int32           mnFitToHeight;          /// Fit to number of pages in vertical direction.
      58             :     sal_Int32           mnHorPrintRes;          /// Horizontal printing resolution in DPI.
      59             :     sal_Int32           mnVerPrintRes;          /// Vertical printing resolution in DPI.
      60             :     sal_Int32           mnOrientation;          /// Landscape or portrait.
      61             :     sal_Int32           mnPageOrder;            /// Page order through sheet area (to left or down).
      62             :     sal_Int32           mnCellComments;         /// Cell comments printing mode.
      63             :     sal_Int32           mnPrintErrors;          /// Cell error printing mode.
      64             :     bool                mbUseEvenHF;            /// True = use maEvenHeader/maEvenFooter.
      65             :     bool                mbUseFirstHF;           /// True = use maFirstHeader/maFirstFooter.
      66             :     bool                mbValidSettings;        /// True = use imported settings.
      67             :     bool                mbUseFirstPage;         /// True = start page numbering with mnFirstPage.
      68             :     bool                mbBlackWhite;           /// True = print black and white.
      69             :     bool                mbDraftQuality;         /// True = print in draft quality.
      70             :     bool                mbFitToPages;           /// True = Fit to width/height; false = scale in percent.
      71             :     bool                mbHorCenter;            /// True = horizontally centered.
      72             :     bool                mbVerCenter;            /// True = vertically centered.
      73             :     bool                mbPrintGrid;            /// True = print grid lines.
      74             :     bool                mbPrintHeadings;        /// True = print column/row headings.
      75             : 
      76             :     explicit            PageSettingsModel();
      77             : 
      78             :     /** Sets the BIFF print errors mode. */
      79             :     void                setBiffPrintErrors( sal_uInt8 nPrintErrors );
      80             : };
      81             : 
      82         269 : class PageSettings : public WorksheetHelper
      83             : {
      84             : public:
      85             :     explicit            PageSettings( const WorksheetHelper& rHelper );
      86             : 
      87             :     /** Imports printing options from a printOptions element. */
      88             :     void                importPrintOptions( const AttributeList& rAttribs );
      89             :     /** Imports pageMarings element containing page margins. */
      90             :     void                importPageMargins( const AttributeList& rAttribs );
      91             :     /** Imports pageSetup element for worksheets. */
      92             :     void                importPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
      93             :     /** Imports pageSetup element for chart sheets. */
      94             :     void                importChartPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
      95             :     /** Imports header and footer settings from a headerFooter element. */
      96             :     void                importHeaderFooter( const AttributeList& rAttribs );
      97             :     /** Imports header/footer characters from a headerFooter element. */
      98             :     void                importHeaderFooterCharacters( const OUString& rChars, sal_Int32 nElement );
      99             :     /** Imports the picture element. */
     100             :     void                importPicture( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
     101             : 
     102             :     /** Imports the PRINTOPTIONS record from the passed stream. */
     103             :     void                importPrintOptions( SequenceInputStream& rStrm );
     104             :     /** Imports the PAGEMARGINS record from the passed stream. */
     105             :     void                importPageMargins( SequenceInputStream& rStrm );
     106             :     /** Imports the PAGESETUP record from the passed stream. */
     107             :     void                importPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
     108             :     /** Imports the CHARTPAGESETUP record from the passed stream. */
     109             :     void                importChartPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
     110             :     /** Imports the HEADERFOOTER record from the passed stream. */
     111             :     void                importHeaderFooter( SequenceInputStream& rStrm );
     112             :     /** Imports the PICTURE record from the passed stream. */
     113             :     void                importPicture( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
     114             : 
     115             :     /** Sets whether percentual scaling or fit to width/height scaling is used. */
     116             :     void                setFitToPagesMode( bool bFitToPages );
     117             : 
     118             :     /** Creates a page style for the spreadsheet and sets all page properties. */
     119             :     void                finalizeImport();
     120             : 
     121             : private:
     122             :     /** Imports the binary picture data from the fragment with the passed identifier. */
     123             :     void                importPictureData( const ::oox::core::Relations& rRelations, const OUString& rRelId );
     124             : 
     125             : private:
     126             :     PageSettingsModel   maModel;
     127             : };
     128             : 
     129             : class PageSettingsConverter : public WorkbookHelper
     130             : {
     131             : public:
     132             :     explicit            PageSettingsConverter( const WorkbookHelper& rHelper );
     133             :     virtual             ~PageSettingsConverter();
     134             : 
     135             :     /** Writes all properties to the passed property set of a page style object. */
     136             :     void                writePageSettingsProperties(
     137             :                             PropertySet& rPropSet,
     138             :                             const PageSettingsModel& rModel,
     139             :                             WorksheetType eSheetType );
     140             : 
     141             : private:
     142             :     struct HFHelperData
     143             :     {
     144             :         sal_Int32           mnLeftPropId;
     145             :         sal_Int32           mnRightPropId;
     146             :         sal_Int32           mnHeight;
     147             :         sal_Int32           mnBodyDist;
     148             :         bool                mbHasContent;
     149             :         bool                mbShareOddEven;
     150             :         bool                mbDynamicHeight;
     151             : 
     152             :         explicit            HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId );
     153             :     };
     154             : 
     155             : private:
     156             :     void                convertHeaderFooterData(
     157             :                             PropertySet& rPropSet,
     158             :                             HFHelperData& orHFData,
     159             :                             const OUString& rOddContent,
     160             :                             const OUString& rEvenContent,
     161             :                             bool bUseEvenContent,
     162             :                             double fPageMargin,
     163             :                             double fContentMargin );
     164             : 
     165             :     sal_Int32           writeHeaderFooter(
     166             :                             PropertySet& rPropSet,
     167             :                             sal_Int32 nPropId,
     168             :                             const OUString& rContent );
     169             : 
     170             : private:
     171             :     typedef ::std::unique_ptr< HeaderFooterParser > HeaderFooterParserPtr;
     172             :     HeaderFooterParserPtr mxHFParser;
     173             :     HFHelperData        maHeaderData;
     174             :     HFHelperData        maFooterData;
     175             : };
     176             : 
     177             : } // namespace xls
     178             : } // namespace oox
     179             : 
     180             : #endif
     181             : 
     182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11