LibreOffice Module sc (master) 1
pagesettings.cxx
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#include <pagesettings.hxx>
21
22#include <algorithm>
23#include <set>
24#include <com/sun/star/awt/Size.hpp>
25#include <com/sun/star/container/XNamed.hpp>
26#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
27#include <com/sun/star/sheet/XSpreadsheet.hpp>
28#include <com/sun/star/style/GraphicLocation.hpp>
29#include <com/sun/star/style/XStyle.hpp>
30#include <com/sun/star/text/FilenameDisplayFormat.hpp>
31#include <com/sun/star/text/XText.hpp>
32#include <com/sun/star/text/XTextCursor.hpp>
33#include <com/sun/star/lang/XMultiServiceFactory.hpp>
34#include <osl/diagnose.h>
35#include <rtl/strbuf.hxx>
36#include <rtl/ustrbuf.hxx>
43#include <oox/token/namespaces.hxx>
44#include <oox/token/properties.hxx>
45#include <oox/token/tokens.hxx>
48#include <stylesbuffer.hxx>
49#include <document.hxx>
50#include <biffhelper.hxx>
52#include <o3tl/string_view.hxx>
53
54namespace oox::xls {
55
56using namespace ::com::sun::star;
57using namespace ::com::sun::star::lang;
58using namespace ::com::sun::star::uno;
59
60using ::oox::core::Relations;
61
62namespace {
63
64const double OOX_MARGIN_DEFAULT_LR = 0.748;
65const double OOX_MARGIN_DEFAULT_TB = 0.984;
66const double OOX_MARGIN_DEFAULT_HF = 0.512;
67
68const sal_uInt16 BIFF12_PRINTOPT_HORCENTER = 0x0001;
69const sal_uInt16 BIFF12_PRINTOPT_VERCENTER = 0x0002;
70const sal_uInt16 BIFF12_PRINTOPT_PRINTHEADING = 0x0004;
71const sal_uInt16 BIFF12_PRINTOPT_PRINTGRID = 0x0008;
72
73const sal_uInt16 BIFF12_HEADERFOOTER_DIFFEVEN = 0x0001;
74const sal_uInt16 BIFF12_HEADERFOOTER_DIFFFIRST = 0x0002;
75
76const sal_uInt16 BIFF12_PAGESETUP_INROWS = 0x0001;
77const sal_uInt16 BIFF12_PAGESETUP_LANDSCAPE = 0x0002;
78const sal_uInt16 BIFF12_PAGESETUP_INVALID = 0x0004;
79const sal_uInt16 BIFF12_PAGESETUP_BLACKWHITE = 0x0008;
80const sal_uInt16 BIFF12_PAGESETUP_DRAFTQUALITY = 0x0010;
81const sal_uInt16 BIFF12_PAGESETUP_PRINTNOTES = 0x0020;
82const sal_uInt16 BIFF12_PAGESETUP_DEFAULTORIENT = 0x0040;
83const sal_uInt16 BIFF12_PAGESETUP_USEFIRSTPAGE = 0x0080;
84const sal_uInt16 BIFF12_PAGESETUP_NOTES_END = 0x0100; // different to BIFF flag
85
86const sal_uInt16 BIFF12_CHARTPAGESETUP_LANDSCAPE = 0x0001;
87const sal_uInt16 BIFF12_CHARTPAGESETUP_INVALID = 0x0002;
88const sal_uInt16 BIFF12_CHARTPAGESETUP_BLACKWHITE = 0x0004;
89const sal_uInt16 BIFF12_CHARTPAGESETUP_DEFAULTORIENT= 0x0008;
90const sal_uInt16 BIFF12_CHARTPAGESETUP_USEFIRSTPAGE = 0x0010;
91const sal_uInt16 BIFF12_CHARTPAGESETUP_DRAFTQUALITY = 0x0020;
92
93} // namespace
94
96 mfLeftMargin( OOX_MARGIN_DEFAULT_LR ),
97 mfRightMargin( OOX_MARGIN_DEFAULT_LR ),
98 mfTopMargin( OOX_MARGIN_DEFAULT_TB ),
99 mfBottomMargin( OOX_MARGIN_DEFAULT_TB ),
100 mfHeaderMargin( OOX_MARGIN_DEFAULT_HF ),
101 mfFooterMargin( OOX_MARGIN_DEFAULT_HF ),
102 mnPaperSize( 1 ),
103 mnPaperWidth( 0 ),
104 mnPaperHeight( 0 ),
105 mnCopies( 1 ),
106 mnScale( 100 ),
107 mnFirstPage( 1 ),
108 mnFitToWidth( 1 ),
109 mnFitToHeight( 1 ),
110 mnHorPrintRes( 600 ),
111 mnVerPrintRes( 600 ),
112 mnOrientation( XML_default ),
113 mnPageOrder( XML_downThenOver ),
114 mnCellComments( XML_none ),
115 mnPrintErrors( XML_displayed ),
116 mbUseEvenHF( false ),
117 mbUseFirstHF( false ),
118 mbValidSettings( true ),
119 mbUseFirstPage( false ),
120 mbBlackWhite( false ),
121 mbDraftQuality( false ),
122 mbFitToPages( false ),
123 mbHorCenter( false ),
124 mbVerCenter( false ),
125 mbPrintGrid( false ),
126 mbPrintHeadings( false )
127{
128}
129
131{
132 static const sal_Int32 spnErrorIds[] = { XML_displayed, XML_none, XML_dash, XML_NA };
133 mnPrintErrors = STATIC_ARRAY_SELECT( spnErrorIds, nPrintErrors, XML_none );
134}
135
137 WorksheetHelper( rHelper )
138{
139}
140
142{
143 maModel.mbHorCenter = rAttribs.getBool( XML_horizontalCentered, false );
144 maModel.mbVerCenter = rAttribs.getBool( XML_verticalCentered, false );
145 maModel.mbPrintGrid = rAttribs.getBool( XML_gridLines, false );
146 maModel.mbPrintHeadings = rAttribs.getBool( XML_headings, false );
147}
148
150{
151 maModel.mfLeftMargin = rAttribs.getDouble( XML_left, OOX_MARGIN_DEFAULT_LR );
152 maModel.mfRightMargin = rAttribs.getDouble( XML_right, OOX_MARGIN_DEFAULT_LR );
153 maModel.mfTopMargin = rAttribs.getDouble( XML_top, OOX_MARGIN_DEFAULT_TB );
154 maModel.mfBottomMargin = rAttribs.getDouble( XML_bottom, OOX_MARGIN_DEFAULT_TB );
155 maModel.mfHeaderMargin = rAttribs.getDouble( XML_header, OOX_MARGIN_DEFAULT_HF );
156 maModel.mfFooterMargin = rAttribs.getDouble( XML_footer, OOX_MARGIN_DEFAULT_HF );
157}
158
159void PageSettings::importPageSetup( const Relations& rRelations, const AttributeList& rAttribs )
160{
161 OUString aStr;
162 maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
163 maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 );
164 aStr = rAttribs.getString ( XML_paperWidth, OUString() );
166 maModel.mnPaperWidth, aStr);
167 aStr = rAttribs.getString ( XML_paperHeight, OUString() );
169 maModel.mnPaperHeight, aStr );
170 maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 );
171 maModel.mnScale = rAttribs.getInteger( XML_scale, 100 );
172 maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 );
173 maModel.mnFitToWidth = rAttribs.getInteger( XML_fitToWidth, 1 );
174 maModel.mnFitToHeight = rAttribs.getInteger( XML_fitToHeight, 1 );
175 maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 );
176 maModel.mnVerPrintRes = rAttribs.getInteger( XML_verticalDpi, 600 );
177 maModel.mnOrientation = rAttribs.getToken( XML_orientation, XML_default );
178 maModel.mnPageOrder = rAttribs.getToken( XML_pageOrder, XML_downThenOver );
179 maModel.mnCellComments = rAttribs.getToken( XML_cellComments, XML_none );
180 maModel.mnPrintErrors = rAttribs.getToken( XML_errors, XML_displayed );
181 maModel.mbValidSettings = rAttribs.getBool( XML_usePrinterDefaults, false );
182 maModel.mbUseFirstPage = rAttribs.getBool( XML_useFirstPageNumber, false );
183 maModel.mbBlackWhite = rAttribs.getBool( XML_blackAndWhite, false );
184 maModel.mbDraftQuality = rAttribs.getBool( XML_draft, false );
185}
186
187void PageSettings::importChartPageSetup( const Relations& rRelations, const AttributeList& rAttribs )
188{
189 OUString aStr;
190 maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
191 maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 );
192 aStr = rAttribs.getString ( XML_paperWidth, OUString() );
194 maModel.mnPaperWidth, aStr );
195 aStr = rAttribs.getString ( XML_paperHeight, OUString() );
197 maModel.mnPaperHeight, aStr );
198 maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 );
199 maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 );
200 maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 );
201 maModel.mnVerPrintRes = rAttribs.getInteger( XML_verticalDpi, 600 );
202 maModel.mnOrientation = rAttribs.getToken( XML_orientation, XML_default );
203 maModel.mbValidSettings = rAttribs.getBool( XML_usePrinterDefaults, false );
204 maModel.mbUseFirstPage = rAttribs.getBool( XML_useFirstPageNumber, false );
205 maModel.mbBlackWhite = rAttribs.getBool( XML_blackAndWhite, false );
206 maModel.mbDraftQuality = rAttribs.getBool( XML_draft, false );
207}
208
210{
211 maModel.mbUseEvenHF = rAttribs.getBool( XML_differentOddEven, false );
212 maModel.mbUseFirstHF = rAttribs.getBool( XML_differentFirst, false );
213}
214
215void PageSettings::importHeaderFooterCharacters( std::u16string_view rChars, sal_Int32 nElement )
216{
217 switch( nElement )
218 {
219 case XLS_TOKEN( oddHeader ): maModel.maOddHeader += rChars; break;
220 case XLS_TOKEN( oddFooter ): maModel.maOddFooter += rChars; break;
221 case XLS_TOKEN( evenHeader ): maModel.maEvenHeader += rChars; break;
222 case XLS_TOKEN( evenFooter ): maModel.maEvenFooter += rChars; break;
223 case XLS_TOKEN( firstHeader ): maModel.maFirstHeader += rChars; break;
224 case XLS_TOKEN( firstFooter ): maModel.maFirstFooter += rChars; break;
225 }
226}
227
228void PageSettings::importPicture( const Relations& rRelations, const AttributeList& rAttribs )
229{
230 importPictureData( rRelations, rAttribs.getString( R_TOKEN( id ), OUString() ) );
231}
232
234{
235 maModel.mfLeftMargin = rStrm.readDouble();
236 maModel.mfRightMargin = rStrm.readDouble();
237 maModel.mfTopMargin = rStrm.readDouble();
238 maModel.mfBottomMargin = rStrm.readDouble();
239 maModel.mfHeaderMargin = rStrm.readDouble();
240 maModel.mfFooterMargin = rStrm.readDouble();
241}
242
244{
245 sal_uInt16 nFlags;
246 nFlags = rStrm.readuInt16();
247 maModel.mbHorCenter = getFlag( nFlags, BIFF12_PRINTOPT_HORCENTER );
248 maModel.mbVerCenter = getFlag( nFlags, BIFF12_PRINTOPT_VERCENTER );
249 maModel.mbPrintGrid = getFlag( nFlags, BIFF12_PRINTOPT_PRINTGRID );
250 maModel.mbPrintHeadings = getFlag( nFlags, BIFF12_PRINTOPT_PRINTHEADING );
251}
252
253void PageSettings::importPageSetup( const Relations& rRelations, SequenceInputStream& rStrm )
254{
255 OUString aRelId;
256 sal_uInt16 nFlags;
257 maModel.mnPaperSize = rStrm.readInt32();
258 maModel.mnScale = rStrm.readInt32();
259 maModel.mnHorPrintRes = rStrm.readInt32();
260 maModel.mnVerPrintRes = rStrm.readInt32();
261 maModel.mnCopies = rStrm.readInt32();
262 maModel.mnFirstPage = rStrm.readInt32();
263 maModel.mnFitToWidth = rStrm.readInt32();
264 maModel.mnFitToHeight = rStrm.readInt32();
265 nFlags = rStrm.readuInt16();
266 rStrm >> aRelId;
267 maModel.setBiffPrintErrors( extractValue< sal_uInt8 >( nFlags, 9, 2 ) );
268 maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( aRelId );
269 maModel.mnOrientation = getFlagValue( nFlags, BIFF12_PAGESETUP_DEFAULTORIENT, XML_default, getFlagValue( nFlags, BIFF12_PAGESETUP_LANDSCAPE, XML_landscape, XML_portrait ) );
270 maModel.mnPageOrder = getFlagValue( nFlags, BIFF12_PAGESETUP_INROWS, XML_overThenDown, XML_downThenOver );
271 maModel.mnCellComments = getFlagValue( nFlags, BIFF12_PAGESETUP_PRINTNOTES, getFlagValue( nFlags, BIFF12_PAGESETUP_NOTES_END, XML_atEnd, XML_asDisplayed ), XML_none );
272 maModel.mbValidSettings = !getFlag( nFlags, BIFF12_PAGESETUP_INVALID );
273 maModel.mbUseFirstPage = getFlag( nFlags, BIFF12_PAGESETUP_USEFIRSTPAGE );
274 maModel.mbBlackWhite = getFlag( nFlags, BIFF12_PAGESETUP_BLACKWHITE );
275 maModel.mbDraftQuality = getFlag( nFlags, BIFF12_PAGESETUP_DRAFTQUALITY );
276}
277
278void PageSettings::importChartPageSetup( const Relations& rRelations, SequenceInputStream& rStrm )
279{
280 OUString aRelId;
281 sal_uInt16 nFirstPage, nFlags;
282 maModel.mnPaperSize = rStrm.readInt32();
283 maModel.mnHorPrintRes = rStrm.readInt32();
284 maModel.mnVerPrintRes = rStrm.readInt32();
285 maModel.mnCopies = rStrm.readInt32();
286 nFirstPage = rStrm.readuInt16();
287 nFlags = rStrm.readuInt16();
288 rStrm >> aRelId;
289 maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( aRelId );
290 maModel.mnFirstPage = nFirstPage; // 16-bit in CHARTPAGESETUP
291 maModel.mnOrientation = getFlagValue( nFlags, BIFF12_CHARTPAGESETUP_DEFAULTORIENT, XML_default, getFlagValue( nFlags, BIFF12_CHARTPAGESETUP_LANDSCAPE, XML_landscape, XML_portrait ) );
292 maModel.mbValidSettings = !getFlag( nFlags, BIFF12_CHARTPAGESETUP_INVALID );
293 maModel.mbUseFirstPage = getFlag( nFlags, BIFF12_CHARTPAGESETUP_USEFIRSTPAGE );
294 maModel.mbBlackWhite = getFlag( nFlags, BIFF12_CHARTPAGESETUP_BLACKWHITE );
295 maModel.mbDraftQuality = getFlag( nFlags, BIFF12_CHARTPAGESETUP_DRAFTQUALITY );
296}
297
299{
300 sal_uInt16 nFlags;
301 nFlags = rStrm.readuInt16();
305 maModel.mbUseEvenHF = getFlag( nFlags, BIFF12_HEADERFOOTER_DIFFEVEN );
306 maModel.mbUseFirstHF = getFlag( nFlags, BIFF12_HEADERFOOTER_DIFFFIRST );
307}
308
309void PageSettings::importPicture( const Relations& rRelations, SequenceInputStream& rStrm )
310{
311 importPictureData( rRelations, BiffHelper::readString( rStrm ) );
312}
313
314void PageSettings::setFitToPagesMode( bool bFitToPages )
315{
316 maModel.mbFitToPages = bFitToPages;
317}
318
320{
321 OUStringBuffer aStyleNameBuffer( "PageStyle_" );
322 Reference<container::XNamed> xSheetName(getSheet(), UNO_QUERY);
323 if( xSheetName.is() )
324 aStyleNameBuffer.append( xSheetName->getName() );
325 else
326 aStyleNameBuffer.append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) );
327 OUString aStyleName = aStyleNameBuffer.makeStringAndClear();
328
329 Reference<style::XStyle> xStyle = createStyleObject(aStyleName, true);
330 PropertySet aStyleProps( xStyle );
332
333 // Set page style name to the sheet.
334 SCTAB nTab = getSheetIndex();
335 getScDocument().SetPageStyle(nTab, aStyleName);
336}
337
338void PageSettings::importPictureData( const Relations& rRelations, const OUString& rRelId )
339{
340 OUString aPicturePath = rRelations.getFragmentPathFromRelId(rRelId);
341 if (!aPicturePath.isEmpty())
342 {
344 }
345}
346
347namespace {
348
349enum HFPortionId
350{
351 HF_LEFT,
352 HF_CENTER,
353 HF_RIGHT,
354 HF_COUNT
355};
356
357struct HFPortionInfo
358{
359 Reference<text::XText> mxText;
360 Reference<text::XTextCursor> mxStart;
361 Reference<text::XTextCursor> mxEnd;
364
365 bool initialize( const Reference<text::XText>& rxText );
366};
367
368}
369
370bool HFPortionInfo::initialize( const Reference<text::XText>& rxText )
371{
373 mxText = rxText;
374 if( mxText.is() )
375 {
376 mxStart = mxText->createTextCursor();
377 mxEnd = mxText->createTextCursor();
378 }
379 bool bRet = mxText.is() && mxStart.is() && mxEnd.is();
380 OSL_ENSURE( bRet, "HFPortionInfo::initialize - missing interfaces" );
381 return bRet;
382}
383
385{
386public:
387 explicit HeaderFooterParser( const WorkbookHelper& rHelper );
388
391 double parse(
392 const Reference<sheet::XHeaderFooterContent>& rxContext,
393 const OUString& rData );
394
395private:
397 HFPortionInfo& getPortion() { return maPortions[ meCurrPortion ]; }
399 const Reference<text::XTextCursor>& getStartPos() { return getPortion().mxStart; }
401 const Reference<text::XTextCursor>& getEndPos() { return getPortion().mxEnd; }
402
404 double getCurrHeight( HFPortionId ePortion ) const;
405
407 void updateCurrHeight( HFPortionId ePortion );
409 void updateCurrHeight();
410
412 void setAttributes();
414 void appendText();
416 void appendLineBreak();
417
419 Reference<text::XTextContent> createField( const OUString& rServiceName ) const;
421 void appendField( const Reference<text::XTextContent>& rxContent );
422
424 void convertFontName( const OUString& rStyle );
426 void convertFontStyle( std::u16string_view aStyle );
428 void convertFontColor( std::u16string_view aColor );
429
431 void finalizePortion();
433 void setNewPortion( HFPortionId ePortion );
434
435private:
436 typedef ::std::vector< HFPortionInfo > HFPortionInfoVec;
437
438 const std::set< OString > maBoldNames;
439 const std::set< OString > maItalicNames;
441 HFPortionId meCurrPortion;
442 OUStringBuffer maBuffer;
444};
445
446namespace {
447
448// different names for bold font style (lowercase)
449const char* const sppcBoldNames[] =
450{
451 "bold",
452 "fett", // German 'bold'
453 "demibold",
454 "halbfett", // German 'demibold'
455 "black",
456 "heavy",
457 "f\303\251lk\303\266v\303\251r" // Hungarian 'bold'
458};
459
460// different names for italic font style (lowercase)
461const char* const sppcItalicNames[] =
462{
463 "italic",
464 "kursiv", // German 'italic'
465 "oblique",
466 "schr\303\204g", // German 'oblique' with uppercase A umlaut
467 "schr\303\244g", // German 'oblique' with lowercase A umlaut
468 "d\305\221lt" // Hungarian 'italic'
469};
470
471} // namespace
472
473constexpr OUStringLiteral gaPageNumberService( u"com.sun.star.text.TextField.PageNumber" );
474constexpr OUStringLiteral gaPageCountService( u"com.sun.star.text.TextField.PageCount" );
475constexpr OUStringLiteral gaSheetNameService( u"com.sun.star.text.TextField.SheetName" );
476constexpr OUStringLiteral gaFileNameService( u"com.sun.star.text.TextField.FileName" );
477constexpr OUStringLiteral gaDateTimeService( u"com.sun.star.text.TextField.DateTime" );
478
480 WorkbookHelper( rHelper ),
481 maBoldNames( sppcBoldNames, sppcBoldNames + SAL_N_ELEMENTS(sppcBoldNames) ),
482 maItalicNames( sppcItalicNames, sppcItalicNames + SAL_N_ELEMENTS(sppcItalicNames) ),
483 maPortions( static_cast< size_t >( HF_COUNT ) ),
484 meCurrPortion( HF_CENTER )
485{
486}
487
488double HeaderFooterParser::parse( const Reference<sheet::XHeaderFooterContent>& rxContext, const OUString& rData )
489{
490 if( !rxContext.is() || rData.isEmpty() ||
491 !maPortions[ HF_LEFT ].initialize( rxContext->getLeftText() ) ||
492 !maPortions[ HF_CENTER ].initialize( rxContext->getCenterText() ) ||
493 !maPortions[ HF_RIGHT ].initialize( rxContext->getRightText() ) )
494 return 0.0;
495
496 meCurrPortion = HF_CENTER;
497 maBuffer.setLength( 0 );
499 OUStringBuffer aFontName; // current font name
500 OUStringBuffer aFontStyle; // current font style
501 sal_Int32 nFontHeight = 0; // current font height
502
504 enum
505 {
506 STATE_TEXT,
507 STATE_TOKEN,
508 STATE_FONTNAME,
509 STATE_FONTSTYLE,
510 STATE_FONTHEIGHT
511 }
512 eState = STATE_TEXT;
513
514 const sal_Unicode* pcChar = rData.getStr();
515 const sal_Unicode* pcEnd = pcChar + rData.getLength();
516 for( ; (pcChar != pcEnd) && (*pcChar != 0); ++pcChar )
517 {
518 sal_Unicode cChar = *pcChar;
519 switch( eState )
520 {
521 case STATE_TEXT:
522 {
523 switch( cChar )
524 {
525 case '&': // new token
526 appendText();
527 eState = STATE_TOKEN;
528 break;
529 case '\n': // line break
530 appendText();
532 break;
533 default:
534 maBuffer.append( cChar );
535 }
536 }
537 break;
538
539 case STATE_TOKEN:
540 {
541 // default: back to text mode, may be changed in specific cases
542 eState = STATE_TEXT;
543 // ignore case of token codes
544 if( ('a' <= cChar) && (cChar <= 'z') )
545 cChar = (cChar - 'a') + 'A';
546 switch( cChar )
547 {
548 case '&': maBuffer.append( cChar ); break; // the '&' character
549
550 case 'L': setNewPortion( HF_LEFT ); break; // left portion
551 case 'C': setNewPortion( HF_CENTER ); break; // center portion
552 case 'R': setNewPortion( HF_RIGHT ); break; // right portion
553
554 case 'P': // page number
556 break;
557 case 'N': // total page count
559 break;
560 case 'A': // current sheet name
562 break;
563
564 case 'F': // file name
565 {
566 Reference<text::XTextContent> xContent = createField( gaFileNameService );
567 PropertySet aPropSet( xContent );
568 aPropSet.setProperty( PROP_FileFormat, css::text::FilenameDisplayFormat::NAME_AND_EXT );
569 appendField( xContent );
570 }
571 break;
572 case 'Z': // file path (without file name), OOXML, BIFF12, and BIFF8 only
573 {
574 Reference<text::XTextContent> xContent = createField( gaFileNameService );
575 PropertySet aPropSet( xContent );
576 // FilenameDisplayFormat::PATH not supported by Calc
577 aPropSet.setProperty( PROP_FileFormat, css::text::FilenameDisplayFormat::FULL );
578 appendField( xContent );
579 /* path only is not supported -- if we find a '&Z&F'
580 combination for path/name, skip the '&F' part */
581 if( (pcChar + 2 < pcEnd) && (pcChar[ 1 ] == '&') && ((pcChar[ 2 ] == 'f') || (pcChar[ 2 ] == 'F')) )
582 pcChar += 2;
583 }
584 break;
585 case 'D': // date
586 {
587 Reference<text::XTextContent> xContent = createField( gaDateTimeService );
588 PropertySet aPropSet( xContent );
589 aPropSet.setProperty( PROP_IsDate, true );
590 appendField( xContent );
591 }
592 break;
593 case 'T': // time
594 {
595 Reference<text::XTextContent> xContent = createField( gaDateTimeService );
596 PropertySet aPropSet( xContent );
597 aPropSet.setProperty( PROP_IsDate, false );
598 appendField( xContent );
599 }
600 break;
601
602 case 'B': // bold
605 break;
606 case 'I': // italic
609 break;
610 case 'U': // underline
612 maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_single) ? XML_none : XML_single;
613 break;
614 case 'E': // double underline
616 maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_double) ? XML_none : XML_double;
617 break;
618 case 'S': // strikeout
621 break;
622 case 'X': // superscript
624 maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_superscript) ? XML_baseline : XML_superscript;
625 break;
626 case 'Y': // subscript
628 maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_subscript) ? XML_baseline : XML_subscript;
629 break;
630 case 'O': // outlined
633 break;
634 case 'H': // shadow
637 break;
638
639 case 'K': // text color (not in BIFF)
640 if( pcChar + 6 < pcEnd )
641 {
643 // eat the following 6 characters
644 convertFontColor( std::u16string_view( pcChar + 1, 6 ) );
645 pcChar += 6;
646 }
647 break;
648
649 case '\"': // font name
650 aFontName.setLength( 0 );
651 aFontStyle.setLength( 0 );
652 eState = STATE_FONTNAME;
653 break;
654 default:
655 if( ('0' <= cChar) && (cChar <= '9') ) // font size
656 {
657 nFontHeight = cChar - '0';
658 eState = STATE_FONTHEIGHT;
659 }
660 }
661 }
662 break;
663
664 case STATE_FONTNAME:
665 {
666 switch( cChar )
667 {
668 case '\"':
670 convertFontName( aFontName.makeStringAndClear() );
671 eState = STATE_TEXT;
672 break;
673 case ',':
674 eState = STATE_FONTSTYLE;
675 break;
676 default:
677 aFontName.append( cChar );
678 }
679 }
680 break;
681
682 case STATE_FONTSTYLE:
683 {
684 switch( cChar )
685 {
686 case '\"':
688 convertFontName( aFontName.makeStringAndClear() );
689 convertFontStyle( aFontStyle );
690 aFontStyle.setLength(0);
691 eState = STATE_TEXT;
692 break;
693 default:
694 aFontStyle.append( cChar );
695 }
696 }
697 break;
698
699 case STATE_FONTHEIGHT:
700 {
701 if( ('0' <= cChar) && (cChar <= '9') )
702 {
703 if( nFontHeight >= 0 )
704 {
705 nFontHeight *= 10;
706 nFontHeight += (cChar - '0');
707 if( nFontHeight > 1000 )
708 nFontHeight = -1;
709 }
710 }
711 else
712 {
713 if( nFontHeight > 0 )
714 {
716 maFontModel.mfHeight = nFontHeight;
717 }
718 --pcChar;
719 eState = STATE_TEXT;
720 }
721 }
722 break;
723 }
724 }
725
726 // finalize
728 maPortions[ HF_LEFT ].mfTotalHeight += getCurrHeight( HF_LEFT );
729 maPortions[ HF_CENTER ].mfTotalHeight += getCurrHeight( HF_CENTER );
730 maPortions[ HF_RIGHT ].mfTotalHeight += getCurrHeight( HF_RIGHT );
731
732 return ::std::max( maPortions[ HF_LEFT ].mfTotalHeight,
733 ::std::max( maPortions[ HF_CENTER ].mfTotalHeight, maPortions[ HF_RIGHT ].mfTotalHeight ) );
734}
735
736// private --------------------------------------------------------------------
737
738double HeaderFooterParser::getCurrHeight( HFPortionId ePortion ) const
739{
740 double fMaxHt = maPortions[ ePortion ].mfCurrHeight;
741 return (fMaxHt == 0.0) ? maFontModel.mfHeight : fMaxHt;
742}
743
744void HeaderFooterParser::updateCurrHeight( HFPortionId ePortion )
745{
746 double& rfMaxHt = maPortions[ ePortion ].mfCurrHeight;
747 rfMaxHt = ::std::max( rfMaxHt, maFontModel.mfHeight );
748}
749
751{
753}
754
756{
757 Reference<text::XTextRange> xRange = getStartPos();
758 getEndPos()->gotoRange( xRange, false );
759 getEndPos()->gotoEnd( true );
760 if( !getEndPos()->isCollapsed() )
761 {
762 Font aFont( *this, maFontModel );
763 aFont.finalizeImport();
764 PropertySet aPropSet( getEndPos() );
765 aFont.writeToPropertySet( aPropSet );
766 getStartPos()->gotoEnd( false );
767 getEndPos()->gotoEnd( false );
768 }
769}
770
772{
773 if( !maBuffer.isEmpty() )
774 {
775 getEndPos()->gotoEnd( false );
776 getEndPos()->setString( maBuffer.makeStringAndClear() );
778 }
779}
780
782{
783 getEndPos()->gotoEnd( false );
784 getEndPos()->setString( OUString( '\n' ) );
785 getPortion().mfTotalHeight += getCurrHeight( meCurrPortion ); // add the current line height.
786 getPortion().mfCurrHeight = 0;
787}
788
789Reference<text::XTextContent> HeaderFooterParser::createField( const OUString& rServiceName ) const
790{
791 Reference<text::XTextContent> xContent;
792 try
793 {
794 xContent.set( getBaseFilter().getModelFactory()->createInstance( rServiceName ), UNO_QUERY_THROW );
795 }
796 catch( Exception& )
797 {
798 OSL_FAIL( OStringBuffer( "HeaderFooterParser::createField - error while creating text field \"" ).
799 append( OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ) ).
800 append( '"' ).getStr() );
801 }
802 return xContent;
803}
804
805void HeaderFooterParser::appendField( const Reference<text::XTextContent>& rxContent )
806{
807 getEndPos()->gotoEnd( false );
808 try
809 {
810 Reference<text::XTextRange> xRange( getEndPos(), UNO_QUERY_THROW );
811 getPortion().mxText->insertTextContent( xRange, rxContent, false );
813 }
814 catch( Exception& )
815 {
816 }
817}
818
819void HeaderFooterParser::convertFontName( const OUString& rName )
820{
821 if( !rName.isEmpty() )
822 {
823 // single dash is document default font
824 if( (rName.getLength() == 1) && (rName[ 0 ] == '-') )
826 else
827 maFontModel.maName = rName;
828 }
829}
830
831void HeaderFooterParser::convertFontStyle( std::u16string_view rStyle )
832{
834 if (rStyle.empty())
835 return;
836 for( sal_Int32 nPos{ 0 }; nPos>=0; )
837 {
838 OString aToken = OUStringToOString( o3tl::getToken(rStyle, 0, ' ', nPos ), RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase();
839 if( !aToken.isEmpty() )
840 {
841 if( maBoldNames.count( aToken ) > 0 )
842 maFontModel.mbBold = true;
843 else if( maItalicNames.count( aToken ) > 0 )
844 maFontModel.mbItalic = true;
845 }
846 }
847}
848
849void HeaderFooterParser::convertFontColor( std::u16string_view aColor )
850{
851 OSL_ENSURE( aColor.size() == 6, "HeaderFooterParser::convertFontColor - invalid font color code" );
852 if( (aColor[ 2 ] == '+') || (aColor[ 2 ] == '-') )
853 // theme color: TTSNNN (TT = decimal theme index, S = +/-, NNN = decimal tint/shade in percent)
855 o3tl::toInt32(aColor.substr( 0, 2 )),
856 static_cast< double >( o3tl::toInt32(aColor.substr( 2 )) ) / 100.0 );
857 else
858 // RGB color: RRGGBB
860}
861
863{
864 appendText();
866}
867
868void HeaderFooterParser::setNewPortion( HFPortionId ePortion )
869{
870 if( ePortion != meCurrPortion )
871 {
873 meCurrPortion = ePortion;
875 }
876}
877
878PageSettingsConverter::HFHelperData::HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId, sal_Int32 nFirstPropId ) :
879 mnLeftPropId( nLeftPropId ),
880 mnRightPropId( nRightPropId ),
881 mnFirstPropId( nFirstPropId ),
882 mnHeight( 0 ),
883 mnBodyDist( 0 ),
884 mbHasContent( false ),
885 mbShareOddEven( false ),
886 mbShareFirst( false ),
887 mbDynamicHeight( false )
888{
889}
890
892 WorkbookHelper( rHelper ),
893 mxHFParser( new HeaderFooterParser( rHelper ) ),
894 maHeaderData( PROP_LeftPageHeaderContent, PROP_RightPageHeaderContent, PROP_FirstPageHeaderContent ),
895 maFooterData( PROP_LeftPageFooterContent, PROP_RightPageFooterContent, PROP_FirstPageFooterContent )
896{
897}
898
900{
901}
902
904 PropertySet& rPropSet, const PageSettingsModel& rModel, WorksheetType eSheetType )
905{
906 // special handling for chart sheets
907 bool bChartSheet = eSheetType == WorksheetType::Chart;
908
909 // printout scaling
910 if( bChartSheet )
911 {
912 // always fit chart sheet to 1 page
913 rPropSet.setProperty< sal_Int16 >( PROP_ScaleToPages, 1 );
914 }
915 else if( rModel.mbFitToPages )
916 {
917 // fit to number of pages
918 rPropSet.setProperty( PROP_ScaleToPagesX, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToWidth, 0, 1000 ) );
919 rPropSet.setProperty( PROP_ScaleToPagesY, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToHeight, 0, 1000 ) );
920 }
921 else
922 {
923 // scale may be 0 which indicates uninitialized
924 sal_Int16 nScale = (rModel.mnScale > 0) ? getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnScale, 10, 400 ) : 100;
925 rPropSet.setProperty( PROP_PageScale, nScale );
926 }
927
928 // paper orientation
929 bool bLandscape = rModel.mnOrientation == XML_landscape;
930 // default orientation for current sheet type (chart sheets default to landscape)
931 if( bChartSheet && ( !rModel.mbValidSettings || (rModel.mnOrientation == XML_default) ) )
932 bLandscape = true;
933
934 // paper size
935 if( !rModel.mbValidSettings )
936 {
937 awt::Size aSize;
938 bool bValid = false;
939
940 if( 0 < rModel.mnPaperSize )
941 {
943 aSize = awt::Size( rPaperSize.mnWidth, rPaperSize.mnHeight );
944 bValid = ( rPaperSize.mnWidth != 0 && rPaperSize.mnHeight != 0 );
945 }
946 if( rModel.mnPaperWidth > 0 && rModel.mnPaperHeight > 0 )
947 {
948 aSize = awt::Size( rModel.mnPaperWidth, rModel.mnPaperHeight );
949 bValid = true;
950 }
951
952 if( bValid )
953 {
954 if( bLandscape )
955 ::std::swap( aSize.Width, aSize.Height );
956 rPropSet.setProperty( PROP_Size, aSize );
957 }
958 }
959
960 // header/footer
961 convertHeaderFooterData( rPropSet, maHeaderData, rModel.maOddHeader, rModel.maEvenHeader, rModel.maFirstHeader, rModel.mbUseEvenHF, rModel.mbUseFirstHF, rModel.mfTopMargin, rModel.mfHeaderMargin );
962 convertHeaderFooterData( rPropSet, maFooterData, rModel.maOddFooter, rModel.maEvenFooter, rModel.maFirstFooter, rModel.mbUseEvenHF, rModel.mbUseFirstHF, rModel.mfBottomMargin, rModel.mfFooterMargin );
963
964 // write all properties to property set
965 PropertyMap aPropMap;
966 aPropMap.setProperty( PROP_IsLandscape, bLandscape);
967 aPropMap.setProperty( PROP_FirstPageNumber, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mbUseFirstPage ? rModel.mnFirstPage : 0, 0, 9999 ));
968 aPropMap.setProperty( PROP_PrintDownFirst, (rModel.mnPageOrder == XML_downThenOver));
969 aPropMap.setProperty( PROP_PrintAnnotations, (rModel.mnCellComments == XML_asDisplayed));
972 aPropMap.setProperty( PROP_PrintGrid, (!bChartSheet && rModel.mbPrintGrid)); // no gridlines in chart sheets
973 aPropMap.setProperty( PROP_PrintHeaders, (!bChartSheet && rModel.mbPrintHeadings)); // no column/row headings in chart sheets
974 aPropMap.setProperty<sal_Int32>( PROP_LeftMargin, std::round(o3tl::convert( rModel.mfLeftMargin, o3tl::Length::in, o3tl::Length::mm100 )));
976 // #i23296# In Calc, "TopMargin" property is distance to top of header if enabled
978 // #i23296# In Calc, "BottomMargin" property is distance to bottom of footer if enabled
980 aPropMap.setProperty( PROP_HeaderIsOn, maHeaderData.mbHasContent);
981 aPropMap.setProperty( PROP_HeaderIsShared, maHeaderData.mbShareOddEven);
982 aPropMap.setProperty( PROP_FirstPageHeaderIsShared, maHeaderData.mbShareFirst);
986 aPropMap.setProperty( PROP_FooterIsOn, maFooterData.mbHasContent);
987 aPropMap.setProperty( PROP_FooterIsShared, maFooterData.mbShareOddEven);
988 aPropMap.setProperty( PROP_FirstPageFooterIsShared, maFooterData.mbShareFirst);
992 // background image
993 if (rModel.mxGraphic.is())
994 {
995 aPropMap.setProperty(PROP_BackGraphic, rModel.mxGraphic);
996 aPropMap.setProperty(PROP_BackGraphicLocation, css::style::GraphicLocation_TILED);
997 }
998
999 rPropSet.setProperties( aPropMap );
1000}
1001
1003 PropertySet& rPropSet, HFHelperData& orHFData,
1004 const OUString& rOddContent, const OUString& rEvenContent, const OUString& rFirstContent,
1005 bool bUseEvenContent, bool bUseFirstContent,
1006 double fPageMargin, double fContentMargin )
1007{
1008 bool bHasOddContent = !rOddContent.isEmpty();
1009 bool bHasEvenContent = bUseEvenContent && !rEvenContent.isEmpty();
1010 bool bHasFirstContent = bUseFirstContent && !rFirstContent.isEmpty();
1011
1012 sal_Int32 nOddHeight = bHasOddContent ? writeHeaderFooter( rPropSet, orHFData.mnRightPropId, rOddContent ) : 0;
1013 sal_Int32 nEvenHeight = bHasEvenContent ? writeHeaderFooter( rPropSet, orHFData.mnLeftPropId, rEvenContent ) : 0;
1014 sal_Int32 nFirstHeight = bHasFirstContent ? writeHeaderFooter( rPropSet, orHFData.mnFirstPropId, rFirstContent ) : 0;
1015
1016 orHFData.mnHeight = 750;
1017 orHFData.mnBodyDist = 250;
1018 orHFData.mbHasContent = bHasOddContent || bHasEvenContent || bHasFirstContent;
1019 orHFData.mbShareOddEven = !bUseEvenContent;
1020 orHFData.mbShareFirst = !bUseFirstContent;
1021 orHFData.mbDynamicHeight = true;
1022
1023 if( !orHFData.mbHasContent )
1024 return;
1025
1026 // use maximum height of odd/even/first header/footer
1027 orHFData.mnHeight = ::std::max( ::std::max( nOddHeight, nEvenHeight ), nFirstHeight );
1028 /* Calc contains distance between bottom of header and top of page
1029 body in "HeaderBodyDistance" property, and distance between bottom
1030 of page body and top of footer in "FooterBodyDistance" property */
1031 orHFData.mnBodyDist = std::round(o3tl::convert( fPageMargin - fContentMargin, o3tl::Length::in, o3tl::Length::mm100 )) - orHFData.mnHeight;
1032 /* #i23296# Distance less than 0 means, header or footer overlays page
1033 body. As this is not possible in Calc, set fixed header or footer
1034 height (crop header/footer) to get correct top position of page body. */
1035 orHFData.mbDynamicHeight = orHFData.mnBodyDist >= 0;
1036 /* "HeaderHeight" property is in fact distance from top of header to
1037 top of page body (including "HeaderBodyDistance").
1038 "FooterHeight" property is in fact distance from bottom of page
1039 body to bottom of footer (including "FooterBodyDistance"). */
1040 orHFData.mnHeight += orHFData.mnBodyDist;
1041 // negative body distance not allowed
1042 orHFData.mnBodyDist = ::std::max< sal_Int32 >( orHFData.mnBodyDist, 0 );
1043}
1044
1046 PropertySet& rPropSet, sal_Int32 nPropId, const OUString& rContent )
1047{
1048 OSL_ENSURE( !rContent.isEmpty(), "PageSettingsConverter::writeHeaderFooter - empty h/f string found" );
1049 sal_Int32 nHeight = 0;
1050 if( !rContent.isEmpty() )
1051 {
1052 Reference<sheet::XHeaderFooterContent> xHFContent(rPropSet.getAnyProperty(nPropId), UNO_QUERY);
1053 if( xHFContent.is() )
1054 {
1055 double fTotalHeight = mxHFParser->parse( xHFContent, rContent );
1056 rPropSet.setProperty( nPropId, xHFContent );
1057 nHeight = std::round(o3tl::convert(fTotalHeight, o3tl::Length::pt, o3tl::Length::mm100));
1058 }
1059 }
1060 return nHeight;
1061}
1062
1063} // namespace oox
1064
1065/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
double mnScale
SC_DLLPUBLIC void SetPageStyle(SCTAB nTab, const OUString &rName)
Definition: document.cxx:6296
static const ApiPaperSize & getApiSizeForMSPaperSizeIndex(sal_Int32 nMSOPaperIndex)
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
std::optional< bool > getBool(sal_Int32 nAttrToken) const
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
std::optional< double > getDouble(sal_Int32 nAttrToken) const
css::uno::Reference< css::graphic::XGraphic > importEmbeddedGraphic(const OUString &rStreamName, const WmfExternal *pExtHeader=nullptr) const
bool setProperty(sal_Int32 nPropId, Type &&rValue)
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
bool setProperty(sal_Int32 nPropId, const Type &rValue)
GraphicHelper & getGraphicHelper() const
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:79
void setRgb(::Color nRgbValue, double fTint=0.0)
Sets the color to the passed RGB value.
void setTheme(sal_Int32 nThemeIdx, double fTint=0.0)
Sets the color to the passed theme index.
void writeToPropertySet(PropertySet &rPropSet) const
Writes all font attributes to the passed property set.
void finalizeImport()
Final processing after import of all style settings.
double getCurrHeight(HFPortionId ePortion) const
Returns the current line height of the specified portion.
HFPortionInfo & getPortion()
Returns the current edit engine text object.
FontModel maFontModel
Text data to append to current text range.
OUStringBuffer maBuffer
Identifier of current H/F portion.
void convertFontStyle(std::u16string_view aStyle)
Converts a font style given as string.
void finalizePortion()
Finalizes current portion: sets font attributes and updates text height data.
void convertFontName(const OUString &rStyle)
Sets the passed font name if it is valid.
void appendText()
Appends and clears internal string buffer.
void convertFontColor(std::u16string_view aColor)
Converts a font color given as string.
double parse(const Reference< sheet::XHeaderFooterContent > &rxContext, const OUString &rData)
Parses the passed string and creates the header/footer contents.
void updateCurrHeight()
Updates the current line height, using the current font size.
const Reference< text::XTextCursor > & getEndPos()
Returns the end cursor of the current text range.
void appendLineBreak()
Appends a line break and adjusts internal text height data.
const std::set< OString > maItalicNames
All names for bold font style in lowercase UTF-8.
const Reference< text::XTextCursor > & getStartPos()
Returns the start cursor of the current text range.
const std::set< OString > maBoldNames
void appendField(const Reference< text::XTextContent > &rxContent)
Appends the passed text field.
Reference< text::XTextContent > createField(const OUString &rServiceName) const
Creates a text field from the passed service name.
HFPortionInfoVec maPortions
All names for italic font style in lowercase UTF-8.
HeaderFooterParser(const WorkbookHelper &rHelper)
::std::vector< HFPortionInfo > HFPortionInfoVec
void setNewPortion(HFPortionId ePortion)
Changes current header/footer portion.
void setAttributes()
Sets the font attributes at the current selection.
void writePageSettingsProperties(PropertySet &rPropSet, const PageSettingsModel &rModel, WorksheetType eSheetType)
Writes all properties to the passed property set of a page style object.
PageSettingsConverter(const WorkbookHelper &rHelper)
void convertHeaderFooterData(PropertySet &rPropSet, HFHelperData &orHFData, const OUString &rOddContent, const OUString &rEvenContent, const OUString &rFirstContent, bool bUseEvenContent, bool bUseFirstContent, double fPageMargin, double fContentMargin)
HeaderFooterParserPtr mxHFParser
virtual ~PageSettingsConverter() override
sal_Int32 writeHeaderFooter(PropertySet &rPropSet, sal_Int32 nPropId, const OUString &rContent)
void importChartPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for chart sheets.
void importPictureData(const ::oox::core::Relations &rRelations, const OUString &rRelId)
Imports the binary picture data from the fragment with the passed identifier.
void importPrintOptions(const AttributeList &rAttribs)
Imports printing options from a printOptions element.
void importPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for worksheets.
void importPicture(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports the picture element.
void importHeaderFooterCharacters(std::u16string_view rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
void importPageMargins(const AttributeList &rAttribs)
Imports pageMarings element containing page margins.
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
void setFitToPagesMode(bool bFitToPages)
Sets whether percentual scaling or fit to width/height scaling is used.
PageSettingsModel maModel
void finalizeImport()
Creates a page style for the spreadsheet and sets all page properties.
PageSettings(const WorksheetHelper &rHelper)
const FontModel & getDefaultFontModel() const
Returns the model of the default application font (used in the "Normal" cell style).
Helper class to provide access to global workbook data.
css::uno::Reference< css::style::XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle) const
Creates and returns a com.sun.star.style.Style object for cells or pages.
PageSettingsConverter & getPageSettingsConverter() const
Returns the page and print settings converter.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
WorksheetType getSheetType() const
Returns the type of this sheet.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
const css::uno::Reference< css::sheet::XSpreadsheet > & getSheet() const
Returns the XSpreadsheet interface of the current sheet.
static bool convertMeasure(sal_Int32 &rValue, std::u16string_view rString, sal_Int16 nTargetUnit=css::util::MeasureUnit::MM_100TH, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
ColorTransparency
#define STATIC_ARRAY_SELECT(array, index, def)
sal_uInt16 nPos
#define SAL_N_ELEMENTS(arr)
aStr
@ Exception
void SvStream & rStrm
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr OUStringLiteral gaDateTimeService(u"com.sun.star.text.TextField.DateTime")
constexpr OUStringLiteral gaSheetNameService(u"com.sun.star.text.TextField.SheetName")
constexpr OUStringLiteral gaPageCountService(u"com.sun.star.text.TextField.PageCount")
constexpr OUStringLiteral gaPageNumberService(u"com.sun.star.text.TextField.PageNumber")
constexpr OUStringLiteral gaFileNameService(u"com.sun.star.text.TextField.FileName")
WorksheetType
An enumeration for all types of sheets in a workbook.
ReturnType getFlagValue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
bool getFlag(Type nBitField, Type nMask)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
XML_none
Reference< text::XText > mxText
double mfTotalHeight
End position of current text range for formatting.
double mfCurrHeight
Sum of heights of previous lines in points.
Reference< text::XTextCursor > mxEnd
Start position of current text range for formatting.
Reference< text::XTextCursor > mxStart
XText interface of this portion.
double mnHeight
Contains all XML font attributes, e.g.
bool mbShadow
True = outlined characters.
bool mbItalic
True = bold characters.
bool mbOutline
True = Strike out characters.
sal_Int32 mnEscapement
Underline style.
sal_Int32 mnUnderline
Font height in points.
bool mbBold
Escapement style.
double mfHeight
Windows font character set.
Color maColor
Font name.
bool mbStrikeout
True = italic characters.
HFHelperData(sal_Int32 nLeftPropId, sal_Int32 nRightPropId, sal_Int32 nFirstPropId)
Holds page style data for a single sheet.
sal_Int32 mnFirstPage
Page scale (zoom in percent).
bool mbDraftQuality
True = print black and white.
sal_Int32 mnOrientation
Vertical printing resolution in DPI.
double mfLeftMargin
Footer string for first page of the sheet.
sal_Int32 mnCopies
Paper height in twips.
double mfTopMargin
Margin between end of sheet area and right edge of page.
void setBiffPrintErrors(sal_uInt8 nPrintErrors)
Sets the BIFF print errors mode.
bool mbPrintHeadings
True = print grid lines.
PageSettingsModel()
True = print column/row headings.
double mfFooterMargin
Margin between top edge of page and begin of header.
sal_Int32 mnHorPrintRes
Fit to number of pages in vertical direction.
sal_Int32 mnScale
Number of copies to print.
bool mbUseFirstHF
True = use maEvenHeader/maEvenFooter.
sal_Int32 mnFitToWidth
First page number.
double mfHeaderMargin
Margin between end of sheet area and bottom edge of page.
OUString maOddHeader
Relation identifier of binary printer settings.
bool mbHorCenter
True = Fit to width/height; false = scale in percent.
bool mbFitToPages
True = print in draft quality.
sal_Int32 mnPrintErrors
Cell comments printing mode.
OUString maEvenFooter
Header string for even pages.
sal_Int32 mnPaperSize
Margin between end of footer and bottom edge of page.
bool mbValidSettings
True = use maFirstHeader/maFirstFooter.
sal_Int32 mnPageOrder
Landscape or portrait.
OUString maFirstHeader
Footer string for even pages.
double mfBottomMargin
Margin between top edge of page and begin of sheet area.
OUString maFirstFooter
Header string for first page of the sheet.
OUString maEvenHeader
Footer string for odd pages.
sal_Int32 mnPaperHeight
Paper width in twips.
sal_Int32 mnPaperWidth
Paper size (enumeration).
bool mbBlackWhite
True = start page numbering with mnFirstPage.
sal_Int32 mnFitToHeight
Fit to number of pages in horizontal direction.
double mfRightMargin
Margin between left edge of page and begin of sheet area.
OUString maBinSettPath
Background Graphic.
sal_Int32 mnCellComments
Page order through sheet area (to left or down).
css::uno::Reference< css::graphic::XGraphic > mxGraphic
bool mbPrintGrid
True = vertically centered.
bool mbUseEvenHF
Cell error printing mode.
bool mbVerCenter
True = horizontally centered.
OUString maOddFooter
Header string for odd pages.
sal_Int32 mnVerPrintRes
Horizontal printing resolution in DPI.
bool mbUseFirstPage
True = use imported settings.
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
sal_Int16 SCTAB
Definition: types.hxx:22
constexpr OUStringLiteral PROP_PageScale
constexpr OUStringLiteral PROP_TopMargin
constexpr OUStringLiteral PROP_BackGraphicLocation
constexpr OUStringLiteral PROP_PrintDownFirst
constexpr OUStringLiteral PROP_ScaleToPagesX
constexpr OUStringLiteral PROP_PrintGrid
constexpr OUStringLiteral PROP_CenterVertically
constexpr OUStringLiteral PROP_BottomMargin
constexpr OUStringLiteral PROP_HeaderBodyDistance
constexpr OUStringLiteral PROP_ScaleToPages
constexpr OUStringLiteral PROP_FooterIsDynamicHeight
constexpr OUStringLiteral PROP_PrintHeaders
constexpr OUStringLiteral PROP_HeaderIsDynamicHeight
constexpr OUStringLiteral PROP_PrintAnnotations
constexpr OUStringLiteral PROP_IsLandscape
constexpr OUStringLiteral PROP_LeftMargin
constexpr OUStringLiteral PROP_BackGraphic
constexpr OUStringLiteral PROP_HeaderHeight
constexpr OUStringLiteral PROP_ScaleToPagesY
constexpr OUStringLiteral PROP_FooterHeight
constexpr OUStringLiteral PROP_RightMargin
constexpr OUStringLiteral PROP_CenterHorizontally
constexpr OUStringLiteral PROP_FooterBodyDistance
constexpr OUStringLiteral PROP_FirstPageNumber