LibreOffice Module sc (master)  1
pagesettings.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include <memory>
23 #include <string_view>
24 
25 #include "worksheethelper.hxx"
26 
27 namespace oox { class AttributeList; }
28 namespace oox { class PropertySet; }
29 namespace oox::core { class Relations; }
30 
31 namespace oox::xls {
32 
33 class HeaderFooterParser;
34 
37 {
38  css::uno::Reference<css::graphic::XGraphic> mxGraphic;
39  OUString maBinSettPath;
40  OUString maOddHeader;
41  OUString maOddFooter;
42  OUString maEvenHeader;
43  OUString maEvenFooter;
44  OUString maFirstHeader;
45  OUString maFirstFooter;
46  double mfLeftMargin;
47  double mfRightMargin;
48  double mfTopMargin;
49  double mfBottomMargin;
50  double mfHeaderMargin;
51  double mfFooterMargin;
52  sal_Int32 mnPaperSize;
53  sal_Int32 mnPaperWidth;
54  sal_Int32 mnPaperHeight;
55  sal_Int32 mnCopies;
56  sal_Int32 mnScale;
57  sal_Int32 mnFirstPage;
58  sal_Int32 mnFitToWidth;
59  sal_Int32 mnFitToHeight;
60  sal_Int32 mnHorPrintRes;
61  sal_Int32 mnVerPrintRes;
62  sal_Int32 mnOrientation;
63  sal_Int32 mnPageOrder;
64  sal_Int32 mnCellComments;
65  sal_Int32 mnPrintErrors;
66  bool mbUseEvenHF;
67  bool mbUseFirstHF;
70  bool mbBlackWhite;
72  bool mbFitToPages;
73  bool mbHorCenter;
74  bool mbVerCenter;
75  bool mbPrintGrid;
77 
78  explicit PageSettingsModel();
79 
81  void setBiffPrintErrors( sal_uInt8 nPrintErrors );
82 };
83 
85 {
86 public:
87  explicit PageSettings( const WorksheetHelper& rHelper );
88 
90  void importPrintOptions( const AttributeList& rAttribs );
92  void importPageMargins( const AttributeList& rAttribs );
94  void importPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
96  void importChartPageSetup( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
98  void importHeaderFooter( const AttributeList& rAttribs );
101  std::u16string_view rChars, sal_Int32 nElement );
103  void importPicture( const ::oox::core::Relations& rRelations, const AttributeList& rAttribs );
104 
108  void importPageMargins( SequenceInputStream& rStrm );
110  void importPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
112  void importChartPageSetup( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
116  void importPicture( const ::oox::core::Relations& rRelations, SequenceInputStream& rStrm );
117 
119  void setFitToPagesMode( bool bFitToPages );
120 
122  void finalizeImport();
123 
124 private:
126  void importPictureData( const ::oox::core::Relations& rRelations, const OUString& rRelId );
127 
128 private:
130 };
131 
133 {
134 public:
135  explicit PageSettingsConverter( const WorkbookHelper& rHelper );
136  virtual ~PageSettingsConverter() override;
137 
140  PropertySet& rPropSet,
141  const PageSettingsModel& rModel,
142  WorksheetType eSheetType );
143 
144 private:
146  {
147  sal_Int32 mnLeftPropId;
148  sal_Int32 mnRightPropId;
149  sal_Int32 mnFirstPropId;
150  sal_Int32 mnHeight;
151  sal_Int32 mnBodyDist;
156 
157  explicit HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId, sal_Int32 nFirstPropId );
158  };
159 
160 private:
162  PropertySet& rPropSet,
163  HFHelperData& orHFData,
164  const OUString& rOddContent,
165  const OUString& rEvenContent,
166  const OUString& rFirstContent,
167  bool bUseEvenContent,
168  bool bUseFirstContent,
169  double fPageMargin,
170  double fContentMargin );
171 
172  sal_Int32 writeHeaderFooter(
173  PropertySet& rPropSet,
174  sal_Int32 nPropId,
175  const OUString& rContent );
176 
177 private:
178  typedef ::std::unique_ptr< HeaderFooterParser > HeaderFooterParserPtr;
179  HeaderFooterParserPtr mxHFParser;
182 };
183 
184 } // namespace oox::xls
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
bool mbHorCenter
True = Fit to width/height; false = scale in percent.
sal_Int32 mnHorPrintRes
Fit to number of pages in vertical direction.
sal_Int32 mnPrintErrors
Cell comments printing mode.
OUString maFirstFooter
Header string for first page of the sheet.
OUString maBinSettPath
Background Graphic.
sal_Int32 mnCopies
Paper height in twips.
PageSettings(const WorksheetHelper &rHelper)
sal_Int32 mnFitToWidth
First page number.
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
bool mbVerCenter
True = horizontally centered.
void convertHeaderFooterData(PropertySet &rPropSet, HFHelperData &orHFData, const OUString &rOddContent, const OUString &rEvenContent, const OUString &rFirstContent, bool bUseEvenContent, bool bUseFirstContent, double fPageMargin, double fContentMargin)
OUString maEvenHeader
Footer string for odd pages.
sal_Int32 mnFirstPage
Page scale (zoom in percent).
css::uno::Reference< css::graphic::XGraphic > mxGraphic
bool mbPrintGrid
True = vertically centered.
OUString maOddHeader
Relation identifier of binary printer settings.
bool mbBlackWhite
True = start page numbering with mnFirstPage.
sal_Int32 mnFitToHeight
Fit to number of pages in horizontal direction.
void importPicture(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports the picture element.
sal_Int32 mnCellComments
Page order through sheet area (to left or down).
HeaderFooterParserPtr mxHFParser
void importPrintOptions(const AttributeList &rAttribs)
Imports printing options from a printOptions element.
double mfHeaderMargin
Margin between end of sheet area and bottom edge of page.
Holds page style data for a single sheet.
PageSettingsConverter(const WorkbookHelper &rHelper)
OUString maEvenFooter
Header string for even pages.
void importHeaderFooterCharacters(std::u16string_view rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
bool mbUseEvenHF
Cell error printing mode.
double mfFooterMargin
Margin between top edge of page and begin of header.
double mfRightMargin
Margin between left edge of page and begin of sheet area.
sal_Int32 mnPageOrder
Landscape or portrait.
double mfLeftMargin
Footer string for first page of the sheet.
sal_Int32 mnPaperWidth
Paper size (enumeration).
void setBiffPrintErrors(sal_uInt8 nPrintErrors)
Sets the BIFF print errors mode.
bool mbUseFirstHF
True = use maEvenHeader/maEvenFooter.
sal_Int32 mnPaperHeight
Paper width in twips.
OUString maOddFooter
Header string for odd pages.
PageSettingsModel maModel
double mfTopMargin
Margin between end of sheet area and right edge of page.
bool mbValidSettings
True = use maFirstHeader/maFirstFooter.
sal_Int32 mnScale
Number of copies to print.
bool mbFitToPages
True = print in draft quality.
void finalizeImport()
Creates a page style for the spreadsheet and sets all page properties.
unsigned char sal_uInt8
void importPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for worksheets.
sal_Int32 mnOrientation
Vertical printing resolution in DPI.
virtual ~PageSettingsConverter() override
bool mbPrintHeadings
True = print grid lines.
void importPageMargins(const AttributeList &rAttribs)
Imports pageMarings element containing page margins.
void importChartPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for chart sheets.
HFHelperData(sal_Int32 nLeftPropId, sal_Int32 nRightPropId, sal_Int32 nFirstPropId)
sal_Int32 mnPaperSize
Margin between end of footer and bottom edge of page.
void writePageSettingsProperties(PropertySet &rPropSet, const PageSettingsModel &rModel, WorksheetType eSheetType)
Writes all properties to the passed property set of a page style object.
bool mbDraftQuality
True = print black and white.
sal_Int32 writeHeaderFooter(PropertySet &rPropSet, sal_Int32 nPropId, const OUString &rContent)
::std::unique_ptr< HeaderFooterParser > HeaderFooterParserPtr
void setFitToPagesMode(bool bFitToPages)
Sets whether percentual scaling or fit to width/height scaling is used.
PageSettingsModel()
True = print column/row headings.
WorksheetType
An enumeration for all types of sheets in a workbook.
void SvStream & rStrm
bool mbUseFirstPage
True = use imported settings.
sal_Int32 mnVerPrintRes
Horizontal printing resolution in DPI.
OUString maFirstHeader
Footer string for even pages.
void importPictureData(const ::oox::core::Relations &rRelations, const OUString &rRelId)
Imports the binary picture data from the fragment with the passed identifier.
double mfBottomMargin
Margin between top edge of page and begin of sheet area.