Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "pagesettings.hxx"
30 : :
31 : : #include <algorithm>
32 : : #include <set>
33 : : #include <com/sun/star/awt/Size.hpp>
34 : : #include <com/sun/star/container/XNamed.hpp>
35 : : #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
36 : : #include <com/sun/star/style/GraphicLocation.hpp>
37 : : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
38 : : #include <com/sun/star/text/XText.hpp>
39 : : #include <com/sun/star/text/XTextContent.hpp>
40 : : #include <com/sun/star/text/XTextCursor.hpp>
41 : : #include <rtl/strbuf.hxx>
42 : : #include <rtl/ustrbuf.hxx>
43 : : #include "oox/core/xmlfilterbase.hxx"
44 : : #include "oox/helper/attributelist.hxx"
45 : : #include "oox/helper/graphichelper.hxx"
46 : : #include "oox/helper/propertymap.hxx"
47 : : #include "oox/helper/propertyset.hxx"
48 : : #include "biffinputstream.hxx"
49 : : #include "excelhandlers.hxx"
50 : : #include "stylesbuffer.hxx"
51 : : #include "unitconverter.hxx"
52 : : #include <sax/tools/converter.hxx>
53 : :
54 : : namespace oox {
55 : : namespace xls {
56 : :
57 : : // ============================================================================
58 : :
59 : : using namespace ::com::sun::star;
60 : : using namespace ::com::sun::star::awt;
61 : : using namespace ::com::sun::star::container;
62 : : using namespace ::com::sun::star::lang;
63 : : using namespace ::com::sun::star::sheet;
64 : : using namespace ::com::sun::star::style;
65 : : using namespace ::com::sun::star::text;
66 : : using namespace ::com::sun::star::uno;
67 : :
68 : : using ::oox::core::Relations;
69 : : using ::rtl::OString;
70 : : using ::rtl::OStringBuffer;
71 : : using ::rtl::OUString;
72 : : using ::rtl::OUStringBuffer;
73 : :
74 : : // ============================================================================
75 : :
76 : : namespace {
77 : :
78 : : const double OOX_MARGIN_DEFAULT_LR = 0.748; /// Left/right default margin in inches.
79 : : const double OOX_MARGIN_DEFAULT_TB = 0.984; /// Top/bottom default margin in inches.
80 : : const double OOX_MARGIN_DEFAULT_HF = 0.512; /// Header/footer default margin in inches.
81 : :
82 : : const sal_uInt16 BIFF12_PRINTOPT_HORCENTER = 0x0001;
83 : : const sal_uInt16 BIFF12_PRINTOPT_VERCENTER = 0x0002;
84 : : const sal_uInt16 BIFF12_PRINTOPT_PRINTHEADING = 0x0004;
85 : : const sal_uInt16 BIFF12_PRINTOPT_PRINTGRID = 0x0008;
86 : :
87 : : const sal_uInt16 BIFF12_HEADERFOOTER_DIFFEVEN = 0x0001;
88 : : const sal_uInt16 BIFF12_HEADERFOOTER_DIFFFIRST = 0x0002;
89 : : const sal_uInt16 BIFF12_HEADERFOOTER_SCALEDOC = 0x0004;
90 : : const sal_uInt16 BIFF12_HEADERFOOTER_ALIGNMARGIN = 0x0008;
91 : :
92 : : const sal_uInt16 BIFF12_PAGESETUP_INROWS = 0x0001;
93 : : const sal_uInt16 BIFF12_PAGESETUP_LANDSCAPE = 0x0002;
94 : : const sal_uInt16 BIFF12_PAGESETUP_INVALID = 0x0004;
95 : : const sal_uInt16 BIFF12_PAGESETUP_BLACKWHITE = 0x0008;
96 : : const sal_uInt16 BIFF12_PAGESETUP_DRAFTQUALITY = 0x0010;
97 : : const sal_uInt16 BIFF12_PAGESETUP_PRINTNOTES = 0x0020;
98 : : const sal_uInt16 BIFF12_PAGESETUP_DEFAULTORIENT = 0x0040;
99 : : const sal_uInt16 BIFF12_PAGESETUP_USEFIRSTPAGE = 0x0080;
100 : : const sal_uInt16 BIFF12_PAGESETUP_NOTES_END = 0x0100; // different to BIFF flag
101 : :
102 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_LANDSCAPE = 0x0001;
103 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_INVALID = 0x0002;
104 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_BLACKWHITE = 0x0004;
105 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_DEFAULTORIENT= 0x0008;
106 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_USEFIRSTPAGE = 0x0010;
107 : : const sal_uInt16 BIFF12_CHARTPAGESETUP_DRAFTQUALITY = 0x0020;
108 : :
109 : : const sal_uInt16 BIFF_PAGESETUP_INROWS = 0x0001;
110 : : const sal_uInt16 BIFF_PAGESETUP_PORTRAIT = 0x0002;
111 : : const sal_uInt16 BIFF_PAGESETUP_INVALID = 0x0004;
112 : : const sal_uInt16 BIFF_PAGESETUP_BLACKWHITE = 0x0008;
113 : : const sal_uInt16 BIFF_PAGESETUP_DRAFTQUALITY = 0x0010;
114 : : const sal_uInt16 BIFF_PAGESETUP_PRINTNOTES = 0x0020;
115 : : const sal_uInt16 BIFF_PAGESETUP_DEFAULTORIENT = 0x0040;
116 : : const sal_uInt16 BIFF_PAGESETUP_USEFIRSTPAGE = 0x0080;
117 : : const sal_uInt16 BIFF_PAGESETUP_NOTES_END = 0x0200;
118 : :
119 : : } // namespace
120 : :
121 : : // ============================================================================
122 : :
123 : 60 : PageSettingsModel::PageSettingsModel() :
124 : : mfLeftMargin( OOX_MARGIN_DEFAULT_LR ),
125 : : mfRightMargin( OOX_MARGIN_DEFAULT_LR ),
126 : : mfTopMargin( OOX_MARGIN_DEFAULT_TB ),
127 : : mfBottomMargin( OOX_MARGIN_DEFAULT_TB ),
128 : : mfHeaderMargin( OOX_MARGIN_DEFAULT_HF ),
129 : : mfFooterMargin( OOX_MARGIN_DEFAULT_HF ),
130 : : mnPaperSize( 1 ),
131 : : mnPaperWidth( 0 ),
132 : : mnPaperHeight( 0 ),
133 : : mnCopies( 1 ),
134 : : mnScale( 100 ),
135 : : mnFirstPage( 1 ),
136 : : mnFitToWidth( 1 ),
137 : : mnFitToHeight( 1 ),
138 : : mnHorPrintRes( 600 ),
139 : : mnVerPrintRes( 600 ),
140 : : mnOrientation( XML_default ),
141 : : mnPageOrder( XML_downThenOver ),
142 : : mnCellComments( XML_none ),
143 : : mnPrintErrors( XML_displayed ),
144 : : mbUseEvenHF( false ),
145 : : mbUseFirstHF( false ),
146 : : mbValidSettings( true ),
147 : : mbUseFirstPage( false ),
148 : : mbBlackWhite( false ),
149 : : mbDraftQuality( false ),
150 : : mbFitToPages( false ),
151 : : mbHorCenter( false ),
152 : : mbVerCenter( false ),
153 : : mbPrintGrid( false ),
154 : 60 : mbPrintHeadings( false )
155 : : {
156 : 60 : }
157 : :
158 : 0 : void PageSettingsModel::setBiffPrintErrors( sal_uInt8 nPrintErrors )
159 : : {
160 : : static const sal_Int32 spnErrorIds[] = { XML_displayed, XML_none, XML_dash, XML_NA };
161 [ # # ]: 0 : mnPrintErrors = STATIC_ARRAY_SELECT( spnErrorIds, nPrintErrors, XML_none );
162 : 0 : }
163 : :
164 : : // ============================================================================
165 : :
166 : 60 : PageSettings::PageSettings( const WorksheetHelper& rHelper ) :
167 : 60 : WorksheetHelper( rHelper )
168 : : {
169 : 60 : }
170 : :
171 : 42 : void PageSettings::importPrintOptions( const AttributeList& rAttribs )
172 : : {
173 : 42 : maModel.mbHorCenter = rAttribs.getBool( XML_horizontalCentered, false );
174 : 42 : maModel.mbVerCenter = rAttribs.getBool( XML_verticalCentered, false );
175 : 42 : maModel.mbPrintGrid = rAttribs.getBool( XML_gridLines, false );
176 : 42 : maModel.mbPrintHeadings = rAttribs.getBool( XML_headings, false );
177 : 42 : }
178 : :
179 : 60 : void PageSettings::importPageMargins( const AttributeList& rAttribs )
180 : : {
181 : 60 : maModel.mfLeftMargin = rAttribs.getDouble( XML_left, OOX_MARGIN_DEFAULT_LR );
182 : 60 : maModel.mfRightMargin = rAttribs.getDouble( XML_right, OOX_MARGIN_DEFAULT_LR );
183 : 60 : maModel.mfTopMargin = rAttribs.getDouble( XML_top, OOX_MARGIN_DEFAULT_TB );
184 : 60 : maModel.mfBottomMargin = rAttribs.getDouble( XML_bottom, OOX_MARGIN_DEFAULT_TB );
185 : 60 : maModel.mfHeaderMargin = rAttribs.getDouble( XML_header, OOX_MARGIN_DEFAULT_HF );
186 : 60 : maModel.mfFooterMargin = rAttribs.getDouble( XML_footer, OOX_MARGIN_DEFAULT_HF );
187 : 60 : }
188 : :
189 : 45 : void PageSettings::importPageSetup( const Relations& rRelations, const AttributeList& rAttribs )
190 : : {
191 : 45 : OUString aStr;
192 [ + - ][ + - ]: 45 : maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
193 [ + - ]: 45 : maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 );
194 [ + - ]: 45 : aStr = rAttribs.getString ( XML_paperWidth, OUString() );
195 : : ::sax::Converter::convertMeasure(
196 [ + - ]: 45 : maModel.mnPaperWidth, aStr, util::MeasureUnit::MM_100TH);
197 [ + - ]: 45 : aStr = rAttribs.getString ( XML_paperHeight, OUString() );
198 : : ::sax::Converter::convertMeasure(
199 [ + - ]: 45 : maModel.mnPaperHeight, aStr, util::MeasureUnit::MM_100TH );
200 [ + - ]: 45 : maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 );
201 [ + - ]: 45 : maModel.mnScale = rAttribs.getInteger( XML_scale, 100 );
202 [ + - ]: 45 : maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 );
203 [ + - ]: 45 : maModel.mnFitToWidth = rAttribs.getInteger( XML_fitToWidth, 1 );
204 [ + - ]: 45 : maModel.mnFitToHeight = rAttribs.getInteger( XML_fitToHeight, 1 );
205 [ + - ]: 45 : maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 );
206 [ + - ]: 45 : maModel.mnVerPrintRes = rAttribs.getInteger( XML_verticalDpi, 600 );
207 [ + - ]: 45 : maModel.mnOrientation = rAttribs.getToken( XML_orientation, XML_default );
208 [ + - ]: 45 : maModel.mnPageOrder = rAttribs.getToken( XML_pageOrder, XML_downThenOver );
209 [ + - ]: 45 : maModel.mnCellComments = rAttribs.getToken( XML_cellComments, XML_none );
210 [ + - ]: 45 : maModel.mnPrintErrors = rAttribs.getToken( XML_errors, XML_displayed );
211 [ + - ]: 45 : maModel.mbValidSettings = rAttribs.getBool( XML_usePrinterDefaults, false );
212 [ + - ]: 45 : maModel.mbUseFirstPage = rAttribs.getBool( XML_useFirstPageNumber, false );
213 [ + - ]: 45 : maModel.mbBlackWhite = rAttribs.getBool( XML_blackAndWhite, false );
214 [ + - ]: 45 : maModel.mbDraftQuality = rAttribs.getBool( XML_draft, false );
215 : 45 : }
216 : :
217 : 0 : void PageSettings::importChartPageSetup( const Relations& rRelations, const AttributeList& rAttribs )
218 : : {
219 : 0 : OUString aStr;
220 [ # # ][ # # ]: 0 : maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
221 [ # # ]: 0 : maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 );
222 [ # # ]: 0 : aStr = rAttribs.getString ( XML_paperWidth, OUString() );
223 : : ::sax::Converter::convertMeasure(
224 [ # # ]: 0 : maModel.mnPaperWidth, aStr, util::MeasureUnit::MM_100TH );
225 [ # # ]: 0 : aStr = rAttribs.getString ( XML_paperHeight, OUString() );
226 : : ::sax::Converter::convertMeasure(
227 [ # # ]: 0 : maModel.mnPaperHeight, aStr, util::MeasureUnit::MM_100TH );
228 [ # # ]: 0 : maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 );
229 [ # # ]: 0 : maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 );
230 [ # # ]: 0 : maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 );
231 [ # # ]: 0 : maModel.mnVerPrintRes = rAttribs.getInteger( XML_verticalDpi, 600 );
232 [ # # ]: 0 : maModel.mnOrientation = rAttribs.getToken( XML_orientation, XML_default );
233 [ # # ]: 0 : maModel.mbValidSettings = rAttribs.getBool( XML_usePrinterDefaults, false );
234 [ # # ]: 0 : maModel.mbUseFirstPage = rAttribs.getBool( XML_useFirstPageNumber, false );
235 [ # # ]: 0 : maModel.mbBlackWhite = rAttribs.getBool( XML_blackAndWhite, false );
236 [ # # ]: 0 : maModel.mbDraftQuality = rAttribs.getBool( XML_draft, false );
237 : 0 : }
238 : :
239 : 51 : void PageSettings::importHeaderFooter( const AttributeList& rAttribs )
240 : : {
241 : 51 : maModel.mbUseEvenHF = rAttribs.getBool( XML_differentOddEven, false );
242 : 51 : maModel.mbUseFirstHF = rAttribs.getBool( XML_differentFirst, false );
243 : 51 : }
244 : :
245 : 102 : void PageSettings::importHeaderFooterCharacters( const OUString& rChars, sal_Int32 nElement )
246 : : {
247 [ + + - - : 102 : switch( nElement )
- - - ]
248 : : {
249 : 51 : case XLS_TOKEN( oddHeader ): maModel.maOddHeader += rChars; break;
250 : 51 : case XLS_TOKEN( oddFooter ): maModel.maOddFooter += rChars; break;
251 : 0 : case XLS_TOKEN( evenHeader ): maModel.maEvenHeader += rChars; break;
252 : 0 : case XLS_TOKEN( evenFooter ): maModel.maEvenFooter += rChars; break;
253 : 0 : case XLS_TOKEN( firstHeader ): maModel.maFirstHeader += rChars; break;
254 : 0 : case XLS_TOKEN( firstFooter ): maModel.maFirstFooter += rChars; break;
255 : : }
256 : 102 : }
257 : :
258 : 0 : void PageSettings::importPicture( const Relations& rRelations, const AttributeList& rAttribs )
259 : : {
260 [ # # ][ # # ]: 0 : importPictureData( rRelations, rAttribs.getString( R_TOKEN( id ), OUString() ) );
261 : 0 : }
262 : :
263 : 0 : void PageSettings::importPageMargins( SequenceInputStream& rStrm )
264 : : {
265 : 0 : rStrm >> maModel.mfLeftMargin >> maModel.mfRightMargin
266 : 0 : >> maModel.mfTopMargin >> maModel.mfBottomMargin
267 : 0 : >> maModel.mfHeaderMargin >> maModel.mfFooterMargin;
268 : 0 : }
269 : :
270 : 0 : void PageSettings::importPrintOptions( SequenceInputStream& rStrm )
271 : : {
272 : : sal_uInt16 nFlags;
273 [ # # ]: 0 : rStrm >> nFlags;
274 : 0 : maModel.mbHorCenter = getFlag( nFlags, BIFF12_PRINTOPT_HORCENTER );
275 : 0 : maModel.mbVerCenter = getFlag( nFlags, BIFF12_PRINTOPT_VERCENTER );
276 : 0 : maModel.mbPrintGrid = getFlag( nFlags, BIFF12_PRINTOPT_PRINTGRID );
277 : 0 : maModel.mbPrintHeadings = getFlag( nFlags, BIFF12_PRINTOPT_PRINTHEADING );
278 : 0 : }
279 : :
280 : 0 : void PageSettings::importPageSetup( const Relations& rRelations, SequenceInputStream& rStrm )
281 : : {
282 : 0 : OUString aRelId;
283 : : sal_uInt16 nFlags;
284 [ # # ][ # # ]: 0 : rStrm >> maModel.mnPaperSize >> maModel.mnScale
285 [ # # ][ # # ]: 0 : >> maModel.mnHorPrintRes >> maModel.mnVerPrintRes
286 [ # # ][ # # ]: 0 : >> maModel.mnCopies >> maModel.mnFirstPage
287 [ # # ][ # # ]: 0 : >> maModel.mnFitToWidth >> maModel.mnFitToHeight
288 [ # # ][ # # ]: 0 : >> nFlags >> aRelId;
289 : 0 : maModel.setBiffPrintErrors( extractValue< sal_uInt8 >( nFlags, 9, 2 ) );
290 [ # # ]: 0 : maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( aRelId );
291 : 0 : maModel.mnOrientation = getFlagValue( nFlags, BIFF12_PAGESETUP_DEFAULTORIENT, XML_default, getFlagValue( nFlags, BIFF12_PAGESETUP_LANDSCAPE, XML_landscape, XML_portrait ) );
292 : 0 : maModel.mnPageOrder = getFlagValue( nFlags, BIFF12_PAGESETUP_INROWS, XML_overThenDown, XML_downThenOver );
293 : 0 : maModel.mnCellComments = getFlagValue( nFlags, BIFF12_PAGESETUP_PRINTNOTES, getFlagValue( nFlags, BIFF12_PAGESETUP_NOTES_END, XML_atEnd, XML_asDisplayed ), XML_none );
294 : 0 : maModel.mbValidSettings = !getFlag( nFlags, BIFF12_PAGESETUP_INVALID );
295 : 0 : maModel.mbUseFirstPage = getFlag( nFlags, BIFF12_PAGESETUP_USEFIRSTPAGE );
296 : 0 : maModel.mbBlackWhite = getFlag( nFlags, BIFF12_PAGESETUP_BLACKWHITE );
297 : 0 : maModel.mbDraftQuality = getFlag( nFlags, BIFF12_PAGESETUP_DRAFTQUALITY );
298 : 0 : }
299 : :
300 : 0 : void PageSettings::importChartPageSetup( const Relations& rRelations, SequenceInputStream& rStrm )
301 : : {
302 : 0 : OUString aRelId;
303 : : sal_uInt16 nFirstPage, nFlags;
304 [ # # ][ # # ]: 0 : rStrm >> maModel.mnPaperSize >> maModel.mnHorPrintRes >> maModel.mnVerPrintRes
[ # # ]
305 [ # # ][ # # ]: 0 : >> maModel.mnCopies >> nFirstPage >> nFlags >> aRelId;
[ # # ][ # # ]
306 [ # # ]: 0 : maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( aRelId );
307 : 0 : maModel.mnFirstPage = nFirstPage; // 16-bit in CHARTPAGESETUP
308 : 0 : maModel.mnOrientation = getFlagValue( nFlags, BIFF12_CHARTPAGESETUP_DEFAULTORIENT, XML_default, getFlagValue( nFlags, BIFF12_CHARTPAGESETUP_LANDSCAPE, XML_landscape, XML_portrait ) );
309 : 0 : maModel.mbValidSettings = !getFlag( nFlags, BIFF12_CHARTPAGESETUP_INVALID );
310 : 0 : maModel.mbUseFirstPage = getFlag( nFlags, BIFF12_CHARTPAGESETUP_USEFIRSTPAGE );
311 : 0 : maModel.mbBlackWhite = getFlag( nFlags, BIFF12_CHARTPAGESETUP_BLACKWHITE );
312 : 0 : maModel.mbDraftQuality = getFlag( nFlags, BIFF12_CHARTPAGESETUP_DRAFTQUALITY );
313 : 0 : }
314 : :
315 : 0 : void PageSettings::importHeaderFooter( SequenceInputStream& rStrm )
316 : : {
317 : : sal_uInt16 nFlags;
318 [ # # ]: 0 : rStrm >> nFlags
319 [ # # ][ # # ]: 0 : >> maModel.maOddHeader >> maModel.maOddFooter
320 [ # # ][ # # ]: 0 : >> maModel.maEvenHeader >> maModel.maEvenFooter
321 [ # # ][ # # ]: 0 : >> maModel.maFirstHeader >> maModel.maFirstFooter;
322 : 0 : maModel.mbUseEvenHF = getFlag( nFlags, BIFF12_HEADERFOOTER_DIFFEVEN );
323 : 0 : maModel.mbUseFirstHF = getFlag( nFlags, BIFF12_HEADERFOOTER_DIFFFIRST );
324 : 0 : }
325 : :
326 : 0 : void PageSettings::importPicture( const Relations& rRelations, SequenceInputStream& rStrm )
327 : : {
328 [ # # ]: 0 : importPictureData( rRelations, BiffHelper::readString( rStrm ) );
329 : 0 : }
330 : :
331 : 42 : void PageSettings::setFitToPagesMode( bool bFitToPages )
332 : : {
333 : 42 : maModel.mbFitToPages = bFitToPages;
334 : 42 : }
335 : :
336 : 60 : void PageSettings::finalizeImport()
337 : : {
338 [ + - ][ + - ]: 60 : OUStringBuffer aStyleNameBuffer( CREATE_OUSTRING( "PageStyle_" ) );
339 [ + - ][ + - ]: 60 : Reference< XNamed > xSheetName( getSheet(), UNO_QUERY );
340 [ + - ]: 60 : if( xSheetName.is() )
341 [ + - ][ + - ]: 60 : aStyleNameBuffer.append( xSheetName->getName() );
[ + - ]
342 : : else
343 [ # # ][ # # ]: 0 : aStyleNameBuffer.append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) );
344 [ + - ]: 60 : OUString aStyleName = aStyleNameBuffer.makeStringAndClear();
345 : :
346 [ + - ]: 60 : Reference< XStyle > xStyle = createStyleObject( aStyleName, true );
347 [ + - ]: 60 : PropertySet aStyleProps( xStyle );
348 [ + - ][ + - ]: 60 : getPageSettingsConverter().writePageSettingsProperties( aStyleProps, maModel, getSheetType() );
[ + - ]
349 : :
350 [ + - ][ + - ]: 60 : PropertySet aSheetProps( getSheet() );
351 [ + - ][ + - ]: 60 : aSheetProps.setProperty( PROP_PageStyle, aStyleName );
[ + - ]
352 : 60 : }
353 : :
354 : 0 : void PageSettings::importPictureData( const Relations& rRelations, const OUString& rRelId )
355 : : {
356 [ # # ]: 0 : OUString aPicturePath = rRelations.getFragmentPathFromRelId( rRelId );
357 [ # # ]: 0 : if( !aPicturePath.isEmpty() )
358 [ # # ][ # # ]: 0 : maModel.maGraphicUrl = getBaseFilter().getGraphicHelper().importEmbeddedGraphicObject( aPicturePath );
[ # # ]
359 : 0 : }
360 : :
361 : : // ============================================================================
362 : : // ============================================================================
363 : :
364 : : enum HFPortionId
365 : : {
366 : : HF_LEFT,
367 : : HF_CENTER,
368 : : HF_RIGHT,
369 : : HF_COUNT
370 : : };
371 : :
372 : : // ----------------------------------------------------------------------------
373 : :
374 : 144 : struct HFPortionInfo
375 : : {
376 : : Reference< XText > mxText; /// XText interface of this portion.
377 : : Reference< XTextCursor > mxStart; /// Start position of current text range for formatting.
378 : : Reference< XTextCursor > mxEnd; /// End position of current text range for formatting.
379 : : double mfTotalHeight; /// Sum of heights of previous lines in points.
380 : : double mfCurrHeight; /// Height of the current text line in points.
381 : :
382 : : bool initialize( const Reference< XText >& rxText );
383 : : };
384 : :
385 : 306 : bool HFPortionInfo::initialize( const Reference< XText >& rxText )
386 : : {
387 : 306 : mfTotalHeight = mfCurrHeight = 0.0;
388 : 306 : mxText = rxText;
389 [ + - ]: 306 : if( mxText.is() )
390 : : {
391 [ + - ]: 306 : mxStart = mxText->createTextCursor();
392 [ + - ]: 306 : mxEnd = mxText->createTextCursor();
393 : : }
394 [ + - ][ + - ]: 306 : bool bRet = mxText.is() && mxStart.is() && mxEnd.is();
[ + - ]
395 : : OSL_ENSURE( bRet, "HFPortionInfo::initialize - missing interfaces" );
396 : 306 : return bRet;
397 : : }
398 : :
399 : : // ============================================================================
400 : :
401 [ + - ][ - + ]: 48 : class HeaderFooterParser : public WorkbookHelper
402 : : {
403 : : public:
404 : : explicit HeaderFooterParser( const WorkbookHelper& rHelper );
405 : :
406 : : /** Parses the passed string and creates the header/footer contents.
407 : : @returns The total height of the converted header or footer in points. */
408 : : double parse(
409 : : const Reference< XHeaderFooterContent >& rxContext,
410 : : const OUString& rData );
411 : :
412 : : private:
413 : : /** Returns the current edit engine text object. */
414 : 1362 : inline HFPortionInfo& getPortion() { return maPortions[ meCurrPortion ]; }
415 : : /** Returns the start cursor of the current text range. */
416 : 264 : inline const Reference< XTextCursor >& getStartPos() { return getPortion().mxStart; }
417 : : /** Returns the end cursor of the current text range. */
418 : 996 : inline const Reference< XTextCursor >& getEndPos() { return getPortion().mxEnd; }
419 : :
420 : : /** Returns the current line height of the specified portion. */
421 : : double getCurrHeight( HFPortionId ePortion ) const;
422 : : /** Returns the current line height. */
423 : : double getCurrHeight() const;
424 : :
425 : : /** Updates the current line height of the specified portion, using the current font size. */
426 : : void updateCurrHeight( HFPortionId ePortion );
427 : : /** Updates the current line height, using the current font size. */
428 : : void updateCurrHeight();
429 : :
430 : : /** Sets the font attributes at the current selection. */
431 : : void setAttributes();
432 : : /** Appends and clears internal string buffer. */
433 : : void appendText();
434 : : /** Appends a line break and adjusts internal text height data. */
435 : : void appendLineBreak();
436 : :
437 : : /** Creates a text field from the passed service name. */
438 : : Reference< XTextContent > createField( const OUString& rServiceName ) const;
439 : : /** Appends the passed text field. */
440 : : void appendField( const Reference< XTextContent >& rxContent );
441 : :
442 : : /** Sets the passed font name if it is valid. */
443 : : void convertFontName( const OUString& rStyle );
444 : : /** Converts a font style given as string. */
445 : : void convertFontStyle( const OUString& rStyle );
446 : : /** Converts a font color given as string. */
447 : : void convertFontColor( const OUString& rColor );
448 : :
449 : : /** Finalizes current portion: sets font attributes and updates text height data. */
450 : : void finalizePortion();
451 : : /** Changes current header/footer portion. */
452 : : void setNewPortion( HFPortionId ePortion );
453 : :
454 : : private:
455 : : typedef ::std::vector< HFPortionInfo > HFPortionInfoVec;
456 : : typedef ::std::set< OString > OStringSet;
457 : :
458 : : const OUString maPageNumberService;
459 : : const OUString maPageCountService;
460 : : const OUString maSheetNameService;
461 : : const OUString maFileNameService;
462 : : const OUString maDateTimeService;
463 : : const OStringSet maBoldNames; /// All names for bold font style in lowercase UTF-8.
464 : : const OStringSet maItalicNames; /// All names for italic font style in lowercase UTF-8.
465 : : HFPortionInfoVec maPortions;
466 : : HFPortionId meCurrPortion; /// Identifier of current H/F portion.
467 : : OUStringBuffer maBuffer; /// Text data to append to current text range.
468 : : FontModel maFontModel; /// Font attributes of current text range.
469 : : };
470 : :
471 : : // ----------------------------------------------------------------------------
472 : :
473 : : namespace {
474 : :
475 : : // different names for bold font style (lowercase)
476 : : static const sal_Char* const sppcBoldNames[] =
477 : : {
478 : : "bold",
479 : : "fett", // German 'bold'
480 : : "demibold",
481 : : "halbfett", // German 'demibold'
482 : : "black",
483 : : "heavy"
484 : : };
485 : :
486 : : // different names for italic font style (lowercase)
487 : : static const sal_Char* const sppcItalicNames[] =
488 : : {
489 : : "italic",
490 : : "kursiv", // German 'italic'
491 : : "oblique",
492 : : "schr\303\204g", // German 'oblique' with uppercase A umlaut
493 : : "schr\303\244g" // German 'oblique' with lowercase A umlaut
494 : : };
495 : :
496 : : } // namespace
497 : :
498 : : // ----------------------------------------------------------------------------
499 : :
500 : 24 : HeaderFooterParser::HeaderFooterParser( const WorkbookHelper& rHelper ) :
501 : : WorkbookHelper( rHelper ),
502 : : maPageNumberService( CREATE_OUSTRING( "com.sun.star.text.TextField.PageNumber" ) ),
503 : : maPageCountService( CREATE_OUSTRING( "com.sun.star.text.TextField.PageCount" ) ),
504 : : maSheetNameService( CREATE_OUSTRING( "com.sun.star.text.TextField.SheetName" ) ),
505 : : maFileNameService( CREATE_OUSTRING( "com.sun.star.text.TextField.FileName" ) ),
506 : : maDateTimeService( CREATE_OUSTRING( "com.sun.star.text.TextField.DateTime" ) ),
507 : : maBoldNames( sppcBoldNames, STATIC_ARRAY_END( sppcBoldNames ) ),
508 : : maItalicNames( sppcItalicNames, STATIC_ARRAY_END( sppcItalicNames ) ),
509 : : maPortions( static_cast< size_t >( HF_COUNT ) ),
510 [ + - ][ + - ]: 24 : meCurrPortion( HF_CENTER )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
511 : : {
512 : 24 : }
513 : :
514 : 102 : double HeaderFooterParser::parse( const Reference< XHeaderFooterContent >& rxContext, const OUString& rData )
515 : : {
516 [ + - ][ + - ]: 510 : if( !rxContext.is() || rData.isEmpty() ||
[ + - ][ + - ]
[ - + ][ - + ]
517 [ + - ][ + - ]: 204 : !maPortions[ HF_LEFT ].initialize( rxContext->getLeftText() ) ||
[ + - ][ + - ]
[ # # ]
518 [ + - ][ + - ]: 204 : !maPortions[ HF_CENTER ].initialize( rxContext->getCenterText() ) ||
[ + - ][ + - ]
[ # # ]
519 [ + - ][ + - ]: 204 : !maPortions[ HF_RIGHT ].initialize( rxContext->getRightText() ) )
[ + - ][ + - ]
[ # # ]
520 : 0 : return 0.0;
521 : :
522 : 102 : meCurrPortion = HF_CENTER;
523 [ + - ]: 102 : maBuffer.setLength( 0 );
524 [ + - ][ + - ]: 102 : maFontModel = getStyles().getDefaultFontModel();
[ + - ]
525 : 102 : OUStringBuffer aFontName; // current font name
526 : 102 : OUStringBuffer aFontStyle; // current font style
527 : 102 : sal_Int32 nFontHeight = 0; // current font height
528 : :
529 : : /** State of the parser. */
530 : : enum
531 : : {
532 : : STATE_TEXT, /// Literal text data.
533 : : STATE_TOKEN, /// Control token following a '&' character.
534 : : STATE_FONTNAME, /// Font name ('&' is followed by '"', reads until next '"' or ',').
535 : : STATE_FONTSTYLE, /// Font style name (font part after ',', reads until next '"').
536 : : STATE_FONTHEIGHT /// Font height ('&' is followed by num. digits, reads until non-digit).
537 : : }
538 : 102 : eState = STATE_TEXT;
539 : :
540 : 102 : const sal_Unicode* pcChar = rData.getStr();
541 : 102 : const sal_Unicode* pcEnd = pcChar + rData.getLength();
542 [ + + ][ + - ]: 1665 : for( ; (pcChar != pcEnd) && (*pcChar != 0); ++pcChar )
[ + + ]
543 : : {
544 : 1563 : sal_Unicode cChar = *pcChar;
545 [ + + + + : 1563 : switch( eState )
+ - ]
546 : : {
547 : : case STATE_TEXT:
548 : : {
549 [ + - + ]: 519 : switch( cChar )
550 : : {
551 : : case '&': // new token
552 [ + - ]: 264 : appendText();
553 : 264 : eState = STATE_TOKEN;
554 : 264 : break;
555 : : case '\n': // line break
556 [ # # ]: 0 : appendText();
557 [ # # ]: 0 : appendLineBreak();
558 : 0 : break;
559 : : default:
560 [ + - ]: 255 : maBuffer.append( cChar );
561 : : }
562 : : }
563 : 519 : break;
564 : :
565 : : case STATE_TOKEN:
566 : : {
567 : : // default: back to text mode, may be changed in specific cases
568 : 264 : eState = STATE_TEXT;
569 : : // ignore case of token codes
570 [ - + ][ # # ]: 264 : if( ('a' <= cChar) && (cChar <= 'z') )
571 : 0 : (cChar -= 'a') += 'A';
572 [ - - + - : 264 : switch( cChar )
+ - + - -
- - - - -
- - - - -
- - + + ]
573 : : {
574 [ # # ]: 0 : case '&': maBuffer.append( cChar ); break; // the '&' character
575 : :
576 [ # # ]: 0 : case 'L': setNewPortion( HF_LEFT ); break; // left portion
577 [ + - ]: 102 : case 'C': setNewPortion( HF_CENTER ); break; // center portion
578 [ # # ]: 0 : case 'R': setNewPortion( HF_RIGHT ); break; // right portion
579 : :
580 : : case 'P': // page number
581 [ + - ][ + - ]: 51 : appendField( createField( maPageNumberService ) );
582 : 51 : break;
583 : : case 'N': // total page count
584 [ # # ][ # # ]: 0 : appendField( createField( maPageCountService ) );
585 : 0 : break;
586 : : case 'A': // current sheet name
587 [ + - ][ + - ]: 51 : appendField( createField( maSheetNameService ) );
588 : 51 : break;
589 : :
590 : : case 'F': // file name
591 : : {
592 [ # # ]: 0 : Reference< XTextContent > xContent = createField( maFileNameService );
593 [ # # ]: 0 : PropertySet aPropSet( xContent );
594 [ # # ]: 0 : aPropSet.setProperty( PROP_FileFormat, ::com::sun::star::text::FilenameDisplayFormat::NAME_AND_EXT );
595 [ # # ][ # # ]: 0 : appendField( xContent );
596 : : }
597 : 0 : break;
598 : : case 'Z': // file path (without file name), OOXML, BIFF12, and BIFF8 only
599 [ # # ][ # # ]: 0 : if( (getFilterType() == FILTER_OOXML) || ((getFilterType() == FILTER_BIFF) && (getBiff() == BIFF8)) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
600 : : {
601 [ # # ]: 0 : Reference< XTextContent > xContent = createField( maFileNameService );
602 [ # # ]: 0 : PropertySet aPropSet( xContent );
603 : : // FilenameDisplayFormat::PATH not supported by Calc
604 [ # # ]: 0 : aPropSet.setProperty( PROP_FileFormat, ::com::sun::star::text::FilenameDisplayFormat::FULL );
605 [ # # ]: 0 : appendField( xContent );
606 : : /* path only is not supported -- if we find a '&Z&F'
607 : : combination for path/name, skip the '&F' part */
608 [ # # ][ # # ]: 0 : if( (pcChar + 2 < pcEnd) && (pcChar[ 1 ] == '&') && ((pcChar[ 2 ] == 'f') || (pcChar[ 2 ] == 'F')) )
[ # # ][ # # ]
609 [ # # ]: 0 : pcChar += 2;
610 : : }
611 : 0 : break;
612 : : case 'D': // date
613 : : {
614 [ # # ]: 0 : Reference< XTextContent > xContent = createField( maDateTimeService );
615 [ # # ]: 0 : PropertySet aPropSet( xContent );
616 [ # # ]: 0 : aPropSet.setProperty( PROP_IsDate, true );
617 [ # # ][ # # ]: 0 : appendField( xContent );
618 : : }
619 : 0 : break;
620 : : case 'T': // time
621 : : {
622 [ # # ]: 0 : Reference< XTextContent > xContent = createField( maDateTimeService );
623 [ # # ]: 0 : PropertySet aPropSet( xContent );
624 [ # # ]: 0 : aPropSet.setProperty( PROP_IsDate, false );
625 [ # # ][ # # ]: 0 : appendField( xContent );
626 : : }
627 : 0 : break;
628 : :
629 : : case 'B': // bold
630 [ # # ]: 0 : setAttributes();
631 : 0 : maFontModel.mbBold = !maFontModel.mbBold;
632 : 0 : break;
633 : : case 'I': // italic
634 [ # # ]: 0 : setAttributes();
635 : 0 : maFontModel.mbItalic = !maFontModel.mbItalic;
636 : 0 : break;
637 : : case 'U': // underline
638 [ # # ]: 0 : setAttributes();
639 [ # # ]: 0 : maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_single) ? XML_none : XML_single;
640 : 0 : break;
641 : : case 'E': // double underline
642 [ # # ]: 0 : setAttributes();
643 [ # # ]: 0 : maFontModel.mnUnderline = (maFontModel.mnUnderline == XML_double) ? XML_none : XML_double;
644 : 0 : break;
645 : : case 'S': // strikeout
646 [ # # ]: 0 : setAttributes();
647 : 0 : maFontModel.mbStrikeout = !maFontModel.mbStrikeout;
648 : 0 : break;
649 : : case 'X': // superscript
650 [ # # ]: 0 : setAttributes();
651 [ # # ]: 0 : maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_superscript) ? XML_baseline : XML_superscript;
652 : 0 : break;
653 : : case 'Y': // subsrcipt
654 [ # # ]: 0 : setAttributes();
655 [ # # ]: 0 : maFontModel.mnEscapement = (maFontModel.mnEscapement == XML_subscript) ? XML_baseline : XML_subscript;
656 : 0 : break;
657 : : case 'O': // outlined
658 [ # # ]: 0 : setAttributes();
659 : 0 : maFontModel.mbOutline = !maFontModel.mbOutline;
660 : 0 : break;
661 : : case 'H': // shadow
662 [ # # ]: 0 : setAttributes();
663 : 0 : maFontModel.mbShadow = !maFontModel.mbShadow;
664 : 0 : break;
665 : :
666 : : case 'K': // text color (not in BIFF)
667 [ # # ][ # # ]: 0 : if( (getFilterType() == FILTER_OOXML) && (pcChar + 6 < pcEnd) )
[ # # ][ # # ]
668 : : {
669 [ # # ]: 0 : setAttributes();
670 : : // eat the following 6 characters
671 [ # # ]: 0 : convertFontColor( OUString( pcChar + 1, 6 ) );
672 : 0 : pcChar += 6;
673 : : }
674 : 0 : break;
675 : :
676 : : case '\"': // font name
677 [ + - ]: 30 : aFontName.setLength( 0 );
678 [ + - ]: 30 : aFontStyle.setLength( 0 );
679 : 30 : eState = STATE_FONTNAME;
680 : 30 : break;
681 : : default:
682 [ + - ][ + - ]: 30 : if( ('0' <= cChar) && (cChar <= '9') ) // font size
683 : : {
684 : 30 : nFontHeight = cChar - '0';
685 : 30 : eState = STATE_FONTHEIGHT;
686 : : }
687 : : }
688 : : }
689 : 264 : break;
690 : :
691 : : case STATE_FONTNAME:
692 : : {
693 [ - + + ]: 480 : switch( cChar )
694 : : {
695 : : case '\"':
696 [ # # ]: 0 : setAttributes();
697 [ # # ][ # # ]: 0 : convertFontName( aFontName.makeStringAndClear() );
698 : 0 : eState = STATE_TEXT;
699 : 0 : break;
700 : : case ',':
701 : 30 : eState = STATE_FONTSTYLE;
702 : 30 : break;
703 : : default:
704 [ + - ]: 450 : aFontName.append( cChar );
705 : : }
706 : : }
707 : 480 : break;
708 : :
709 : : case STATE_FONTSTYLE:
710 : : {
711 [ + + ]: 240 : switch( cChar )
712 : : {
713 : : case '\"':
714 [ + - ]: 30 : setAttributes();
715 [ + - ][ + - ]: 30 : convertFontName( aFontName.makeStringAndClear() );
716 [ + - ][ + - ]: 30 : convertFontStyle( aFontStyle.makeStringAndClear() );
717 : 30 : eState = STATE_TEXT;
718 : 30 : break;
719 : : default:
720 [ + - ]: 210 : aFontStyle.append( cChar );
721 : : }
722 : : }
723 : 240 : break;
724 : :
725 : : case STATE_FONTHEIGHT:
726 : : {
727 [ + + ][ + + ]: 60 : if( ('0' <= cChar) && (cChar <= '9') )
728 : : {
729 [ + - ]: 60 : if( nFontHeight >= 0 )
730 : : {
731 : 30 : nFontHeight *= 10;
732 : 30 : nFontHeight += (cChar - '0');
733 [ - + ]: 30 : if( nFontHeight > 1000 )
734 : 0 : nFontHeight = -1;
735 : : }
736 : : }
737 : : else
738 : : {
739 [ + - ]: 30 : if( nFontHeight > 0 )
740 : : {
741 [ + - ]: 30 : setAttributes();
742 : 30 : maFontModel.mfHeight = nFontHeight;
743 : : }
744 : 30 : --pcChar;
745 : 30 : eState = STATE_TEXT;
746 : : }
747 : : }
748 : 60 : break;
749 : : }
750 : : }
751 : :
752 : : // finalize
753 [ + - ]: 102 : finalizePortion();
754 [ + - ]: 102 : maPortions[ HF_LEFT ].mfTotalHeight += getCurrHeight( HF_LEFT );
755 [ + - ]: 102 : maPortions[ HF_CENTER ].mfTotalHeight += getCurrHeight( HF_CENTER );
756 [ + - ]: 102 : maPortions[ HF_RIGHT ].mfTotalHeight += getCurrHeight( HF_RIGHT );
757 : :
758 : 102 : return ::std::max( maPortions[ HF_LEFT ].mfTotalHeight,
759 [ + - + - ]: 204 : ::std::max( maPortions[ HF_CENTER ].mfTotalHeight, maPortions[ HF_RIGHT ].mfTotalHeight ) );
760 : : }
761 : :
762 : : // private --------------------------------------------------------------------
763 : :
764 : 306 : double HeaderFooterParser::getCurrHeight( HFPortionId ePortion ) const
765 : : {
766 : 306 : double fMaxHt = maPortions[ ePortion ].mfCurrHeight;
767 [ + + ]: 306 : return (fMaxHt == 0.0) ? maFontModel.mfHeight : fMaxHt;
768 : : }
769 : :
770 : 0 : double HeaderFooterParser::getCurrHeight() const
771 : : {
772 : 0 : return getCurrHeight( meCurrPortion );
773 : : }
774 : :
775 : 153 : void HeaderFooterParser::updateCurrHeight( HFPortionId ePortion )
776 : : {
777 : 153 : double& rfMaxHt = maPortions[ ePortion ].mfCurrHeight;
778 : 153 : rfMaxHt = ::std::max( rfMaxHt, maFontModel.mfHeight );
779 : 153 : }
780 : :
781 : 153 : void HeaderFooterParser::updateCurrHeight()
782 : : {
783 : 153 : updateCurrHeight( meCurrPortion );
784 : 153 : }
785 : :
786 : 162 : void HeaderFooterParser::setAttributes()
787 : : {
788 [ + - ][ + - ]: 162 : Reference< XTextRange > xRange( getStartPos(), UNO_QUERY );
789 [ + - ][ + - ]: 162 : getEndPos()->gotoRange( xRange, sal_False );
[ + - ]
790 [ + - ][ + - ]: 162 : getEndPos()->gotoEnd( sal_True );
[ + - ]
791 [ + - ][ + - ]: 162 : if( !getEndPos()->isCollapsed() )
[ + - ][ + + ]
792 : : {
793 [ + - ]: 102 : Font aFont( *this, maFontModel );
794 [ + - ]: 102 : aFont.finalizeImport();
795 [ + - ][ + - ]: 102 : PropertySet aPropSet( getEndPos() );
796 [ + - ]: 102 : aFont.writeToPropertySet( aPropSet, FONT_PROPTYPE_TEXT );
797 [ + - ][ + - ]: 102 : getStartPos()->gotoEnd( sal_False );
[ + - ]
798 [ + - ][ + - ]: 102 : getEndPos()->gotoEnd( sal_False );
[ + - ][ + - ]
[ + - ]
799 : 162 : }
800 : 162 : }
801 : :
802 : 366 : void HeaderFooterParser::appendText()
803 : : {
804 [ + + ]: 366 : if( maBuffer.getLength() > 0 )
805 : : {
806 : 51 : getEndPos()->gotoEnd( sal_False );
807 [ + - ]: 51 : getEndPos()->setString( maBuffer.makeStringAndClear() );
808 : 51 : updateCurrHeight();
809 : : }
810 : 366 : }
811 : :
812 : 0 : void HeaderFooterParser::appendLineBreak()
813 : : {
814 : 0 : getEndPos()->gotoEnd( sal_False );
815 [ # # ]: 0 : getEndPos()->setString( OUString( sal_Unicode( '\n' ) ) );
816 : 0 : getPortion().mfTotalHeight += getCurrHeight();
817 : 0 : getPortion().mfCurrHeight = 0;
818 : 0 : }
819 : :
820 : 102 : Reference< XTextContent > HeaderFooterParser::createField( const OUString& rServiceName ) const
821 : : {
822 : 102 : Reference< XTextContent > xContent;
823 : : try
824 : : {
825 [ + - ][ + - ]: 102 : xContent.set( getBaseFilter().getModelFactory()->createInstance( rServiceName ), UNO_QUERY_THROW );
[ + - ][ + - ]
[ # # ][ + - ]
826 : : }
827 [ # # ]: 0 : catch( Exception& )
828 : : {
829 : : OSL_FAIL( OStringBuffer( "HeaderFooterParser::createField - error while creating text field \"" ).
830 : : append( OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ) ).
831 : : append( '"' ).getStr() );
832 : : }
833 : 102 : return xContent;
834 : : }
835 : :
836 : 102 : void HeaderFooterParser::appendField( const Reference< XTextContent >& rxContent )
837 : : {
838 : 102 : getEndPos()->gotoEnd( sal_False );
839 : : try
840 : : {
841 [ + - ][ + - ]: 102 : Reference< XTextRange > xRange( getEndPos(), UNO_QUERY_THROW );
842 [ + - ][ + - ]: 102 : getPortion().mxText->insertTextContent( xRange, rxContent, sal_False );
[ + - ]
843 [ + - ][ # # ]: 102 : updateCurrHeight();
844 : : }
845 : 0 : catch( Exception& )
846 : : {
847 : : }
848 : 102 : }
849 : :
850 : 30 : void HeaderFooterParser::convertFontName( const OUString& rName )
851 : : {
852 [ + - ]: 30 : if( !rName.isEmpty() )
853 : : {
854 : : // single dash is document default font
855 [ - + ][ # # ]: 30 : if( (rName.getLength() == 1) && (rName[ 0 ] == '-') )
[ - + ]
856 : 0 : maFontModel.maName = getStyles().getDefaultFontModel().maName;
857 : : else
858 : 30 : maFontModel.maName = rName;
859 : : }
860 : 30 : }
861 : :
862 : 30 : void HeaderFooterParser::convertFontStyle( const OUString& rStyle )
863 : : {
864 : 30 : maFontModel.mbBold = maFontModel.mbItalic = false;
865 : 30 : sal_Int32 nPos = 0;
866 : 30 : sal_Int32 nLen = rStyle.getLength();
867 [ + + ][ + - ]: 60 : while( (0 <= nPos) && (nPos < nLen) )
[ + + ]
868 : : {
869 [ + - ]: 30 : OString aToken = OUStringToOString( rStyle.getToken( 0, ' ', nPos ), RTL_TEXTENCODING_UTF8 ).toAsciiLowerCase();
870 [ + - ]: 30 : if( !aToken.isEmpty() )
871 : : {
872 [ + - ][ - + ]: 30 : if( maBoldNames.count( aToken ) > 0 )
873 : 0 : maFontModel.mbBold = true;
874 [ + - ][ - + ]: 30 : else if( maItalicNames.count( aToken ) > 0 )
875 : 0 : maFontModel.mbItalic = true;
876 : : }
877 : 30 : }
878 : 30 : }
879 : :
880 : 0 : void HeaderFooterParser::convertFontColor( const OUString& rColor )
881 : : {
882 : : OSL_ENSURE( rColor.getLength() == 6, "HeaderFooterParser::convertFontColor - invalid font color code" );
883 [ # # ][ # # ]: 0 : if( (rColor[ 2 ] == '+') || (rColor[ 2 ] == '-') )
[ # # ]
884 : : // theme color: TTSNNN (TT = decimal theme index, S = +/-, NNN = decimal tint/shade in percent)
885 : : maFontModel.maColor.setTheme(
886 : : rColor.copy( 0, 2 ).toInt32(),
887 [ # # ]: 0 : static_cast< double >( rColor.copy( 2 ).toInt32() ) / 100.0 );
888 : : else
889 : : // RGB color: RRGGBB
890 : 0 : maFontModel.maColor.setRgb( rColor.toInt32( 16 ) );
891 : 0 : }
892 : :
893 : 102 : void HeaderFooterParser::finalizePortion()
894 : : {
895 : 102 : appendText();
896 : 102 : setAttributes();
897 : 102 : }
898 : :
899 : 102 : void HeaderFooterParser::setNewPortion( HFPortionId ePortion )
900 : : {
901 [ - + ]: 102 : if( ePortion != meCurrPortion )
902 : : {
903 : 0 : finalizePortion();
904 : 0 : meCurrPortion = ePortion;
905 : 0 : maFontModel = getStyles().getDefaultFontModel();
906 : : }
907 : 102 : }
908 : :
909 : : // ============================================================================
910 : :
911 : : namespace {
912 : :
913 : : /** Paper size in 1/100 millimeters. */
914 : : struct ApiPaperSize
915 : : {
916 : : sal_Int32 mnWidth;
917 : : sal_Int32 mnHeight;
918 : : };
919 : :
920 : : #define IN2MM100( v ) static_cast< sal_Int32 >( (v) * 2540.0 + 0.5 )
921 : : #define MM2MM100( v ) static_cast< sal_Int32 >( (v) * 100.0 + 0.5 )
922 : :
923 : : static const ApiPaperSize spPaperSizeTable[] =
924 : : {
925 : : { 0, 0 }, // 0 - (undefined)
926 : : { IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 1 - Letter paper
927 : : { IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 2 - Letter small paper
928 : : { IN2MM100( 11 ), IN2MM100( 17 ) }, // 3 - Tabloid paper
929 : : { IN2MM100( 17 ), IN2MM100( 11 ) }, // 4 - Ledger paper
930 : : { IN2MM100( 8.5 ), IN2MM100( 14 ) }, // 5 - Legal paper
931 : : { IN2MM100( 5.5 ), IN2MM100( 8.5 ) }, // 6 - Statement paper
932 : : { IN2MM100( 7.25 ), IN2MM100( 10.5 ) }, // 7 - Executive paper
933 : : { MM2MM100( 297 ), MM2MM100( 420 ) }, // 8 - A3 paper
934 : : { MM2MM100( 210 ), MM2MM100( 297 ) }, // 9 - A4 paper
935 : : { MM2MM100( 210 ), MM2MM100( 297 ) }, // 10 - A4 small paper
936 : : { MM2MM100( 148 ), MM2MM100( 210 ) }, // 11 - A5 paper
937 : : { MM2MM100( 250 ), MM2MM100( 353 ) }, // 12 - B4 paper
938 : : { MM2MM100( 176 ), MM2MM100( 250 ) }, // 13 - B5 paper
939 : : { IN2MM100( 8.5 ), IN2MM100( 13 ) }, // 14 - Folio paper
940 : : { MM2MM100( 215 ), MM2MM100( 275 ) }, // 15 - Quarto paper
941 : : { IN2MM100( 10 ), IN2MM100( 14 ) }, // 16 - Standard paper
942 : : { IN2MM100( 11 ), IN2MM100( 17 ) }, // 17 - Standard paper
943 : : { IN2MM100( 8.5 ), IN2MM100( 11 ) }, // 18 - Note paper
944 : : { IN2MM100( 3.875 ), IN2MM100( 8.875 ) }, // 19 - #9 envelope
945 : : { IN2MM100( 4.125 ), IN2MM100( 9.5 ) }, // 20 - #10 envelope
946 : : { IN2MM100( 4.5 ), IN2MM100( 10.375 ) }, // 21 - #11 envelope
947 : : { IN2MM100( 4.75 ), IN2MM100( 11 ) }, // 22 - #12 envelope
948 : : { IN2MM100( 5 ), IN2MM100( 11.5 ) }, // 23 - #14 envelope
949 : : { IN2MM100( 17 ), IN2MM100( 22 ) }, // 24 - C paper
950 : : { IN2MM100( 22 ), IN2MM100( 34 ) }, // 25 - D paper
951 : : { IN2MM100( 34 ), IN2MM100( 44 ) }, // 26 - E paper
952 : : { MM2MM100( 110 ), MM2MM100( 220 ) }, // 27 - DL envelope
953 : : { MM2MM100( 162 ), MM2MM100( 229 ) }, // 28 - C5 envelope
954 : : { MM2MM100( 324 ), MM2MM100( 458 ) }, // 29 - C3 envelope
955 : : { MM2MM100( 229 ), MM2MM100( 324 ) }, // 30 - C4 envelope
956 : : { MM2MM100( 114 ), MM2MM100( 162 ) }, // 31 - C6 envelope
957 : : { MM2MM100( 114 ), MM2MM100( 229 ) }, // 32 - C65 envelope
958 : : { MM2MM100( 250 ), MM2MM100( 353 ) }, // 33 - B4 envelope
959 : : { MM2MM100( 176 ), MM2MM100( 250 ) }, // 34 - B5 envelope
960 : : { MM2MM100( 176 ), MM2MM100( 125 ) }, // 35 - B6 envelope
961 : : { MM2MM100( 110 ), MM2MM100( 230 ) }, // 36 - Italy envelope
962 : : { IN2MM100( 3.875 ), IN2MM100( 7.5 ) }, // 37 - Monarch envelope
963 : : { IN2MM100( 3.625 ), IN2MM100( 6.5 ) }, // 38 - 6 3/4 envelope
964 : : { IN2MM100( 14.875 ), IN2MM100( 11 ) }, // 39 - US standard fanfold
965 : : { IN2MM100( 8.5 ), IN2MM100( 12 ) }, // 40 - German standard fanfold
966 : : { IN2MM100( 8.5 ), IN2MM100( 13 ) }, // 41 - German legal fanfold
967 : : { MM2MM100( 250 ), MM2MM100( 353 ) }, // 42 - ISO B4
968 : : { MM2MM100( 200 ), MM2MM100( 148 ) }, // 43 - Japanese double postcard
969 : : { IN2MM100( 9 ), IN2MM100( 11 ) }, // 44 - Standard paper
970 : : { IN2MM100( 10 ), IN2MM100( 11 ) }, // 45 - Standard paper
971 : : { IN2MM100( 15 ), IN2MM100( 11 ) }, // 46 - Standard paper
972 : : { MM2MM100( 220 ), MM2MM100( 220 ) }, // 47 - Invite envelope
973 : : { 0, 0 }, // 48 - (undefined)
974 : : { 0, 0 }, // 49 - (undefined)
975 : : { IN2MM100( 9.275 ), IN2MM100( 12 ) }, // 50 - Letter extra paper
976 : : { IN2MM100( 9.275 ), IN2MM100( 15 ) }, // 51 - Legal extra paper
977 : : { IN2MM100( 11.69 ), IN2MM100( 18 ) }, // 52 - Tabloid extra paper
978 : : { MM2MM100( 236 ), MM2MM100( 322 ) }, // 53 - A4 extra paper
979 : : { IN2MM100( 8.275 ), IN2MM100( 11 ) }, // 54 - Letter transverse paper
980 : : { MM2MM100( 210 ), MM2MM100( 297 ) }, // 55 - A4 transverse paper
981 : : { IN2MM100( 9.275 ), IN2MM100( 12 ) }, // 56 - Letter extra transverse paper
982 : : { MM2MM100( 227 ), MM2MM100( 356 ) }, // 57 - SuperA/SuperA/A4 paper
983 : : { MM2MM100( 305 ), MM2MM100( 487 ) }, // 58 - SuperB/SuperB/A3 paper
984 : : { IN2MM100( 8.5 ), IN2MM100( 12.69 ) }, // 59 - Letter plus paper
985 : : { MM2MM100( 210 ), MM2MM100( 330 ) }, // 60 - A4 plus paper
986 : : { MM2MM100( 148 ), MM2MM100( 210 ) }, // 61 - A5 transverse paper
987 : : { MM2MM100( 182 ), MM2MM100( 257 ) }, // 62 - JIS B5 transverse paper
988 : : { MM2MM100( 322 ), MM2MM100( 445 ) }, // 63 - A3 extra paper
989 : : { MM2MM100( 174 ), MM2MM100( 235 ) }, // 64 - A5 extra paper
990 : : { MM2MM100( 201 ), MM2MM100( 276 ) }, // 65 - ISO B5 extra paper
991 : : { MM2MM100( 420 ), MM2MM100( 594 ) }, // 66 - A2 paper
992 : : { MM2MM100( 297 ), MM2MM100( 420 ) }, // 67 - A3 transverse paper
993 : : { MM2MM100( 322 ), MM2MM100( 445 ) } // 68 - A3 extra transverse paper
994 : : };
995 : :
996 : : } // namespace
997 : :
998 : : // ----------------------------------------------------------------------------
999 : :
1000 : 48 : PageSettingsConverter::HFHelperData::HFHelperData( sal_Int32 nLeftPropId, sal_Int32 nRightPropId ) :
1001 : : mnLeftPropId( nLeftPropId ),
1002 : : mnRightPropId( nRightPropId ),
1003 : : mnHeight( 0 ),
1004 : : mnBodyDist( 0 ),
1005 : : mbHasContent( false ),
1006 : : mbShareOddEven( false ),
1007 : 48 : mbDynamicHeight( false )
1008 : : {
1009 : 48 : }
1010 : :
1011 : : // ----------------------------------------------------------------------------
1012 : :
1013 : 24 : PageSettingsConverter::PageSettingsConverter( const WorkbookHelper& rHelper ) :
1014 : : WorkbookHelper( rHelper ),
1015 [ + - ]: 24 : mxHFParser( new HeaderFooterParser( rHelper ) ),
1016 : : maHeaderData( PROP_LeftPageHeaderContent, PROP_RightPageHeaderContent ),
1017 [ + - ]: 48 : maFooterData( PROP_LeftPageFooterContent, PROP_RightPageFooterContent )
1018 : : {
1019 : 24 : }
1020 : :
1021 [ + - ]: 24 : PageSettingsConverter::~PageSettingsConverter()
1022 : : {
1023 [ - + ]: 48 : }
1024 : :
1025 : 60 : void PageSettingsConverter::writePageSettingsProperties(
1026 : : PropertySet& rPropSet, const PageSettingsModel& rModel, WorksheetType eSheetType )
1027 : : {
1028 : : // special handling for chart sheets
1029 : 60 : bool bChartSheet = eSheetType == SHEETTYPE_CHARTSHEET;
1030 : :
1031 : : // printout scaling
1032 [ - + ]: 60 : if( bChartSheet )
1033 : : {
1034 : : // always fit chart sheet to 1 page
1035 [ # # ]: 0 : rPropSet.setProperty< sal_Int16 >( PROP_ScaleToPages, 1 );
1036 : : }
1037 [ - + ]: 60 : else if( rModel.mbFitToPages )
1038 : : {
1039 : : // fit to number of pages
1040 [ # # ][ # # ]: 0 : rPropSet.setProperty( PROP_ScaleToPagesX, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToWidth, 0, 1000 ) );
1041 [ # # ][ # # ]: 0 : rPropSet.setProperty( PROP_ScaleToPagesY, getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnFitToHeight, 0, 1000 ) );
1042 : : }
1043 : : else
1044 : : {
1045 : : // scale may be 0 which indicates uninitialized
1046 [ + + ][ + - ]: 60 : sal_Int16 nScale = (rModel.mbValidSettings && (rModel.mnScale > 0)) ? getLimitedValue< sal_Int16, sal_Int32 >( rModel.mnScale, 10, 400 ) : 100;
[ + - ]
1047 [ + - ]: 60 : rPropSet.setProperty( PROP_PageScale, nScale );
1048 : : }
1049 : :
1050 : : // paper orientation
1051 : 60 : bool bLandscape = rModel.mnOrientation == XML_landscape;
1052 : : // default orientation for current sheet type (chart sheets default to landscape)
1053 [ - + ][ # # ]: 60 : if( bChartSheet && ( !rModel.mbValidSettings || (rModel.mnOrientation == XML_default) ) )
[ # # ]
1054 : 0 : bLandscape = true;
1055 : :
1056 : : // paper size
1057 [ + + ]: 60 : if( !rModel.mbValidSettings )
1058 : : {
1059 : 45 : Size aSize;
1060 : 45 : bool bValid = false;
1061 : :
1062 [ + - ][ + - ]: 45 : if( (0 < rModel.mnPaperSize) && (rModel.mnPaperSize < static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( spPaperSizeTable ) )) )
1063 : : {
1064 : 45 : const ApiPaperSize& rPaperSize = spPaperSizeTable[ rModel.mnPaperSize ];
1065 : 45 : aSize = Size( rPaperSize.mnWidth, rPaperSize.mnHeight );
1066 : 45 : bValid = true;
1067 : : }
1068 [ - + ][ # # ]: 45 : if( rModel.mnPaperWidth > 0 && rModel.mnPaperHeight > 0 )
1069 : : {
1070 : 0 : aSize = Size( rModel.mnPaperWidth, rModel.mnPaperHeight );
1071 : 0 : bValid = true;
1072 : : }
1073 : :
1074 [ + - ]: 45 : if( bValid )
1075 : : {
1076 [ - + ]: 45 : if( bLandscape )
1077 : 0 : ::std::swap( aSize.Width, aSize.Height );
1078 [ + - ]: 45 : rPropSet.setProperty( PROP_Size, aSize );
1079 : : }
1080 : : }
1081 : :
1082 : : // header/footer
1083 [ + - ]: 60 : convertHeaderFooterData( rPropSet, maHeaderData, rModel.maOddHeader, rModel.maEvenHeader, rModel.mbUseEvenHF, rModel.mfTopMargin, rModel.mfHeaderMargin );
1084 [ + - ]: 60 : convertHeaderFooterData( rPropSet, maFooterData, rModel.maOddFooter, rModel.maEvenFooter, rModel.mbUseEvenHF, rModel.mfBottomMargin, rModel.mfFooterMargin );
1085 : :
1086 : : // write all properties to property set
1087 [ + - ]: 60 : const UnitConverter& rUnitConv = getUnitConverter();
1088 [ + - ]: 60 : PropertyMap aPropMap;
1089 [ + - ][ + - ]: 60 : aPropMap[ PROP_IsLandscape ] <<= bLandscape;
1090 [ + + ][ + - ]: 60 : aPropMap[ PROP_FirstPageNumber ] <<= getLimitedValue< sal_Int16, sal_Int32 >( rModel.mbUseFirstPage ? rModel.mnFirstPage : 0, 0, 9999 );
[ + - ][ + - ]
1091 [ + - ][ + - ]: 60 : aPropMap[ PROP_PrintDownFirst ] <<= (rModel.mnPageOrder == XML_downThenOver);
1092 [ + - ][ + - ]: 60 : aPropMap[ PROP_PrintAnnotations ] <<= (rModel.mnCellComments == XML_asDisplayed);
1093 [ + - ][ + - ]: 60 : aPropMap[ PROP_CenterHorizontally ] <<= rModel.mbHorCenter;
1094 [ + - ][ + - ]: 60 : aPropMap[ PROP_CenterVertically ] <<= rModel.mbVerCenter;
1095 [ + - ][ - + ]: 60 : aPropMap[ PROP_PrintGrid ] <<= (!bChartSheet && rModel.mbPrintGrid); // no gridlines in chart sheets
[ + - ][ + - ]
1096 [ + - ][ - + ]: 60 : aPropMap[ PROP_PrintHeaders ] <<= (!bChartSheet && rModel.mbPrintHeadings); // no column/row headings in chart sheets
[ + - ][ + - ]
1097 [ + - ][ + - ]: 60 : aPropMap[ PROP_LeftMargin ] <<= rUnitConv.scaleToMm100( rModel.mfLeftMargin, UNIT_INCH );
[ + - ]
1098 [ + - ][ + - ]: 60 : aPropMap[ PROP_RightMargin ] <<= rUnitConv.scaleToMm100( rModel.mfRightMargin, UNIT_INCH );
[ + - ]
1099 : : // #i23296# In Calc, "TopMargin" property is distance to top of header if enabled
1100 [ + + ][ + - ]: 60 : aPropMap[ PROP_TopMargin ] <<= rUnitConv.scaleToMm100( maHeaderData.mbHasContent ? rModel.mfHeaderMargin : rModel.mfTopMargin, UNIT_INCH );
[ + - ][ + - ]
1101 : : // #i23296# In Calc, "BottomMargin" property is distance to bottom of footer if enabled
1102 [ + + ][ + - ]: 60 : aPropMap[ PROP_BottomMargin ] <<= rUnitConv.scaleToMm100( maFooterData.mbHasContent ? rModel.mfFooterMargin : rModel.mfBottomMargin, UNIT_INCH );
[ + - ][ + - ]
1103 [ + - ][ + - ]: 60 : aPropMap[ PROP_HeaderIsOn ] <<= maHeaderData.mbHasContent;
1104 [ + - ][ + - ]: 60 : aPropMap[ PROP_HeaderIsShared ] <<= maHeaderData.mbShareOddEven;
1105 [ + - ][ + - ]: 60 : aPropMap[ PROP_HeaderIsDynamicHeight ] <<= maHeaderData.mbDynamicHeight;
1106 [ + - ][ + - ]: 60 : aPropMap[ PROP_HeaderHeight ] <<= maHeaderData.mnHeight;
1107 [ + - ][ + - ]: 60 : aPropMap[ PROP_HeaderBodyDistance ] <<= maHeaderData.mnBodyDist;
1108 [ + - ][ + - ]: 60 : aPropMap[ PROP_FooterIsOn ] <<= maFooterData.mbHasContent;
1109 [ + - ][ + - ]: 60 : aPropMap[ PROP_FooterIsShared ] <<= maFooterData.mbShareOddEven;
1110 [ + - ][ + - ]: 60 : aPropMap[ PROP_FooterIsDynamicHeight ] <<= maFooterData.mbDynamicHeight;
1111 [ + - ][ + - ]: 60 : aPropMap[ PROP_FooterHeight ] <<= maFooterData.mnHeight;
1112 [ + - ][ + - ]: 60 : aPropMap[ PROP_FooterBodyDistance ] <<= maFooterData.mnBodyDist;
1113 : : // background image
1114 [ - + ]: 60 : if( !rModel.maGraphicUrl.isEmpty() )
1115 : : {
1116 [ # # ][ # # ]: 0 : aPropMap[ PROP_BackGraphicURL ] <<= rModel.maGraphicUrl;
1117 [ # # ][ # # ]: 0 : aPropMap[ PROP_BackGraphicLocation ] <<= ::com::sun::star::style::GraphicLocation_TILED;
1118 : : }
1119 : :
1120 [ + - ]: 60 : rPropSet.setProperties( aPropMap );
1121 : 60 : }
1122 : :
1123 : 120 : void PageSettingsConverter::convertHeaderFooterData(
1124 : : PropertySet& rPropSet, HFHelperData& orHFData,
1125 : : const OUString rOddContent, const OUString rEvenContent, bool bUseEvenContent,
1126 : : double fPageMargin, double fContentMargin )
1127 : : {
1128 : 120 : bool bHasOddContent = !rOddContent.isEmpty();
1129 [ # # ][ - + ]: 120 : bool bHasEvenContent = bUseEvenContent && !rEvenContent.isEmpty();
1130 : :
1131 [ + + ][ + - ]: 120 : sal_Int32 nOddHeight = bHasOddContent ? writeHeaderFooter( rPropSet, orHFData.mnRightPropId, rOddContent ) : 0;
1132 [ - + ][ # # ]: 120 : sal_Int32 nEvenHeight = bHasEvenContent ? writeHeaderFooter( rPropSet, orHFData.mnLeftPropId, rEvenContent ) : 0;
1133 : :
1134 : 120 : orHFData.mnHeight = 750;
1135 : 120 : orHFData.mnBodyDist = 250;
1136 [ + + ][ - + ]: 120 : orHFData.mbHasContent = bHasOddContent || bHasEvenContent;
1137 : 120 : orHFData.mbShareOddEven = !bUseEvenContent;
1138 : 120 : orHFData.mbDynamicHeight = true;
1139 : :
1140 [ + + ]: 120 : if( orHFData.mbHasContent )
1141 : : {
1142 : : // use maximum height of odd/even header/footer
1143 [ + - ]: 102 : orHFData.mnHeight = ::std::max( nOddHeight, nEvenHeight );
1144 : : /* Calc contains distance between bottom of header and top of page
1145 : : body in "HeaderBodyDistance" property, and distance between bottom
1146 : : of page body and top of footer in "FooterBodyDistance" property */
1147 [ + - ][ + - ]: 102 : orHFData.mnBodyDist = getUnitConverter().scaleToMm100( fPageMargin - fContentMargin, UNIT_INCH ) - orHFData.mnHeight;
1148 : : /* #i23296# Distance less than 0 means, header or footer overlays page
1149 : : body. As this is not possible in Calc, set fixed header or footer
1150 : : height (crop header/footer) to get correct top position of page body. */
1151 : 102 : orHFData.mbDynamicHeight = orHFData.mnBodyDist >= 0;
1152 : : /* "HeaderHeight" property is in fact distance from top of header to
1153 : : top of page body (including "HeaderBodyDistance").
1154 : : "FooterHeight" property is in fact distance from bottom of page
1155 : : body to bottom of footer (including "FooterBodyDistance"). */
1156 : 102 : orHFData.mnHeight += orHFData.mnBodyDist;
1157 : : // negative body distance not allowed
1158 [ + - ]: 102 : orHFData.mnBodyDist = ::std::max< sal_Int32 >( orHFData.mnBodyDist, 0 );
1159 : : }
1160 : 120 : }
1161 : :
1162 : 102 : sal_Int32 PageSettingsConverter::writeHeaderFooter(
1163 : : PropertySet& rPropSet, sal_Int32 nPropId, const OUString& rContent )
1164 : : {
1165 : : OSL_ENSURE( !rContent.isEmpty(), "PageSettingsConverter::writeHeaderFooter - empty h/f string found" );
1166 : 102 : sal_Int32 nHeight = 0;
1167 [ + - ]: 102 : if( !rContent.isEmpty() )
1168 : : {
1169 [ + - ][ + - ]: 102 : Reference< XHeaderFooterContent > xHFContent( rPropSet.getAnyProperty( nPropId ), UNO_QUERY );
1170 [ + - ]: 102 : if( xHFContent.is() )
1171 : : {
1172 [ + - ]: 102 : double fTotalHeight = mxHFParser->parse( xHFContent, rContent );
1173 [ + - ]: 102 : rPropSet.setProperty( nPropId, xHFContent );
1174 [ + - ][ + - ]: 102 : nHeight = getUnitConverter().scaleToMm100( fTotalHeight, UNIT_POINT );
1175 : 102 : }
1176 : : }
1177 : 102 : return nHeight;
1178 : : }
1179 : :
1180 : : // ============================================================================
1181 : :
1182 : : } // namespace xls
1183 [ + - ][ + - ]: 24 : } // namespace oox
1184 : :
1185 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|