xref: /trunk/main/xmloff/source/style/PageMasterExportPropMapper.cxx (revision d666495c4f609ab94ddded8b0141831070b22d11)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24 
25 #include "PageMasterExportPropMapper.hxx"
26 #include <xmloff/xmltoken.hxx>
27 #include <comphelper/types.hxx>
28 #include <com/sun/star/table/BorderLine.hpp>
29 #include <xmloff/PageMasterStyleMap.hxx>
30 #include <tools/debug.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <unotools/saveopt.hxx>
33 #include <comphelper/extract.hxx>
34 
35 //UUUU
36 #include <xmloff/txtprmap.hxx>
37 
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::beans;
41 using namespace ::comphelper;
42 using namespace ::xmloff::token;
43 
44 //______________________________________________________________________________
45 
lcl_HasSameLineWidth(const table::BorderLine & rLine1,const table::BorderLine & rLine2)46 inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
47 {
48     return  (rLine1.InnerLineWidth == rLine2.InnerLineWidth) &&
49             (rLine1.OuterLineWidth == rLine2.OuterLineWidth) &&
50             (rLine1.LineDistance == rLine2.LineDistance);
51 }
52 
operator ==(const table::BorderLine & rLine1,const table::BorderLine & rLine2)53 inline sal_Bool operator==( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
54 {
55     return  (rLine1.Color == rLine2.Color) &&
56             lcl_HasSameLineWidth( rLine1, rLine2 );
57 }
58 
lcl_RemoveState(XMLPropertyState * pState)59 inline void lcl_RemoveState( XMLPropertyState* pState )
60 {
61     pState->mnIndex = -1;
62     pState->maValue.clear();
63 }
64 
lcl_RemoveStateIfZero16(XMLPropertyState * pState)65 void lcl_RemoveStateIfZero16( XMLPropertyState* pState )
66 {
67     sal_Int16   nValue = sal_Int16();
68     if( (pState->maValue >>= nValue) && !nValue )
69         lcl_RemoveState( pState );
70 }
71 
lcl_AddState(::std::vector<XMLPropertyState> & rPropState,sal_Int32 nIndex,const rtl::OUString & rProperty,uno::Reference<beans::XPropertySet> & xProps)72 void lcl_AddState(::std::vector< XMLPropertyState >& rPropState, sal_Int32 nIndex, const rtl::OUString& rProperty, uno::Reference< beans::XPropertySet >& xProps)
73 {
74     if(::cppu::any2bool(xProps->getPropertyValue(rProperty)))
75         rPropState.push_back(XMLPropertyState (nIndex, cppu::bool2any(sal_True)));
76 }
77 
78 //______________________________________________________________________________
79 // helper struct to handle equal XMLPropertyState's for page, header and footer
80 
81 struct XMLPropertyStateBuffer
82 {
83     XMLPropertyState*       pPMMarginAll;
84     XMLPropertyState*       pPMMarginTop;
85     XMLPropertyState*       pPMMarginBottom;
86     XMLPropertyState*       pPMMarginLeft;
87     XMLPropertyState*       pPMMarginRight;
88 
89     XMLPropertyState*       pPMBorderAll;
90     XMLPropertyState*       pPMBorderTop;
91     XMLPropertyState*       pPMBorderBottom;
92     XMLPropertyState*       pPMBorderLeft;
93     XMLPropertyState*       pPMBorderRight;
94 
95     XMLPropertyState*       pPMBorderWidthAll;
96     XMLPropertyState*       pPMBorderWidthTop;
97     XMLPropertyState*       pPMBorderWidthBottom;
98     XMLPropertyState*       pPMBorderWidthLeft;
99     XMLPropertyState*       pPMBorderWidthRight;
100 
101     XMLPropertyState*       pPMPaddingAll;
102     XMLPropertyState*       pPMPaddingTop;
103     XMLPropertyState*       pPMPaddingBottom;
104     XMLPropertyState*       pPMPaddingLeft;
105     XMLPropertyState*       pPMPaddingRight;
106 
107                             XMLPropertyStateBuffer();
108     void                    ContextFilter( ::std::vector< XMLPropertyState >& rPropState );
109 };
110 
XMLPropertyStateBuffer()111 XMLPropertyStateBuffer::XMLPropertyStateBuffer()
112     :   pPMMarginAll( NULL )
113     ,   pPMMarginTop( NULL )
114     ,   pPMMarginBottom( NULL )
115     ,   pPMMarginLeft( NULL )
116     ,   pPMMarginRight( NULL )
117     ,
118         pPMBorderAll( NULL ),
119         pPMBorderTop( NULL ),
120         pPMBorderBottom( NULL ),
121         pPMBorderLeft( NULL ),
122         pPMBorderRight( NULL ),
123 
124         pPMBorderWidthAll( NULL ),
125         pPMBorderWidthTop( NULL ),
126         pPMBorderWidthBottom( NULL ),
127         pPMBorderWidthLeft( NULL ),
128         pPMBorderWidthRight( NULL ),
129 
130         pPMPaddingAll( NULL ),
131         pPMPaddingTop( NULL ),
132         pPMPaddingBottom( NULL ),
133         pPMPaddingLeft( NULL ),
134         pPMPaddingRight( NULL )
135 {
136 }
137 
ContextFilter(::std::vector<XMLPropertyState> &)138 void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& )
139 {
140     if (pPMMarginAll)
141     {
142         lcl_RemoveState(pPMMarginAll); // #i117696# do not write fo:margin
143     }
144 
145     if( pPMBorderAll )
146     {
147         if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight )
148         {
149             table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
150 
151             pPMBorderTop->maValue >>= aLineTop;
152             pPMBorderBottom->maValue >>= aLineBottom;
153             pPMBorderLeft->maValue >>= aLineLeft;
154             pPMBorderRight->maValue >>= aLineRight;
155 
156             if( (aLineTop == aLineBottom) && (aLineBottom == aLineLeft) && (aLineLeft == aLineRight) )
157             {
158                 lcl_RemoveState( pPMBorderTop );
159                 lcl_RemoveState( pPMBorderBottom );
160                 lcl_RemoveState( pPMBorderLeft );
161                 lcl_RemoveState( pPMBorderRight );
162             }
163             else
164                 lcl_RemoveState( pPMBorderAll );
165         }
166         else
167             lcl_RemoveState( pPMBorderAll );
168     }
169 
170     if( pPMBorderWidthAll )
171     {
172         if( pPMBorderWidthTop && pPMBorderWidthBottom && pPMBorderWidthLeft && pPMBorderWidthRight )
173         {
174             table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
175 
176             pPMBorderWidthTop->maValue >>= aLineTop;
177             pPMBorderWidthBottom->maValue >>= aLineBottom;
178             pPMBorderWidthLeft->maValue >>= aLineLeft;
179             pPMBorderWidthRight->maValue >>= aLineRight;
180 
181             if( lcl_HasSameLineWidth( aLineTop, aLineBottom ) &&
182                 lcl_HasSameLineWidth( aLineBottom, aLineLeft ) &&
183                 lcl_HasSameLineWidth( aLineLeft, aLineRight ) )
184             {
185                 lcl_RemoveState( pPMBorderWidthTop );
186                 lcl_RemoveState( pPMBorderWidthBottom );
187                 lcl_RemoveState( pPMBorderWidthLeft );
188                 lcl_RemoveState( pPMBorderWidthRight );
189             }
190             else
191                 lcl_RemoveState( pPMBorderWidthAll );
192         }
193         else
194             lcl_RemoveState( pPMBorderWidthAll );
195     }
196 
197     if( pPMPaddingAll )
198     {
199         if( pPMPaddingTop && pPMPaddingBottom && pPMPaddingLeft && pPMPaddingRight )
200         {
201             sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0;
202 
203             pPMPaddingTop->maValue >>= nTop;
204             pPMPaddingBottom->maValue >>= nBottom;
205             pPMPaddingLeft->maValue >>= nLeft;
206             pPMPaddingRight->maValue >>= nRight;
207 
208             if( (nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight) )
209             {
210                 lcl_RemoveState( pPMPaddingTop );
211                 lcl_RemoveState( pPMPaddingBottom );
212                 lcl_RemoveState( pPMPaddingLeft );
213                 lcl_RemoveState( pPMPaddingRight );
214             }
215             else
216                 lcl_RemoveState( pPMPaddingAll );
217         }
218         else
219             lcl_RemoveState( pPMPaddingAll );
220     }
221 }
222 
223 //______________________________________________________________________________
224 
XMLPageMasterExportPropMapper(const UniReference<XMLPropertySetMapper> & rMapper,SvXMLExport & rExport)225 XMLPageMasterExportPropMapper::XMLPageMasterExportPropMapper(
226         const UniReference< XMLPropertySetMapper >& rMapper,
227         SvXMLExport& rExport ) :
228     SvXMLExportPropertyMapper( rMapper ),
229     aBackgroundImageExport( rExport ),
230     aTextColumnsExport( rExport ),
231     aFootnoteSeparatorExport( rExport )
232 {
233 }
234 
~XMLPageMasterExportPropMapper()235 XMLPageMasterExportPropMapper::~XMLPageMasterExportPropMapper()
236 {
237 }
238 
handleElementItem(SvXMLExport &,const XMLPropertyState & rProperty,sal_uInt16,const::std::vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx) const239 void XMLPageMasterExportPropMapper::handleElementItem(
240         SvXMLExport&,
241         const XMLPropertyState& rProperty,
242         sal_uInt16 /*nFlags*/,
243         const ::std::vector< XMLPropertyState >* pProperties,
244         sal_uInt32 nIdx ) const
245 {
246     XMLPageMasterExportPropMapper* pThis = (XMLPageMasterExportPropMapper*) this;
247 
248     sal_uInt32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
249     switch( nContextId )
250     {
251         case CTF_PM_GRAPHICURL:
252         case CTF_PM_HEADERGRAPHICURL:
253         case CTF_PM_FOOTERGRAPHICURL:
254             {
255                 DBG_ASSERT( pProperties && (nIdx >= 2), "property vector missing" );
256                 sal_Int32 nPos;
257                 sal_Int32 nFilter;
258                 switch( nContextId  )
259                 {
260                 case CTF_PM_GRAPHICURL:
261                     nPos = CTF_PM_GRAPHICPOSITION;
262                     nFilter = CTF_PM_GRAPHICFILTER;
263                     break;
264                 case CTF_PM_HEADERGRAPHICURL:
265                     nPos = CTF_PM_HEADERGRAPHICPOSITION;
266                     nFilter = CTF_PM_HEADERGRAPHICFILTER;
267                     break;
268                 case CTF_PM_FOOTERGRAPHICURL:
269                     nPos = CTF_PM_FOOTERGRAPHICPOSITION;
270                     nFilter = CTF_PM_FOOTERGRAPHICFILTER;
271                     break;
272                 default:
273                     nPos = 0;  // TODO What values should this be?
274                     nFilter = 0;
275                 }
276                 const Any*  pPos    = NULL;
277                 const Any*  pFilter = NULL;
278                 if( pProperties && (nIdx >= 2) )
279                 {
280                     const XMLPropertyState& rPos = (*pProperties)[nIdx - 2];
281                     DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos,
282                                 "invalid property map: pos expected" );
283                     if( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos )
284                         pPos = &rPos.maValue;
285 
286                     const XMLPropertyState& rFilter = (*pProperties)[nIdx - 1];
287                     DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter,
288                                 "invalid property map: filter expected" );
289                     if( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter )
290                         pFilter = &rFilter.maValue;
291                 }
292                 sal_uInt32 nPropIndex = rProperty.mnIndex;
293                 pThis->aBackgroundImageExport.exportXML( rProperty.maValue, pPos, pFilter, NULL,
294                     getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
295                     getPropertySetMapper()->GetEntryXMLName( nPropIndex ) );
296             }
297             break;
298         case CTF_PM_TEXTCOLUMNS:
299             pThis->aTextColumnsExport.exportXML( rProperty.maValue );
300             break;
301         case CTF_PM_FTN_LINE_WEIGTH:
302             pThis->aFootnoteSeparatorExport.exportXML( pProperties, nIdx,
303                                                        getPropertySetMapper());
304             break;
305     }
306 }
307 
handleSpecialItem(SvXMLAttributeList &,const XMLPropertyState &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &,const::std::vector<XMLPropertyState> *,sal_uInt32) const308 void XMLPageMasterExportPropMapper::handleSpecialItem(
309         SvXMLAttributeList&,
310         const XMLPropertyState&,
311         const SvXMLUnitConverter&,
312         const SvXMLNamespaceMap&,
313         const ::std::vector< XMLPropertyState >*,
314         sal_uInt32 /*nIdx*/) const
315 {
316 }
317 
ContextFilter(::std::vector<XMLPropertyState> & rPropState,Reference<XPropertySet> rPropSet) const318 void XMLPageMasterExportPropMapper::ContextFilter(
319         ::std::vector< XMLPropertyState >& rPropState,
320         Reference< XPropertySet > rPropSet ) const
321 {
322     XMLPropertyStateBuffer  aPageBuffer;
323     XMLPropertyStateBuffer  aHeaderBuffer;
324     XMLPropertyStateBuffer  aFooterBuffer;
325 
326     XMLPropertyState*       pPMHeaderHeight     = NULL;
327     XMLPropertyState*       pPMHeaderMinHeight  = NULL;
328     XMLPropertyState*       pPMHeaderDynamic    = NULL;
329 
330     XMLPropertyState*       pPMFooterHeight     = NULL;
331     XMLPropertyState*       pPMFooterMinHeight  = NULL;
332     XMLPropertyState*       pPMFooterDynamic    = NULL;
333 
334     XMLPropertyState*       pPMScaleTo          = NULL;
335     XMLPropertyState*       pPMScaleToPages     = NULL;
336     XMLPropertyState*       pPMScaleToX         = NULL;
337     XMLPropertyState*       pPMScaleToY         = NULL;
338     XMLPropertyState*       pPMStandardMode     = NULL;
339     XMLPropertyState*       pPMGridBaseWidth    = NULL;
340     XMLPropertyState*       pPMGridSnapToChars  = NULL;
341     XMLPropertyState*       pPMGridSnapTo       = NULL;
342     XMLPropertyState*       pPMHeaderGraphicUrl = NULL;
343     XMLPropertyState*       pPMFooterGraphicUrl = NULL;
344 
345     XMLPropertyState*       pPrint              = NULL;
346 
347     //UUUU
348     XMLPropertyState* pRepeatOffsetX = NULL;
349     XMLPropertyState* pRepeatOffsetY = NULL;
350     XMLPropertyState* pHeaderRepeatOffsetX = NULL;
351     XMLPropertyState* pHeaderRepeatOffsetY = NULL;
352     XMLPropertyState* pFooterRepeatOffsetX = NULL;
353     XMLPropertyState* pFooterRepeatOffsetY = NULL;
354 
355     UniReference < XMLPropertySetMapper > aPropMapper(getPropertySetMapper());
356 
357     for( ::std::vector< XMLPropertyState >::iterator aIter = rPropState.begin(); aIter != rPropState.end(); ++aIter )
358     {
359         XMLPropertyState *pProp = &(*aIter);
360         sal_Int16 nContextId    = aPropMapper->GetEntryContextId( pProp->mnIndex );
361         sal_Int16 nFlag         = nContextId & CTF_PM_FLAGMASK;
362         sal_Int16 nSimpleId     = nContextId & (~CTF_PM_FLAGMASK | XML_PM_CTF_START);
363         sal_Int16 nPrintId      = nContextId & CTF_PM_PRINTMASK;
364 
365         XMLPropertyStateBuffer* pBuffer;
366         switch( nFlag )
367         {
368             case CTF_PM_HEADERFLAG:         pBuffer = &aHeaderBuffer;   break;
369             case CTF_PM_FOOTERFLAG:         pBuffer = &aFooterBuffer;   break;
370             default:                        pBuffer = &aPageBuffer;     break;
371         }
372 
373         switch( nSimpleId )
374         {
375             case CTF_PM_MARGINALL:          pBuffer->pPMMarginAll           = pProp;    break;
376             case CTF_PM_MARGINTOP:          pBuffer->pPMMarginTop           = pProp;    break;
377             case CTF_PM_MARGINBOTTOM:       pBuffer->pPMMarginBottom        = pProp;    break;
378             case CTF_PM_MARGINLEFT:         pBuffer->pPMMarginLeft          = pProp;    break;
379             case CTF_PM_MARGINRIGHT:        pBuffer->pPMMarginRight         = pProp;    break;
380             case CTF_PM_BORDERALL:          pBuffer->pPMBorderAll           = pProp;    break;
381             case CTF_PM_BORDERTOP:          pBuffer->pPMBorderTop           = pProp;    break;
382             case CTF_PM_BORDERBOTTOM:       pBuffer->pPMBorderBottom        = pProp;    break;
383             case CTF_PM_BORDERLEFT:         pBuffer->pPMBorderLeft          = pProp;    break;
384             case CTF_PM_BORDERRIGHT:        pBuffer->pPMBorderRight         = pProp;    break;
385             case CTF_PM_BORDERWIDTHALL:     pBuffer->pPMBorderWidthAll      = pProp;    break;
386             case CTF_PM_BORDERWIDTHTOP:     pBuffer->pPMBorderWidthTop      = pProp;    break;
387             case CTF_PM_BORDERWIDTHBOTTOM:  pBuffer->pPMBorderWidthBottom   = pProp;    break;
388             case CTF_PM_BORDERWIDTHLEFT:    pBuffer->pPMBorderWidthLeft     = pProp;    break;
389             case CTF_PM_BORDERWIDTHRIGHT:   pBuffer->pPMBorderWidthRight    = pProp;    break;
390             case CTF_PM_PADDINGALL:         pBuffer->pPMPaddingAll          = pProp;    break;
391             case CTF_PM_PADDINGTOP:         pBuffer->pPMPaddingTop          = pProp;    break;
392             case CTF_PM_PADDINGBOTTOM:      pBuffer->pPMPaddingBottom       = pProp;    break;
393             case CTF_PM_PADDINGLEFT:        pBuffer->pPMPaddingLeft         = pProp;    break;
394             case CTF_PM_PADDINGRIGHT:       pBuffer->pPMPaddingRight        = pProp;    break;
395         }
396 
397         switch( nContextId )
398         {
399             case CTF_PM_HEADERHEIGHT:       pPMHeaderHeight     = pProp;    break;
400             case CTF_PM_HEADERMINHEIGHT:    pPMHeaderMinHeight  = pProp;    break;
401             case CTF_PM_HEADERDYNAMIC:      pPMHeaderDynamic    = pProp;    break;
402             case CTF_PM_FOOTERHEIGHT:       pPMFooterHeight     = pProp;    break;
403             case CTF_PM_FOOTERMINHEIGHT:    pPMFooterMinHeight  = pProp;    break;
404             case CTF_PM_FOOTERDYNAMIC:      pPMFooterDynamic    = pProp;    break;
405             case CTF_PM_SCALETO:            pPMScaleTo          = pProp;    break;
406             case CTF_PM_SCALETOPAGES:       pPMScaleToPages     = pProp;    break;
407             case CTF_PM_SCALETOX:           pPMScaleToX         = pProp;    break;
408             case CTF_PM_SCALETOY:           pPMScaleToY         = pProp;    break;
409             case CTF_PM_STANDARD_MODE:      pPMStandardMode     = pProp;    break;
410             case CTP_PM_GRID_BASE_WIDTH:        pPMGridBaseWidth    = pProp;    break;
411             case CTP_PM_GRID_SNAP_TO_CHARS:     pPMGridSnapToChars  = pProp;    break;
412             case CTP_PM_GRID_SNAP_TO:           pPMGridSnapTo       = pProp;    break;
413             case CTF_PM_HEADERGRAPHICURL:       pPMHeaderGraphicUrl = pProp;    break;
414             case CTF_PM_FOOTERGRAPHICURL:       pPMFooterGraphicUrl = pProp;    break;
415 
416             //UUUU
417             case CTF_PM_REPEAT_OFFSET_X:
418                 pRepeatOffsetX = pProp;
419                 break;
420 
421             //UUUU
422             case CTF_PM_REPEAT_OFFSET_Y:
423                 pRepeatOffsetY = pProp;
424                 break;
425 
426             //UUUU
427             case CTF_PM_HEADERREPEAT_OFFSET_X:
428                 pHeaderRepeatOffsetX = pProp;
429                 break;
430 
431             //UUUU
432             case CTF_PM_HEADERREPEAT_OFFSET_Y:
433                 pHeaderRepeatOffsetY = pProp;
434                 break;
435 
436             //UUUU
437             case CTF_PM_FOOTERREPEAT_OFFSET_X:
438                 pFooterRepeatOffsetX = pProp;
439                 break;
440 
441             //UUUU
442             case CTF_PM_FOOTERREPEAT_OFFSET_Y:
443                 pFooterRepeatOffsetY = pProp;
444                 break;
445 
446             //UUUU Sort out empty entries
447             case CTF_PM_FILLGRADIENTNAME:
448             case CTF_PM_FILLHATCHNAME:
449             case CTF_PM_FILLBITMAPNAME:
450             case CTF_PM_FILLTRANSNAME:
451 
452             case CTF_PM_HEADERFILLGRADIENTNAME:
453             case CTF_PM_HEADERFILLHATCHNAME:
454             case CTF_PM_HEADERFILLBITMAPNAME:
455             case CTF_PM_HEADERFILLTRANSNAME:
456 
457             case CTF_PM_FOOTERFILLGRADIENTNAME:
458             case CTF_PM_FOOTERFILLHATCHNAME:
459             case CTF_PM_FOOTERFILLBITMAPNAME:
460             case CTF_PM_FOOTERFILLTRANSNAME:
461             {
462                 rtl::OUString aStr;
463 
464                 if( (pProp->maValue >>= aStr) && 0 == aStr.getLength() )
465                 {
466                     pProp->mnIndex = -1;
467                 }
468 
469                 break;
470             }
471         }
472 
473         if (nPrintId == CTF_PM_PRINTMASK)
474         {
475             pPrint = pProp;
476             lcl_RemoveState(pPrint);
477         }
478     }
479 
480     //UUUU These entries need to be reduced to a single one for XML export.
481     // Both would be exported as 'draw:tile-repeat-offset' following a percent
482     // value and a 'vertical' or 'horizontal' tag as mark. If both would be active
483     // and both would be exported this would create an XML error (same property twice)
484     if(pRepeatOffsetX && pRepeatOffsetY)
485     {
486         sal_Int32 nOffset(0);
487 
488         if((pRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
489         {
490             pRepeatOffsetX->mnIndex = -1;
491         }
492         else
493         {
494             pRepeatOffsetY->mnIndex = -1;
495         }
496     }
497 
498     //UUUU Same as above for Header
499     if(pHeaderRepeatOffsetX && pHeaderRepeatOffsetY)
500     {
501         sal_Int32 nOffset(0);
502 
503         if((pHeaderRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
504         {
505             pHeaderRepeatOffsetX->mnIndex = -1;
506         }
507         else
508         {
509             pHeaderRepeatOffsetY->mnIndex = -1;
510         }
511     }
512 
513     //UUUU Same as above for Footer
514     if(pFooterRepeatOffsetX && pFooterRepeatOffsetY)
515     {
516         sal_Int32 nOffset(0);
517 
518         if((pFooterRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
519         {
520             pFooterRepeatOffsetX->mnIndex = -1;
521         }
522         else
523         {
524             pFooterRepeatOffsetY->mnIndex = -1;
525         }
526     }
527 
528     if( pPMStandardMode && !getBOOL(pPMStandardMode->maValue) )
529     {
530         lcl_RemoveState(pPMStandardMode);
531         if( pPMGridBaseWidth )
532             lcl_RemoveState(pPMGridBaseWidth);
533         if( pPMGridSnapToChars )
534             lcl_RemoveState(pPMGridSnapToChars);
535         if( pPMGridSnapTo )
536             lcl_RemoveState(pPMGridSnapTo);
537     }
538 
539     // ODF 1.2 calls it style:layout-grid-snap-to; the other modes keep the old name, which released versions read
540     if( pPMGridSnapToChars && pPMGridSnapTo )
541     {
542         if( SvtSaveOptions::IsODFStrict( SvtSaveOptions().GetODFDefaultVersion() ) )
543             lcl_RemoveState( pPMGridSnapToChars );
544         else
545             lcl_RemoveState( pPMGridSnapTo );
546     }
547 
548     // ext output stays as before (the ids once collided with the repeat offsets, so none was written)
549     if( SvtSaveOptions::IsODFExtended( SvtSaveOptions().GetODFDefaultVersion() ) )
550     {
551         if( pPMHeaderGraphicUrl )
552             lcl_RemoveState(pPMHeaderGraphicUrl);
553         if( pPMFooterGraphicUrl )
554             lcl_RemoveState(pPMFooterGraphicUrl);
555     }
556 
557     // ext output writes the page fill as the drawing page style of the master page instead
558     if( SvtSaveOptions::IsODFExtended( SvtSaveOptions().GetODFDefaultVersion() ) )
559     {
560         for( ::std::vector< XMLPropertyState >::iterator aIter = rPropState.begin(); aIter != rPropState.end(); ++aIter )
561         {
562             if( aIter->mnIndex != -1 &&
563                 ( aPropMapper->GetEntryType( aIter->mnIndex ) & XML_TYPE_PROP_MASK ) == XML_TYPE_PROP_PAGE_LAYOUT &&
564                 aPropMapper->GetEntryAPIName( aIter->mnIndex ).matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Fill" ) ) )
565                 lcl_RemoveState( &(*aIter) );
566         }
567     }
568 
569     // ODF 1.2 allows style:layout-grid-standard-mode in the default page layout only, so the other modes
570     // drop it; extended mode keeps it so that a page style in standard mode survives a round trip
571     if( pPMGridBaseWidth && pPMStandardMode && !SvtSaveOptions::IsODFExtended( SvtSaveOptions().GetODFDefaultVersion() ) )
572         lcl_RemoveState(pPMStandardMode);
573 
574     aPageBuffer.ContextFilter( rPropState );
575     aHeaderBuffer.ContextFilter( rPropState );
576     aFooterBuffer.ContextFilter( rPropState );
577 
578     if( pPMHeaderHeight && (!pPMHeaderDynamic || (pPMHeaderDynamic && getBOOL( pPMHeaderDynamic->maValue ))) )
579         lcl_RemoveState( pPMHeaderHeight );
580     if( pPMHeaderMinHeight && pPMHeaderDynamic && !getBOOL( pPMHeaderDynamic->maValue ) )
581         lcl_RemoveState( pPMHeaderMinHeight );
582     if( pPMHeaderDynamic )
583         lcl_RemoveState( pPMHeaderDynamic );
584 
585     if( pPMFooterHeight && (!pPMFooterDynamic || (pPMFooterDynamic && getBOOL( pPMFooterDynamic->maValue ))) )
586         lcl_RemoveState( pPMFooterHeight );
587     if( pPMFooterMinHeight && pPMFooterDynamic && !getBOOL( pPMFooterDynamic->maValue ) )
588         lcl_RemoveState( pPMFooterMinHeight );
589     if( pPMFooterDynamic )
590         lcl_RemoveState( pPMFooterDynamic );
591 
592     if( pPMScaleTo )
593         lcl_RemoveStateIfZero16( pPMScaleTo );
594     if( pPMScaleToPages )
595         lcl_RemoveStateIfZero16( pPMScaleToPages );
596     // style:scale-to-X and -Y are not in ODF 1.2
597     const SvtSaveOptions::ODFDefaultVersion nODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
598     const sal_Bool bStrict = nODFVersion == SvtSaveOptions::ODFVER_012;
599     if( pPMScaleToX )
600     {
601         if( bStrict )
602             lcl_RemoveState( pPMScaleToX );
603         else
604             lcl_RemoveStateIfZero16( pPMScaleToX );
605     }
606     if( pPMScaleToY )
607     {
608         if( bStrict )
609             lcl_RemoveState( pPMScaleToY );
610         else
611             lcl_RemoveStateIfZero16( pPMScaleToY );
612     }
613     // ODF 1.3: style:scale-to-X and -Y exclude style:scale-to and style:scale-to-pages
614     if( nODFVersion >= SvtSaveOptions::ODFVER_013 && ( ( pPMScaleToX && pPMScaleToX->mnIndex != -1 ) || ( pPMScaleToY && pPMScaleToY->mnIndex != -1 ) ) )
615     {
616         if( pPMScaleTo )
617             lcl_RemoveState( pPMScaleTo );
618         if( pPMScaleToPages )
619             lcl_RemoveState( pPMScaleToPages );
620     }
621 
622     if (pPrint)
623     {
624         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ANNOTATIONS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintAnnotations")), rPropSet);
625         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_CHARTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintCharts")), rPropSet);
626         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_DRAWING), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintDrawing")), rPropSet);
627         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_FORMULAS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintFormulas")), rPropSet);
628         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_GRID), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintGrid")), rPropSet);
629         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_HEADERS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")), rPropSet);
630         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_OBJECTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintObjects")), rPropSet);
631         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintZeroValues")), rPropSet);
632     }
633 
634     SvXMLExportPropertyMapper::ContextFilter(rPropState,rPropSet);
635 }
636