Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / pagesettings.hxx
blob41b876d26480cc9d3cd63642605a3d8a417ca59a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_PAGESETTINGS_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_PAGESETTINGS_HXX
23 #include <memory>
24 #include "worksheethelper.hxx"
26 namespace oox { class AttributeList; }
27 namespace oox { class PropertySet; }
28 namespace oox { namespace core { class Relations; } }
30 namespace oox {
31 namespace xls {
33 class HeaderFooterParser;
35 /** Holds page style data for a single sheet. */
36 struct PageSettingsModel
38 css::uno::Reference<css::graphic::XGraphic> mxGraphic; /// Background Graphic
39 OUString maBinSettPath; /// Relation identifier of binary printer settings.
40 OUString maOddHeader; /// Header string for odd pages.
41 OUString maOddFooter; /// Footer string for odd pages.
42 OUString maEvenHeader; /// Header string for even pages.
43 OUString maEvenFooter; /// Footer string for even pages.
44 OUString maFirstHeader; /// Header string for first page of the sheet.
45 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 edge 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.
78 explicit PageSettingsModel();
80 /** Sets the BIFF print errors mode. */
81 void setBiffPrintErrors( sal_uInt8 nPrintErrors );
84 class PageSettings : public WorksheetHelper
86 public:
87 explicit PageSettings( const WorksheetHelper& rHelper );
89 /** Imports printing options from a printOptions element. */
90 void importPrintOptions( const AttributeList& rAttribs );
91 /** Imports pageMarings element containing page margins. */
92 void importPageMargins( const AttributeList& rAttribs );
93 /** Imports pageSetup element for worksheets. */
94 void importPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
95 /** Imports pageSetup element for chart sheets. */
96 void importChartPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
97 /** Imports header and footer settings from a headerFooter element. */
98 void importHeaderFooter( const AttributeList& rAttribs );
99 /** Imports header/footer characters from a headerFooter element. */
100 void importHeaderFooterCharacters( const OUString& rChars, sal_Int32 nElement );
101 /** Imports the picture element. */
102 void importPicture( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
104 /** Imports the PRINTOPTIONS record from the passed stream. */
105 void importPrintOptions( SequenceInputStream& rStrm );
106 /** Imports the PAGEMARGINS record from the passed stream. */
107 void importPageMargins( SequenceInputStream& rStrm );
108 /** Imports the PAGESETUP record from the passed stream. */
109 void importPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
110 /** Imports the CHARTPAGESETUP record from the passed stream. */
111 void importChartPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
112 /** Imports the HEADERFOOTER record from the passed stream. */
113 void importHeaderFooter( SequenceInputStream& rStrm );
114 /** Imports the PICTURE record from the passed stream. */
115 void importPicture( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
117 /** Sets whether percentual scaling or fit to width/height scaling is used. */
118 void setFitToPagesMode( bool bFitToPages );
120 /** Creates a page style for the spreadsheet and sets all page properties. */
121 void finalizeImport();
123 private:
124 /** Imports the binary picture data from the fragment with the passed identifier. */
125 void importPictureData( const ::oox::core::Relations& rRelations, const OUString& rRelId );
127 private:
128 PageSettingsModel maModel;
131 class PageSettingsConverter : public WorkbookHelper
133 public:
134 explicit PageSettingsConverter( const WorkbookHelper& rHelper );
135 virtual ~PageSettingsConverter() override;
137 /** Writes all properties to the passed property set of a page style object. */
138 void writePageSettingsProperties(
139 PropertySet& rPropSet,
140 const PageSettingsModel& rModel,
141 WorksheetType eSheetType );
143 private:
144 struct HFHelperData
146 sal_Int32 const mnLeftPropId;
147 sal_Int32 const mnRightPropId;
148 sal_Int32 mnHeight;
149 sal_Int32 mnBodyDist;
150 bool mbHasContent;
151 bool mbShareOddEven;
152 bool mbDynamicHeight;
154 explicit HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId );
157 private:
158 void convertHeaderFooterData(
159 PropertySet& rPropSet,
160 HFHelperData& orHFData,
161 const OUString& rOddContent,
162 const OUString& rEvenContent,
163 bool bUseEvenContent,
164 double fPageMargin,
165 double fContentMargin );
167 sal_Int32 writeHeaderFooter(
168 PropertySet& rPropSet,
169 sal_Int32 nPropId,
170 const OUString& rContent );
172 private:
173 typedef ::std::unique_ptr< HeaderFooterParser > HeaderFooterParserPtr;
174 HeaderFooterParserPtr mxHFParser;
175 HFHelperData maHeaderData;
176 HFHelperData maFooterData;
179 } // namespace xls
180 } // namespace oox
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */