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