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>
37 #include <sax/tools/converter.hxx>
43 #include <oox/token/namespaces.hxx>
44 #include <oox/token/properties.hxx>
45 #include <oox/token/tokens.hxx>
46 #include <oox/core/filterbase.hxx>
47 #include <oox/core/relations.hxx>
48 #include <stylesbuffer.hxx>
49 #include <unitconverter.hxx>
50 #include <document.hxx>
51 #include <biffhelper.hxx>
52 #include <filter/msfilter/util.hxx>
53 
54 namespace oox::xls {
55 
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star::uno;
59 
60 using ::oox::core::Relations;
61 
62 namespace {
63 
64 const double OOX_MARGIN_DEFAULT_LR = 0.748;
65 const double OOX_MARGIN_DEFAULT_TB = 0.984;
66 const double OOX_MARGIN_DEFAULT_HF = 0.512;
67 
68 const sal_uInt16 BIFF12_PRINTOPT_HORCENTER = 0x0001;
69 const sal_uInt16 BIFF12_PRINTOPT_VERCENTER = 0x0002;
70 const sal_uInt16 BIFF12_PRINTOPT_PRINTHEADING = 0x0004;
71 const sal_uInt16 BIFF12_PRINTOPT_PRINTGRID = 0x0008;
72 
73 const sal_uInt16 BIFF12_HEADERFOOTER_DIFFEVEN = 0x0001;
74 const sal_uInt16 BIFF12_HEADERFOOTER_DIFFFIRST = 0x0002;
75 
76 const sal_uInt16 BIFF12_PAGESETUP_INROWS = 0x0001;
77 const sal_uInt16 BIFF12_PAGESETUP_LANDSCAPE = 0x0002;
78 const sal_uInt16 BIFF12_PAGESETUP_INVALID = 0x0004;
79 const sal_uInt16 BIFF12_PAGESETUP_BLACKWHITE = 0x0008;
80 const sal_uInt16 BIFF12_PAGESETUP_DRAFTQUALITY = 0x0010;
81 const sal_uInt16 BIFF12_PAGESETUP_PRINTNOTES = 0x0020;
82 const sal_uInt16 BIFF12_PAGESETUP_DEFAULTORIENT = 0x0040;
83 const sal_uInt16 BIFF12_PAGESETUP_USEFIRSTPAGE = 0x0080;
84 const sal_uInt16 BIFF12_PAGESETUP_NOTES_END = 0x0100; // different to BIFF flag
85 
86 const sal_uInt16 BIFF12_CHARTPAGESETUP_LANDSCAPE = 0x0001;
87 const sal_uInt16 BIFF12_CHARTPAGESETUP_INVALID = 0x0002;
88 const sal_uInt16 BIFF12_CHARTPAGESETUP_BLACKWHITE = 0x0004;
89 const sal_uInt16 BIFF12_CHARTPAGESETUP_DEFAULTORIENT= 0x0008;
90 const sal_uInt16 BIFF12_CHARTPAGESETUP_USEFIRSTPAGE = 0x0010;
91 const 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 
159 void 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 
187 void 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 
215 void PageSettings::importHeaderFooterCharacters( const OUString& 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 
228 void 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();
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 
253 void 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 
278 void 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 
309 void PageSettings::importPicture( const Relations& rRelations, SequenceInputStream& rStrm )
310 {
311  importPictureData( rRelations, BiffHelper::readString( rStrm ) );
312 }
313 
314 void 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 
338 void PageSettings::importPictureData( const Relations& rRelations, const OUString& rRelId )
339 {
340  OUString aPicturePath = rRelations.getFragmentPathFromRelId(rRelId);
341  if (!aPicturePath.isEmpty())
342  {
344  }
345 }
346 
347 namespace {
348 
349 enum HFPortionId
350 {
351  HF_LEFT,
352  HF_CENTER,
353  HF_RIGHT,
354  HF_COUNT
355 };
356 
357 struct HFPortionInfo
358 {
359  Reference<text::XText> mxText;
360  Reference<text::XTextCursor> mxStart;
361  Reference<text::XTextCursor> mxEnd;
362  double mfTotalHeight;
363  double mfCurrHeight;
364 
365  bool initialize( const Reference<text::XText>& rxText );
366 };
367 
368 }
369 
370 bool HFPortionInfo::initialize( const Reference<text::XText>& rxText )
371 {
372  mfTotalHeight = mfCurrHeight = 0.0;
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 {
386 public:
387  explicit HeaderFooterParser( const WorkbookHelper& rHelper );
388 
391  double parse(
392  const Reference<sheet::XHeaderFooterContent>& rxContext,
393  const OUString& rData );
394 
395 private:
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( const OUString& rStyle );
428  void convertFontColor( const OUString& rColor );
429 
431  void finalizePortion();
433  void setNewPortion( HFPortionId ePortion );
434 
435 private:
436  typedef ::std::vector< HFPortionInfo > HFPortionInfoVec;
437 
438  const std::set< OString > maBoldNames;
439  const std::set< OString > maItalicNames;
440  HFPortionInfoVec maPortions;
441  HFPortionId meCurrPortion;
442  OUStringBuffer maBuffer;
444 };
445 
446 namespace {
447 
448 // different names for bold font style (lowercase)
449 const 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)
461 const 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 
473 constexpr OUStringLiteral gaPageNumberService( u"com.sun.star.text.TextField.PageNumber" );
474 constexpr OUStringLiteral gaPageCountService( u"com.sun.star.text.TextField.PageCount" );
475 constexpr OUStringLiteral gaSheetNameService( u"com.sun.star.text.TextField.SheetName" );
476 constexpr OUStringLiteral gaFileNameService( u"com.sun.star.text.TextField.FileName" );
477 constexpr 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 
488 double 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();
531  appendLineBreak();
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
603  setAttributes();
605  break;
606  case 'I': // italic
607  setAttributes();
609  break;
610  case 'U': // underline
611  setAttributes();
612  maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_single) ? XML_none : XML_single;
613  break;
614  case 'E': // double underline
615  setAttributes();
616  maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_double) ? XML_none : XML_double;
617  break;
618  case 'S': // strikeout
619  setAttributes();
621  break;
622  case 'X': // superscript
623  setAttributes();
624  maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_superscript) ? XML_baseline : XML_superscript;
625  break;
626  case 'Y': // subscript
627  setAttributes();
628  maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_subscript) ? XML_baseline : XML_subscript;
629  break;
630  case 'O': // outlined
631  setAttributes();
633  break;
634  case 'H': // shadow
635  setAttributes();
637  break;
638 
639  case 'K': // text color (not in BIFF)
640  if( pcChar + 6 < pcEnd )
641  {
642  setAttributes();
643  // eat the following 6 characters
644  convertFontColor( OUString( 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 '\"':
669  setAttributes();
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 '\"':
687  setAttributes();
688  convertFontName( aFontName.makeStringAndClear() );
689  convertFontStyle( aFontStyle.makeStringAndClear() );
690  eState = STATE_TEXT;
691  break;
692  default:
693  aFontStyle.append( cChar );
694  }
695  }
696  break;
697 
698  case STATE_FONTHEIGHT:
699  {
700  if( ('0' <= cChar) && (cChar <= '9') )
701  {
702  if( nFontHeight >= 0 )
703  {
704  nFontHeight *= 10;
705  nFontHeight += (cChar - '0');
706  if( nFontHeight > 1000 )
707  nFontHeight = -1;
708  }
709  }
710  else
711  {
712  if( nFontHeight > 0 )
713  {
714  setAttributes();
715  maFontModel.mfHeight = nFontHeight;
716  }
717  --pcChar;
718  eState = STATE_TEXT;
719  }
720  }
721  break;
722  }
723  }
724 
725  // finalize
726  finalizePortion();
727  maPortions[ HF_LEFT ].mfTotalHeight += getCurrHeight( HF_LEFT );
728  maPortions[ HF_CENTER ].mfTotalHeight += getCurrHeight( HF_CENTER );
729  maPortions[ HF_RIGHT ].mfTotalHeight += getCurrHeight( HF_RIGHT );
730 
731  return ::std::max( maPortions[ HF_LEFT ].mfTotalHeight,
732  ::std::max( maPortions[ HF_CENTER ].mfTotalHeight, maPortions[ HF_RIGHT ].mfTotalHeight ) );
733 }
734 
735 // private --------------------------------------------------------------------
736 
737 double HeaderFooterParser::getCurrHeight( HFPortionId ePortion ) const
738 {
739  double fMaxHt = maPortions[ ePortion ].mfCurrHeight;
740  return (fMaxHt == 0.0) ? maFontModel.mfHeight : fMaxHt;
741 }
742 
743 void HeaderFooterParser::updateCurrHeight( HFPortionId ePortion )
744 {
745  double& rfMaxHt = maPortions[ ePortion ].mfCurrHeight;
746  rfMaxHt = ::std::max( rfMaxHt, maFontModel.mfHeight );
747 }
748 
750 {
752 }
753 
755 {
756  Reference<text::XTextRange> xRange = getStartPos();
757  getEndPos()->gotoRange( xRange, false );
758  getEndPos()->gotoEnd( true );
759  if( !getEndPos()->isCollapsed() )
760  {
761  Font aFont( *this, maFontModel );
762  aFont.finalizeImport();
763  PropertySet aPropSet( getEndPos() );
764  aFont.writeToPropertySet( aPropSet );
765  getStartPos()->gotoEnd( false );
766  getEndPos()->gotoEnd( false );
767  }
768 }
769 
771 {
772  if( !maBuffer.isEmpty() )
773  {
774  getEndPos()->gotoEnd( false );
775  getEndPos()->setString( maBuffer.makeStringAndClear() );
777  }
778 }
779 
781 {
782  getEndPos()->gotoEnd( false );
783  getEndPos()->setString( OUString( '\n' ) );
784  getPortion().mfTotalHeight += getCurrHeight( meCurrPortion ); // add the current line height.
785  getPortion().mfCurrHeight = 0;
786 }
787 
788 Reference<text::XTextContent> HeaderFooterParser::createField( const OUString& rServiceName ) const
789 {
790  Reference<text::XTextContent> xContent;
791  try
792  {
793  xContent.set( getBaseFilter().getModelFactory()->createInstance( rServiceName ), UNO_QUERY_THROW );
794  }
795  catch( Exception& )
796  {
797  OSL_FAIL( OStringBuffer( "HeaderFooterParser::createField - error while creating text field \"" ).
798  append( OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ) ).
799  append( '"' ).getStr() );
800  }
801  return xContent;
802 }
803 
804 void HeaderFooterParser::appendField( const Reference<text::XTextContent>& rxContent )
805 {
806  getEndPos()->gotoEnd( false );
807  try
808  {
809  Reference<text::XTextRange> xRange( getEndPos(), UNO_QUERY_THROW );
810  getPortion().mxText->insertTextContent( xRange, rxContent, false );
812  }
813  catch( Exception& )
814  {
815  }
816 }
817 
818 void HeaderFooterParser::convertFontName( const OUString& rName )
819 {
820  if( !rName.isEmpty() )
821  {
822  // single dash is document default font
823  if( (rName.getLength() == 1) && (rName[ 0 ] == '-') )
825  else
826  maFontModel.maName = rName;
827  }
828 }
829 
830 void HeaderFooterParser::convertFontStyle( const OUString& rStyle )
831 {
833  if (rStyle.isEmpty())
834  return;
835  for( sal_Int32 nPos{ 0 }; nPos>=0; )
836  {
837  OString aToken = OUStringToOString( rStyle.getToken( 0, ' ', nPos ), RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase();
838  if( !aToken.isEmpty() )
839  {
840  if( maBoldNames.count( aToken ) > 0 )
841  maFontModel.mbBold = true;
842  else if( maItalicNames.count( aToken ) > 0 )
843  maFontModel.mbItalic = true;
844  }
845  }
846 }
847 
848 void HeaderFooterParser::convertFontColor( const OUString& rColor )
849 {
850  OSL_ENSURE( rColor.getLength() == 6, "HeaderFooterParser::convertFontColor - invalid font color code" );
851  if( (rColor[ 2 ] == '+') || (rColor[ 2 ] == '-') )
852  // theme color: TTSNNN (TT = decimal theme index, S = +/-, NNN = decimal tint/shade in percent)
854  rColor.copy( 0, 2 ).toInt32(),
855  static_cast< double >( rColor.copy( 2 ).toInt32() ) / 100.0 );
856  else
857  // RGB color: RRGGBB
858  maFontModel.maColor.setRgb( ::Color(rColor.toUInt32( 16 )) );
859 }
860 
862 {
863  appendText();
864  setAttributes();
865 }
866 
867 void HeaderFooterParser::setNewPortion( HFPortionId ePortion )
868 {
869  if( ePortion != meCurrPortion )
870  {
871  finalizePortion();
872  meCurrPortion = ePortion;
874  }
875 }
876 
877 PageSettingsConverter::HFHelperData::HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId ) :
878  mnLeftPropId( nLeftPropId ),
879  mnRightPropId( nRightPropId ),
880  mnHeight( 0 ),
881  mnBodyDist( 0 ),
882  mbHasContent( false ),
883  mbShareOddEven( false ),
884  mbDynamicHeight( false )
885 {
886 }
887 
889  WorkbookHelper( rHelper ),
890  mxHFParser( new HeaderFooterParser( rHelper ) ),
891  maHeaderData( PROP_LeftPageHeaderContent, PROP_RightPageHeaderContent ),
892  maFooterData( PROP_LeftPageFooterContent, PROP_RightPageFooterContent )
893 {
894 }
895 
897 {
898 }
899 
901  PropertySet& rPropSet, const PageSettingsModel& rModel, WorksheetType eSheetType )
902 {
903  // special handling for chart sheets
904  bool bChartSheet = eSheetType == WorksheetType::Chart;
905 
906  // printout scaling
907  if( bChartSheet )
908  {
909  // always fit chart sheet to 1 page
910  rPropSet.setProperty< sal_Int16 >( PROP_ScaleToPages, 1 );
911  }
912  else if( rModel.mbFitToPages )
913  {
914  // fit to number of pages
915  rPropSet.setProperty( PROP_ScaleToPagesX, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToWidth, 0, 1000 ) );
916  rPropSet.setProperty( PROP_ScaleToPagesY, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToHeight, 0, 1000 ) );
917  }
918  else
919  {
920  // scale may be 0 which indicates uninitialized
921  sal_Int16 nScale = (rModel.mnScale > 0) ? getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnScale, 10, 400 ) : 100;
922  rPropSet.setProperty( PROP_PageScale, nScale );
923  }
924 
925  // paper orientation
926  bool bLandscape = rModel.mnOrientation == XML_landscape;
927  // default orientation for current sheet type (chart sheets default to landscape)
928  if( bChartSheet && ( !rModel.mbValidSettings || (rModel.mnOrientation == XML_default) ) )
929  bLandscape = true;
930 
931  // paper size
932  if( !rModel.mbValidSettings )
933  {
934  awt::Size aSize;
935  bool bValid = false;
936 
937  if( 0 < rModel.mnPaperSize )
938  {
940  aSize = awt::Size( rPaperSize.mnWidth, rPaperSize.mnHeight );
941  bValid = ( rPaperSize.mnWidth != 0 && rPaperSize.mnHeight != 0 );
942  }
943  if( rModel.mnPaperWidth > 0 && rModel.mnPaperHeight > 0 )
944  {
945  aSize = awt::Size( rModel.mnPaperWidth, rModel.mnPaperHeight );
946  bValid = true;
947  }
948 
949  if( bValid )
950  {
951  if( bLandscape )
952  ::std::swap( aSize.Width, aSize.Height );
953  rPropSet.setProperty( PROP_Size, aSize );
954  }
955  }
956 
957  // header/footer
958  convertHeaderFooterData( rPropSet, maHeaderData, rModel.maOddHeader, rModel.maEvenHeader, rModel.mbUseEvenHF, rModel.mfTopMargin, rModel.mfHeaderMargin );
959  convertHeaderFooterData( rPropSet, maFooterData, rModel.maOddFooter, rModel.maEvenFooter, rModel.mbUseEvenHF, rModel.mfBottomMargin, rModel.mfFooterMargin );
960 
961  // write all properties to property set
962  const UnitConverter& rUnitConv = getUnitConverter();
963  PropertyMap aPropMap;
964  aPropMap.setProperty( PROP_IsLandscape, bLandscape);
965  aPropMap.setProperty( PROP_FirstPageNumber, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mbUseFirstPage ? rModel.mnFirstPage : 0, 0, 9999 ));
966  aPropMap.setProperty( PROP_PrintDownFirst, (rModel.mnPageOrder == XML_downThenOver));
967  aPropMap.setProperty( PROP_PrintAnnotations, (rModel.mnCellComments == XML_asDisplayed));
968  aPropMap.setProperty( PROP_CenterHorizontally, rModel.mbHorCenter);
969  aPropMap.setProperty( PROP_CenterVertically, rModel.mbVerCenter);
970  aPropMap.setProperty( PROP_PrintGrid, (!bChartSheet && rModel.mbPrintGrid)); // no gridlines in chart sheets
971  aPropMap.setProperty( PROP_PrintHeaders, (!bChartSheet && rModel.mbPrintHeadings)); // no column/row headings in chart sheets
972  aPropMap.setProperty( PROP_LeftMargin, rUnitConv.scaleToMm100( rModel.mfLeftMargin, Unit::Inch ));
973  aPropMap.setProperty( PROP_RightMargin, rUnitConv.scaleToMm100( rModel.mfRightMargin, Unit::Inch ));
974  // #i23296# In Calc, "TopMargin" property is distance to top of header if enabled
975  aPropMap.setProperty( PROP_TopMargin, rUnitConv.scaleToMm100( maHeaderData.mbHasContent ? rModel.mfHeaderMargin : rModel.mfTopMargin, Unit::Inch ));
976  // #i23296# In Calc, "BottomMargin" property is distance to bottom of footer if enabled
977  aPropMap.setProperty( PROP_BottomMargin, rUnitConv.scaleToMm100( maFooterData.mbHasContent ? rModel.mfFooterMargin : rModel.mfBottomMargin, Unit::Inch ));
978  aPropMap.setProperty( PROP_HeaderIsOn, maHeaderData.mbHasContent);
979  aPropMap.setProperty( PROP_HeaderIsShared, maHeaderData.mbShareOddEven);
980  aPropMap.setProperty( PROP_HeaderIsDynamicHeight, maHeaderData.mbDynamicHeight);
981  aPropMap.setProperty( PROP_HeaderHeight, maHeaderData.mnHeight);
982  aPropMap.setProperty( PROP_HeaderBodyDistance, maHeaderData.mnBodyDist);
983  aPropMap.setProperty( PROP_FooterIsOn, maFooterData.mbHasContent);
984  aPropMap.setProperty( PROP_FooterIsShared, maFooterData.mbShareOddEven);
985  aPropMap.setProperty( PROP_FooterIsDynamicHeight, maFooterData.mbDynamicHeight);
986  aPropMap.setProperty( PROP_FooterHeight, maFooterData.mnHeight);
987  aPropMap.setProperty( PROP_FooterBodyDistance, maFooterData.mnBodyDist);
988  // background image
989  if (rModel.mxGraphic.is())
990  {
991  aPropMap.setProperty(PROP_BackGraphic, rModel.mxGraphic);
992  aPropMap.setProperty(PROP_BackGraphicLocation, css::style::GraphicLocation_TILED);
993  }
994 
995  rPropSet.setProperties( aPropMap );
996 }
997 
999  PropertySet& rPropSet, HFHelperData& orHFData,
1000  const OUString& rOddContent, const OUString& rEvenContent, bool bUseEvenContent,
1001  double fPageMargin, double fContentMargin )
1002 {
1003  bool bHasOddContent = !rOddContent.isEmpty();
1004  bool bHasEvenContent = bUseEvenContent && !rEvenContent.isEmpty();
1005 
1006  sal_Int32 nOddHeight = bHasOddContent ? writeHeaderFooter( rPropSet, orHFData.mnRightPropId, rOddContent ) : 0;
1007  sal_Int32 nEvenHeight = bHasEvenContent ? writeHeaderFooter( rPropSet, orHFData.mnLeftPropId, rEvenContent ) : 0;
1008 
1009  orHFData.mnHeight = 750;
1010  orHFData.mnBodyDist = 250;
1011  orHFData.mbHasContent = bHasOddContent || bHasEvenContent;
1012  orHFData.mbShareOddEven = !bUseEvenContent;
1013  orHFData.mbDynamicHeight = true;
1014 
1015  if( !orHFData.mbHasContent )
1016  return;
1017 
1018  // use maximum height of odd/even header/footer
1019  orHFData.mnHeight = ::std::max( nOddHeight, nEvenHeight );
1020  /* Calc contains distance between bottom of header and top of page
1021  body in "HeaderBodyDistance" property, and distance between bottom
1022  of page body and top of footer in "FooterBodyDistance" property */
1023  orHFData.mnBodyDist = getUnitConverter().scaleToMm100( fPageMargin - fContentMargin, Unit::Inch ) - orHFData.mnHeight;
1024  /* #i23296# Distance less than 0 means, header or footer overlays page
1025  body. As this is not possible in Calc, set fixed header or footer
1026  height (crop header/footer) to get correct top position of page body. */
1027  orHFData.mbDynamicHeight = orHFData.mnBodyDist >= 0;
1028  /* "HeaderHeight" property is in fact distance from top of header to
1029  top of page body (including "HeaderBodyDistance").
1030  "FooterHeight" property is in fact distance from bottom of page
1031  body to bottom of footer (including "FooterBodyDistance"). */
1032  orHFData.mnHeight += orHFData.mnBodyDist;
1033  // negative body distance not allowed
1034  orHFData.mnBodyDist = ::std::max< sal_Int32 >( orHFData.mnBodyDist, 0 );
1035 }
1036 
1038  PropertySet& rPropSet, sal_Int32 nPropId, const OUString& rContent )
1039 {
1040  OSL_ENSURE( !rContent.isEmpty(), "PageSettingsConverter::writeHeaderFooter - empty h/f string found" );
1041  sal_Int32 nHeight = 0;
1042  if( !rContent.isEmpty() )
1043  {
1044  Reference<sheet::XHeaderFooterContent> xHFContent(rPropSet.getAnyProperty(nPropId), UNO_QUERY);
1045  if( xHFContent.is() )
1046  {
1047  double fTotalHeight = mxHFParser->parse( xHFContent, rContent );
1048  rPropSet.setProperty( nPropId, xHFContent );
1049  nHeight = getUnitConverter().scaleToMm100( fTotalHeight, Unit::Point );
1050  }
1051  }
1052  return nHeight;
1053 }
1054 
1055 } // namespace oox
1056 
1057 /* 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.
double mfHeight
Windows font character set.
double mfCurrHeight
Sum of heights of previous lines in points.
double mnHeight
Color maColor
Font name.
void appendLineBreak()
Appends a line break and adjusts internal text height data.
Contains all XML font attributes, e.g.
constexpr OUStringLiteral gaFileNameService(u"com.sun.star.text.TextField.FileName")
sal_Int32 mnHorPrintRes
Fit to number of pages in vertical direction.
sal_Int32 mnPrintErrors
Cell comments printing mode.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
HFHelperData(sal_Int32 nLeftPropId, sal_Int32 nRightPropId)
static bool convertMeasure(sal_Int32 &rValue, const OUString &rString, sal_Int16 nTargetUnit=css::util::MeasureUnit::MM_100TH, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
OUString maFirstFooter
Header string for first page of the sheet.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
OUString maBinSettPath
Background Graphic.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
sal_Int32 mnCopies
Paper height in twips.
void convertHeaderFooterData(PropertySet &rPropSet, HFHelperData &orHFData, const OUString &rOddContent, const OUString &rEvenContent, bool bUseEvenContent, double fPageMargin, double fContentMargin)
PageSettings(const WorksheetHelper &rHelper)
constexpr OUStringLiteral gaPageNumberService(u"com.sun.star.text.TextField.PageNumber")
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
double mnScale
bool setProperty(sal_Int32 nPropId, Type &&rValue)
sal_Int32 mnFitToWidth
First page number.
const ContentProperties & rData
Reference< text::XTextCursor > mxEnd
Start position of current text range for formatting.
sal_Int32 mnUnderline
Font height in points.
double parse(const Reference< sheet::XHeaderFooterContent > &rxContext, const OUString &rData)
Parses the passed string and creates the header/footer contents.
Helper class that provides functions to convert values from and to different units.
OptValue< double > getDouble(sal_Int32 nAttrToken) const
void importHeaderFooter(const AttributeList &rAttribs)
Imports header and footer settings from a headerFooter element.
#define STATIC_ARRAY_SELECT(array, index, def)
OptValue< OUString > getString(sal_Int32 nAttrToken) const
void importHeaderFooterCharacters(const OUString &rChars, sal_Int32 nElement)
Imports header/footer characters from a headerFooter element.
bool mbVerCenter
True = horizontally centered.
OUString maEvenHeader
Footer string for odd pages.
sal_Int32 mnFirstPage
Page scale (zoom in percent).
const Reference< text::XTextCursor > & getEndPos()
Returns the end cursor of the current text range.
bool mbBold
Escapement style.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
::std::vector< HFPortionInfo > HFPortionInfoVec
css::uno::Reference< css::graphic::XGraphic > mxGraphic
sal_Int32 scaleToMm100(double fValue, Unit eUnit) const
Converts the passed value to 1/100 millimeters.
GraphicHelper & getGraphicHelper() const
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
bool mbPrintGrid
True = vertically centered.
OUString maOddHeader
Relation identifier of binary printer settings.
sal_uInt16 sal_Unicode
sal_uInt16 readuInt16()
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.
static const ApiPaperSize & getApiSizeForMSPaperSizeIndex(sal_Int32 nMSOPaperIndex)
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.
sal_Int32 mnCellComments
Page order through sheet area (to left or down).
HeaderFooterParserPtr mxHFParser
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
HFPortionInfo & getPortion()
Returns the current edit engine text object.
const std::set< OString > maItalicNames
All names for bold font style in lowercase UTF-8.
void finalizePortion()
Finalizes current portion: sets font attributes and updates text height data.
double getCurrHeight(HFPortionId ePortion) const
Returns the current line height of the specified portion.
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.
bool getFlag(Type nBitField, Type nMask)
#define SAL_N_ELEMENTS(arr)
void setAttributes()
Sets the font attributes at the current selection.
PageSettingsConverter(const WorkbookHelper &rHelper)
PageSettingsConverter & getPageSettingsConverter() const
Returns the page and print settings converter.
bool mbStrikeout
True = italic characters.
HFPortionInfoVec maPortions
All names for italic font style in lowercase UTF-8.
css::uno::Reference< css::graphic::XGraphic > importEmbeddedGraphic(const OUString &rStreamName, const WmfExternal *pExtHeader=nullptr) const
OUString maEvenFooter
Header string for even pages.
constexpr OUStringLiteral gaDateTimeService(u"com.sun.star.text.TextField.DateTime")
FontModel maFontModel
Text data to append to current text range.
double mfTotalHeight
End position of current text range for formatting.
void convertFontStyle(const OUString &rStyle)
Converts a font style given as string.
void appendField(const Reference< text::XTextContent > &rxContent)
Appends the passed text field.
WorksheetType getSheetType() const
Returns the type of this sheet.
const FontModel & getDefaultFontModel() const
Returns the model of the default application font (used in the "Normal" cell style).
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:78
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
bool mbItalic
True = bold characters.
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.
const std::set< OString > maBoldNames
Reference< text::XText > mxText
sal_Int32 mnPageOrder
Landscape or portrait.
OUStringBuffer maBuffer
Identifier of current H/F portion.
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.
const Reference< text::XTextCursor > & getStartPos()
Returns the start cursor of the current text range.
Reference< text::XTextCursor > mxStart
XText interface of this portion.
bool mbUseFirstHF
True = use maEvenHeader/maEvenFooter.
sal_Int32 mnPaperHeight
Paper width in twips.
OUString maOddFooter
Header string for odd pages.
Reference< text::XTextContent > createField(const OUString &rServiceName) const
Creates a text field from the passed service name.
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
bool mbOutline
True = Strike out characters.
PageSettingsModel maModel
void setTheme(sal_Int32 nThemeIdx, double fTint=0.0)
Sets the color to the passed theme index.
double mfTopMargin
Margin between end of sheet area and right edge of page.
SC_DLLPUBLIC void SetPageStyle(SCTAB nTab, const OUString &rName)
Definition: document.cxx:6180
bool mbValidSettings
True = use maFirstHeader/maFirstFooter.
void setNewPortion(HFPortionId ePortion)
Changes current header/footer portion.
void appendText()
Appends and clears internal string buffer.
void finalizeImport()
Final processing after import of all style settings.
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.
const css::uno::Reference< css::sheet::XSpreadsheet > & getSheet() const
Returns the XSpreadsheet interface of the current sheet.
unsigned char sal_uInt8
void writeToPropertySet(PropertySet &rPropSet) const
Writes all font attributes to the passed property set.
void importPageSetup(const ::oox::core::Relations &rRelations, const AttributeList &rAttribs)
Imports pageSetup element for worksheets.
sal_Int32 mnEscapement
Underline style.
sal_Int32 mnOrientation
Vertical printing resolution in DPI.
ReturnType getFlagValue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
virtual ~PageSettingsConverter() override
bool mbPrintHeadings
True = print grid lines.
SCTAB getSheetIndex() const
Returns the index of the current sheet.
void convertFontName(const OUString &rStyle)
Sets the passed font name if it is valid.
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.
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.
uno::Reference< ucb::XContent > xContent
bool mbDraftQuality
True = print black and white.
void convertFontColor(const OUString &rColor)
Converts a font color given as string.
sal_Int32 writeHeaderFooter(PropertySet &rPropSet, sal_Int32 nPropId, const OUString &rContent)
void setFitToPagesMode(bool bFitToPages)
Sets whether percentual scaling or fit to width/height scaling is used.
HeaderFooterParser(const WorkbookHelper &rHelper)
PageSettingsModel()
True = print column/row headings.
WorksheetType
An enumeration for all types of sheets in a workbook.
constexpr OUStringLiteral gaPageCountService(u"com.sun.star.text.TextField.PageCount")
void updateCurrHeight()
Updates the current line height, using the current font size.
bool mbUseFirstPage
True = use imported settings.
sal_Int32 mnVerPrintRes
Horizontal printing resolution in DPI.
OUString maFirstHeader
Footer string for even pages.
aStr
void setRgb(::Color nRgbValue, double fTint=0.0)
Sets the color to the passed RGB value.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
bool mbShadow
True = outlined characters.
sal_uInt16 nPos
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
sal_Int16 SCTAB
Definition: types.hxx:23
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.
constexpr OUStringLiteral gaSheetNameService(u"com.sun.star.text.TextField.SheetName")