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 <comphelper/extract.hxx>
33 
34 //UUUU
35 #include <xmloff/txtprmap.hxx>
36 
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::beans;
40 using namespace ::comphelper;
41 using namespace ::xmloff::token;
42 
43 //______________________________________________________________________________
44 
lcl_HasSameLineWidth(const table::BorderLine & rLine1,const table::BorderLine & rLine2)45 inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
46 {
47 	return	(rLine1.InnerLineWidth == rLine2.InnerLineWidth) &&
48 			(rLine1.OuterLineWidth == rLine2.OuterLineWidth) &&
49 			(rLine1.LineDistance == rLine2.LineDistance);
50 }
51 
operator ==(const table::BorderLine & rLine1,const table::BorderLine & rLine2)52 inline sal_Bool operator==( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
53 {
54 	return	(rLine1.Color == rLine2.Color) &&
55 			lcl_HasSameLineWidth( rLine1, rLine2 );
56 }
57 
lcl_RemoveState(XMLPropertyState * pState)58 inline void lcl_RemoveState( XMLPropertyState* pState )
59 {
60 	pState->mnIndex = -1;
61 	pState->maValue.clear();
62 }
63 
lcl_RemoveStateIfZero16(XMLPropertyState * pState)64 void lcl_RemoveStateIfZero16( XMLPropertyState* pState )
65 {
66 	sal_Int16	nValue = sal_Int16();
67 	if( (pState->maValue >>= nValue) && !nValue )
68 		lcl_RemoveState( pState );
69 }
70 
lcl_AddState(::std::vector<XMLPropertyState> & rPropState,sal_Int32 nIndex,const rtl::OUString & rProperty,uno::Reference<beans::XPropertySet> & xProps)71 void lcl_AddState(::std::vector< XMLPropertyState >& rPropState, sal_Int32 nIndex, const rtl::OUString& rProperty, uno::Reference< beans::XPropertySet >& xProps)
72 {
73     if(::cppu::any2bool(xProps->getPropertyValue(rProperty)))
74         rPropState.push_back(XMLPropertyState (nIndex, cppu::bool2any(sal_True)));
75 }
76 
77 //______________________________________________________________________________
78 // helper struct to handle equal XMLPropertyState's for page, header and footer
79 
80 struct XMLPropertyStateBuffer
81 {
82     XMLPropertyState*       pPMMarginAll;
83     XMLPropertyState*       pPMMarginTop;
84     XMLPropertyState*       pPMMarginBottom;
85     XMLPropertyState*       pPMMarginLeft;
86     XMLPropertyState*       pPMMarginRight;
87 
88 	XMLPropertyState*		pPMBorderAll;
89 	XMLPropertyState*		pPMBorderTop;
90 	XMLPropertyState*		pPMBorderBottom;
91 	XMLPropertyState*		pPMBorderLeft;
92 	XMLPropertyState*		pPMBorderRight;
93 
94 	XMLPropertyState*		pPMBorderWidthAll;
95 	XMLPropertyState*		pPMBorderWidthTop;
96 	XMLPropertyState*		pPMBorderWidthBottom;
97 	XMLPropertyState*		pPMBorderWidthLeft;
98 	XMLPropertyState*		pPMBorderWidthRight;
99 
100 	XMLPropertyState*		pPMPaddingAll;
101 	XMLPropertyState*		pPMPaddingTop;
102 	XMLPropertyState*		pPMPaddingBottom;
103 	XMLPropertyState*		pPMPaddingLeft;
104 	XMLPropertyState*		pPMPaddingRight;
105 
106 							XMLPropertyStateBuffer();
107 	void					ContextFilter( ::std::vector< XMLPropertyState >& rPropState );
108 };
109 
XMLPropertyStateBuffer()110 XMLPropertyStateBuffer::XMLPropertyStateBuffer()
111     :   pPMMarginAll( NULL )
112     ,   pPMMarginTop( NULL )
113     ,   pPMMarginBottom( NULL )
114     ,   pPMMarginLeft( NULL )
115     ,   pPMMarginRight( NULL )
116     ,
117 		pPMBorderAll( NULL ),
118 		pPMBorderTop( NULL ),
119 		pPMBorderBottom( NULL ),
120 		pPMBorderLeft( NULL ),
121 		pPMBorderRight( NULL ),
122 
123 		pPMBorderWidthAll( NULL ),
124 		pPMBorderWidthTop( NULL ),
125 		pPMBorderWidthBottom( NULL ),
126 		pPMBorderWidthLeft( NULL ),
127 		pPMBorderWidthRight( NULL ),
128 
129 		pPMPaddingAll( NULL ),
130 		pPMPaddingTop( NULL ),
131 		pPMPaddingBottom( NULL ),
132 		pPMPaddingLeft( NULL ),
133 		pPMPaddingRight( NULL )
134 {
135 }
136 
ContextFilter(::std::vector<XMLPropertyState> &)137 void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& )
138 {
139     if (pPMMarginAll)
140     {
141         lcl_RemoveState(pPMMarginAll); // #i117696# do not write fo:margin
142     }
143 
144 	if( pPMBorderAll )
145 	{
146 		if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight )
147 		{
148 			table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
149 
150 			pPMBorderTop->maValue >>= aLineTop;
151 			pPMBorderBottom->maValue >>= aLineBottom;
152 			pPMBorderLeft->maValue >>= aLineLeft;
153 			pPMBorderRight->maValue >>= aLineRight;
154 
155 			if( (aLineTop == aLineBottom) && (aLineBottom == aLineLeft) && (aLineLeft == aLineRight) )
156 			{
157 				lcl_RemoveState( pPMBorderTop );
158 				lcl_RemoveState( pPMBorderBottom );
159 				lcl_RemoveState( pPMBorderLeft );
160 				lcl_RemoveState( pPMBorderRight );
161 			}
162 			else
163 				lcl_RemoveState( pPMBorderAll );
164 		}
165 		else
166 			lcl_RemoveState( pPMBorderAll );
167 	}
168 
169 	if( pPMBorderWidthAll )
170 	{
171 		if( pPMBorderWidthTop && pPMBorderWidthBottom && pPMBorderWidthLeft && pPMBorderWidthRight )
172 		{
173 			table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
174 
175 			pPMBorderWidthTop->maValue >>= aLineTop;
176 			pPMBorderWidthBottom->maValue >>= aLineBottom;
177 			pPMBorderWidthLeft->maValue >>= aLineLeft;
178 			pPMBorderWidthRight->maValue >>= aLineRight;
179 
180 			if( lcl_HasSameLineWidth( aLineTop, aLineBottom ) &&
181 				lcl_HasSameLineWidth( aLineBottom, aLineLeft ) &&
182 				lcl_HasSameLineWidth( aLineLeft, aLineRight ) )
183 			{
184 				lcl_RemoveState( pPMBorderWidthTop );
185 				lcl_RemoveState( pPMBorderWidthBottom );
186 				lcl_RemoveState( pPMBorderWidthLeft );
187 				lcl_RemoveState( pPMBorderWidthRight );
188 			}
189 			else
190 				lcl_RemoveState( pPMBorderWidthAll );
191 		}
192 		else
193 			lcl_RemoveState( pPMBorderWidthAll );
194 	}
195 
196 	if( pPMPaddingAll )
197 	{
198 		if( pPMPaddingTop && pPMPaddingBottom && pPMPaddingLeft && pPMPaddingRight )
199 		{
200 			sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0;
201 
202 			pPMPaddingTop->maValue >>= nTop;
203 			pPMPaddingBottom->maValue >>= nBottom;
204 			pPMPaddingLeft->maValue >>= nLeft;
205 			pPMPaddingRight->maValue >>= nRight;
206 
207 			if( (nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight) )
208 			{
209 				lcl_RemoveState( pPMPaddingTop );
210 				lcl_RemoveState( pPMPaddingBottom );
211 				lcl_RemoveState( pPMPaddingLeft );
212 				lcl_RemoveState( pPMPaddingRight );
213 			}
214 			else
215 				lcl_RemoveState( pPMPaddingAll );
216 		}
217 		else
218 			lcl_RemoveState( pPMPaddingAll );
219 	}
220 }
221 
222 //______________________________________________________________________________
223 
XMLPageMasterExportPropMapper(const UniReference<XMLPropertySetMapper> & rMapper,SvXMLExport & rExport)224 XMLPageMasterExportPropMapper::XMLPageMasterExportPropMapper(
225 		const UniReference< XMLPropertySetMapper >& rMapper,
226 		SvXMLExport& rExport ) :
227 	SvXMLExportPropertyMapper( rMapper ),
228 	aBackgroundImageExport( rExport ),
229 	aTextColumnsExport( rExport ),
230 	aFootnoteSeparatorExport( rExport )
231 {
232 }
233 
~XMLPageMasterExportPropMapper()234 XMLPageMasterExportPropMapper::~XMLPageMasterExportPropMapper()
235 {
236 }
237 
handleElementItem(SvXMLExport &,const XMLPropertyState & rProperty,sal_uInt16,const::std::vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx) const238 void XMLPageMasterExportPropMapper::handleElementItem(
239         SvXMLExport&,
240 		const XMLPropertyState& rProperty,
241 		sal_uInt16 /*nFlags*/,
242 		const ::std::vector< XMLPropertyState >* pProperties,
243 		sal_uInt32 nIdx ) const
244 {
245 	XMLPageMasterExportPropMapper* pThis = (XMLPageMasterExportPropMapper*) this;
246 
247 	sal_uInt32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
248 	switch( nContextId )
249 	{
250 		case CTF_PM_GRAPHICURL:
251 		case CTF_PM_HEADERGRAPHICURL:
252 		case CTF_PM_FOOTERGRAPHICURL:
253 			{
254 				DBG_ASSERT( pProperties && (nIdx >= 2), "property vector missing" );
255 				sal_Int32 nPos;
256 				sal_Int32 nFilter;
257 				switch( nContextId  )
258 				{
259 				case CTF_PM_GRAPHICURL:
260 					nPos = CTF_PM_GRAPHICPOSITION;
261 					nFilter = CTF_PM_GRAPHICFILTER;
262 					break;
263 				case CTF_PM_HEADERGRAPHICURL:
264 					nPos = CTF_PM_HEADERGRAPHICPOSITION;
265 					nFilter = CTF_PM_HEADERGRAPHICFILTER;
266 					break;
267 				case CTF_PM_FOOTERGRAPHICURL:
268 					nPos = CTF_PM_FOOTERGRAPHICPOSITION;
269 					nFilter = CTF_PM_FOOTERGRAPHICFILTER;
270 					break;
271 				default:
272 					nPos = 0;  // TODO What values should this be?
273 					nFilter = 0;
274 				}
275 				const Any*	pPos	= NULL;
276 				const Any*	pFilter	= NULL;
277 				if( pProperties && (nIdx >= 2) )
278 				{
279 					const XMLPropertyState& rPos = (*pProperties)[nIdx - 2];
280 					DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos,
281 								"invalid property map: pos expected" );
282 					if( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos )
283 						pPos = &rPos.maValue;
284 
285 					const XMLPropertyState& rFilter = (*pProperties)[nIdx - 1];
286 					DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter,
287 								"invalid property map: filter expected" );
288 					if( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter )
289 						pFilter = &rFilter.maValue;
290 				}
291 				sal_uInt32 nPropIndex = rProperty.mnIndex;
292 				pThis->aBackgroundImageExport.exportXML( rProperty.maValue, pPos, pFilter, NULL,
293 					getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
294 					getPropertySetMapper()->GetEntryXMLName( nPropIndex ) );
295 			}
296 			break;
297 		case CTF_PM_TEXTCOLUMNS:
298 			pThis->aTextColumnsExport.exportXML( rProperty.maValue );
299 			break;
300 		case CTF_PM_FTN_LINE_WEIGTH:
301 			pThis->aFootnoteSeparatorExport.exportXML( pProperties, nIdx,
302 													   getPropertySetMapper());
303 			break;
304 	}
305 }
306 
handleSpecialItem(SvXMLAttributeList &,const XMLPropertyState &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &,const::std::vector<XMLPropertyState> *,sal_uInt32) const307 void XMLPageMasterExportPropMapper::handleSpecialItem(
308 		SvXMLAttributeList&,
309 		const XMLPropertyState&,
310 		const SvXMLUnitConverter&,
311 		const SvXMLNamespaceMap&,
312 		const ::std::vector< XMLPropertyState >*,
313 		sal_uInt32 /*nIdx*/) const
314 {
315 }
316 
ContextFilter(::std::vector<XMLPropertyState> & rPropState,Reference<XPropertySet> rPropSet) const317 void XMLPageMasterExportPropMapper::ContextFilter(
318 		::std::vector< XMLPropertyState >& rPropState,
319 		Reference< XPropertySet > rPropSet ) const
320 {
321 	XMLPropertyStateBuffer	aPageBuffer;
322 	XMLPropertyStateBuffer	aHeaderBuffer;
323 	XMLPropertyStateBuffer	aFooterBuffer;
324 
325 	XMLPropertyState*		pPMHeaderHeight		= NULL;
326 	XMLPropertyState*		pPMHeaderMinHeight	= NULL;
327 	XMLPropertyState*		pPMHeaderDynamic	= NULL;
328 
329 	XMLPropertyState*		pPMFooterHeight		= NULL;
330 	XMLPropertyState*		pPMFooterMinHeight	= NULL;
331 	XMLPropertyState*		pPMFooterDynamic	= NULL;
332 
333 	XMLPropertyState*		pPMScaleTo			= NULL;
334 	XMLPropertyState*		pPMScaleToPages		= NULL;
335 	XMLPropertyState*		pPMScaleToX 		= NULL;
336 	XMLPropertyState*		pPMScaleToY	    	= NULL;
337 	XMLPropertyState*		pPMStandardMode    	= NULL;
338 	XMLPropertyState*		pPMGridBaseWidth   	= NULL;
339 	XMLPropertyState*		pPMGridSnapToChars 	= NULL;
340 
341     XMLPropertyState*       pPrint              = NULL;
342 
343     //UUUU
344     XMLPropertyState* pRepeatOffsetX = NULL;
345     XMLPropertyState* pRepeatOffsetY = NULL;
346     XMLPropertyState* pHeaderRepeatOffsetX = NULL;
347     XMLPropertyState* pHeaderRepeatOffsetY = NULL;
348     XMLPropertyState* pFooterRepeatOffsetX = NULL;
349     XMLPropertyState* pFooterRepeatOffsetY = NULL;
350 
351     UniReference < XMLPropertySetMapper > aPropMapper(getPropertySetMapper());
352 
353 	for( ::std::vector< XMLPropertyState >::iterator aIter = rPropState.begin(); aIter != rPropState.end(); ++aIter )
354 	{
355         XMLPropertyState *pProp = &(*aIter);
356 		sal_Int16 nContextId	= aPropMapper->GetEntryContextId( pProp->mnIndex );
357 		sal_Int16 nFlag			= nContextId & CTF_PM_FLAGMASK;
358 		sal_Int16 nSimpleId		= nContextId & (~CTF_PM_FLAGMASK | XML_PM_CTF_START);
359         sal_Int16 nPrintId      = nContextId & CTF_PM_PRINTMASK;
360 
361 		XMLPropertyStateBuffer* pBuffer;
362 		switch( nFlag )
363 		{
364 			case CTF_PM_HEADERFLAG:			pBuffer = &aHeaderBuffer;	break;
365 			case CTF_PM_FOOTERFLAG:			pBuffer = &aFooterBuffer;	break;
366 			default:						pBuffer = &aPageBuffer;		break;
367 		}
368 
369 		switch( nSimpleId )
370 		{
371             case CTF_PM_MARGINALL:          pBuffer->pPMMarginAll           = pProp;    break;
372             case CTF_PM_MARGINTOP:          pBuffer->pPMMarginTop           = pProp;    break;
373             case CTF_PM_MARGINBOTTOM:       pBuffer->pPMMarginBottom        = pProp;    break;
374             case CTF_PM_MARGINLEFT:         pBuffer->pPMMarginLeft          = pProp;    break;
375             case CTF_PM_MARGINRIGHT:        pBuffer->pPMMarginRight         = pProp;    break;
376 			case CTF_PM_BORDERALL:			pBuffer->pPMBorderAll			= pProp;	break;
377 			case CTF_PM_BORDERTOP:			pBuffer->pPMBorderTop			= pProp;	break;
378 			case CTF_PM_BORDERBOTTOM:		pBuffer->pPMBorderBottom		= pProp;	break;
379 			case CTF_PM_BORDERLEFT:			pBuffer->pPMBorderLeft			= pProp;	break;
380 			case CTF_PM_BORDERRIGHT:		pBuffer->pPMBorderRight			= pProp;	break;
381 			case CTF_PM_BORDERWIDTHALL:		pBuffer->pPMBorderWidthAll		= pProp;	break;
382 			case CTF_PM_BORDERWIDTHTOP:		pBuffer->pPMBorderWidthTop		= pProp;	break;
383 			case CTF_PM_BORDERWIDTHBOTTOM:	pBuffer->pPMBorderWidthBottom	= pProp;	break;
384 			case CTF_PM_BORDERWIDTHLEFT:	pBuffer->pPMBorderWidthLeft		= pProp;	break;
385 			case CTF_PM_BORDERWIDTHRIGHT:	pBuffer->pPMBorderWidthRight	= pProp;	break;
386 			case CTF_PM_PADDINGALL:			pBuffer->pPMPaddingAll			= pProp;	break;
387 			case CTF_PM_PADDINGTOP:			pBuffer->pPMPaddingTop			= pProp;	break;
388 			case CTF_PM_PADDINGBOTTOM:		pBuffer->pPMPaddingBottom		= pProp;	break;
389 			case CTF_PM_PADDINGLEFT:		pBuffer->pPMPaddingLeft			= pProp;	break;
390 			case CTF_PM_PADDINGRIGHT:		pBuffer->pPMPaddingRight		= pProp;	break;
391 		}
392 
393 		switch( nContextId )
394 		{
395 			case CTF_PM_HEADERHEIGHT:		pPMHeaderHeight		= pProp;	break;
396 			case CTF_PM_HEADERMINHEIGHT:	pPMHeaderMinHeight	= pProp;	break;
397 			case CTF_PM_HEADERDYNAMIC:		pPMHeaderDynamic	= pProp;	break;
398 			case CTF_PM_FOOTERHEIGHT:		pPMFooterHeight		= pProp;	break;
399 			case CTF_PM_FOOTERMINHEIGHT:	pPMFooterMinHeight	= pProp;	break;
400 			case CTF_PM_FOOTERDYNAMIC:		pPMFooterDynamic	= pProp;	break;
401 			case CTF_PM_SCALETO:			pPMScaleTo			= pProp;	break;
402 			case CTF_PM_SCALETOPAGES:		pPMScaleToPages		= pProp;	break;
403             case CTF_PM_SCALETOX:   		pPMScaleToX 		= pProp;	break;
404             case CTF_PM_SCALETOY:   		pPMScaleToY 		= pProp;	break;
405             case CTF_PM_STANDARD_MODE:		pPMStandardMode		= pProp;	break;
406             case CTP_PM_GRID_BASE_WIDTH:		pPMGridBaseWidth	= pProp;	break;
407             case CTP_PM_GRID_SNAP_TO_CHARS:		pPMGridSnapToChars	= pProp;	break;
408 
409             //UUUU
410             case CTF_PM_REPEAT_OFFSET_X:
411                 pRepeatOffsetX = pProp;
412                 break;
413 
414             //UUUU
415             case CTF_PM_REPEAT_OFFSET_Y:
416                 pRepeatOffsetY = pProp;
417                 break;
418 
419             //UUUU
420             case CTF_PM_HEADERREPEAT_OFFSET_X:
421                 pHeaderRepeatOffsetX = pProp;
422                 break;
423 
424             //UUUU
425             case CTF_PM_HEADERREPEAT_OFFSET_Y:
426                 pHeaderRepeatOffsetY = pProp;
427                 break;
428 
429             //UUUU
430             case CTF_PM_FOOTERREPEAT_OFFSET_X:
431                 pFooterRepeatOffsetX = pProp;
432                 break;
433 
434             //UUUU
435             case CTF_PM_FOOTERREPEAT_OFFSET_Y:
436                 pFooterRepeatOffsetY = pProp;
437                 break;
438 
439             //UUUU Sort out empty entries
440             case CTF_PM_FILLGRADIENTNAME:
441             case CTF_PM_FILLHATCHNAME:
442             case CTF_PM_FILLBITMAPNAME:
443             case CTF_PM_FILLTRANSNAME:
444 
445             case CTF_PM_HEADERFILLGRADIENTNAME:
446             case CTF_PM_HEADERFILLHATCHNAME:
447             case CTF_PM_HEADERFILLBITMAPNAME:
448             case CTF_PM_HEADERFILLTRANSNAME:
449 
450             case CTF_PM_FOOTERFILLGRADIENTNAME:
451             case CTF_PM_FOOTERFILLHATCHNAME:
452             case CTF_PM_FOOTERFILLBITMAPNAME:
453             case CTF_PM_FOOTERFILLTRANSNAME:
454             {
455                 rtl::OUString aStr;
456 
457                 if( (pProp->maValue >>= aStr) && 0 == aStr.getLength() )
458                 {
459                     pProp->mnIndex = -1;
460                 }
461 
462                 break;
463             }
464         }
465 
466         if (nPrintId == CTF_PM_PRINTMASK)
467         {
468             pPrint = pProp;
469             lcl_RemoveState(pPrint);
470         }
471     }
472 
473     //UUUU These entries need to be reduced to a single one for XML export.
474     // Both would be exported as 'draw:tile-repeat-offset' following a percent
475     // value and a 'vertical' or 'horizontal' tag as mark. If both would be active
476     // and both would be exported this would create an XML error (same property twice)
477     if(pRepeatOffsetX && pRepeatOffsetY)
478     {
479         sal_Int32 nOffset(0);
480 
481         if((pRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
482         {
483             pRepeatOffsetX->mnIndex = -1;
484         }
485         else
486         {
487             pRepeatOffsetY->mnIndex = -1;
488         }
489     }
490 
491     //UUUU Same as above for Header
492     if(pHeaderRepeatOffsetX && pHeaderRepeatOffsetY)
493     {
494         sal_Int32 nOffset(0);
495 
496         if((pHeaderRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
497         {
498             pHeaderRepeatOffsetX->mnIndex = -1;
499         }
500         else
501         {
502             pHeaderRepeatOffsetY->mnIndex = -1;
503         }
504     }
505 
506     //UUUU Same as above for Footer
507     if(pFooterRepeatOffsetX && pFooterRepeatOffsetY)
508     {
509         sal_Int32 nOffset(0);
510 
511         if((pFooterRepeatOffsetX->maValue >>= nOffset) && (!nOffset))
512         {
513             pFooterRepeatOffsetX->mnIndex = -1;
514         }
515         else
516         {
517             pFooterRepeatOffsetY->mnIndex = -1;
518         }
519     }
520 
521 	if( pPMStandardMode && !getBOOL(pPMStandardMode->maValue) )
522 	{
523 		lcl_RemoveState(pPMStandardMode);
524 		if( pPMGridBaseWidth )
525 			lcl_RemoveState(pPMGridBaseWidth);
526 		if( pPMGridSnapToChars )
527 			lcl_RemoveState(pPMGridSnapToChars);
528 	}
529 
530 	if( pPMGridBaseWidth && pPMStandardMode )
531 		lcl_RemoveState(pPMStandardMode);
532 
533 	aPageBuffer.ContextFilter( rPropState );
534 	aHeaderBuffer.ContextFilter( rPropState );
535 	aFooterBuffer.ContextFilter( rPropState );
536 
537 	if( pPMHeaderHeight && (!pPMHeaderDynamic || (pPMHeaderDynamic && getBOOL( pPMHeaderDynamic->maValue ))) )
538 		lcl_RemoveState( pPMHeaderHeight );
539 	if( pPMHeaderMinHeight && pPMHeaderDynamic && !getBOOL( pPMHeaderDynamic->maValue ) )
540 		lcl_RemoveState( pPMHeaderMinHeight );
541 	if( pPMHeaderDynamic )
542 		lcl_RemoveState( pPMHeaderDynamic );
543 
544 	if( pPMFooterHeight && (!pPMFooterDynamic || (pPMFooterDynamic && getBOOL( pPMFooterDynamic->maValue ))) )
545 		lcl_RemoveState( pPMFooterHeight );
546 	if( pPMFooterMinHeight && pPMFooterDynamic && !getBOOL( pPMFooterDynamic->maValue ) )
547 		lcl_RemoveState( pPMFooterMinHeight );
548 	if( pPMFooterDynamic )
549 		lcl_RemoveState( pPMFooterDynamic );
550 
551 	if( pPMScaleTo )
552 		lcl_RemoveStateIfZero16( pPMScaleTo );
553 	if( pPMScaleToPages )
554 		lcl_RemoveStateIfZero16( pPMScaleToPages );
555 	if( pPMScaleToX )
556 		lcl_RemoveStateIfZero16( pPMScaleToX );
557 	if( pPMScaleToY )
558 		lcl_RemoveStateIfZero16( pPMScaleToY );
559 
560     if (pPrint)
561     {
562         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ANNOTATIONS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintAnnotations")), rPropSet);
563         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_CHARTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintCharts")), rPropSet);
564         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_DRAWING), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintDrawing")), rPropSet);
565         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_FORMULAS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintFormulas")), rPropSet);
566         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_GRID), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintGrid")), rPropSet);
567         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_HEADERS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")), rPropSet);
568         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_OBJECTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintObjects")), rPropSet);
569         lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintZeroValues")), rPropSet);
570     }
571 
572 	SvXMLExportPropertyMapper::ContextFilter(rPropState,rPropSet);
573 }
574 
575