/src/libreoffice/xmloff/source/style/PageMasterExportPropMapper.cxx
Line | Count | Source |
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 "PageMasterExportPropMapper.hxx" |
21 | | #include <xmloff/xmlprmap.hxx> |
22 | | #include <xmloff/xmlexp.hxx> |
23 | | #include <comphelper/types.hxx> |
24 | | #include <com/sun/star/beans/XPropertySet.hpp> |
25 | | #include <com/sun/star/table/BorderLine2.hpp> |
26 | | #include <PageMasterStyleMap.hxx> |
27 | | #include <rtl/ref.hxx> |
28 | | #include <comphelper/extract.hxx> |
29 | | |
30 | | using namespace ::com::sun::star; |
31 | | using namespace ::com::sun::star::uno; |
32 | | using namespace ::com::sun::star::beans; |
33 | | using namespace ::comphelper; |
34 | | |
35 | | static bool lcl_HasSameLineWidth( const table::BorderLine2& rLine1, const table::BorderLine2& rLine2 ) |
36 | 0 | { |
37 | 0 | return (rLine1.InnerLineWidth == rLine2.InnerLineWidth) && |
38 | 0 | (rLine1.OuterLineWidth == rLine2.OuterLineWidth) && |
39 | 0 | (rLine1.LineDistance == rLine2.LineDistance) && |
40 | 0 | (rLine1.LineWidth == rLine2.LineWidth); |
41 | 0 | } |
42 | | |
43 | | static void lcl_RemoveState( XMLPropertyState* pState ) |
44 | 0 | { |
45 | 0 | pState->mnIndex = -1; |
46 | 0 | pState->maValue.clear(); |
47 | 0 | } |
48 | | |
49 | | static void lcl_RemoveStateIfZero16( XMLPropertyState* pState ) |
50 | 0 | { |
51 | 0 | sal_Int16 nValue = sal_Int16(); |
52 | 0 | if( (pState->maValue >>= nValue) && !nValue ) |
53 | 0 | lcl_RemoveState( pState ); |
54 | 0 | } |
55 | | |
56 | | static void lcl_AddState(::std::vector< XMLPropertyState >& rPropState, sal_Int32 nIndex, const OUString& rProperty, const uno::Reference< beans::XPropertySet >& xProps) |
57 | 0 | { |
58 | 0 | if(::cppu::any2bool(xProps->getPropertyValue(rProperty))) |
59 | 0 | rPropState.emplace_back(nIndex, css::uno::Any(true)); |
60 | 0 | } |
61 | | |
62 | | // helper struct to handle equal XMLPropertyState's for page, header and footer |
63 | | |
64 | | namespace { |
65 | | |
66 | | struct XMLPropertyStateBuffer |
67 | | { |
68 | | XMLPropertyState* pPMMarginAll; |
69 | | |
70 | | XMLPropertyState* pPMBorderAll; |
71 | | XMLPropertyState* pPMBorderTop; |
72 | | XMLPropertyState* pPMBorderBottom; |
73 | | XMLPropertyState* pPMBorderLeft; |
74 | | XMLPropertyState* pPMBorderRight; |
75 | | |
76 | | XMLPropertyState* pPMBorderWidthAll; |
77 | | XMLPropertyState* pPMBorderWidthTop; |
78 | | XMLPropertyState* pPMBorderWidthBottom; |
79 | | XMLPropertyState* pPMBorderWidthLeft; |
80 | | XMLPropertyState* pPMBorderWidthRight; |
81 | | |
82 | | XMLPropertyState* pPMPaddingAll; |
83 | | XMLPropertyState* pPMPaddingTop; |
84 | | XMLPropertyState* pPMPaddingBottom; |
85 | | XMLPropertyState* pPMPaddingLeft; |
86 | | XMLPropertyState* pPMPaddingRight; |
87 | | |
88 | | XMLPropertyState* pPMMarginGutter; |
89 | | XMLPropertyState* pPMMarginLeft; |
90 | | XMLPropertyState* pPMRtlGutter; |
91 | | XMLPropertyState* pPMMarginRight; |
92 | | bool m_bGutterAtTop; |
93 | | XMLPropertyState* pPMMarginTop; |
94 | | |
95 | | XMLPropertyStateBuffer(); |
96 | | void ContextFilter( ::std::vector< XMLPropertyState >& rPropState ); |
97 | | }; |
98 | | |
99 | | } |
100 | | |
101 | | XMLPropertyStateBuffer::XMLPropertyStateBuffer() |
102 | 0 | : pPMMarginAll( nullptr ) |
103 | | , |
104 | 0 | pPMBorderAll( nullptr ), |
105 | 0 | pPMBorderTop( nullptr ), |
106 | 0 | pPMBorderBottom( nullptr ), |
107 | 0 | pPMBorderLeft( nullptr ), |
108 | 0 | pPMBorderRight( nullptr ), |
109 | | |
110 | 0 | pPMBorderWidthAll( nullptr ), |
111 | 0 | pPMBorderWidthTop( nullptr ), |
112 | 0 | pPMBorderWidthBottom( nullptr ), |
113 | 0 | pPMBorderWidthLeft( nullptr ), |
114 | 0 | pPMBorderWidthRight( nullptr ), |
115 | | |
116 | 0 | pPMPaddingAll( nullptr ), |
117 | 0 | pPMPaddingTop( nullptr ), |
118 | 0 | pPMPaddingBottom( nullptr ), |
119 | 0 | pPMPaddingLeft( nullptr ), |
120 | 0 | pPMPaddingRight( nullptr ), |
121 | | |
122 | 0 | pPMMarginGutter( nullptr ), |
123 | 0 | pPMMarginLeft( nullptr ), |
124 | 0 | pPMRtlGutter( nullptr ), |
125 | 0 | pPMMarginRight( nullptr ), |
126 | 0 | m_bGutterAtTop( false ), |
127 | 0 | pPMMarginTop( nullptr ) |
128 | 0 | { |
129 | 0 | } |
130 | | |
131 | | void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& ) |
132 | 0 | { |
133 | 0 | if (pPMMarginGutter) |
134 | 0 | { |
135 | 0 | sal_Int32 nGutterMargin{}; |
136 | 0 | pPMMarginGutter->maValue >>= nGutterMargin; |
137 | 0 | if (m_bGutterAtTop) |
138 | 0 | { |
139 | 0 | if (nGutterMargin && pPMMarginTop) |
140 | 0 | { |
141 | | // Increase top margin to include gutter. |
142 | 0 | sal_Int32 nTopMargin{}; |
143 | 0 | pPMMarginTop->maValue >>= nTopMargin; |
144 | 0 | nTopMargin += nGutterMargin; |
145 | 0 | pPMMarginTop->maValue <<= nTopMargin; |
146 | 0 | } |
147 | 0 | } |
148 | 0 | else |
149 | 0 | { |
150 | 0 | bool bRtlGutter{}; |
151 | 0 | if (nGutterMargin && pPMRtlGutter) |
152 | 0 | { |
153 | 0 | pPMRtlGutter->maValue >>= bRtlGutter; |
154 | 0 | } |
155 | 0 | if (bRtlGutter) |
156 | 0 | { |
157 | 0 | if (nGutterMargin && pPMMarginRight) |
158 | 0 | { |
159 | | // Increase right margin to include gutter. |
160 | 0 | sal_Int32 nRightMargin{}; |
161 | 0 | pPMMarginRight->maValue >>= nRightMargin; |
162 | 0 | nRightMargin += nGutterMargin; |
163 | 0 | pPMMarginRight->maValue <<= nRightMargin; |
164 | 0 | } |
165 | 0 | } |
166 | 0 | else |
167 | 0 | { |
168 | 0 | if (nGutterMargin && pPMMarginLeft) |
169 | 0 | { |
170 | | // Increase left margin to include gutter. |
171 | 0 | sal_Int32 nLeftMargin{}; |
172 | 0 | pPMMarginLeft->maValue >>= nLeftMargin; |
173 | 0 | nLeftMargin += nGutterMargin; |
174 | 0 | pPMMarginLeft->maValue <<= nLeftMargin; |
175 | 0 | } |
176 | 0 | } |
177 | 0 | } |
178 | 0 | } |
179 | |
|
180 | 0 | if (pPMMarginAll) |
181 | 0 | { |
182 | 0 | lcl_RemoveState(pPMMarginAll); // #i117696# do not write fo:margin |
183 | 0 | } |
184 | |
|
185 | 0 | if( pPMBorderAll ) |
186 | 0 | { |
187 | 0 | if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight ) |
188 | 0 | { |
189 | 0 | table::BorderLine2 aLineTop, aLineBottom, aLineLeft, aLineRight; |
190 | |
|
191 | 0 | pPMBorderTop->maValue >>= aLineTop; |
192 | 0 | pPMBorderBottom->maValue >>= aLineBottom; |
193 | 0 | pPMBorderLeft->maValue >>= aLineLeft; |
194 | 0 | pPMBorderRight->maValue >>= aLineRight; |
195 | |
|
196 | 0 | if( (aLineTop == aLineBottom) && (aLineBottom == aLineLeft) && (aLineLeft == aLineRight) ) |
197 | 0 | { |
198 | 0 | lcl_RemoveState( pPMBorderTop ); |
199 | 0 | lcl_RemoveState( pPMBorderBottom ); |
200 | 0 | lcl_RemoveState( pPMBorderLeft ); |
201 | 0 | lcl_RemoveState( pPMBorderRight ); |
202 | 0 | } |
203 | 0 | else |
204 | 0 | lcl_RemoveState( pPMBorderAll ); |
205 | 0 | } |
206 | 0 | else |
207 | 0 | lcl_RemoveState( pPMBorderAll ); |
208 | 0 | } |
209 | |
|
210 | 0 | if( pPMBorderWidthAll ) |
211 | 0 | { |
212 | 0 | if( pPMBorderWidthTop && pPMBorderWidthBottom && pPMBorderWidthLeft && pPMBorderWidthRight ) |
213 | 0 | { |
214 | 0 | table::BorderLine2 aLineTop, aLineBottom, aLineLeft, aLineRight; |
215 | |
|
216 | 0 | pPMBorderWidthTop->maValue >>= aLineTop; |
217 | 0 | pPMBorderWidthBottom->maValue >>= aLineBottom; |
218 | 0 | pPMBorderWidthLeft->maValue >>= aLineLeft; |
219 | 0 | pPMBorderWidthRight->maValue >>= aLineRight; |
220 | |
|
221 | 0 | if( lcl_HasSameLineWidth( aLineTop, aLineBottom ) && |
222 | 0 | lcl_HasSameLineWidth( aLineBottom, aLineLeft ) && |
223 | 0 | lcl_HasSameLineWidth( aLineLeft, aLineRight ) ) |
224 | 0 | { |
225 | 0 | lcl_RemoveState( pPMBorderWidthTop ); |
226 | 0 | lcl_RemoveState( pPMBorderWidthBottom ); |
227 | 0 | lcl_RemoveState( pPMBorderWidthLeft ); |
228 | 0 | lcl_RemoveState( pPMBorderWidthRight ); |
229 | 0 | } |
230 | 0 | else |
231 | 0 | lcl_RemoveState( pPMBorderWidthAll ); |
232 | 0 | } |
233 | 0 | else |
234 | 0 | lcl_RemoveState( pPMBorderWidthAll ); |
235 | 0 | } |
236 | |
|
237 | 0 | if( !pPMPaddingAll ) |
238 | 0 | return; |
239 | | |
240 | 0 | if( pPMPaddingTop && pPMPaddingBottom && pPMPaddingLeft && pPMPaddingRight ) |
241 | 0 | { |
242 | 0 | sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0; |
243 | |
|
244 | 0 | pPMPaddingTop->maValue >>= nTop; |
245 | 0 | pPMPaddingBottom->maValue >>= nBottom; |
246 | 0 | pPMPaddingLeft->maValue >>= nLeft; |
247 | 0 | pPMPaddingRight->maValue >>= nRight; |
248 | |
|
249 | 0 | if( (nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight) ) |
250 | 0 | { |
251 | 0 | lcl_RemoveState( pPMPaddingTop ); |
252 | 0 | lcl_RemoveState( pPMPaddingBottom ); |
253 | 0 | lcl_RemoveState( pPMPaddingLeft ); |
254 | 0 | lcl_RemoveState( pPMPaddingRight ); |
255 | 0 | } |
256 | 0 | else |
257 | 0 | lcl_RemoveState( pPMPaddingAll ); |
258 | 0 | } |
259 | 0 | else |
260 | 0 | lcl_RemoveState( pPMPaddingAll ); |
261 | 0 | } |
262 | | |
263 | | XMLPageMasterExportPropMapper::XMLPageMasterExportPropMapper( |
264 | | const rtl::Reference< XMLPropertySetMapper >& rMapper, |
265 | | SvXMLExport& rExport ) : |
266 | 0 | SvXMLExportPropertyMapper( rMapper ), |
267 | 0 | aBackgroundImageExport( rExport ), |
268 | 0 | aTextColumnsExport( rExport ), |
269 | 0 | aFootnoteSeparatorExport( rExport ) |
270 | 0 | { |
271 | 0 | } |
272 | | |
273 | | XMLPageMasterExportPropMapper::~XMLPageMasterExportPropMapper() |
274 | 0 | { |
275 | 0 | } |
276 | | |
277 | | void XMLPageMasterExportPropMapper::handleElementItem( |
278 | | SvXMLExport&, |
279 | | const XMLPropertyState& rProperty, |
280 | | SvXmlExportFlags /*nFlags*/, |
281 | | const ::std::vector< XMLPropertyState >* pProperties, |
282 | | sal_uInt32 nIdx ) const |
283 | 0 | { |
284 | 0 | XMLPageMasterExportPropMapper* pThis = const_cast<XMLPageMasterExportPropMapper*>(this); |
285 | |
|
286 | 0 | sal_uInt32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ); |
287 | 0 | switch( nContextId ) |
288 | 0 | { |
289 | 0 | case CTF_PM_GRAPHICURL: |
290 | 0 | case CTF_PM_HEADERGRAPHICURL: |
291 | 0 | case CTF_PM_FOOTERGRAPHICURL: |
292 | 0 | { |
293 | 0 | assert(pProperties); |
294 | 0 | assert(nIdx >= 2 && "horrible array ordering borked again"); |
295 | 0 | sal_Int32 nPos(-1); |
296 | 0 | sal_Int32 nFilter(-1); |
297 | 0 | switch( nContextId ) |
298 | 0 | { |
299 | 0 | case CTF_PM_GRAPHICURL: |
300 | 0 | nPos = CTF_PM_GRAPHICPOSITION; |
301 | 0 | nFilter = CTF_PM_GRAPHICFILTER; |
302 | 0 | break; |
303 | 0 | case CTF_PM_HEADERGRAPHICURL: |
304 | 0 | nPos = CTF_PM_HEADERGRAPHICPOSITION; |
305 | 0 | nFilter = CTF_PM_HEADERGRAPHICFILTER; |
306 | 0 | break; |
307 | 0 | case CTF_PM_FOOTERGRAPHICURL: |
308 | 0 | nPos = CTF_PM_FOOTERGRAPHICPOSITION; |
309 | 0 | nFilter = CTF_PM_FOOTERGRAPHICFILTER; |
310 | 0 | break; |
311 | 0 | default: |
312 | 0 | assert(false); |
313 | 0 | } |
314 | 0 | const Any* pPos = nullptr; |
315 | 0 | const Any* pFilter = nullptr; |
316 | 0 | sal_uInt32 nIndex(nIdx - 1); |
317 | 0 | const XMLPropertyState& rFilter = (*pProperties)[nIndex]; |
318 | 0 | if (getPropertySetMapper()->GetEntryContextId(rFilter.mnIndex) == nFilter) |
319 | 0 | { |
320 | 0 | pFilter = &rFilter.maValue; |
321 | 0 | --nIndex; |
322 | 0 | } |
323 | 0 | const XMLPropertyState& rPos = (*pProperties)[nIndex]; |
324 | 0 | if (getPropertySetMapper()->GetEntryContextId(rPos.mnIndex) == nPos) |
325 | 0 | { |
326 | 0 | pPos = &rPos.maValue; |
327 | 0 | --nIndex; |
328 | 0 | } |
329 | 0 | sal_uInt32 nPropIndex = rProperty.mnIndex; |
330 | 0 | pThis->aBackgroundImageExport.exportXML( rProperty.maValue, pPos, pFilter, nullptr, |
331 | 0 | getPropertySetMapper()->GetEntryNameSpace( nPropIndex ), |
332 | 0 | getPropertySetMapper()->GetEntryXMLName( nPropIndex ) ); |
333 | 0 | } |
334 | 0 | break; |
335 | 0 | case CTF_PM_TEXTCOLUMNS: |
336 | 0 | pThis->aTextColumnsExport.exportXML( rProperty.maValue ); |
337 | 0 | break; |
338 | 0 | case CTF_PM_FTN_LINE_WEIGHT: |
339 | 0 | pThis->aFootnoteSeparatorExport.exportXML( pProperties, nIdx, |
340 | 0 | getPropertySetMapper()); |
341 | 0 | break; |
342 | 0 | } |
343 | 0 | } |
344 | | |
345 | | void XMLPageMasterExportPropMapper::handleSpecialItem( |
346 | | comphelper::AttributeList&, |
347 | | const XMLPropertyState&, |
348 | | const SvXMLUnitConverter&, |
349 | | const SvXMLNamespaceMap&, |
350 | | const ::std::vector< XMLPropertyState >*, |
351 | | sal_uInt32 /*nIdx*/) const |
352 | 0 | { |
353 | 0 | } |
354 | | |
355 | | void XMLPageMasterExportPropMapper::ContextFilter( |
356 | | bool bEnableFoFontFamily, |
357 | | ::std::vector< XMLPropertyState >& rPropState, |
358 | | const Reference< XPropertySet >& rPropSet ) const |
359 | 0 | { |
360 | 0 | XMLPropertyStateBuffer aPageBuffer; |
361 | 0 | if (m_bGutterAtTop) |
362 | 0 | { |
363 | 0 | aPageBuffer.m_bGutterAtTop = true; |
364 | 0 | } |
365 | |
|
366 | 0 | XMLPropertyStateBuffer aHeaderBuffer; |
367 | 0 | XMLPropertyStateBuffer aFooterBuffer; |
368 | |
|
369 | 0 | XMLPropertyState* pPMHeaderHeight = nullptr; |
370 | 0 | XMLPropertyState* pPMHeaderMinHeight = nullptr; |
371 | 0 | XMLPropertyState* pPMHeaderDynamic = nullptr; |
372 | |
|
373 | 0 | XMLPropertyState* pPMFooterHeight = nullptr; |
374 | 0 | XMLPropertyState* pPMFooterMinHeight = nullptr; |
375 | 0 | XMLPropertyState* pPMFooterDynamic = nullptr; |
376 | |
|
377 | 0 | XMLPropertyState* pPMScaleTo = nullptr; |
378 | 0 | XMLPropertyState* pPMScaleToPages = nullptr; |
379 | 0 | XMLPropertyState* pPMScaleToX = nullptr; |
380 | 0 | XMLPropertyState* pPMScaleToY = nullptr; |
381 | 0 | XMLPropertyState* pPMStandardMode = nullptr; |
382 | 0 | XMLPropertyState* pPMGridBaseWidth = nullptr; |
383 | | // same as pPMGridSnapTo but for backward compatibility only |
384 | 0 | XMLPropertyState* pPMGridSnapToChars = nullptr; |
385 | 0 | XMLPropertyState* pPMGridSnapTo = nullptr; |
386 | |
|
387 | 0 | XMLPropertyState* pPrint = nullptr; |
388 | |
|
389 | 0 | XMLPropertyState* pRepeatOffsetX = nullptr; |
390 | 0 | XMLPropertyState* pRepeatOffsetY = nullptr; |
391 | 0 | XMLPropertyState* pHeaderRepeatOffsetX = nullptr; |
392 | 0 | XMLPropertyState* pHeaderRepeatOffsetY = nullptr; |
393 | 0 | XMLPropertyState* pFooterRepeatOffsetX = nullptr; |
394 | 0 | XMLPropertyState* pFooterRepeatOffsetY = nullptr; |
395 | |
|
396 | 0 | rtl::Reference < XMLPropertySetMapper > aPropMapper(getPropertySetMapper()); |
397 | | |
398 | | // distinguish 2 cases: drawing-page export has CTF_PM_FILL, page-layout-properties export does not |
399 | 0 | bool const isDrawingPageExport(aPropMapper->FindEntryIndex(CTF_PM_FILL) != -1); |
400 | |
|
401 | 0 | for( auto& rProp : rPropState ) |
402 | 0 | { |
403 | 0 | XMLPropertyState *pProp = &rProp; |
404 | 0 | sal_Int16 nContextId = aPropMapper->GetEntryContextId( pProp->mnIndex ); |
405 | 0 | sal_Int16 nFlag = nContextId & CTF_PM_FLAGMASK; |
406 | 0 | sal_Int16 nSimpleId = nContextId & (~CTF_PM_FLAGMASK | XML_PM_CTF_START); |
407 | 0 | sal_Int16 nPrintId = nContextId & CTF_PM_PRINTMASK; |
408 | | |
409 | | |
410 | | // tdf#103602 don't export draw:fill attributes on page-layout-properties in strict ODF |
411 | 0 | if (!isDrawingPageExport |
412 | 0 | && [](OUString const& rName) -> bool { |
413 | 0 | return rName.startsWith("Fill") |
414 | 0 | || rName.startsWith("HeaderFill") |
415 | 0 | || rName.startsWith("FooterFill"); |
416 | 0 | } (aPropMapper->GetEntryAPIName(rProp.mnIndex)) |
417 | 0 | && ((aBackgroundImageExport.GetExport().getSaneDefaultVersion() |
418 | 0 | & SvtSaveOptions::ODFSVER_EXTENDED) == 0)) |
419 | 0 | { |
420 | 0 | lcl_RemoveState(&rProp); |
421 | 0 | continue; |
422 | 0 | } |
423 | | |
424 | 0 | XMLPropertyStateBuffer* pBuffer; |
425 | 0 | switch( nFlag ) |
426 | 0 | { |
427 | 0 | case CTF_PM_HEADERFLAG: pBuffer = &aHeaderBuffer; break; |
428 | 0 | case CTF_PM_FOOTERFLAG: pBuffer = &aFooterBuffer; break; |
429 | 0 | default: pBuffer = &aPageBuffer; break; |
430 | 0 | } |
431 | | |
432 | 0 | switch( nSimpleId ) |
433 | 0 | { |
434 | 0 | case CTF_PM_MARGINALL: pBuffer->pPMMarginAll = pProp; break; |
435 | 0 | case CTF_PM_BORDERALL: pBuffer->pPMBorderAll = pProp; break; |
436 | 0 | case CTF_PM_BORDERTOP: pBuffer->pPMBorderTop = pProp; break; |
437 | 0 | case CTF_PM_BORDERBOTTOM: pBuffer->pPMBorderBottom = pProp; break; |
438 | 0 | case CTF_PM_BORDERLEFT: pBuffer->pPMBorderLeft = pProp; break; |
439 | 0 | case CTF_PM_BORDERRIGHT: pBuffer->pPMBorderRight = pProp; break; |
440 | 0 | case CTF_PM_BORDERWIDTHALL: pBuffer->pPMBorderWidthAll = pProp; break; |
441 | 0 | case CTF_PM_BORDERWIDTHTOP: pBuffer->pPMBorderWidthTop = pProp; break; |
442 | 0 | case CTF_PM_BORDERWIDTHBOTTOM: pBuffer->pPMBorderWidthBottom = pProp; break; |
443 | 0 | case CTF_PM_BORDERWIDTHLEFT: pBuffer->pPMBorderWidthLeft = pProp; break; |
444 | 0 | case CTF_PM_BORDERWIDTHRIGHT: pBuffer->pPMBorderWidthRight = pProp; break; |
445 | 0 | case CTF_PM_PADDINGALL: pBuffer->pPMPaddingAll = pProp; break; |
446 | 0 | case CTF_PM_PADDINGTOP: pBuffer->pPMPaddingTop = pProp; break; |
447 | 0 | case CTF_PM_PADDINGBOTTOM: pBuffer->pPMPaddingBottom = pProp; break; |
448 | 0 | case CTF_PM_PADDINGLEFT: pBuffer->pPMPaddingLeft = pProp; break; |
449 | 0 | case CTF_PM_PADDINGRIGHT: pBuffer->pPMPaddingRight = pProp; break; |
450 | 0 | case CTF_PM_MARGINGUTTER: |
451 | 0 | pBuffer->pPMMarginGutter = pProp; |
452 | 0 | break; |
453 | 0 | case CTF_PM_MARGINLEFT: |
454 | 0 | pBuffer->pPMMarginLeft = pProp; |
455 | 0 | break; |
456 | 0 | case CTF_PM_RTLGUTTER: |
457 | 0 | pBuffer->pPMRtlGutter = pProp; |
458 | 0 | break; |
459 | 0 | case CTF_PM_MARGINRIGHT: |
460 | 0 | pBuffer->pPMMarginRight = pProp; |
461 | 0 | break; |
462 | 0 | case CTF_PM_MARGINTOP: |
463 | 0 | pBuffer->pPMMarginTop = pProp; |
464 | 0 | break; |
465 | 0 | } |
466 | | |
467 | 0 | switch( nContextId ) |
468 | 0 | { |
469 | 0 | case CTF_PM_HEADERHEIGHT: pPMHeaderHeight = pProp; break; |
470 | 0 | case CTF_PM_HEADERMINHEIGHT: pPMHeaderMinHeight = pProp; break; |
471 | 0 | case CTF_PM_HEADERDYNAMIC: pPMHeaderDynamic = pProp; break; |
472 | 0 | case CTF_PM_FOOTERHEIGHT: pPMFooterHeight = pProp; break; |
473 | 0 | case CTF_PM_FOOTERMINHEIGHT: pPMFooterMinHeight = pProp; break; |
474 | 0 | case CTF_PM_FOOTERDYNAMIC: pPMFooterDynamic = pProp; break; |
475 | 0 | case CTF_PM_SCALETO: pPMScaleTo = pProp; break; |
476 | 0 | case CTF_PM_SCALETOPAGES: pPMScaleToPages = pProp; break; |
477 | 0 | case CTF_PM_SCALETOX: pPMScaleToX = pProp; break; |
478 | 0 | case CTF_PM_SCALETOY: pPMScaleToY = pProp; break; |
479 | 0 | case CTF_PM_STANDARD_MODE: pPMStandardMode = pProp; break; |
480 | 0 | case CTP_PM_GRID_BASE_WIDTH: pPMGridBaseWidth = pProp; break; |
481 | 0 | case CTP_PM_GRID_SNAP_TO_CHARS: pPMGridSnapToChars = pProp; break; |
482 | 0 | case CTP_PM_GRID_SNAP_TO: pPMGridSnapTo = pProp; break; |
483 | | |
484 | 0 | case CTF_PM_REPEAT_OFFSET_X: |
485 | 0 | pRepeatOffsetX = pProp; |
486 | 0 | break; |
487 | | |
488 | 0 | case CTF_PM_REPEAT_OFFSET_Y: |
489 | 0 | pRepeatOffsetY = pProp; |
490 | 0 | break; |
491 | | |
492 | 0 | case CTF_PM_HEADERREPEAT_OFFSET_X: |
493 | 0 | pHeaderRepeatOffsetX = pProp; |
494 | 0 | break; |
495 | | |
496 | 0 | case CTF_PM_HEADERREPEAT_OFFSET_Y: |
497 | 0 | pHeaderRepeatOffsetY = pProp; |
498 | 0 | break; |
499 | | |
500 | 0 | case CTF_PM_FOOTERREPEAT_OFFSET_X: |
501 | 0 | pFooterRepeatOffsetX = pProp; |
502 | 0 | break; |
503 | | |
504 | 0 | case CTF_PM_FOOTERREPEAT_OFFSET_Y: |
505 | 0 | pFooterRepeatOffsetY = pProp; |
506 | 0 | break; |
507 | | |
508 | | // Sort out empty entries |
509 | 0 | case CTF_PM_FILLGRADIENTNAME: |
510 | 0 | case CTF_PM_FILLHATCHNAME: |
511 | 0 | case CTF_PM_FILLBITMAPNAME: |
512 | 0 | case CTF_PM_FILLTRANSNAME: |
513 | |
|
514 | 0 | case CTF_PM_HEADERFILLGRADIENTNAME: |
515 | 0 | case CTF_PM_HEADERFILLHATCHNAME: |
516 | 0 | case CTF_PM_HEADERFILLBITMAPNAME: |
517 | 0 | case CTF_PM_HEADERFILLTRANSNAME: |
518 | |
|
519 | 0 | case CTF_PM_FOOTERFILLGRADIENTNAME: |
520 | 0 | case CTF_PM_FOOTERFILLHATCHNAME: |
521 | 0 | case CTF_PM_FOOTERFILLBITMAPNAME: |
522 | 0 | case CTF_PM_FOOTERFILLTRANSNAME: |
523 | 0 | { |
524 | 0 | OUString aStr; |
525 | |
|
526 | 0 | if( (pProp->maValue >>= aStr) && 0 == aStr.getLength() ) |
527 | 0 | { |
528 | 0 | pProp->mnIndex = -1; |
529 | 0 | } |
530 | |
|
531 | 0 | break; |
532 | 0 | } |
533 | 0 | } |
534 | | |
535 | 0 | if (nPrintId == CTF_PM_PRINTMASK) |
536 | 0 | { |
537 | 0 | pPrint = pProp; |
538 | 0 | lcl_RemoveState(pPrint); |
539 | 0 | } |
540 | 0 | } |
541 | | |
542 | | // These entries need to be reduced to a single one for XML export. |
543 | | // Both would be exported as 'draw:tile-repeat-offset' following a percent |
544 | | // value and a 'vertical' or 'horizontal' tag as mark. If both would be active |
545 | | // and both would be exported this would create an XML error (same property twice) |
546 | 0 | if(pRepeatOffsetX && pRepeatOffsetY) |
547 | 0 | { |
548 | 0 | sal_Int32 nOffset(0); |
549 | |
|
550 | 0 | if((pRepeatOffsetX->maValue >>= nOffset) && (!nOffset)) |
551 | 0 | { |
552 | 0 | pRepeatOffsetX->mnIndex = -1; |
553 | 0 | } |
554 | 0 | else |
555 | 0 | { |
556 | 0 | pRepeatOffsetY->mnIndex = -1; |
557 | 0 | } |
558 | 0 | } |
559 | | |
560 | | // Same as above for Header |
561 | 0 | if(pHeaderRepeatOffsetX && pHeaderRepeatOffsetY) |
562 | 0 | { |
563 | 0 | sal_Int32 nOffset(0); |
564 | |
|
565 | 0 | if((pHeaderRepeatOffsetX->maValue >>= nOffset) && (!nOffset)) |
566 | 0 | { |
567 | 0 | pHeaderRepeatOffsetX->mnIndex = -1; |
568 | 0 | } |
569 | 0 | else |
570 | 0 | { |
571 | 0 | pHeaderRepeatOffsetY->mnIndex = -1; |
572 | 0 | } |
573 | 0 | } |
574 | | |
575 | | // Same as above for Footer |
576 | 0 | if(pFooterRepeatOffsetX && pFooterRepeatOffsetY) |
577 | 0 | { |
578 | 0 | sal_Int32 nOffset(0); |
579 | |
|
580 | 0 | if((pFooterRepeatOffsetX->maValue >>= nOffset) && (!nOffset)) |
581 | 0 | { |
582 | 0 | pFooterRepeatOffsetX->mnIndex = -1; |
583 | 0 | } |
584 | 0 | else |
585 | 0 | { |
586 | 0 | pFooterRepeatOffsetY->mnIndex = -1; |
587 | 0 | } |
588 | 0 | } |
589 | |
|
590 | 0 | if( pPMStandardMode && !getBOOL(pPMStandardMode->maValue) ) |
591 | 0 | { |
592 | 0 | lcl_RemoveState(pPMStandardMode); |
593 | 0 | if( pPMGridBaseWidth ) |
594 | 0 | lcl_RemoveState(pPMGridBaseWidth); |
595 | 0 | if( pPMGridSnapToChars ) |
596 | 0 | lcl_RemoveState(pPMGridSnapToChars); |
597 | 0 | if (pPMGridSnapTo) |
598 | 0 | { |
599 | 0 | lcl_RemoveState(pPMGridSnapTo); |
600 | 0 | } |
601 | 0 | } |
602 | |
|
603 | 0 | if( pPMGridBaseWidth && pPMStandardMode ) |
604 | 0 | lcl_RemoveState(pPMStandardMode); |
605 | |
|
606 | 0 | aPageBuffer.ContextFilter( rPropState ); |
607 | 0 | aHeaderBuffer.ContextFilter( rPropState ); |
608 | 0 | aFooterBuffer.ContextFilter( rPropState ); |
609 | |
|
610 | 0 | if( pPMHeaderHeight && (!pPMHeaderDynamic || getBOOL( pPMHeaderDynamic->maValue )) ) |
611 | 0 | lcl_RemoveState( pPMHeaderHeight ); |
612 | 0 | if( pPMHeaderMinHeight && pPMHeaderDynamic && !getBOOL( pPMHeaderDynamic->maValue ) ) |
613 | 0 | lcl_RemoveState( pPMHeaderMinHeight ); |
614 | 0 | if( pPMHeaderDynamic ) |
615 | 0 | lcl_RemoveState( pPMHeaderDynamic ); |
616 | |
|
617 | 0 | if( pPMFooterHeight && (!pPMFooterDynamic || getBOOL( pPMFooterDynamic->maValue )) ) |
618 | 0 | lcl_RemoveState( pPMFooterHeight ); |
619 | 0 | if( pPMFooterMinHeight && pPMFooterDynamic && !getBOOL( pPMFooterDynamic->maValue ) ) |
620 | 0 | lcl_RemoveState( pPMFooterMinHeight ); |
621 | 0 | if( pPMFooterDynamic ) |
622 | 0 | lcl_RemoveState( pPMFooterDynamic ); |
623 | |
|
624 | 0 | if( pPMScaleTo ) |
625 | 0 | lcl_RemoveStateIfZero16( pPMScaleTo ); |
626 | 0 | if( pPMScaleToPages ) |
627 | 0 | lcl_RemoveStateIfZero16( pPMScaleToPages ); |
628 | 0 | if( pPMScaleToX ) |
629 | 0 | lcl_RemoveStateIfZero16( pPMScaleToX ); |
630 | 0 | if( pPMScaleToY ) |
631 | 0 | lcl_RemoveStateIfZero16( pPMScaleToY ); |
632 | |
|
633 | 0 | if (pPrint) |
634 | 0 | { |
635 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ANNOTATIONS), u"PrintAnnotations"_ustr, rPropSet); |
636 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_CHARTS), u"PrintCharts"_ustr, rPropSet); |
637 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_DRAWING), u"PrintDrawing"_ustr, rPropSet); |
638 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_FORMULAS), u"PrintFormulas"_ustr, rPropSet); |
639 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_GRID), u"PrintGrid"_ustr, rPropSet); |
640 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_HEADERS), u"PrintHeaders"_ustr, rPropSet); |
641 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_OBJECTS), u"PrintObjects"_ustr, rPropSet); |
642 | 0 | lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), u"PrintZeroValues"_ustr, rPropSet); |
643 | 0 | } |
644 | |
|
645 | 0 | SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rPropState, rPropSet); |
646 | 0 | } |
647 | | |
648 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |