1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "PageMasterExportPropMapper.hxx"
27cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
28cdf0e10cSrcweir #include <comphelper/types.hxx>
29cdf0e10cSrcweir #include <com/sun/star/table/BorderLine.hpp>
30cdf0e10cSrcweir #include <xmloff/PageMasterStyleMap.hxx>
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
33cdf0e10cSrcweir #include <comphelper/extract.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::beans;
38cdf0e10cSrcweir using namespace ::comphelper;
39cdf0e10cSrcweir using namespace ::xmloff::token;
40cdf0e10cSrcweir
41cdf0e10cSrcweir
42cdf0e10cSrcweir //______________________________________________________________________________
43cdf0e10cSrcweir
lcl_HasSameLineWidth(const table::BorderLine & rLine1,const table::BorderLine & rLine2)44cdf0e10cSrcweir inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir return (rLine1.InnerLineWidth == rLine2.InnerLineWidth) &&
47cdf0e10cSrcweir (rLine1.OuterLineWidth == rLine2.OuterLineWidth) &&
48cdf0e10cSrcweir (rLine1.LineDistance == rLine2.LineDistance);
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
operator ==(const table::BorderLine & rLine1,const table::BorderLine & rLine2)51cdf0e10cSrcweir inline sal_Bool operator==( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir return (rLine1.Color == rLine2.Color) &&
54cdf0e10cSrcweir lcl_HasSameLineWidth( rLine1, rLine2 );
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
lcl_RemoveState(XMLPropertyState * pState)57cdf0e10cSrcweir inline void lcl_RemoveState( XMLPropertyState* pState )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir pState->mnIndex = -1;
60cdf0e10cSrcweir pState->maValue.clear();
61cdf0e10cSrcweir }
62cdf0e10cSrcweir
lcl_RemoveStateIfZero16(XMLPropertyState * pState)63cdf0e10cSrcweir void lcl_RemoveStateIfZero16( XMLPropertyState* pState )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir sal_Int16 nValue = sal_Int16();
66cdf0e10cSrcweir if( (pState->maValue >>= nValue) && !nValue )
67cdf0e10cSrcweir lcl_RemoveState( pState );
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
lcl_AddState(::std::vector<XMLPropertyState> & rPropState,sal_Int32 nIndex,const rtl::OUString & rProperty,uno::Reference<beans::XPropertySet> & xProps)70cdf0e10cSrcweir void lcl_AddState(::std::vector< XMLPropertyState >& rPropState, sal_Int32 nIndex, const rtl::OUString& rProperty, uno::Reference< beans::XPropertySet >& xProps)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir if(::cppu::any2bool(xProps->getPropertyValue(rProperty)))
73cdf0e10cSrcweir rPropState.push_back(XMLPropertyState (nIndex, cppu::bool2any(sal_True)));
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
76cdf0e10cSrcweir //______________________________________________________________________________
77cdf0e10cSrcweir // helper struct to handle equal XMLPropertyState's for page, header and footer
78cdf0e10cSrcweir
79cdf0e10cSrcweir struct XMLPropertyStateBuffer
80cdf0e10cSrcweir {
81cdf0e10cSrcweir XMLPropertyState* pPMMarginAll;
82cdf0e10cSrcweir XMLPropertyState* pPMMarginTop;
83cdf0e10cSrcweir XMLPropertyState* pPMMarginBottom;
84cdf0e10cSrcweir XMLPropertyState* pPMMarginLeft;
85cdf0e10cSrcweir XMLPropertyState* pPMMarginRight;
86cdf0e10cSrcweir
87cdf0e10cSrcweir XMLPropertyState* pPMBorderAll;
88cdf0e10cSrcweir XMLPropertyState* pPMBorderTop;
89cdf0e10cSrcweir XMLPropertyState* pPMBorderBottom;
90cdf0e10cSrcweir XMLPropertyState* pPMBorderLeft;
91cdf0e10cSrcweir XMLPropertyState* pPMBorderRight;
92cdf0e10cSrcweir
93cdf0e10cSrcweir XMLPropertyState* pPMBorderWidthAll;
94cdf0e10cSrcweir XMLPropertyState* pPMBorderWidthTop;
95cdf0e10cSrcweir XMLPropertyState* pPMBorderWidthBottom;
96cdf0e10cSrcweir XMLPropertyState* pPMBorderWidthLeft;
97cdf0e10cSrcweir XMLPropertyState* pPMBorderWidthRight;
98cdf0e10cSrcweir
99cdf0e10cSrcweir XMLPropertyState* pPMPaddingAll;
100cdf0e10cSrcweir XMLPropertyState* pPMPaddingTop;
101cdf0e10cSrcweir XMLPropertyState* pPMPaddingBottom;
102cdf0e10cSrcweir XMLPropertyState* pPMPaddingLeft;
103cdf0e10cSrcweir XMLPropertyState* pPMPaddingRight;
104cdf0e10cSrcweir
105cdf0e10cSrcweir XMLPropertyStateBuffer();
106cdf0e10cSrcweir void ContextFilter( ::std::vector< XMLPropertyState >& rPropState );
107cdf0e10cSrcweir };
108cdf0e10cSrcweir
XMLPropertyStateBuffer()109cdf0e10cSrcweir XMLPropertyStateBuffer::XMLPropertyStateBuffer()
110cdf0e10cSrcweir : pPMMarginAll( NULL )
111cdf0e10cSrcweir , pPMMarginTop( NULL )
112cdf0e10cSrcweir , pPMMarginBottom( NULL )
113cdf0e10cSrcweir , pPMMarginLeft( NULL )
114cdf0e10cSrcweir , pPMMarginRight( NULL )
115cdf0e10cSrcweir ,
116cdf0e10cSrcweir pPMBorderAll( NULL ),
117cdf0e10cSrcweir pPMBorderTop( NULL ),
118cdf0e10cSrcweir pPMBorderBottom( NULL ),
119cdf0e10cSrcweir pPMBorderLeft( NULL ),
120cdf0e10cSrcweir pPMBorderRight( NULL ),
121cdf0e10cSrcweir
122cdf0e10cSrcweir pPMBorderWidthAll( NULL ),
123cdf0e10cSrcweir pPMBorderWidthTop( NULL ),
124cdf0e10cSrcweir pPMBorderWidthBottom( NULL ),
125cdf0e10cSrcweir pPMBorderWidthLeft( NULL ),
126cdf0e10cSrcweir pPMBorderWidthRight( NULL ),
127cdf0e10cSrcweir
128cdf0e10cSrcweir pPMPaddingAll( NULL ),
129cdf0e10cSrcweir pPMPaddingTop( NULL ),
130cdf0e10cSrcweir pPMPaddingBottom( NULL ),
131cdf0e10cSrcweir pPMPaddingLeft( NULL ),
132cdf0e10cSrcweir pPMPaddingRight( NULL )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
ContextFilter(::std::vector<XMLPropertyState> &)136cdf0e10cSrcweir void XMLPropertyStateBuffer::ContextFilter( ::std::vector< XMLPropertyState >& )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir if (pPMMarginAll)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir lcl_RemoveState(pPMMarginAll); // #i117696# do not write fo:margin
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir if( pPMBorderAll )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir if( pPMBorderTop && pPMBorderBottom && pPMBorderLeft && pPMBorderRight )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
148cdf0e10cSrcweir
149cdf0e10cSrcweir pPMBorderTop->maValue >>= aLineTop;
150cdf0e10cSrcweir pPMBorderBottom->maValue >>= aLineBottom;
151cdf0e10cSrcweir pPMBorderLeft->maValue >>= aLineLeft;
152cdf0e10cSrcweir pPMBorderRight->maValue >>= aLineRight;
153cdf0e10cSrcweir
154cdf0e10cSrcweir if( (aLineTop == aLineBottom) && (aLineBottom == aLineLeft) && (aLineLeft == aLineRight) )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir lcl_RemoveState( pPMBorderTop );
157cdf0e10cSrcweir lcl_RemoveState( pPMBorderBottom );
158cdf0e10cSrcweir lcl_RemoveState( pPMBorderLeft );
159cdf0e10cSrcweir lcl_RemoveState( pPMBorderRight );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir else
162cdf0e10cSrcweir lcl_RemoveState( pPMBorderAll );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir else
165cdf0e10cSrcweir lcl_RemoveState( pPMBorderAll );
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir if( pPMBorderWidthAll )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir if( pPMBorderWidthTop && pPMBorderWidthBottom && pPMBorderWidthLeft && pPMBorderWidthRight )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir table::BorderLine aLineTop, aLineBottom, aLineLeft, aLineRight;
173cdf0e10cSrcweir
174cdf0e10cSrcweir pPMBorderWidthTop->maValue >>= aLineTop;
175cdf0e10cSrcweir pPMBorderWidthBottom->maValue >>= aLineBottom;
176cdf0e10cSrcweir pPMBorderWidthLeft->maValue >>= aLineLeft;
177cdf0e10cSrcweir pPMBorderWidthRight->maValue >>= aLineRight;
178cdf0e10cSrcweir
179cdf0e10cSrcweir if( lcl_HasSameLineWidth( aLineTop, aLineBottom ) &&
180cdf0e10cSrcweir lcl_HasSameLineWidth( aLineBottom, aLineLeft ) &&
181cdf0e10cSrcweir lcl_HasSameLineWidth( aLineLeft, aLineRight ) )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthTop );
184cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthBottom );
185cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthLeft );
186cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthRight );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir else
189cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthAll );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir else
192cdf0e10cSrcweir lcl_RemoveState( pPMBorderWidthAll );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir if( pPMPaddingAll )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir if( pPMPaddingTop && pPMPaddingBottom && pPMPaddingLeft && pPMPaddingRight )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir sal_Int32 nTop = 0, nBottom = 0, nLeft = 0, nRight = 0;
200cdf0e10cSrcweir
201cdf0e10cSrcweir pPMPaddingTop->maValue >>= nTop;
202cdf0e10cSrcweir pPMPaddingBottom->maValue >>= nBottom;
203cdf0e10cSrcweir pPMPaddingLeft->maValue >>= nLeft;
204cdf0e10cSrcweir pPMPaddingRight->maValue >>= nRight;
205cdf0e10cSrcweir
206cdf0e10cSrcweir if( (nTop == nBottom) && (nBottom == nLeft) && (nLeft == nRight) )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir lcl_RemoveState( pPMPaddingTop );
209cdf0e10cSrcweir lcl_RemoveState( pPMPaddingBottom );
210cdf0e10cSrcweir lcl_RemoveState( pPMPaddingLeft );
211cdf0e10cSrcweir lcl_RemoveState( pPMPaddingRight );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir else
214cdf0e10cSrcweir lcl_RemoveState( pPMPaddingAll );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir else
217cdf0e10cSrcweir lcl_RemoveState( pPMPaddingAll );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir //______________________________________________________________________________
222cdf0e10cSrcweir
XMLPageMasterExportPropMapper(const UniReference<XMLPropertySetMapper> & rMapper,SvXMLExport & rExport)223cdf0e10cSrcweir XMLPageMasterExportPropMapper::XMLPageMasterExportPropMapper(
224cdf0e10cSrcweir const UniReference< XMLPropertySetMapper >& rMapper,
225cdf0e10cSrcweir SvXMLExport& rExport ) :
226cdf0e10cSrcweir SvXMLExportPropertyMapper( rMapper ),
227cdf0e10cSrcweir aBackgroundImageExport( rExport ),
228cdf0e10cSrcweir aTextColumnsExport( rExport ),
229cdf0e10cSrcweir aFootnoteSeparatorExport( rExport )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
~XMLPageMasterExportPropMapper()233cdf0e10cSrcweir XMLPageMasterExportPropMapper::~XMLPageMasterExportPropMapper()
234cdf0e10cSrcweir {
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
handleElementItem(SvXMLExport &,const XMLPropertyState & rProperty,sal_uInt16,const::std::vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx) const237cdf0e10cSrcweir void XMLPageMasterExportPropMapper::handleElementItem(
238cdf0e10cSrcweir SvXMLExport&,
239cdf0e10cSrcweir const XMLPropertyState& rProperty,
240cdf0e10cSrcweir sal_uInt16 /*nFlags*/,
241cdf0e10cSrcweir const ::std::vector< XMLPropertyState >* pProperties,
242cdf0e10cSrcweir sal_uInt32 nIdx ) const
243cdf0e10cSrcweir {
244cdf0e10cSrcweir XMLPageMasterExportPropMapper* pThis = (XMLPageMasterExportPropMapper*) this;
245cdf0e10cSrcweir
246cdf0e10cSrcweir sal_uInt32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
247cdf0e10cSrcweir switch( nContextId )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir case CTF_PM_GRAPHICURL:
250cdf0e10cSrcweir case CTF_PM_HEADERGRAPHICURL:
251cdf0e10cSrcweir case CTF_PM_FOOTERGRAPHICURL:
252cdf0e10cSrcweir {
253cdf0e10cSrcweir DBG_ASSERT( pProperties && (nIdx >= 2), "property vector missing" );
254cdf0e10cSrcweir sal_Int32 nPos;
255cdf0e10cSrcweir sal_Int32 nFilter;
256cdf0e10cSrcweir switch( nContextId )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir case CTF_PM_GRAPHICURL:
259cdf0e10cSrcweir nPos = CTF_PM_GRAPHICPOSITION;
260cdf0e10cSrcweir nFilter = CTF_PM_GRAPHICFILTER;
261cdf0e10cSrcweir break;
262cdf0e10cSrcweir case CTF_PM_HEADERGRAPHICURL:
263cdf0e10cSrcweir nPos = CTF_PM_HEADERGRAPHICPOSITION;
264cdf0e10cSrcweir nFilter = CTF_PM_HEADERGRAPHICFILTER;
265cdf0e10cSrcweir break;
266cdf0e10cSrcweir case CTF_PM_FOOTERGRAPHICURL:
267cdf0e10cSrcweir nPos = CTF_PM_FOOTERGRAPHICPOSITION;
268cdf0e10cSrcweir nFilter = CTF_PM_FOOTERGRAPHICFILTER;
269cdf0e10cSrcweir break;
270cdf0e10cSrcweir default:
271cdf0e10cSrcweir nPos = 0; // TODO What values should this be?
272cdf0e10cSrcweir nFilter = 0;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir const Any* pPos = NULL;
275cdf0e10cSrcweir const Any* pFilter = NULL;
276cdf0e10cSrcweir if( pProperties && (nIdx >= 2) )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir const XMLPropertyState& rPos = (*pProperties)[nIdx - 2];
279cdf0e10cSrcweir DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos,
280cdf0e10cSrcweir "invalid property map: pos expected" );
281cdf0e10cSrcweir if( getPropertySetMapper()->GetEntryContextId( rPos.mnIndex ) == nPos )
282cdf0e10cSrcweir pPos = &rPos.maValue;
283cdf0e10cSrcweir
284cdf0e10cSrcweir const XMLPropertyState& rFilter = (*pProperties)[nIdx - 1];
285cdf0e10cSrcweir DBG_ASSERT( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter,
286cdf0e10cSrcweir "invalid property map: filter expected" );
287cdf0e10cSrcweir if( getPropertySetMapper()->GetEntryContextId( rFilter.mnIndex ) == nFilter )
288cdf0e10cSrcweir pFilter = &rFilter.maValue;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir sal_uInt32 nPropIndex = rProperty.mnIndex;
291cdf0e10cSrcweir pThis->aBackgroundImageExport.exportXML( rProperty.maValue, pPos, pFilter, NULL,
292cdf0e10cSrcweir getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
293cdf0e10cSrcweir getPropertySetMapper()->GetEntryXMLName( nPropIndex ) );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir break;
296cdf0e10cSrcweir case CTF_PM_TEXTCOLUMNS:
297cdf0e10cSrcweir pThis->aTextColumnsExport.exportXML( rProperty.maValue );
298cdf0e10cSrcweir break;
299cdf0e10cSrcweir case CTF_PM_FTN_LINE_WEIGTH:
300cdf0e10cSrcweir pThis->aFootnoteSeparatorExport.exportXML( pProperties, nIdx,
301cdf0e10cSrcweir getPropertySetMapper());
302cdf0e10cSrcweir break;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
handleSpecialItem(SvXMLAttributeList &,const XMLPropertyState &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &,const::std::vector<XMLPropertyState> *,sal_uInt32) const306cdf0e10cSrcweir void XMLPageMasterExportPropMapper::handleSpecialItem(
307cdf0e10cSrcweir SvXMLAttributeList&,
308cdf0e10cSrcweir const XMLPropertyState&,
309cdf0e10cSrcweir const SvXMLUnitConverter&,
310cdf0e10cSrcweir const SvXMLNamespaceMap&,
311cdf0e10cSrcweir const ::std::vector< XMLPropertyState >*,
312cdf0e10cSrcweir sal_uInt32 /*nIdx*/) const
313cdf0e10cSrcweir {
314cdf0e10cSrcweir }
315cdf0e10cSrcweir
ContextFilter(::std::vector<XMLPropertyState> & rPropState,Reference<XPropertySet> rPropSet) const316cdf0e10cSrcweir void XMLPageMasterExportPropMapper::ContextFilter(
317cdf0e10cSrcweir ::std::vector< XMLPropertyState >& rPropState,
318cdf0e10cSrcweir Reference< XPropertySet > rPropSet ) const
319cdf0e10cSrcweir {
320cdf0e10cSrcweir XMLPropertyStateBuffer aPageBuffer;
321cdf0e10cSrcweir XMLPropertyStateBuffer aHeaderBuffer;
322cdf0e10cSrcweir XMLPropertyStateBuffer aFooterBuffer;
323cdf0e10cSrcweir
324cdf0e10cSrcweir XMLPropertyState* pPMHeaderHeight = NULL;
325cdf0e10cSrcweir XMLPropertyState* pPMHeaderMinHeight = NULL;
326cdf0e10cSrcweir XMLPropertyState* pPMHeaderDynamic = NULL;
327cdf0e10cSrcweir
328cdf0e10cSrcweir XMLPropertyState* pPMFooterHeight = NULL;
329cdf0e10cSrcweir XMLPropertyState* pPMFooterMinHeight = NULL;
330cdf0e10cSrcweir XMLPropertyState* pPMFooterDynamic = NULL;
331cdf0e10cSrcweir
332cdf0e10cSrcweir XMLPropertyState* pPMScaleTo = NULL;
333cdf0e10cSrcweir XMLPropertyState* pPMScaleToPages = NULL;
334cdf0e10cSrcweir XMLPropertyState* pPMScaleToX = NULL;
335cdf0e10cSrcweir XMLPropertyState* pPMScaleToY = NULL;
336cdf0e10cSrcweir XMLPropertyState* pPMStandardMode = NULL;
337cdf0e10cSrcweir XMLPropertyState* pPMGridBaseWidth = NULL;
338cdf0e10cSrcweir XMLPropertyState* pPMGridSnapToChars = NULL;
339cdf0e10cSrcweir
340cdf0e10cSrcweir XMLPropertyState* pPrint = NULL;
341cdf0e10cSrcweir
342cdf0e10cSrcweir UniReference < XMLPropertySetMapper > aPropMapper(getPropertySetMapper());
343cdf0e10cSrcweir
344cdf0e10cSrcweir for( ::std::vector< XMLPropertyState >::iterator aIter = rPropState.begin(); aIter != rPropState.end(); ++aIter )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir XMLPropertyState *pProp = &(*aIter);
347cdf0e10cSrcweir sal_Int16 nContextId = aPropMapper->GetEntryContextId( pProp->mnIndex );
348cdf0e10cSrcweir sal_Int16 nFlag = nContextId & CTF_PM_FLAGMASK;
349cdf0e10cSrcweir sal_Int16 nSimpleId = nContextId & (~CTF_PM_FLAGMASK | XML_PM_CTF_START);
350cdf0e10cSrcweir sal_Int16 nPrintId = nContextId & CTF_PM_PRINTMASK;
351cdf0e10cSrcweir
352cdf0e10cSrcweir XMLPropertyStateBuffer* pBuffer;
353cdf0e10cSrcweir switch( nFlag )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir case CTF_PM_HEADERFLAG: pBuffer = &aHeaderBuffer; break;
356cdf0e10cSrcweir case CTF_PM_FOOTERFLAG: pBuffer = &aFooterBuffer; break;
357cdf0e10cSrcweir default: pBuffer = &aPageBuffer; break;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir switch( nSimpleId )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir case CTF_PM_MARGINALL: pBuffer->pPMMarginAll = pProp; break;
363cdf0e10cSrcweir case CTF_PM_MARGINTOP: pBuffer->pPMMarginTop = pProp; break;
364cdf0e10cSrcweir case CTF_PM_MARGINBOTTOM: pBuffer->pPMMarginBottom = pProp; break;
365cdf0e10cSrcweir case CTF_PM_MARGINLEFT: pBuffer->pPMMarginLeft = pProp; break;
366cdf0e10cSrcweir case CTF_PM_MARGINRIGHT: pBuffer->pPMMarginRight = pProp; break;
367cdf0e10cSrcweir case CTF_PM_BORDERALL: pBuffer->pPMBorderAll = pProp; break;
368cdf0e10cSrcweir case CTF_PM_BORDERTOP: pBuffer->pPMBorderTop = pProp; break;
369cdf0e10cSrcweir case CTF_PM_BORDERBOTTOM: pBuffer->pPMBorderBottom = pProp; break;
370cdf0e10cSrcweir case CTF_PM_BORDERLEFT: pBuffer->pPMBorderLeft = pProp; break;
371cdf0e10cSrcweir case CTF_PM_BORDERRIGHT: pBuffer->pPMBorderRight = pProp; break;
372cdf0e10cSrcweir case CTF_PM_BORDERWIDTHALL: pBuffer->pPMBorderWidthAll = pProp; break;
373cdf0e10cSrcweir case CTF_PM_BORDERWIDTHTOP: pBuffer->pPMBorderWidthTop = pProp; break;
374cdf0e10cSrcweir case CTF_PM_BORDERWIDTHBOTTOM: pBuffer->pPMBorderWidthBottom = pProp; break;
375cdf0e10cSrcweir case CTF_PM_BORDERWIDTHLEFT: pBuffer->pPMBorderWidthLeft = pProp; break;
376cdf0e10cSrcweir case CTF_PM_BORDERWIDTHRIGHT: pBuffer->pPMBorderWidthRight = pProp; break;
377cdf0e10cSrcweir case CTF_PM_PADDINGALL: pBuffer->pPMPaddingAll = pProp; break;
378cdf0e10cSrcweir case CTF_PM_PADDINGTOP: pBuffer->pPMPaddingTop = pProp; break;
379cdf0e10cSrcweir case CTF_PM_PADDINGBOTTOM: pBuffer->pPMPaddingBottom = pProp; break;
380cdf0e10cSrcweir case CTF_PM_PADDINGLEFT: pBuffer->pPMPaddingLeft = pProp; break;
381cdf0e10cSrcweir case CTF_PM_PADDINGRIGHT: pBuffer->pPMPaddingRight = pProp; break;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
384cdf0e10cSrcweir switch( nContextId )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir case CTF_PM_HEADERHEIGHT: pPMHeaderHeight = pProp; break;
387cdf0e10cSrcweir case CTF_PM_HEADERMINHEIGHT: pPMHeaderMinHeight = pProp; break;
388cdf0e10cSrcweir case CTF_PM_HEADERDYNAMIC: pPMHeaderDynamic = pProp; break;
389cdf0e10cSrcweir case CTF_PM_FOOTERHEIGHT: pPMFooterHeight = pProp; break;
390cdf0e10cSrcweir case CTF_PM_FOOTERMINHEIGHT: pPMFooterMinHeight = pProp; break;
391cdf0e10cSrcweir case CTF_PM_FOOTERDYNAMIC: pPMFooterDynamic = pProp; break;
392cdf0e10cSrcweir case CTF_PM_SCALETO: pPMScaleTo = pProp; break;
393cdf0e10cSrcweir case CTF_PM_SCALETOPAGES: pPMScaleToPages = pProp; break;
394cdf0e10cSrcweir case CTF_PM_SCALETOX: pPMScaleToX = pProp; break;
395cdf0e10cSrcweir case CTF_PM_SCALETOY: pPMScaleToY = pProp; break;
396cdf0e10cSrcweir case CTF_PM_STANDARD_MODE: pPMStandardMode = pProp; break;
397cdf0e10cSrcweir case CTP_PM_GRID_BASE_WIDTH: pPMGridBaseWidth = pProp; break;
398cdf0e10cSrcweir case CTP_PM_GRID_SNAP_TO_CHARS: pPMGridSnapToChars = pProp; break;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir if (nPrintId == CTF_PM_PRINTMASK)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir pPrint = pProp;
403cdf0e10cSrcweir lcl_RemoveState(pPrint);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir if( pPMStandardMode && !getBOOL(pPMStandardMode->maValue) )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir lcl_RemoveState(pPMStandardMode);
410cdf0e10cSrcweir if( pPMGridBaseWidth )
411cdf0e10cSrcweir lcl_RemoveState(pPMGridBaseWidth);
412cdf0e10cSrcweir if( pPMGridSnapToChars )
413cdf0e10cSrcweir lcl_RemoveState(pPMGridSnapToChars);
414cdf0e10cSrcweir }
415cdf0e10cSrcweir
416cdf0e10cSrcweir if( pPMGridBaseWidth && pPMStandardMode )
417cdf0e10cSrcweir lcl_RemoveState(pPMStandardMode);
418cdf0e10cSrcweir
419cdf0e10cSrcweir aPageBuffer.ContextFilter( rPropState );
420cdf0e10cSrcweir aHeaderBuffer.ContextFilter( rPropState );
421cdf0e10cSrcweir aFooterBuffer.ContextFilter( rPropState );
422cdf0e10cSrcweir
423cdf0e10cSrcweir if( pPMHeaderHeight && (!pPMHeaderDynamic || (pPMHeaderDynamic && getBOOL( pPMHeaderDynamic->maValue ))) )
424cdf0e10cSrcweir lcl_RemoveState( pPMHeaderHeight );
425cdf0e10cSrcweir if( pPMHeaderMinHeight && pPMHeaderDynamic && !getBOOL( pPMHeaderDynamic->maValue ) )
426cdf0e10cSrcweir lcl_RemoveState( pPMHeaderMinHeight );
427cdf0e10cSrcweir if( pPMHeaderDynamic )
428cdf0e10cSrcweir lcl_RemoveState( pPMHeaderDynamic );
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( pPMFooterHeight && (!pPMFooterDynamic || (pPMFooterDynamic && getBOOL( pPMFooterDynamic->maValue ))) )
431cdf0e10cSrcweir lcl_RemoveState( pPMFooterHeight );
432cdf0e10cSrcweir if( pPMFooterMinHeight && pPMFooterDynamic && !getBOOL( pPMFooterDynamic->maValue ) )
433cdf0e10cSrcweir lcl_RemoveState( pPMFooterMinHeight );
434cdf0e10cSrcweir if( pPMFooterDynamic )
435cdf0e10cSrcweir lcl_RemoveState( pPMFooterDynamic );
436cdf0e10cSrcweir
437cdf0e10cSrcweir if( pPMScaleTo )
438cdf0e10cSrcweir lcl_RemoveStateIfZero16( pPMScaleTo );
439cdf0e10cSrcweir if( pPMScaleToPages )
440cdf0e10cSrcweir lcl_RemoveStateIfZero16( pPMScaleToPages );
441cdf0e10cSrcweir if( pPMScaleToX )
442cdf0e10cSrcweir lcl_RemoveStateIfZero16( pPMScaleToX );
443cdf0e10cSrcweir if( pPMScaleToY )
444cdf0e10cSrcweir lcl_RemoveStateIfZero16( pPMScaleToY );
445cdf0e10cSrcweir
446cdf0e10cSrcweir if (pPrint)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ANNOTATIONS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintAnnotations")), rPropSet);
449cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_CHARTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintCharts")), rPropSet);
450cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_DRAWING), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintDrawing")), rPropSet);
451cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_FORMULAS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintFormulas")), rPropSet);
452cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_GRID), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintGrid")), rPropSet);
453cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_HEADERS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")), rPropSet);
454cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_OBJECTS), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintObjects")), rPropSet);
455cdf0e10cSrcweir lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintZeroValues")), rPropSet);
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
458cdf0e10cSrcweir SvXMLExportPropertyMapper::ContextFilter(rPropState,rPropSet);
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
461