use insert function instead of for loop
[LibreOffice.git] / sc / source / filter / excel / xepage.cxx
blob28779bd209a1d308a6c27659fda77a38097031a4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <utility>
21 #include <xepage.hxx>
22 #include <svl/itemset.hxx>
23 #include <scitems.hxx>
24 #include <svl/eitem.hxx>
25 #include <svl/intitem.hxx>
26 #include <svx/pageitem.hxx>
27 #include <editeng/sizeitem.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <editeng/ulspitem.hxx>
30 #include <editeng/brushitem.hxx>
31 #include <oox/export/utils.hxx>
32 #include <oox/token/tokens.hxx>
33 #include <sax/fastattribs.hxx>
34 #include <document.hxx>
35 #include <stlpool.hxx>
36 #include <attrib.hxx>
37 #include <xehelper.hxx>
38 #include <xeescher.hxx>
39 #include <xltools.hxx>
41 #include <set>
42 #include <limits>
44 using namespace ::oox;
46 using ::std::set;
47 using ::std::numeric_limits;
49 // Page settings records ======================================================
51 // Header/footer --------------------------------------------------------------
53 XclExpHeaderFooter::XclExpHeaderFooter( sal_uInt16 nRecId, OUString aHdrString ) :
54 XclExpRecord( nRecId ),
55 maHdrString(std::move( aHdrString ))
59 void XclExpHeaderFooter::SaveXml( XclExpXmlStream& rStrm )
61 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
62 sal_Int32 nElement;
63 switch(GetRecId()) {
64 case EXC_ID_HEADER_FIRST: nElement = XML_firstHeader; break;
65 case EXC_ID_FOOTER_FIRST: nElement = XML_firstFooter; break;
66 case EXC_ID_HEADER_EVEN: nElement = XML_evenHeader; break;
67 case EXC_ID_FOOTER_EVEN: nElement = XML_evenFooter; break;
68 case EXC_ID_HEADER: nElement = XML_oddHeader; break;
69 case EXC_ID_FOOTER:
70 default: nElement = XML_oddFooter;
72 rWorksheet->startElement(nElement);
73 rWorksheet->writeEscaped( maHdrString );
74 rWorksheet->endElement( nElement );
77 void XclExpHeaderFooter::WriteBody( XclExpStream& rStrm )
79 if( !maHdrString.isEmpty() )
81 XclExpString aExString;
82 if( rStrm.GetRoot().GetBiff() <= EXC_BIFF5 )
83 aExString.AssignByte( maHdrString, rStrm.GetRoot().GetTextEncoding(), XclStrFlags::EightBitLength );
84 else
85 aExString.Assign( maHdrString, XclStrFlags::NONE, 255 ); // 16-bit length, but max 255 chars
86 rStrm << aExString;
90 // General page settings ------------------------------------------------------
92 XclExpSetup::XclExpSetup( const XclPageData& rPageData ) :
93 XclExpRecord( EXC_ID_SETUP, 34 ),
94 mrData( rPageData )
98 void XclExpSetup::SaveXml( XclExpXmlStream& rStrm )
100 rtl::Reference<sax_fastparser::FastAttributeList> pAttrList = sax_fastparser::FastSerializerHelper::createAttrList();
101 if( rStrm.getVersion() != oox::core::ISOIEC_29500_2008 ||
102 mrData.mnStrictPaperSize != EXC_PAPERSIZE_USER )
104 pAttrList->add( XML_paperSize, OString::number( mrData.mnPaperSize ) );
106 else
108 pAttrList->add( XML_paperWidth, OString::number( mrData.mnPaperWidth ) + "mm" );
109 pAttrList->add( XML_paperHeight, OString::number( mrData.mnPaperHeight ) + "mm" );
110 // pAttrList->add( XML_paperUnits, "mm" );
112 pAttrList->add( XML_scale, OString::number( mrData.mnScaling ) );
113 pAttrList->add( XML_fitToWidth, OString::number( mrData.mnFitToWidth ) );
114 pAttrList->add( XML_fitToHeight, OString::number( mrData.mnFitToHeight ) );
115 pAttrList->add( XML_pageOrder, mrData.mbPrintInRows ? "overThenDown" : "downThenOver" );
116 pAttrList->add( XML_orientation, mrData.mbPortrait ? "portrait" : "landscape" ); // OOXTODO: "default"?
117 // tdf#48767 if XML_usePrinterDefaults field is exist, then XML_orientation is always "portrait" in MS Excel
118 // To resolve that import issue, if XML_usePrinterDefaults has default value (false) then XML_usePrinterDefaults is not added.
119 if ( !mrData.mbValid )
120 pAttrList->add( XML_usePrinterDefaults, ToPsz( !mrData.mbValid ) );
121 pAttrList->add( XML_blackAndWhite, ToPsz( mrData.mbBlackWhite ) );
122 pAttrList->add( XML_draft, ToPsz( mrData.mbDraftQuality ) );
123 pAttrList->add( XML_cellComments, mrData.mbPrintNotes ? "atEnd" : "none" ); // OOXTODO: "asDisplayed"?
125 if ( mrData.mbManualStart )
127 pAttrList->add( XML_firstPageNumber, OString::number( mrData.mnStartPage ) );
128 pAttrList->add( XML_useFirstPageNumber, ToPsz( mrData.mbManualStart ) );
130 // OOXTODO: XML_errors, // == displayed|blank|dash|NA
131 pAttrList->add( XML_horizontalDpi, OString::number( mrData.mnHorPrintRes ) );
132 pAttrList->add( XML_verticalDpi, OString::number( mrData.mnVerPrintRes ) );
133 pAttrList->add( XML_copies, OString::number( mrData.mnCopies ) );
134 // OOXTODO: devMode settings part RelationshipId: FSNS( XML_r, XML_id ),
136 rStrm.GetCurrentStream()->singleElement( XML_pageSetup, pAttrList );
139 void XclExpSetup::WriteBody( XclExpStream& rStrm )
141 XclBiff eBiff = rStrm.GetRoot().GetBiff();
143 sal_uInt16 nFlags = 0;
144 ::set_flag( nFlags, EXC_SETUP_INROWS, mrData.mbPrintInRows );
145 ::set_flag( nFlags, EXC_SETUP_PORTRAIT, mrData.mbPortrait );
146 ::set_flag( nFlags, EXC_SETUP_INVALID, !mrData.mbValid );
147 ::set_flag( nFlags, EXC_SETUP_BLACKWHITE, mrData.mbBlackWhite );
148 if( eBiff >= EXC_BIFF5 )
150 ::set_flag( nFlags, EXC_SETUP_DRAFT, mrData.mbDraftQuality );
151 /* Set the Comments/Notes to "At end of sheet" if Print Notes is true.
152 We don't currently support "as displayed on sheet". Thus this value
153 will be re-interpreted to "At end of sheet". */
154 const sal_uInt16 nNotes = EXC_SETUP_PRINTNOTES | EXC_SETUP_NOTES_END;
155 ::set_flag( nFlags, nNotes, mrData.mbPrintNotes );
156 ::set_flag( nFlags, EXC_SETUP_STARTPAGE, mrData.mbManualStart );
159 rStrm << mrData.mnPaperSize << mrData.mnScaling << mrData.mnStartPage
160 << mrData.mnFitToWidth << mrData.mnFitToHeight << nFlags;
161 if( eBiff >= EXC_BIFF5 )
163 rStrm << mrData.mnHorPrintRes << mrData.mnVerPrintRes
164 << mrData.mfHeaderMargin << mrData.mfFooterMargin << mrData.mnCopies;
168 // Manual page breaks ---------------------------------------------------------
170 XclExpPageBreaks::XclExpPageBreaks( sal_uInt16 nRecId, const ScfUInt16Vec& rPageBreaks, sal_uInt16 nMaxPos ) :
171 XclExpRecord( nRecId ),
172 mrPageBreaks( rPageBreaks ),
173 mnMaxPos( nMaxPos )
177 void XclExpPageBreaks::Save( XclExpStream& rStrm )
179 if( !mrPageBreaks.empty() )
181 SetRecSize( 2 + ((rStrm.GetRoot().GetBiff() <= EXC_BIFF5) ? 2 : 6) * mrPageBreaks.size() );
182 XclExpRecord::Save( rStrm );
186 void XclExpPageBreaks::WriteBody( XclExpStream& rStrm )
188 bool bWriteRange = (rStrm.GetRoot().GetBiff() == EXC_BIFF8);
190 rStrm << static_cast< sal_uInt16 >( mrPageBreaks.size() );
191 for( const auto& rPageBreak : mrPageBreaks )
193 rStrm << rPageBreak;
194 if( bWriteRange )
195 rStrm << sal_uInt16( 0 ) << mnMaxPos;
199 void XclExpPageBreaks::SaveXml( XclExpXmlStream& rStrm )
201 if( mrPageBreaks.empty() )
202 return;
204 sal_Int32 nElement = GetRecId() == EXC_ID_HORPAGEBREAKS ? XML_rowBreaks : XML_colBreaks;
205 sax_fastparser::FSHelperPtr& pWorksheet = rStrm.GetCurrentStream();
206 OString sNumPageBreaks = OString::number( mrPageBreaks.size() );
207 pWorksheet->startElement( nElement,
208 XML_count, sNumPageBreaks,
209 XML_manualBreakCount, sNumPageBreaks );
210 for( const auto& rPageBreak : mrPageBreaks )
212 pWorksheet->singleElement( XML_brk,
213 XML_id, OString::number(rPageBreak),
214 XML_man, "true",
215 XML_max, OString::number(mnMaxPos),
216 XML_min, "0"
217 // OOXTODO: XML_pt, ""
220 pWorksheet->endElement( nElement );
223 // Page settings ==============================================================
225 XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) :
226 XclExpRoot( rRoot )
228 ScDocument& rDoc = GetDoc();
229 SCTAB nScTab = GetCurrScTab();
231 if( SfxStyleSheetBase* pStyleSheet = GetStyleSheetPool().Find( rDoc.GetPageStyle( nScTab ), SfxStyleFamily::Page ) )
233 const SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
234 maData.mbValid = true;
236 // *** page settings ***
238 maData.mbPrintInRows = ! rItemSet.Get( ATTR_PAGE_TOPDOWN ).GetValue();
239 maData.mbHorCenter = rItemSet.Get( ATTR_PAGE_HORCENTER ).GetValue();
240 maData.mbVerCenter = rItemSet.Get( ATTR_PAGE_VERCENTER ).GetValue();
241 maData.mbPrintHeadings = rItemSet.Get( ATTR_PAGE_HEADERS ).GetValue();
242 maData.mbPrintGrid = rItemSet.Get( ATTR_PAGE_GRID ).GetValue();
243 maData.mbPrintNotes = rItemSet.Get( ATTR_PAGE_NOTES ).GetValue();
245 maData.mnStartPage = rItemSet.Get( ATTR_PAGE_FIRSTPAGENO ).GetValue();
246 maData.mbManualStart = maData.mnStartPage && (!nScTab || rDoc.NeedPageResetAfterTab( nScTab - 1 ));
248 const SvxLRSpaceItem& rLRItem = rItemSet.Get( ATTR_LRSPACE );
249 maData.mfLeftMargin = XclTools::GetInchFromTwips(rLRItem.ResolveLeft({}));
250 maData.mfRightMargin = XclTools::GetInchFromTwips(rLRItem.ResolveRight({}));
251 const SvxULSpaceItem& rULItem = rItemSet.Get( ATTR_ULSPACE );
252 maData.mfTopMargin = XclTools::GetInchFromTwips( rULItem.GetUpper() );
253 maData.mfBottomMargin = XclTools::GetInchFromTwips( rULItem.GetLower() );
255 const SvxPageItem& rPageItem = rItemSet.Get( ATTR_PAGE );
256 const SvxSizeItem& rSizeItem = rItemSet.Get( ATTR_PAGE_SIZE );
257 maData.SetScPaperSize( rSizeItem.GetSize(), !rPageItem.IsLandscape() );
259 const ScPageScaleToItem& rScaleToItem = rItemSet.Get( ATTR_PAGE_SCALETO );
260 sal_uInt16 nPages = rItemSet.Get( ATTR_PAGE_SCALETOPAGES ).GetValue();
261 sal_uInt16 nScale = rItemSet.Get( ATTR_PAGE_SCALE ).GetValue();
263 if( ScfTools::CheckItem( rItemSet, ATTR_PAGE_SCALETO, false ) && rScaleToItem.IsValid() )
265 maData.mnFitToWidth = rScaleToItem.GetWidth();
266 maData.mnFitToHeight = rScaleToItem.GetHeight();
267 maData.mbFitToPages = true;
269 else if( ScfTools::CheckItem( rItemSet, ATTR_PAGE_SCALETOPAGES, false ) && nPages )
271 maData.mnFitToWidth = 1;
272 maData.mnFitToHeight = nPages;
273 maData.mbFitToPages = true;
275 else if( nScale )
277 maData.mnScaling = nScale;
278 maData.mbFitToPages = false;
281 maData.mxBrushItem.reset( new SvxBrushItem( rItemSet.Get( ATTR_BACKGROUND ) ) );
282 maData.mbUseEvenHF = false;
283 maData.mbUseFirstHF = false;
285 // *** header and footer ***
287 XclExpHFConverter aHFConv( GetRoot() );
289 // header
290 const SfxItemSet& rHdrItemSet = rItemSet.Get( ATTR_PAGE_HEADERSET ).GetItemSet();
291 if( rHdrItemSet.Get( ATTR_PAGE_ON ).GetValue() )
293 const ScPageHFItem& rHFItem = rItemSet.Get( ATTR_PAGE_HEADERRIGHT );
294 aHFConv.GenerateString( rHFItem.GetLeftArea(), rHFItem.GetCenterArea(), rHFItem.GetRightArea() );
295 maData.maHeader = aHFConv.GetHFString();
296 if ( rHdrItemSet.HasItem(ATTR_PAGE_SHARED) && !rHdrItemSet.Get(ATTR_PAGE_SHARED).GetValue())
298 const ScPageHFItem& rHFItemLeft = rItemSet.Get( ATTR_PAGE_HEADERLEFT );
299 aHFConv.GenerateString( rHFItemLeft.GetLeftArea(), rHFItemLeft.GetCenterArea(), rHFItemLeft.GetRightArea() );
300 maData.maHeaderEven = aHFConv.GetHFString();
301 maData.mbUseEvenHF = true;
303 else
305 // If maData.mbUseEvenHF become true, then we will need a copy of maHeader in maHeaderEven.
306 maData.maHeaderEven = maData.maHeader;
308 if (rHdrItemSet.HasItem(ATTR_PAGE_SHARED_FIRST) && !rHdrItemSet.Get(ATTR_PAGE_SHARED_FIRST).GetValue())
310 const ScPageHFItem& rHFItemFirst = rItemSet.Get( ATTR_PAGE_HEADERFIRST );
311 aHFConv.GenerateString( rHFItemFirst.GetLeftArea(), rHFItemFirst.GetCenterArea(), rHFItemFirst.GetRightArea() );
312 maData.maHeaderFirst = aHFConv.GetHFString();
313 maData.mbUseFirstHF = true;
315 else
317 maData.maHeaderFirst = maData.maHeader;
319 // header height (Excel excludes header from top margin)
320 sal_Int32 nHdrHeight = rHdrItemSet.Get( ATTR_PAGE_DYNAMIC ).GetValue() ?
321 // dynamic height: calculate header height, add header <-> sheet area distance
322 (aHFConv.GetTotalHeight() + rHdrItemSet.Get( ATTR_ULSPACE ).GetLower()) :
323 // static height: ATTR_PAGE_SIZE already includes header <-> sheet area distance
324 static_cast< sal_Int32 >( rHdrItemSet.Get( ATTR_PAGE_SIZE ).GetSize().Height() );
325 maData.mfHeaderMargin = maData.mfTopMargin;
326 maData.mfTopMargin += XclTools::GetInchFromTwips( nHdrHeight );
329 // footer
330 const SfxItemSet& rFtrItemSet = rItemSet.Get( ATTR_PAGE_FOOTERSET ).GetItemSet();
331 if( rFtrItemSet.Get( ATTR_PAGE_ON ).GetValue() )
333 const ScPageHFItem& rHFItem = rItemSet.Get( ATTR_PAGE_FOOTERRIGHT );
334 aHFConv.GenerateString( rHFItem.GetLeftArea(), rHFItem.GetCenterArea(), rHFItem.GetRightArea() );
335 maData.maFooter = aHFConv.GetHFString();
336 if (rFtrItemSet.HasItem(ATTR_PAGE_SHARED) && !rFtrItemSet.Get(ATTR_PAGE_SHARED).GetValue())
338 const ScPageHFItem& rHFItemLeft = rItemSet.Get( ATTR_PAGE_FOOTERLEFT );
339 aHFConv.GenerateString( rHFItemLeft.GetLeftArea(), rHFItemLeft.GetCenterArea(), rHFItemLeft.GetRightArea() );
340 maData.maFooterEven = aHFConv.GetHFString();
341 maData.mbUseEvenHF = true;
343 else
345 maData.maFooterEven = maData.maFooter;
347 if (rFtrItemSet.HasItem(ATTR_PAGE_SHARED_FIRST) && !rFtrItemSet.Get(ATTR_PAGE_SHARED_FIRST).GetValue())
349 const ScPageHFItem& rHFItemFirst = rItemSet.Get( ATTR_PAGE_FOOTERFIRST );
350 aHFConv.GenerateString( rHFItemFirst.GetLeftArea(), rHFItemFirst.GetCenterArea(), rHFItemFirst.GetRightArea() );
351 maData.maFooterFirst = aHFConv.GetHFString();
352 maData.mbUseFirstHF = true;
354 else
356 maData.maFooterFirst = maData.maFooter;
358 // footer height (Excel excludes footer from bottom margin)
359 sal_Int32 nFtrHeight = rFtrItemSet.Get( ATTR_PAGE_DYNAMIC ).GetValue() ?
360 // dynamic height: calculate footer height, add sheet area <-> footer distance
361 (aHFConv.GetTotalHeight() + rFtrItemSet.Get( ATTR_ULSPACE ).GetUpper()) :
362 // static height: ATTR_PAGE_SIZE already includes sheet area <-> footer distance
363 static_cast< sal_Int32 >( rFtrItemSet.Get( ATTR_PAGE_SIZE ).GetSize().Height() );
364 maData.mfFooterMargin = maData.mfBottomMargin;
365 maData.mfBottomMargin += XclTools::GetInchFromTwips( nFtrHeight );
369 // *** page breaks ***
371 set<SCROW> aRowBreaks;
372 rDoc.GetAllRowBreaks(aRowBreaks, nScTab, false, true);
374 SCROW const nMaxRow = numeric_limits<sal_uInt16>::max();
375 for (const SCROW nRow : aRowBreaks)
377 if (nRow > nMaxRow)
378 break;
380 maData.maHorPageBreaks.push_back(nRow);
383 if (maData.maHorPageBreaks.size() > 1026)
385 // Excel allows only up to 1026 page breaks. Trim any excess page breaks.
386 ScfUInt16Vec::iterator itr = maData.maHorPageBreaks.begin();
387 ::std::advance(itr, 1026);
388 maData.maHorPageBreaks.erase(itr, maData.maHorPageBreaks.end());
391 set<SCCOL> aColBreaks;
392 rDoc.GetAllColBreaks(aColBreaks, nScTab, false, true);
393 for (const auto& rColBreak : aColBreaks)
394 maData.maVerPageBreaks.push_back(rColBreak);
397 namespace {
399 class XclExpXmlStartHeaderFooterElementRecord : public XclExpXmlElementRecord
401 public:
402 explicit XclExpXmlStartHeaderFooterElementRecord(sal_Int32 const nElement, bool const bDifferentOddEven = false, bool const bDifferentFirst = false)
403 : XclExpXmlElementRecord(nElement), mbDifferentOddEven(bDifferentOddEven), mbDifferentFirst(bDifferentFirst) {}
405 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
406 private:
407 bool mbDifferentOddEven;
408 bool mbDifferentFirst;
413 void XclExpXmlStartHeaderFooterElementRecord::SaveXml(XclExpXmlStream& rStrm)
415 // OOXTODO: we currently only emit oddHeader/oddFooter elements, and
416 // do not support the first/even/odd page distinction.
417 sax_fastparser::FSHelperPtr& rStream = rStrm.GetCurrentStream();
418 rStream->startElement( mnElement,
419 // OOXTODO: XML_alignWithMargins,
420 XML_differentFirst, mbDifferentFirst ? "true" : "false",
421 XML_differentOddEven, mbDifferentOddEven ? "true" : "false"
422 // OOXTODO: XML_scaleWithDoc
426 void XclExpPageSettings::Save( XclExpStream& rStrm )
428 XclExpBoolRecord( EXC_ID_PRINTHEADERS, maData.mbPrintHeadings ).Save( rStrm );
429 XclExpBoolRecord( EXC_ID_PRINTGRIDLINES, maData.mbPrintGrid ).Save( rStrm );
430 XclExpBoolRecord( EXC_ID_GRIDSET, true ).Save( rStrm );
431 XclExpPageBreaks( EXC_ID_HORPAGEBREAKS, maData.maHorPageBreaks, static_cast< sal_uInt16 >( GetXclMaxPos().Col() ) ).Save( rStrm );
432 XclExpPageBreaks( EXC_ID_VERPAGEBREAKS, maData.maVerPageBreaks, static_cast< sal_uInt16 >( GetXclMaxPos().Row() ) ).Save( rStrm );
433 XclExpHeaderFooter( EXC_ID_HEADER, maData.maHeader ).Save( rStrm );
434 XclExpHeaderFooter( EXC_ID_FOOTER, maData.maFooter ).Save( rStrm );
435 XclExpBoolRecord( EXC_ID_HCENTER, maData.mbHorCenter ).Save( rStrm );
436 XclExpBoolRecord( EXC_ID_VCENTER, maData.mbVerCenter ).Save( rStrm );
437 XclExpDoubleRecord( EXC_ID_LEFTMARGIN, maData.mfLeftMargin ).Save( rStrm );
438 XclExpDoubleRecord( EXC_ID_RIGHTMARGIN, maData.mfRightMargin ).Save( rStrm );
439 XclExpDoubleRecord( EXC_ID_TOPMARGIN, maData.mfTopMargin ).Save( rStrm );
440 XclExpDoubleRecord( EXC_ID_BOTTOMMARGIN, maData.mfBottomMargin ).Save( rStrm );
441 XclExpSetup( maData ).Save( rStrm );
443 if( (GetBiff() == EXC_BIFF8) && maData.mxBrushItem )
444 if( const Graphic* pGraphic = maData.mxBrushItem->GetGraphic() )
445 XclExpImgData( *pGraphic, EXC_ID8_IMGDATA ).Save( rStrm );
448 void XclExpPageSettings::SaveXml( XclExpXmlStream& rStrm )
450 XclExpXmlStartSingleElementRecord( XML_printOptions ).SaveXml( rStrm );
451 XclExpBoolRecord( EXC_ID_PRINTHEADERS, maData.mbPrintHeadings, XML_headings ).SaveXml( rStrm );
452 XclExpBoolRecord( EXC_ID_PRINTGRIDLINES, maData.mbPrintGrid, XML_gridLines ).SaveXml( rStrm );
453 XclExpBoolRecord( EXC_ID_GRIDSET, true, XML_gridLinesSet ).SaveXml( rStrm );
454 XclExpBoolRecord( EXC_ID_HCENTER, maData.mbHorCenter, XML_horizontalCentered ).SaveXml( rStrm );
455 XclExpBoolRecord( EXC_ID_VCENTER, maData.mbVerCenter, XML_verticalCentered ).SaveXml( rStrm );
456 XclExpXmlEndSingleElementRecord().SaveXml( rStrm ); // XML_printOptions
458 XclExpXmlStartSingleElementRecord( XML_pageMargins ).SaveXml( rStrm );
459 XclExpDoubleRecord( EXC_ID_LEFTMARGIN, maData.mfLeftMargin ).SetAttribute( XML_left )->SaveXml( rStrm );
460 XclExpDoubleRecord( EXC_ID_RIGHTMARGIN, maData.mfRightMargin ).SetAttribute( XML_right )->SaveXml( rStrm );
461 XclExpDoubleRecord( EXC_ID_TOPMARGIN, maData.mfTopMargin ).SetAttribute( XML_top )->SaveXml( rStrm );
462 XclExpDoubleRecord( EXC_ID_BOTTOMMARGIN, maData.mfBottomMargin ).SetAttribute( XML_bottom )->SaveXml( rStrm );
463 XclExpDoubleRecord( 0, maData.mfHeaderMargin).SetAttribute( XML_header )->SaveXml( rStrm );
464 XclExpDoubleRecord( 0, maData.mfFooterMargin).SetAttribute( XML_footer )->SaveXml( rStrm );
465 XclExpXmlEndSingleElementRecord().SaveXml( rStrm ); // XML_pageMargins
467 XclExpSetup( maData ).SaveXml( rStrm );
469 XclExpXmlStartHeaderFooterElementRecord(XML_headerFooter, maData.mbUseEvenHF, maData.mbUseFirstHF).SaveXml(rStrm);
470 XclExpHeaderFooter( EXC_ID_HEADER, maData.maHeader ).SaveXml( rStrm );
471 XclExpHeaderFooter( EXC_ID_FOOTER, maData.maFooter ).SaveXml( rStrm );
472 if (maData.mbUseEvenHF)
474 XclExpHeaderFooter( EXC_ID_HEADER_EVEN, maData.maHeaderEven ).SaveXml( rStrm );
475 XclExpHeaderFooter( EXC_ID_FOOTER_EVEN, maData.maFooterEven ).SaveXml( rStrm );
477 if (maData.mbUseFirstHF)
479 XclExpHeaderFooter( EXC_ID_HEADER_FIRST, maData.maHeaderFirst ).SaveXml( rStrm );
480 XclExpHeaderFooter( EXC_ID_FOOTER_FIRST, maData.maFooterFirst ).SaveXml( rStrm );
482 XclExpXmlEndElementRecord( XML_headerFooter ).SaveXml( rStrm );
484 XclExpPageBreaks( EXC_ID_HORPAGEBREAKS, maData.maHorPageBreaks,
485 static_cast< sal_uInt16 >( GetXclMaxPos().Col() ) ).SaveXml( rStrm );
486 XclExpPageBreaks( EXC_ID_VERPAGEBREAKS, maData.maVerPageBreaks,
487 static_cast< sal_uInt16 >( GetXclMaxPos().Row() ) ).SaveXml( rStrm );
490 XclExpImgData* XclExpPageSettings::getGraphicExport()
492 if( const Graphic* pGraphic = maData.mxBrushItem->GetGraphic() )
493 return new XclExpImgData( *pGraphic, EXC_ID8_IMGDATA );
495 return nullptr;
498 XclExpChartPageSettings::XclExpChartPageSettings( const XclExpRoot& rRoot ) :
499 XclExpRoot( rRoot )
503 void XclExpChartPageSettings::Save( XclExpStream& rStrm )
505 XclExpHeaderFooter( EXC_ID_HEADER, maData.maHeader ).Save( rStrm );
506 XclExpHeaderFooter( EXC_ID_FOOTER, maData.maFooter ).Save( rStrm );
507 XclExpBoolRecord( EXC_ID_HCENTER, maData.mbHorCenter ).Save( rStrm );
508 XclExpBoolRecord( EXC_ID_VCENTER, maData.mbVerCenter ).Save( rStrm );
509 XclExpSetup( maData ).Save( rStrm );
510 XclExpUInt16Record( EXC_ID_PRINTSIZE, EXC_PRINTSIZE_FULL ).Save( rStrm );
513 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */