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

Generated by: LCOV version 1.10