Update ooo320-m1
[ooovba.git] / xmloff / source / text / txtexppr.cxx
blob8b267bba18efc87db8c2c8d7fc8bc4855257a997
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtexppr.cxx,v $
10 * $Revision: 1.41 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <tools/debug.hxx>
34 #include <xmloff/txtprmap.hxx>
35 #include <com/sun/star/table/BorderLine.hpp>
36 #include <com/sun/star/text/SizeType.hpp>
37 #include <com/sun/star/text/WrapTextMode.hpp>
38 #ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP
39 #include <com/sun/star/text/TextContentAnchorType.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_AWT_FONTFAMILY_HPP
42 #include <com/sun/star/awt/FontFamily.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_AWT_FONTPITCH_HPP
45 #include <com/sun/star/awt/FontPitch.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP
48 #include <com/sun/star/awt/FontUnderline.hpp>
49 #endif
50 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
51 #include "txtexppr.hxx"
52 #include <xmloff/xmlexp.hxx>
53 #include "XMLSectionFootnoteConfigExport.hxx"
55 using ::rtl::OUString;
56 using ::rtl::OUStringBuffer;
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::uno;
60 using namespace ::com::sun::star::style;
61 using namespace ::com::sun::star::beans;
62 using namespace ::com::sun::star::text;
63 using namespace ::com::sun::star::awt;
65 void XMLTextExportPropertySetMapper::handleElementItem(
66 SvXMLExport& rExp,
67 const XMLPropertyState& rProperty,
68 sal_uInt16 nFlags,
69 const ::std::vector< XMLPropertyState > *pProperties,
70 sal_uInt32 nIdx ) const
72 XMLTextExportPropertySetMapper *pThis =
73 ((XMLTextExportPropertySetMapper *)this);
75 switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ) )
77 case CTF_DROPCAPFORMAT:
78 pThis->maDropCapExport.exportXML( rProperty.maValue, bDropWholeWord,
79 sDropCharStyle );
80 pThis->bDropWholeWord = sal_False;
81 pThis->sDropCharStyle = OUString();
82 break;
84 case CTF_TABSTOP:
85 pThis->maTabStopExport.Export( rProperty.maValue );
86 break;
88 case CTF_TEXTCOLUMNS:
89 pThis->maTextColumnsExport.exportXML( rProperty.maValue );
90 break;
92 case CTF_BACKGROUND_URL:
94 DBG_ASSERT( pProperties && nIdx >= 3,
95 "property vector missing" );
96 const Any *pPos = 0, *pFilter = 0, *pTrans = 0;
97 if( pProperties && nIdx >= 3 )
99 const XMLPropertyState& rTrans = (*pProperties)[nIdx-3];
100 // #99657# transparency may be there, but doesn't have to be.
101 // If it's there, it must be in the right position.
102 if( CTF_BACKGROUND_TRANSPARENCY == getPropertySetMapper()
103 ->GetEntryContextId( rTrans.mnIndex ) )
104 pTrans = &rTrans.maValue;
106 const XMLPropertyState& rPos = (*pProperties)[nIdx-2];
107 DBG_ASSERT( CTF_BACKGROUND_POS == getPropertySetMapper()
108 ->GetEntryContextId( rPos.mnIndex ),
109 "invalid property map: pos expected" );
110 if( CTF_BACKGROUND_POS == getPropertySetMapper()
111 ->GetEntryContextId( rPos.mnIndex ) )
112 pPos = &rPos.maValue;
114 const XMLPropertyState& rFilter = (*pProperties)[nIdx-1];
115 DBG_ASSERT( CTF_BACKGROUND_FILTER == getPropertySetMapper()
116 ->GetEntryContextId( rFilter.mnIndex ),
117 "invalid property map: filter expected" );
118 if( CTF_BACKGROUND_FILTER == getPropertySetMapper()
119 ->GetEntryContextId( rFilter.mnIndex ) )
120 pFilter = &rFilter.maValue;
122 sal_uInt32 nPropIndex = rProperty.mnIndex;
123 pThis->maBackgroundImageExport.exportXML(
124 rProperty.maValue, pPos, pFilter, pTrans,
125 getPropertySetMapper()->GetEntryNameSpace( nPropIndex ),
126 getPropertySetMapper()->GetEntryXMLName( nPropIndex ) );
128 break;
130 case CTF_SECTION_FOOTNOTE_END:
131 XMLSectionFootnoteConfigExport::exportXML(rExp, sal_False,
132 pProperties, nIdx,
133 getPropertySetMapper());
134 break;
136 case CTF_SECTION_ENDNOTE_END:
137 XMLSectionFootnoteConfigExport::exportXML(rExp, sal_True,
138 pProperties, nIdx,
139 getPropertySetMapper());
140 break;
142 default:
143 SvXMLExportPropertyMapper::handleElementItem( rExp, rProperty, nFlags, pProperties, nIdx );
144 break;
148 void XMLTextExportPropertySetMapper::handleSpecialItem(
149 SvXMLAttributeList& rAttrList,
150 const XMLPropertyState& rProperty,
151 const SvXMLUnitConverter& rUnitConverter,
152 const SvXMLNamespaceMap& rNamespaceMap,
153 const ::std::vector< XMLPropertyState > *pProperties,
154 sal_uInt32 nIdx ) const
156 XMLTextExportPropertySetMapper *pThis =
157 ((XMLTextExportPropertySetMapper *)this);
159 switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ) )
161 case CTF_DROPCAPWHOLEWORD:
162 DBG_ASSERT( !bDropWholeWord, "drop whole word is set already!" );
163 pThis->bDropWholeWord = *(sal_Bool *)rProperty.maValue.getValue();
164 break;
165 case CTF_DROPCAPCHARSTYLE:
166 DBG_ASSERT( !sDropCharStyle.getLength(),
167 "drop char style is set already!" );
168 rProperty.maValue >>= pThis->sDropCharStyle;
169 break;
170 case CTF_NUMBERINGSTYLENAME:
171 case CTF_PAGEDESCNAME:
172 case CTF_OLDTEXTBACKGROUND:
173 case CTF_BACKGROUND_POS:
174 case CTF_BACKGROUND_FILTER:
175 case CTF_BACKGROUND_TRANSPARENCY:
176 case CTF_SECTION_FOOTNOTE_NUM_OWN:
177 case CTF_SECTION_FOOTNOTE_NUM_RESTART:
178 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
179 case CTF_SECTION_FOOTNOTE_NUM_TYPE:
180 case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
181 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
182 case CTF_SECTION_ENDNOTE_NUM_OWN:
183 case CTF_SECTION_ENDNOTE_NUM_RESTART:
184 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
185 case CTF_SECTION_ENDNOTE_NUM_TYPE:
186 case CTF_SECTION_ENDNOTE_NUM_PREFIX:
187 case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
188 case CTF_DEFAULT_OUTLINE_LEVEL:
189 case CTF_OLD_FLOW_WITH_TEXT:
190 // There's nothing to do here!
191 break;
192 default:
193 SvXMLExportPropertyMapper::handleSpecialItem(rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
194 break;
198 XMLTextExportPropertySetMapper::XMLTextExportPropertySetMapper(
199 const UniReference< XMLPropertySetMapper >& rMapper,
200 SvXMLExport& rExp ) :
201 SvXMLExportPropertyMapper( rMapper ),
202 rExport( rExp ),
203 bDropWholeWord( sal_False ),
204 maDropCapExport( rExp ),
205 maTabStopExport( rExp ),
206 maTextColumnsExport( rExp ),
207 maBackgroundImageExport( rExp )
211 XMLTextExportPropertySetMapper::~XMLTextExportPropertySetMapper()
215 void XMLTextExportPropertySetMapper::ContextFontFilter(
216 XMLPropertyState *pFontNameState,
217 XMLPropertyState *pFontFamilyNameState,
218 XMLPropertyState *pFontStyleNameState,
219 XMLPropertyState *pFontFamilyState,
220 XMLPropertyState *pFontPitchState,
221 XMLPropertyState *pFontCharsetState ) const
223 OUString sFamilyName;
224 OUString sStyleName;
225 sal_Int16 nFamily = FontFamily::DONTKNOW;
226 sal_Int16 nPitch = FontPitch::DONTKNOW;
227 rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW;
229 OUString sTmp;
230 if( pFontFamilyNameState && (pFontFamilyNameState->maValue >>= sTmp ) )
231 sFamilyName = sTmp;
232 if( pFontStyleNameState && (pFontStyleNameState->maValue >>= sTmp ) )
233 sStyleName = sTmp;
235 sal_Int16 nTmp = sal_Int16();
236 if( pFontFamilyState && (pFontFamilyState->maValue >>= nTmp ) )
237 nFamily = nTmp;
238 if( pFontPitchState && (pFontPitchState->maValue >>= nTmp ) )
239 nPitch = nTmp;
240 if( pFontCharsetState && (pFontCharsetState->maValue >>= nTmp ) )
241 eEnc = (rtl_TextEncoding)nTmp;
243 OUString sName( ((SvXMLExport&)GetExport()).GetFontAutoStylePool()->Find(
244 sFamilyName, sStyleName, nFamily, nPitch, eEnc ) );
245 if( sName.getLength() )
247 pFontNameState->maValue <<= sName;
248 if( pFontFamilyNameState )
249 pFontFamilyNameState->mnIndex = -1;
250 if( pFontStyleNameState )
251 pFontStyleNameState->mnIndex = -1;
252 if( pFontFamilyState )
253 pFontFamilyState->mnIndex = -1;
254 if( pFontPitchState )
255 pFontPitchState->mnIndex = -1;
256 if( pFontCharsetState )
257 pFontCharsetState->mnIndex = -1;
259 else
261 pFontNameState->mnIndex = -1;
264 if( pFontFamilyNameState && (0 == sFamilyName.getLength()) )
266 pFontFamilyNameState->mnIndex = -1;
269 if( pFontStyleNameState && (0 == sStyleName.getLength()) )
271 pFontStyleNameState->mnIndex = -1;
275 void XMLTextExportPropertySetMapper::ContextFontHeightFilter(
276 XMLPropertyState* pCharHeightState,
277 XMLPropertyState* pCharPropHeightState,
278 XMLPropertyState* pCharDiffHeightState ) const
280 if( pCharPropHeightState )
282 sal_Int32 nTemp = 0;
283 pCharPropHeightState->maValue >>= nTemp;
284 if( nTemp == 100 )
286 pCharPropHeightState->mnIndex = -1;
287 pCharPropHeightState->maValue.clear();
289 else
291 pCharHeightState->mnIndex = -1;
292 pCharHeightState->maValue.clear();
295 if( pCharDiffHeightState )
297 float nTemp = 0;
298 pCharDiffHeightState->maValue >>= nTemp;
299 if( nTemp == 0. )
301 pCharDiffHeightState->mnIndex = -1;
302 pCharDiffHeightState->maValue.clear();
304 else
306 pCharHeightState->mnIndex = -1;
307 pCharHeightState->maValue.clear();
313 // helper method; implementation below
314 bool lcl_IsOutlineStyle(const SvXMLExport&, const OUString&);
317 void XMLTextExportPropertySetMapper::ContextFilter(
318 ::std::vector< XMLPropertyState >& rProperties,
319 Reference< XPropertySet > rPropSet ) const
321 // filter font
322 XMLPropertyState *pFontNameState = 0;
323 XMLPropertyState *pFontFamilyNameState = 0;
324 XMLPropertyState *pFontStyleNameState = 0;
325 XMLPropertyState *pFontFamilyState = 0;
326 XMLPropertyState *pFontPitchState = 0;
327 XMLPropertyState *pFontCharsetState = 0;
328 XMLPropertyState *pFontNameCJKState = 0;
329 XMLPropertyState *pFontFamilyNameCJKState = 0;
330 XMLPropertyState *pFontStyleNameCJKState = 0;
331 XMLPropertyState *pFontFamilyCJKState = 0;
332 XMLPropertyState *pFontPitchCJKState = 0;
333 XMLPropertyState *pFontCharsetCJKState = 0;
334 XMLPropertyState *pFontNameCTLState = 0;
335 XMLPropertyState *pFontFamilyNameCTLState = 0;
336 XMLPropertyState *pFontStyleNameCTLState = 0;
337 XMLPropertyState *pFontFamilyCTLState = 0;
338 XMLPropertyState *pFontPitchCTLState = 0;
339 XMLPropertyState *pFontCharsetCTLState = 0;
341 // filter char height point/percent
342 XMLPropertyState* pCharHeightState = NULL;
343 XMLPropertyState* pCharPropHeightState = NULL;
344 XMLPropertyState* pCharDiffHeightState = NULL;
345 XMLPropertyState* pCharHeightCJKState = NULL;
346 XMLPropertyState* pCharPropHeightCJKState = NULL;
347 XMLPropertyState* pCharDiffHeightCJKState = NULL;
348 XMLPropertyState* pCharHeightCTLState = NULL;
349 XMLPropertyState* pCharPropHeightCTLState = NULL;
350 XMLPropertyState* pCharDiffHeightCTLState = NULL;
352 // filter left margin measure/percent
353 XMLPropertyState* pParaLeftMarginState = NULL;
354 XMLPropertyState* pParaLeftMarginRelState = NULL;
356 // filter right margin measure/percent
357 XMLPropertyState* pParaRightMarginState = NULL;
358 XMLPropertyState* pParaRightMarginRelState = NULL;
360 // filter first line indent measure/percent
361 XMLPropertyState* pParaFirstLineState = NULL;
362 XMLPropertyState* pParaFirstLineRelState = NULL;
364 // filter ParaTopMargin/Relative
365 XMLPropertyState* pParaTopMarginState = NULL;
366 XMLPropertyState* pParaTopMarginRelState = NULL;
368 // filter ParaTopMargin/Relative
369 XMLPropertyState* pParaBottomMarginState = NULL;
370 XMLPropertyState* pParaBottomMarginRelState = NULL;
372 // filter (Left|Right|Top|Bottom|)BorderWidth
373 XMLPropertyState* pAllBorderWidthState = NULL;
374 XMLPropertyState* pLeftBorderWidthState = NULL;
375 XMLPropertyState* pRightBorderWidthState = NULL;
376 XMLPropertyState* pTopBorderWidthState = NULL;
377 XMLPropertyState* pBottomBorderWidthState = NULL;
379 // filter (Left|Right|Top|)BorderDistance
380 XMLPropertyState* pAllBorderDistanceState = NULL;
381 XMLPropertyState* pLeftBorderDistanceState = NULL;
382 XMLPropertyState* pRightBorderDistanceState = NULL;
383 XMLPropertyState* pTopBorderDistanceState = NULL;
384 XMLPropertyState* pBottomBorderDistanceState = NULL;
386 // filter (Left|Right|Top|Bottom|)Border
387 XMLPropertyState* pAllBorderState = NULL;
388 XMLPropertyState* pLeftBorderState = NULL;
389 XMLPropertyState* pRightBorderState = NULL;
390 XMLPropertyState* pTopBorderState = NULL;
391 XMLPropertyState* pBottomBorderState = NULL;
393 // filter height properties
394 XMLPropertyState* pHeightMinAbsState = NULL;
395 XMLPropertyState* pHeightMinRelState = NULL;
396 XMLPropertyState* pHeightAbsState = NULL;
397 XMLPropertyState* pHeightRelState = NULL;
398 XMLPropertyState* pSizeTypeState = NULL;
400 // filter width properties
401 XMLPropertyState* pWidthMinAbsState = NULL;
402 XMLPropertyState* pWidthMinRelState = NULL;
403 XMLPropertyState* pWidthAbsState = NULL;
404 XMLPropertyState* pWidthRelState = NULL;
405 XMLPropertyState* pWidthTypeState = NULL;
407 // wrap
408 XMLPropertyState* pWrapState = NULL;
409 XMLPropertyState* pWrapContourState = NULL;
410 XMLPropertyState* pWrapContourModeState = NULL;
411 XMLPropertyState* pWrapParagraphOnlyState = NULL;
413 // anchor
414 XMLPropertyState* pAnchorTypeState = NULL;
416 // horizontal position and relation
417 XMLPropertyState* pHoriOrientState = NULL;
418 XMLPropertyState* pHoriOrientMirroredState = NULL;
419 XMLPropertyState* pHoriOrientRelState = NULL;
420 XMLPropertyState* pHoriOrientRelFrameState = NULL;
421 XMLPropertyState* pHoriOrientMirrorState = NULL;
422 // --> OD 2004-08-09 #i28749# - horizontal position and relation for shapes
423 XMLPropertyState* pShapeHoriOrientState = NULL;
424 XMLPropertyState* pShapeHoriOrientMirroredState = NULL;
425 XMLPropertyState* pShapeHoriOrientRelState = NULL;
426 XMLPropertyState* pShapeHoriOrientRelFrameState = NULL;
427 XMLPropertyState* pShapeHoriOrientMirrorState = NULL;
428 // <--
430 // vertical position and relation
431 XMLPropertyState* pVertOrientState = NULL;
432 XMLPropertyState* pVertOrientAtCharState = NULL;
433 XMLPropertyState* pVertOrientRelState = NULL;
434 XMLPropertyState* pVertOrientRelPageState = NULL;
435 XMLPropertyState* pVertOrientRelFrameState = NULL;
436 XMLPropertyState* pVertOrientRelAsCharState = NULL;
438 // --> OD 2004-08-09 #i28749# - vertical position and relation for shapes
439 XMLPropertyState* pShapeVertOrientState = NULL;
440 XMLPropertyState* pShapeVertOrientAtCharState = NULL;
441 XMLPropertyState* pShapeVertOrientRelState = NULL;
442 XMLPropertyState* pShapeVertOrientRelPageState = NULL;
443 XMLPropertyState* pShapeVertOrientRelFrameState = NULL;
444 // <--
446 // filter underline color
447 XMLPropertyState* pUnderlineState = NULL;
448 XMLPropertyState* pUnderlineColorState = NULL;
449 XMLPropertyState* pUnderlineHasColorState = NULL;
451 // filter list style name
452 XMLPropertyState* pListStyleName = NULL;
454 // filter fo:clip
455 XMLPropertyState* pClip11State = NULL;
456 XMLPropertyState* pClipState = NULL;
458 sal_Bool bNeedsAnchor = sal_False;
460 for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
461 aIter != rProperties.end();
462 ++aIter )
464 XMLPropertyState *propertie = &(*aIter);
465 if( propertie->mnIndex == -1 )
466 continue;
468 switch( getPropertySetMapper()->GetEntryContextId( propertie->mnIndex ) )
470 case CTF_CHARHEIGHT: pCharHeightState = propertie; break;
471 case CTF_CHARHEIGHT_REL: pCharPropHeightState = propertie; break;
472 case CTF_CHARHEIGHT_DIFF: pCharDiffHeightState = propertie; break;
473 case CTF_CHARHEIGHT_CJK: pCharHeightCJKState = propertie; break;
474 case CTF_CHARHEIGHT_REL_CJK: pCharPropHeightCJKState = propertie; break;
475 case CTF_CHARHEIGHT_DIFF_CJK: pCharDiffHeightCJKState = propertie; break;
476 case CTF_CHARHEIGHT_CTL: pCharHeightCTLState = propertie; break;
477 case CTF_CHARHEIGHT_REL_CTL: pCharPropHeightCTLState = propertie; break;
478 case CTF_CHARHEIGHT_DIFF_CTL: pCharDiffHeightCTLState = propertie; break;
479 case CTF_PARALEFTMARGIN: pParaLeftMarginState = propertie; break;
480 case CTF_PARALEFTMARGIN_REL: pParaLeftMarginRelState = propertie; break;
481 case CTF_PARARIGHTMARGIN: pParaRightMarginState = propertie; break;
482 case CTF_PARARIGHTMARGIN_REL: pParaRightMarginRelState = propertie; break;
483 case CTF_PARAFIRSTLINE: pParaFirstLineState = propertie; break;
484 case CTF_PARAFIRSTLINE_REL: pParaFirstLineRelState = propertie; break;
485 case CTF_PARATOPMARGIN: pParaTopMarginState = propertie; break;
486 case CTF_PARATOPMARGIN_REL: pParaTopMarginRelState = propertie; break;
487 case CTF_PARABOTTOMMARGIN: pParaBottomMarginState = propertie; break;
488 case CTF_PARABOTTOMMARGIN_REL: pParaBottomMarginRelState = propertie; break;
489 case CTF_ALLBORDERWIDTH: pAllBorderWidthState = propertie; break;
490 case CTF_LEFTBORDERWIDTH: pLeftBorderWidthState = propertie; break;
491 case CTF_RIGHTBORDERWIDTH: pRightBorderWidthState = propertie; break;
492 case CTF_TOPBORDERWIDTH: pTopBorderWidthState = propertie; break;
493 case CTF_BOTTOMBORDERWIDTH: pBottomBorderWidthState = propertie; break;
494 case CTF_ALLBORDERDISTANCE: pAllBorderDistanceState = propertie; break;
495 case CTF_LEFTBORDERDISTANCE: pLeftBorderDistanceState = propertie; break;
496 case CTF_RIGHTBORDERDISTANCE: pRightBorderDistanceState = propertie; break;
497 case CTF_TOPBORDERDISTANCE: pTopBorderDistanceState = propertie; break;
498 case CTF_BOTTOMBORDERDISTANCE: pBottomBorderDistanceState = propertie; break;
499 case CTF_ALLBORDER: pAllBorderState = propertie; break;
500 case CTF_LEFTBORDER: pLeftBorderState = propertie; break;
501 case CTF_RIGHTBORDER: pRightBorderState = propertie; break;
502 case CTF_TOPBORDER: pTopBorderState = propertie; break;
503 case CTF_BOTTOMBORDER: pBottomBorderState = propertie; break;
505 case CTF_FRAMEHEIGHT_MIN_ABS: pHeightMinAbsState = propertie; break;
506 case CTF_FRAMEHEIGHT_MIN_REL: pHeightMinRelState = propertie; break;
507 case CTF_FRAMEHEIGHT_ABS: pHeightAbsState = propertie; break;
508 case CTF_FRAMEHEIGHT_REL: pHeightRelState = propertie; break;
509 case CTF_SIZETYPE: pSizeTypeState = propertie; break;
511 case CTF_FRAMEWIDTH_MIN_ABS: pWidthMinAbsState = propertie; break;
512 case CTF_FRAMEWIDTH_MIN_REL: pWidthMinRelState = propertie; break;
513 case CTF_FRAMEWIDTH_ABS: pWidthAbsState = propertie; break;
514 case CTF_FRAMEWIDTH_REL: pWidthRelState = propertie; break;
515 case CTF_FRAMEWIDTH_TYPE: pWidthTypeState = propertie; break;
517 case CTF_WRAP: pWrapState = propertie; break;
518 case CTF_WRAP_CONTOUR: pWrapContourState = propertie; break;
519 case CTF_WRAP_CONTOUR_MODE: pWrapContourModeState = propertie; break;
520 case CTF_WRAP_PARAGRAPH_ONLY: pWrapParagraphOnlyState = propertie; break;
521 case CTF_ANCHORTYPE: pAnchorTypeState = propertie; break;
523 case CTF_HORIZONTALPOS: pHoriOrientState = propertie; bNeedsAnchor = sal_True; break;
524 case CTF_HORIZONTALPOS_MIRRORED: pHoriOrientMirroredState = propertie; bNeedsAnchor = sal_True; break;
525 case CTF_HORIZONTALREL: pHoriOrientRelState = propertie; bNeedsAnchor = sal_True; break;
526 case CTF_HORIZONTALREL_FRAME: pHoriOrientRelFrameState = propertie; bNeedsAnchor = sal_True; break;
527 case CTF_HORIZONTALMIRROR: pHoriOrientMirrorState = propertie; bNeedsAnchor = sal_True; break;
528 case CTF_VERTICALPOS: pVertOrientState = propertie; bNeedsAnchor = sal_True; break;
529 case CTF_VERTICALPOS_ATCHAR: pVertOrientAtCharState = propertie; bNeedsAnchor = sal_True; break;
530 case CTF_VERTICALREL: pVertOrientRelState = propertie; bNeedsAnchor = sal_True; break;
531 case CTF_VERTICALREL_PAGE: pVertOrientRelPageState = propertie; bNeedsAnchor = sal_True; break;
532 case CTF_VERTICALREL_FRAME: pVertOrientRelFrameState = propertie; bNeedsAnchor = sal_True; break;
533 case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsCharState = propertie; bNeedsAnchor = sal_True; break;
535 // --> OD 2004-08-09 #i28749# - handle new CTFs for shape positioning properties
536 case CTF_SHAPE_HORIZONTALPOS: pShapeHoriOrientState = propertie; bNeedsAnchor = sal_True; break;
537 case CTF_SHAPE_HORIZONTALPOS_MIRRORED: pShapeHoriOrientMirroredState = propertie; bNeedsAnchor = sal_True; break;
538 case CTF_SHAPE_HORIZONTALREL: pShapeHoriOrientRelState = propertie; bNeedsAnchor = sal_True; break;
539 case CTF_SHAPE_HORIZONTALREL_FRAME: pShapeHoriOrientRelFrameState = propertie; bNeedsAnchor = sal_True; break;
540 case CTF_SHAPE_HORIZONTALMIRROR: pShapeHoriOrientMirrorState = propertie; bNeedsAnchor = sal_True; break;
541 case CTF_SHAPE_VERTICALPOS: pShapeVertOrientState = propertie; bNeedsAnchor = sal_True; break;
542 case CTF_SHAPE_VERTICALPOS_ATCHAR: pShapeVertOrientAtCharState = propertie; bNeedsAnchor = sal_True; break;
543 case CTF_SHAPE_VERTICALREL: pShapeVertOrientRelState = propertie; bNeedsAnchor = sal_True; break;
544 case CTF_SHAPE_VERTICALREL_PAGE: pShapeVertOrientRelPageState = propertie; bNeedsAnchor = sal_True; break;
545 case CTF_SHAPE_VERTICALREL_FRAME: pShapeVertOrientRelFrameState = propertie; bNeedsAnchor = sal_True; break;
546 // <--
548 case CTF_FONTNAME: pFontNameState = propertie; break;
549 case CTF_FONTFAMILYNAME: pFontFamilyNameState = propertie; break;
550 case CTF_FONTSTYLENAME: pFontStyleNameState = propertie; break;
551 case CTF_FONTFAMILY: pFontFamilyState = propertie; break;
552 case CTF_FONTPITCH: pFontPitchState = propertie; break;
553 case CTF_FONTCHARSET: pFontCharsetState = propertie; break;
555 case CTF_FONTNAME_CJK: pFontNameCJKState = propertie; break;
556 case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJKState = propertie; break;
557 case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJKState = propertie; break;
558 case CTF_FONTFAMILY_CJK: pFontFamilyCJKState = propertie; break;
559 case CTF_FONTPITCH_CJK: pFontPitchCJKState = propertie; break;
560 case CTF_FONTCHARSET_CJK: pFontCharsetCJKState = propertie; break;
562 case CTF_FONTNAME_CTL: pFontNameCTLState = propertie; break;
563 case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTLState = propertie; break;
564 case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTLState = propertie; break;
565 case CTF_FONTFAMILY_CTL: pFontFamilyCTLState = propertie; break;
566 case CTF_FONTPITCH_CTL: pFontPitchCTLState = propertie; break;
567 case CTF_FONTCHARSET_CTL: pFontCharsetCTLState = propertie; break;
568 case CTF_UNDERLINE: pUnderlineState = propertie; break;
569 case CTF_UNDERLINE_COLOR: pUnderlineColorState = propertie; break;
570 case CTF_UNDERLINE_HASCOLOR: pUnderlineHasColorState = propertie; break;
571 case CTF_NUMBERINGSTYLENAME: pListStyleName = propertie; break;
572 case CTF_TEXT_CLIP11: pClip11State = propertie; break;
573 case CTF_TEXT_CLIP: pClipState = propertie; break;
577 if( pFontNameState )
578 ContextFontFilter( pFontNameState, pFontFamilyNameState,
579 pFontStyleNameState, pFontFamilyState,
580 pFontPitchState, pFontCharsetState );
581 if( pFontNameCJKState )
582 ContextFontFilter( pFontNameCJKState, pFontFamilyNameCJKState,
583 pFontStyleNameCJKState, pFontFamilyCJKState,
584 pFontPitchCJKState, pFontCharsetCJKState );
585 if( pFontNameCTLState )
586 ContextFontFilter( pFontNameCTLState, pFontFamilyNameCTLState,
587 pFontStyleNameCTLState, pFontFamilyCTLState,
588 pFontPitchCTLState, pFontCharsetCTLState );
590 if( pCharHeightState && (pCharPropHeightState || pCharDiffHeightState ) )
591 ContextFontHeightFilter( pCharHeightState, pCharPropHeightState,
592 pCharDiffHeightState );
593 if( pCharHeightCJKState &&
594 (pCharPropHeightCJKState || pCharDiffHeightCJKState ) )
595 ContextFontHeightFilter( pCharHeightCJKState, pCharPropHeightCJKState,
596 pCharDiffHeightCJKState );
597 if( pCharHeightCTLState &&
598 (pCharPropHeightCTLState || pCharDiffHeightCTLState ) )
599 ContextFontHeightFilter( pCharHeightCTLState, pCharPropHeightCTLState,
600 pCharDiffHeightCTLState );
601 if( pUnderlineColorState || pUnderlineHasColorState )
603 sal_Bool bClear = !pUnderlineState;
604 if( !bClear )
606 sal_Int16 nUnderline = 0;
607 pUnderlineState->maValue >>= nUnderline;
608 bClear = FontUnderline::NONE == nUnderline;
610 if( bClear )
612 if( pUnderlineColorState )
613 pUnderlineColorState->mnIndex = -1;
614 if( pUnderlineHasColorState )
615 pUnderlineHasColorState->mnIndex = -1;
619 if( pParaLeftMarginState && pParaLeftMarginRelState )
621 sal_Int32 nTemp = 0;
622 pParaLeftMarginRelState->maValue >>= nTemp;
623 if( nTemp == 100 )
625 pParaLeftMarginRelState->mnIndex = -1;
626 pParaLeftMarginRelState->maValue.clear();
628 else
630 pParaLeftMarginState->mnIndex = -1;
631 pParaLeftMarginState->maValue.clear();
636 if( pParaRightMarginState && pParaRightMarginRelState )
638 sal_Int32 nTemp = 0;
639 pParaRightMarginRelState->maValue >>= nTemp;
640 if( nTemp == 100 )
642 pParaRightMarginRelState->mnIndex = -1;
643 pParaRightMarginRelState->maValue.clear();
645 else
647 pParaRightMarginState->mnIndex = -1;
648 pParaRightMarginState->maValue.clear();
652 if( pParaFirstLineState && pParaFirstLineRelState )
654 sal_Int32 nTemp = 0;
655 pParaFirstLineRelState->maValue >>= nTemp;
656 if( nTemp == 100 )
658 pParaFirstLineRelState->mnIndex = -1;
659 pParaFirstLineRelState->maValue.clear();
661 else
663 pParaFirstLineState->mnIndex = -1;
664 pParaFirstLineState->maValue.clear();
668 if( pParaTopMarginState && pParaTopMarginRelState )
670 sal_Int32 nTemp = 0;
671 pParaTopMarginRelState->maValue >>= nTemp;
672 if( nTemp == 100 )
674 pParaTopMarginRelState->mnIndex = -1;
675 pParaTopMarginRelState->maValue.clear();
677 else
679 pParaTopMarginState->mnIndex = -1;
680 pParaTopMarginState->maValue.clear();
685 if( pParaBottomMarginState && pParaBottomMarginRelState )
687 sal_Int32 nTemp = 0;
688 pParaBottomMarginRelState->maValue >>= nTemp;
689 if( nTemp == 100 )
691 pParaBottomMarginRelState->mnIndex = -1;
692 pParaBottomMarginRelState->maValue.clear();
694 else
696 pParaBottomMarginState->mnIndex = -1;
697 pParaBottomMarginState->maValue.clear();
702 if( pAllBorderWidthState )
704 if( pLeftBorderWidthState && pRightBorderWidthState && pTopBorderWidthState && pBottomBorderWidthState )
706 table::BorderLine aLeft, aRight, aTop, aBottom;
708 pLeftBorderWidthState->maValue >>= aLeft;
709 pRightBorderWidthState->maValue >>= aRight;
710 pTopBorderWidthState->maValue >>= aTop;
711 pBottomBorderWidthState->maValue >>= aBottom;
712 if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth &&
713 aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance &&
714 aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth &&
715 aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance &&
716 aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth &&
717 aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance )
719 pLeftBorderWidthState->mnIndex = -1;
720 pLeftBorderWidthState->maValue.clear();
721 pRightBorderWidthState->mnIndex = -1;
722 pRightBorderWidthState->maValue.clear();
723 pTopBorderWidthState->mnIndex = -1;
724 pTopBorderWidthState->maValue.clear();
725 pBottomBorderWidthState->mnIndex = -1;
726 pBottomBorderWidthState->maValue.clear();
728 else
730 pAllBorderWidthState->mnIndex = -1;
731 pAllBorderWidthState->maValue.clear();
734 else
736 pAllBorderWidthState->mnIndex = -1;
737 pAllBorderWidthState->maValue.clear();
741 if( pAllBorderDistanceState )
743 if( pLeftBorderDistanceState && pRightBorderDistanceState && pTopBorderDistanceState && pBottomBorderDistanceState )
745 sal_Int32 aLeft = 0, aRight = 0, aTop = 0, aBottom = 0;
747 pLeftBorderDistanceState->maValue >>= aLeft;
748 pRightBorderDistanceState->maValue >>= aRight;
749 pTopBorderDistanceState->maValue >>= aTop;
750 pBottomBorderDistanceState->maValue >>= aBottom;
751 if( aLeft == aRight && aLeft == aTop && aLeft == aBottom )
753 pLeftBorderDistanceState->mnIndex = -1;
754 pLeftBorderDistanceState->maValue.clear();
755 pRightBorderDistanceState->mnIndex = -1;
756 pRightBorderDistanceState->maValue.clear();
757 pTopBorderDistanceState->mnIndex = -1;
758 pTopBorderDistanceState->maValue.clear();
759 pBottomBorderDistanceState->mnIndex = -1;
760 pBottomBorderDistanceState->maValue.clear();
762 else
764 pAllBorderDistanceState->mnIndex = -1;
765 pAllBorderDistanceState->maValue.clear();
768 else
770 pAllBorderDistanceState->mnIndex = -1;
771 pAllBorderDistanceState->maValue.clear();
775 if( pAllBorderState )
777 if( pLeftBorderState && pRightBorderState && pTopBorderState && pBottomBorderState )
779 table::BorderLine aLeft, aRight, aTop, aBottom;
781 pLeftBorderState->maValue >>= aLeft;
782 pRightBorderState->maValue >>= aRight;
783 pTopBorderState->maValue >>= aTop;
784 pBottomBorderState->maValue >>= aBottom;
785 if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth &&
786 aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance &&
787 aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth &&
788 aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance &&
789 aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth &&
790 aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance )
792 pLeftBorderState->mnIndex = -1;
793 pLeftBorderState->maValue.clear();
794 pRightBorderState->mnIndex = -1;
795 pRightBorderState->maValue.clear();
796 pTopBorderState->mnIndex = -1;
797 pTopBorderState->maValue.clear();
798 pBottomBorderState->mnIndex = -1;
799 pBottomBorderState->maValue.clear();
801 else
803 pAllBorderState->mnIndex = -1;
804 pAllBorderState->maValue.clear();
807 else
809 pAllBorderState->mnIndex = -1;
810 pAllBorderState->maValue.clear();
814 sal_Int16 nSizeType = SizeType::FIX;
815 if( pSizeTypeState )
817 pSizeTypeState->maValue >>= nSizeType;
818 pSizeTypeState->mnIndex = -1;
821 if( pHeightMinAbsState )
823 sal_Int16 nRel = sal_Int16();
824 if( (SizeType::FIX == nSizeType) ||
825 ( pHeightMinRelState &&
826 ( !(pHeightMinRelState->maValue >>= nRel) || nRel > 0 ) ) )
828 pHeightMinAbsState->mnIndex = -1;
831 // export SizeType::VARIABLE als min-width="0"
832 if( SizeType::VARIABLE == nSizeType )
833 pHeightMinAbsState->maValue <<= static_cast<sal_Int32>( 0 );
835 if( pHeightMinRelState && SizeType::MIN != nSizeType)
836 pHeightMinRelState->mnIndex = -1;
837 if( pHeightAbsState && pHeightMinAbsState &&
838 -1 != pHeightMinAbsState->mnIndex )
839 pHeightAbsState->mnIndex = -1;
840 if( pHeightRelState && SizeType::FIX != nSizeType)
841 pHeightRelState->mnIndex = -1;
843 // frame width
844 nSizeType = SizeType::FIX;
845 if( pWidthTypeState )
847 pWidthTypeState->maValue >>= nSizeType;
848 pWidthTypeState->mnIndex = -1;
850 if( pWidthMinAbsState )
852 sal_Int16 nRel = sal_Int16();
853 if( (SizeType::FIX == nSizeType) ||
854 ( pWidthMinRelState &&
855 ( !(pWidthMinRelState->maValue >>= nRel) || nRel > 0 ) ) )
857 pWidthMinAbsState->mnIndex = -1;
860 // export SizeType::VARIABLE als min-width="0"
861 if( SizeType::VARIABLE == nSizeType )
862 pWidthMinAbsState->maValue <<= static_cast<sal_Int32>( 0 );
864 if( pWidthMinRelState && SizeType::MIN != nSizeType)
865 pWidthMinRelState->mnIndex = -1;
866 if( pWidthAbsState && pWidthMinAbsState &&
867 -1 != pWidthMinAbsState->mnIndex )
868 pWidthAbsState->mnIndex = -1;
869 if( pWidthRelState && SizeType::FIX != nSizeType)
870 pWidthRelState->mnIndex = -1;
872 if( pWrapState )
874 WrapTextMode eVal;
875 pWrapState->maValue >>= eVal;
876 switch( eVal )
878 case WrapTextMode_NONE:
879 // no wrapping: disable para-only and contour
880 if( pWrapParagraphOnlyState )
881 pWrapParagraphOnlyState->mnIndex = -1;
882 // no break
883 case WrapTextMode_THROUGHT:
884 // wrap through: disable only contour
885 if( pWrapContourState )
886 pWrapContourState->mnIndex = -1;
887 break;
888 default:
889 break;
891 if( pWrapContourModeState &&
892 (!pWrapContourState ||
893 !*(sal_Bool *)pWrapContourState ->maValue.getValue() ) )
894 pWrapContourModeState->mnIndex = -1;
897 TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH;
898 if( pAnchorTypeState )
899 pAnchorTypeState->maValue >>= eAnchor;
900 else if( bNeedsAnchor )
902 Any aAny = rPropSet->getPropertyValue(
903 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AnchorType") ) );
904 aAny >>= eAnchor;
907 // states for frame positioning attributes
909 if( pHoriOrientState && pHoriOrientMirroredState )
911 if( pHoriOrientMirrorState &&
912 *(sal_Bool *)pHoriOrientMirrorState->maValue.getValue() )
913 pHoriOrientState->mnIndex = -1;
914 else
915 pHoriOrientMirroredState->mnIndex = -1;
917 if( pHoriOrientMirrorState )
918 pHoriOrientMirrorState->mnIndex = -1;
920 if( pHoriOrientRelState && TextContentAnchorType_AT_FRAME == eAnchor )
921 pHoriOrientRelState->mnIndex = -1;
922 if( pHoriOrientRelFrameState && TextContentAnchorType_AT_FRAME != eAnchor )
923 pHoriOrientRelFrameState->mnIndex = -1;;
925 if( pVertOrientState && TextContentAnchorType_AT_CHARACTER == eAnchor )
926 pVertOrientState->mnIndex = -1;
927 if( pVertOrientAtCharState && TextContentAnchorType_AT_CHARACTER != eAnchor )
928 pVertOrientAtCharState->mnIndex = -1;
929 if( pVertOrientRelState && TextContentAnchorType_AT_PARAGRAPH != eAnchor &&
930 TextContentAnchorType_AT_CHARACTER != eAnchor )
931 pVertOrientRelState->mnIndex = -1;
932 if( pVertOrientRelPageState && TextContentAnchorType_AT_PAGE != eAnchor )
933 pVertOrientRelPageState->mnIndex = -1;
934 if( pVertOrientRelFrameState && TextContentAnchorType_AT_FRAME != eAnchor )
935 pVertOrientRelFrameState->mnIndex = -1;
936 if( pVertOrientRelAsCharState && TextContentAnchorType_AS_CHARACTER != eAnchor )
937 pVertOrientRelAsCharState->mnIndex = -1;
940 // --> OD 2004-08-09 #i28749# - states for shape positioning properties
941 if ( eAnchor != TextContentAnchorType_AS_CHARACTER &&
942 ( GetExport().getExportFlags() & EXPORT_OASIS ) == 0 )
944 // no export of shape positioning properties,
945 // if shape isn't anchored as-character and
946 // destination file format is OpenOffice.org file format
947 if ( pShapeHoriOrientState )
948 pShapeHoriOrientState->mnIndex = -1;
949 if ( pShapeHoriOrientMirroredState )
950 pShapeHoriOrientMirroredState->mnIndex = -1;
951 if ( pShapeHoriOrientRelState )
952 pShapeHoriOrientRelState->mnIndex = -1;
953 if ( pShapeHoriOrientRelFrameState )
954 pShapeHoriOrientRelFrameState->mnIndex = -1;
955 if ( pShapeHoriOrientMirrorState )
956 pShapeHoriOrientMirrorState->mnIndex = -1;
957 if ( pShapeVertOrientState )
958 pShapeVertOrientState->mnIndex = -1;
959 if ( pShapeVertOrientAtCharState )
960 pShapeVertOrientAtCharState->mnIndex = -1;
961 if ( pShapeVertOrientRelState )
962 pShapeVertOrientRelState->mnIndex = -1;
963 if ( pShapeVertOrientRelPageState )
964 pShapeVertOrientRelPageState->mnIndex = -1;
965 if ( pShapeVertOrientRelFrameState )
966 pShapeVertOrientRelFrameState->mnIndex = -1;
968 else
970 // handling of shape positioning property states as for frames - see above
971 if( pShapeHoriOrientState && pShapeHoriOrientMirroredState )
973 if( pShapeHoriOrientMirrorState &&
974 *(sal_Bool *)pShapeHoriOrientMirrorState->maValue.getValue() )
975 pShapeHoriOrientState->mnIndex = -1;
976 else
977 pShapeHoriOrientMirroredState->mnIndex = -1;
979 if( pShapeHoriOrientMirrorState )
980 pShapeHoriOrientMirrorState->mnIndex = -1;
982 if( pShapeHoriOrientRelState && TextContentAnchorType_AT_FRAME == eAnchor )
983 pShapeHoriOrientRelState->mnIndex = -1;
984 if( pShapeHoriOrientRelFrameState && TextContentAnchorType_AT_FRAME != eAnchor )
985 pShapeHoriOrientRelFrameState->mnIndex = -1;;
987 if( pShapeVertOrientState && TextContentAnchorType_AT_CHARACTER == eAnchor )
988 pShapeVertOrientState->mnIndex = -1;
989 if( pShapeVertOrientAtCharState && TextContentAnchorType_AT_CHARACTER != eAnchor )
990 pShapeVertOrientAtCharState->mnIndex = -1;
991 if( pShapeVertOrientRelState && TextContentAnchorType_AT_PARAGRAPH != eAnchor &&
992 TextContentAnchorType_AT_CHARACTER != eAnchor )
993 pShapeVertOrientRelState->mnIndex = -1;
994 if( pShapeVertOrientRelPageState && TextContentAnchorType_AT_PAGE != eAnchor )
995 pShapeVertOrientRelPageState->mnIndex = -1;
996 if( pShapeVertOrientRelFrameState && TextContentAnchorType_AT_FRAME != eAnchor )
997 pShapeVertOrientRelFrameState->mnIndex = -1;
999 // <--
1001 // list style name: remove list style if it is the default outline style
1002 if( pListStyleName != NULL )
1004 OUString sListStyleName;
1005 pListStyleName->maValue >>= sListStyleName;
1006 if( lcl_IsOutlineStyle( GetExport(), sListStyleName ) )
1007 pListStyleName->mnIndex = -1;
1010 if( pClipState != NULL && pClip11State != NULL )
1011 pClip11State->mnIndex = -1;
1013 SvXMLExportPropertyMapper::ContextFilter(rProperties,rPropSet);
1017 bool lcl_IsOutlineStyle(const SvXMLExport &rExport, const OUString & rName)
1019 Reference< XChapterNumberingSupplier >
1020 xCNSupplier(rExport.GetModel(), UNO_QUERY);
1022 OUString sOutlineName;
1023 OUString sName(RTL_CONSTASCII_USTRINGPARAM("Name"));
1025 if (xCNSupplier.is())
1027 Reference<XPropertySet> xNumRule(
1028 xCNSupplier->getChapterNumberingRules(), UNO_QUERY );
1029 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
1030 if (xNumRule.is())
1032 xNumRule->getPropertyValue(sName) >>= sOutlineName;
1036 return rName == sOutlineName;