merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / transform / StyleOOoTContext.cxx
blob544c05b56d19d7364009bf94379f0811655cc41e
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: StyleOOoTContext.cxx,v $
10 * $Revision: 1.20 $
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 <com/sun/star/xml/sax/SAXParseException.hpp>
34 #include <com/sun/star/xml/sax/SAXException.hpp>
35 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
36 #include <com/sun/star/xml/sax/XAttributeList.hpp>
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include "xmlnmspe.hxx"
40 #include "PropType.hxx"
41 #include "DeepTContext.hxx"
42 #include "RenameElemTContext.hxx"
43 #include "ProcAttrTContext.hxx"
44 #include "ActionMapTypesOOo.hxx"
45 #include "MutableAttrList.hxx"
46 #include "TransformerActions.hxx"
47 #include "PropertyActionsOOo.hxx"
48 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
49 #include "TransformerBase.hxx"
50 #endif
52 #ifndef _XMLOFF_STYLEOASISTCONTEXT_HXX
53 #include "StyleOOoTContext.hxx"
54 #endif
55 #include <xmloff/xmluconv.hxx>
56 #include <rtl/ustrbuf.hxx>
57 #include <rtl/math.hxx>
59 using ::rtl::OUString;
60 using namespace ::xmloff::token;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::xml::sax;
64 const sal_uInt16 MAX_PROP_TYPES = 4;
65 #define ENTRY4(a,b,c,d) \
66 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
67 XML_PROP_TYPE_##c, XML_PROP_TYPE_##d }
68 #define ENTRY3(a,b,c) \
69 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
70 XML_PROP_TYPE_##c, XML_PROP_TYPE_END }
71 #define ENTRY2(a,b) \
72 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
73 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
74 #define ENTRY1(a) \
75 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##END, \
76 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
78 static XMLPropType aPropTypes[XML_FAMILY_TYPE_END][MAX_PROP_TYPES] =
80 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_GRAPHIC,
81 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PRESENTATION,
82 ENTRY1( DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE,
83 ENTRY1( END ), // XML_FAMILY_TYPE_MASTER_PAGE
84 ENTRY1( PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT,
85 ENTRY1( HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER
86 ENTRY1( TEXT ), // XML_FAMILY_TYPE_TEXT,
87 ENTRY2( PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PARAGRAPH,
88 ENTRY1( RUBY ), //XML_FAMILY_TYPE_RUBY,
89 ENTRY1( SECTION ), // XML_FAMILY_TYPE_SECTION,
90 ENTRY1( TABLE ), // XML_FAMILY_TYPE_TABLE,
91 ENTRY1( TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN,
92 ENTRY1( TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW,
93 ENTRY3( TABLE_CELL, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_TABLE_CELL,
94 ENTRY1( LIST_LEVEL ), // XML_FAMILY_TYPE_LIST,
95 ENTRY4( CHART, GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_CHART,
96 ENTRY1( TEXT ), // XML_FAMILY_TYPE_DATA,
97 ENTRY1( END ), // XML_FAMILY_TYPE_GRADIENT,
98 ENTRY1( END ), // XML_FAMILY_TYPE_HATCH,
99 ENTRY1( END ), // XML_FAMILY_TYPE_FILL_IMAGE,
100 ENTRY1( END ), // XML_FAMILY_TYPE_STROKE_DASH,
101 ENTRY1( END ), // XML_FAMILY_TYPE_MARKER,
102 ENTRY1( END ) // XML_FAMILY_TYPE_PRESENTATION_PAGE_LAYOUT,
105 static XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] =
107 XML_GRAPHIC_PROPERTIES,
108 XML_DRAWING_PAGE_PROPERTIES,
109 XML_PAGE_LAYOUT_PROPERTIES,
110 XML_HEADER_FOOTER_PROPERTIES,
111 XML_TEXT_PROPERTIES,
112 XML_PARAGRAPH_PROPERTIES,
113 XML_RUBY_PROPERTIES,
114 XML_SECTION_PROPERTIES,
115 XML_TABLE_PROPERTIES,
116 XML_TABLE_COLUMN_PROPERTIES,
117 XML_TABLE_ROW_PROPERTIES,
118 XML_TABLE_CELL_PROPERTIES,
119 XML_LIST_LEVEL_PROPERTIES,
120 XML_CHART_PROPERTIES
123 static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] =
125 PROP_OOO_GRAPHIC_ATTR_ACTIONS,
126 PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE
127 PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS,
128 PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS,
129 PROP_OOO_TEXT_ATTR_ACTIONS,
130 PROP_OOO_PARAGRAPH_ATTR_ACTIONS,
131 MAX_OOO_PROP_ACTIONS, // RUBY
132 PROP_OOO_SECTION_ATTR_ACTIONS,
133 PROP_OOO_TABLE_ATTR_ACTIONS,
134 PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS,
135 PROP_OOO_TABLE_ROW_ATTR_ACTIONS,
136 PROP_OOO_TABLE_CELL_ATTR_ACTIONS,
137 PROP_OOO_LIST_LEVEL_ATTR_ACTIONS,
138 PROP_OOO_CHART_ATTR_ACTIONS
141 static sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] =
143 PROP_OOO_GRAPHIC_ELEM_ACTIONS,
144 MAX_OOO_PROP_ACTIONS,
145 MAX_OOO_PROP_ACTIONS,
146 MAX_OOO_PROP_ACTIONS,
147 PROP_OOO_TEXT_ELEM_ACTIONS,
148 PROP_OOO_PARAGRAPH_ELEM_ACTIONS,
149 MAX_OOO_PROP_ACTIONS,
150 MAX_OOO_PROP_ACTIONS,
151 MAX_OOO_PROP_ACTIONS,
152 MAX_OOO_PROP_ACTIONS,
153 MAX_OOO_PROP_ACTIONS,
154 PROP_OOO_TABLE_CELL_ELEM_ACTIONS,
155 MAX_OOO_PROP_ACTIONS,
156 PROP_OOO_CHART_ELEM_ACTIONS
160 //------------------------------------------------------------------------------
162 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
164 ::com::sun::star::uno::Reference<
165 ::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
167 public:
169 TYPEINFO();
171 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
172 const ::rtl::OUString& rQName );
174 virtual ~XMLTypedPropertiesOOoTContext_Impl();
176 using XMLPersAttrListTContext::AddAttribute;
177 void AddAttribute( const ::rtl::OUString &sName ,
178 const ::rtl::OUString &sValue );
179 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken,
180 const ::rtl::OUString &sValue );
182 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList );
184 virtual void Export();
187 TYPEINIT1( XMLTypedPropertiesOOoTContext_Impl, XMLPersElemContentTContext );
189 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
190 XMLTransformerBase& rImp,
191 const OUString& rQName ) :
192 XMLPersElemContentTContext( rImp, rQName ),
193 m_xAttrList( new XMLMutableAttributeList() )
197 XMLTypedPropertiesOOoTContext_Impl::~XMLTypedPropertiesOOoTContext_Impl()
201 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
202 const ::rtl::OUString &sName ,
203 const ::rtl::OUString &sValue )
205 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
206 ->AddAttribute( sName, sValue );
209 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
210 sal_uInt16 nPrefix, XMLTokenEnum eToken,
211 const ::rtl::OUString &sValue )
213 OUString sName(
214 GetTransformer().GetNamespaceMap().GetQNameByKey(
215 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) );
216 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
217 ->AddAttribute( sName, sValue );
220 void XMLTypedPropertiesOOoTContext_Impl::StartElement(
221 const Reference< XAttributeList >& )
223 // empty, ignore even the attribute list
226 void XMLTypedPropertiesOOoTContext_Impl::Export()
228 if( m_xAttrList->getLength() || HasElementContent() )
230 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList );
231 ExportContent();
232 GetTransformer().GetDocHandler()->endElement( GetQName() );
236 //------------------------------------------------------------------------------
238 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
240 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
241 m_aPropContexts[MAX_PROP_TYPES];
243 typedef XMLPropType XMLPropTypes[MAX_PROP_TYPES];
245 XMLPropTypes m_aPropTypes;
247 sal_Bool m_bPersistent;
249 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction(
250 TransformerAction_Impl& rAction,
251 sal_uInt16 nPrefix, const OUString& rLocalName,
252 sal_Bool bElem );
254 XMLTypedPropertiesOOoTContext_Impl *GetPropContext(
255 XMLPropType eType );
258 public:
260 TYPEINFO();
262 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
263 const ::rtl::OUString& rQName,
264 XMLPropTypes& rTypes,
265 sal_Bool bPersistent );
267 virtual ~XMLPropertiesOOoTContext_Impl();
269 XMLTransformerContext *CreateChildContext(
270 sal_uInt16 nPrefix,
271 const OUString& rLocalName,
272 const OUString& rQName,
273 const Reference< XAttributeList >& rAttrList );
275 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList );
277 virtual void EndElement();
279 virtual void Characters( const ::rtl::OUString& rChars );
281 virtual void Export();
283 virtual sal_Bool IsPersistent() const;
286 TYPEINIT1( XMLPropertiesOOoTContext_Impl, XMLTransformerContext );
288 XMLTypedPropertiesOOoTContext_Impl
289 *XMLPropertiesOOoTContext_Impl::GetPropContext(
290 XMLPropType eType )
292 sal_uInt16 nIndex = MAX_PROP_TYPES;
293 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ )
295 if( m_aPropTypes[i] == eType )
297 nIndex = i;
298 break;
301 if( MAX_PROP_TYPES == nIndex )
302 return 0;
304 if( !m_aPropContexts[nIndex].is() )
306 m_aPropContexts[nIndex] =
307 new XMLTypedPropertiesOOoTContext_Impl(
308 GetTransformer(),
309 GetTransformer().GetNamespaceMap().GetQNameByKey(
310 XML_NAMESPACE_STYLE,
311 ::xmloff::token::GetXMLToken(
312 aPropTokens[m_aPropTypes[nIndex]] ) ));
315 return m_aPropContexts[nIndex].get();
319 XMLTypedPropertiesOOoTContext_Impl
320 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction(
321 TransformerAction_Impl& rAction,
322 sal_uInt16 nPrefix, const OUString& rLocalName,
323 sal_Bool bElem )
325 rAction.m_nActionType = XML_ATACTION_COPY;
326 sal_uInt16 nIndex = 0;
328 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
329 sal_uInt16 i=0;
330 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i])
332 sal_uInt16 nActionMap =
333 (bElem ? aElemActionMaps : aAttrActionMaps)[m_aPropTypes[i]];
334 if( nActionMap < MAX_OOO_PROP_ACTIONS )
336 XMLTransformerActions *pActions =
337 GetTransformer().GetUserDefinedActions( nActionMap );
338 OSL_ENSURE( pActions, "go no actions" );
339 if( pActions )
341 XMLTransformerActions::const_iterator aIter =
342 pActions->find( aKey );
344 if( !(aIter == pActions->end()) )
346 rAction = (*aIter).second;
347 nIndex = i;
348 break;
352 ++i;
355 #ifndef PRODUCT
356 if( !( XML_NAMESPACE_NONE == nPrefix ||
357 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
358 XML_PROP_TYPE_END==m_aPropTypes[1] ||
359 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) ) )
361 ::rtl::OString aTmp("Didnt't find property: ");
362 const ::rtl::OUString& rPrefix =
363 GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix );
364 aTmp += ::rtl::OString( rPrefix.getStr(), rPrefix.getLength(),
365 RTL_TEXTENCODING_ASCII_US );
366 aTmp += ::rtl::OString::valueOf( ':' );
367 aTmp += ::rtl::OString( rLocalName.getStr(), rLocalName.getLength(),
368 RTL_TEXTENCODING_ASCII_US );
369 aTmp += ::rtl::OString(", assuming <style:");
370 const ::rtl::OUString& rName =
371 ::xmloff::token::GetXMLToken( aPropTokens[m_aPropTypes[0]] );
372 aTmp += ::rtl::OString( rName.getStr(), rName.getLength(),
373 RTL_TEXTENCODING_ASCII_US );
374 aTmp += ::rtl::OString::valueOf( '>' );
376 OSL_ENSURE( !this, aTmp );
378 #endif
380 if( !m_aPropContexts[nIndex].is() )
382 m_aPropContexts[nIndex] =
383 new XMLTypedPropertiesOOoTContext_Impl(
384 GetTransformer(),
385 GetTransformer().GetNamespaceMap().GetQNameByKey(
386 XML_NAMESPACE_STYLE,
387 ::xmloff::token::GetXMLToken(
388 aPropTokens[m_aPropTypes[nIndex]] ) ));
391 return m_aPropContexts[nIndex].get();
394 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl(
395 XMLTransformerBase& rImp,
396 const OUString& rQName,
397 XMLPropTypes& rTypes,
398 sal_Bool bPersistent ) :
399 XMLTransformerContext( rImp, rQName ),
400 m_bPersistent( bPersistent )
402 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; ++i )
404 // remember the types that belong to the attribute and element lists
405 m_aPropTypes[i] = rTypes[i];
409 XMLPropertiesOOoTContext_Impl::~XMLPropertiesOOoTContext_Impl()
413 XMLTransformerContext *XMLPropertiesOOoTContext_Impl::CreateChildContext(
414 sal_uInt16 nPrefix,
415 const OUString& rLocalName,
416 const OUString& rQName,
417 const Reference< XAttributeList >& rAttrList )
419 TransformerAction_Impl aAction;
420 return GetPropContextAndAction( aAction, nPrefix, rLocalName, sal_True )
421 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList );
425 void XMLPropertiesOOoTContext_Impl::StartElement(
426 const Reference< XAttributeList >& rAttrList )
428 Reference< XAttributeList > xAttrList( rAttrList );
430 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = 0;
431 double fIntervalMajor = 0.0;
432 double fIntervalMinor = 0.0;
433 sal_Bool bMoveProtect = sal_False;
434 sal_Bool bSizeProtect = sal_False;
435 OUString aProtectAttrValue;
436 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = 0;
438 // --> OD 2005-05-13 #i49139# - attribute <style:mirror> has to be priority
439 // over attribute <style:draw>. The filter from OpenDocument file format
440 // to OpenOffice.org file format produces styles with both attributes.
441 sal_Bool bExistStyleMirror( sal_False );
442 OUString aStyleMirrorAttrValue;
443 sal_Bool bExistDrawMirror( sal_False );
444 OUString aDrawMirrorAttrValue;
445 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( 0L );
446 // <--
448 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
449 for( sal_Int16 i=0; i < nAttrCount; i++ )
451 const OUString sAttrName = xAttrList->getNameByIndex( i );
452 const OUString sAttrValue = xAttrList->getValueByIndex( i );
453 OUString aLocalName;
454 sal_uInt16 nPrefix =
455 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
456 &aLocalName );
457 TransformerAction_Impl aAction;
458 XMLTypedPropertiesOOoTContext_Impl *pContext =
459 GetPropContextAndAction( aAction, nPrefix, aLocalName, sal_False );
460 switch( aAction.m_nActionType )
462 case XML_ATACTION_REMOVE:
463 break;
464 case XML_ATACTION_COPY:
465 pContext->AddAttribute( sAttrName, sAttrValue );
466 break;
467 case XML_ATACTION_COPY_DUPLICATE:
469 pContext->AddAttribute( sAttrName, sAttrValue );
470 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
471 GetPropContext( (XMLPropType)aAction.m_nParam1 );
472 if( pContext2 )
473 pContext2->AddAttribute( sAttrName, sAttrValue );
475 break;
476 case XML_ATACTION_RENAME:
478 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
479 aAction.GetQNameTokenFromParam1(),
480 sAttrValue );
482 break;
483 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
485 OUString aAttrValue( sAttrValue );
486 GetTransformer().EncodeStyleName(aAttrValue);
487 pContext->AddAttribute( sAttrName, aAttrValue );
489 break;
490 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
492 OUString aAttrValue( sAttrValue );
493 GetTransformer().EncodeStyleName(aAttrValue);
494 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
495 aAction.GetQNameTokenFromParam1(),
496 aAttrValue );
498 break;
499 case XML_ATACTION_NEG_PERCENT:
501 OUString aAttrValue( sAttrValue );
502 GetTransformer().NegPercent(aAttrValue);
503 pContext->AddAttribute( sAttrName, aAttrValue );
505 break;
506 case XML_ATACTION_RENAME_NEG_PERCENT:
508 OUString aAttrValue( sAttrValue );
509 GetTransformer().NegPercent(aAttrValue);
510 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
511 aAction.GetQNameTokenFromParam1(),
512 aAttrValue );
514 break;
515 case XML_ATACTION_INCH2IN:
517 OUString aAttrValue( sAttrValue );
518 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
519 pContext->AddAttribute( sAttrName, aAttrValue );
521 break;
522 case XML_ATACTION_INCH2IN_DUPLICATE:
524 OUString aAttrValue( sAttrValue );
525 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
526 pContext->AddAttribute( sAttrName, aAttrValue );
527 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
528 GetPropContext( (XMLPropType)aAction.m_nParam1 );
529 if( pContext2 )
530 pContext2->AddAttribute( sAttrName, aAttrValue );
532 break;
533 case XML_ATACTION_INCHS2INS:
535 OUString aAttrValue( sAttrValue );
536 XMLTransformerBase::ReplaceInchWithIn( aAttrValue );
537 pContext->AddAttribute( sAttrName, aAttrValue );
539 break;
540 case XML_PTACTION_LINE_MODE:
542 OUString aAttrValue( GetXMLToken(
543 IsXMLToken( sAttrValue, XML_TRUE )
544 ? XML_CONTINUOUS
545 : XML_SKIP_WHITE_SPACE) );
546 OUString aAttrQName(
547 GetTransformer().GetNamespaceMap().GetQNameByKey(
548 XML_NAMESPACE_STYLE,
549 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) );
550 pContext->AddAttribute( aAttrQName, aAttrValue );
552 aAttrQName =
553 GetTransformer().GetNamespaceMap().GetQNameByKey(
554 XML_NAMESPACE_STYLE,
555 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) );
556 pContext->AddAttribute( aAttrQName, aAttrValue );
558 break;
559 case XML_PTACTION_KEEP_WITH_NEXT:
561 OUString aAttrValue( GetXMLToken(
562 IsXMLToken( sAttrValue, XML_TRUE )
563 ? XML_ALWAYS
564 : XML_AUTO) );
565 pContext->AddAttribute( sAttrName, aAttrValue );
567 break;
568 case XML_PTACTION_UNDERLINE:
570 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
571 sal_Bool bBold = sal_False, bDouble = sal_False;
572 switch( eToken )
574 case XML_SINGLE:
575 eToken = XML_SOLID;
576 break;
577 case XML_DOUBLE:
578 eToken = XML_SOLID;
579 bDouble = sal_True;
580 break;
581 case XML_BOLD:
582 eToken = XML_SOLID;
583 bBold = sal_True;
584 break;
585 case XML_BOLD_DOTTED:
586 eToken = XML_DOTTED;
587 bBold = sal_True;
588 break;
589 case XML_BOLD_DASH:
590 eToken = XML_DASH;
591 bBold = sal_True;
592 break;
593 case XML_BOLD_LONG_DASH:
594 eToken = XML_LONG_DASH;
595 bBold = sal_True;
596 break;
597 case XML_BOLD_DOT_DASH:
598 eToken = XML_DOT_DASH;
599 bBold = sal_True;
600 break;
601 case XML_BOLD_DOT_DOT_DASH:
602 eToken = XML_DOT_DOT_DASH;
603 bBold = sal_True;
604 break;
605 case XML_BOLD_WAVE:
606 eToken = XML_WAVE;
607 bBold = sal_True;
608 break;
609 case XML_DOUBLE_WAVE:
610 eToken = XML_WAVE;
611 bDouble = sal_True;
612 break;
613 case XML_NONE:
614 eToken = XML_NONE;
615 bDouble = sal_False;
616 break;
617 default:
618 OSL_ENSURE( false, "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" );
619 break;
621 pContext->AddAttribute(
622 GetTransformer().GetNamespaceMap().GetQNameByKey(
623 XML_NAMESPACE_STYLE,
624 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ),
625 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
626 : sAttrValue );
627 if( bDouble )
628 pContext->AddAttribute(
629 GetTransformer().GetNamespaceMap().GetQNameByKey(
630 XML_NAMESPACE_STYLE,
631 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ),
632 GetXMLToken( XML_DOUBLE ) );
633 if( bBold )
634 pContext->AddAttribute(
635 GetTransformer().GetNamespaceMap().GetQNameByKey(
636 XML_NAMESPACE_STYLE,
637 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ),
638 GetXMLToken( XML_BOLD ) );
640 break;
641 case XML_PTACTION_LINETHROUGH:
643 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
644 sal_Bool bBold = sal_False, bDouble = sal_False;
645 sal_Unicode c = 0;
646 switch( eToken )
648 case XML_SINGLE_LINE:
649 eToken = XML_SOLID;
650 break;
651 case XML_DOUBLE_LINE:
652 eToken = XML_SOLID;
653 bDouble = sal_True;
654 break;
655 case XML_THICK_LINE:
656 eToken = XML_SOLID;
657 bBold = sal_True;
658 break;
659 case XML_SLASH:
660 eToken = XML_SOLID;
661 c = '/';
662 break;
663 case XML_uX:
664 eToken = XML_SOLID;
665 c = 'X';
666 break;
667 default:
668 break;
670 pContext->AddAttribute(
671 GetTransformer().GetNamespaceMap().GetQNameByKey(
672 XML_NAMESPACE_STYLE,
673 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ),
674 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
675 : sAttrValue );
676 if( bDouble )
677 pContext->AddAttribute(
678 GetTransformer().GetNamespaceMap().GetQNameByKey(
679 XML_NAMESPACE_STYLE,
680 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ),
681 GetXMLToken( XML_DOUBLE ) );
682 if( bBold )
683 pContext->AddAttribute(
684 GetTransformer().GetNamespaceMap().GetQNameByKey(
685 XML_NAMESPACE_STYLE,
686 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ),
687 GetXMLToken( XML_BOLD ) );
688 if( c )
689 pContext->AddAttribute(
690 GetTransformer().GetNamespaceMap().GetQNameByKey(
691 XML_NAMESPACE_STYLE,
692 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ),
693 OUString::valueOf( c ) );
695 break;
696 case XML_PTACTION_SPLINES:
698 sal_Int32 nSplineType = sAttrValue.toInt32();
699 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
700 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) );
702 switch( nSplineType )
704 // straight lines
705 case 0:
706 pContext->AddAttribute(
707 aNewAttrName, GetXMLToken( XML_NONE ));
708 break;
709 // cubic spline
710 case 1:
711 pContext->AddAttribute(
712 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE ));
713 break;
714 // B-spline
715 case 2:
716 pContext->AddAttribute(
717 aNewAttrName, GetXMLToken( XML_B_SPLINE ));
718 break;
720 default:
721 OSL_ENSURE( false, "invalid spline type" );
722 pContext->AddAttribute(
723 aNewAttrName, GetXMLToken( XML_NONE ));
724 break;
727 break;
728 case XML_PTACTION_INTERVAL_MAJOR:
729 pContext->AddAttribute( sAttrName, sAttrValue );
730 SvXMLUnitConverter::convertDouble( fIntervalMajor, sAttrValue );
731 break;
732 case XML_PTACTION_INTERVAL_MINOR:
733 SvXMLUnitConverter::convertDouble( fIntervalMinor, sAttrValue );
734 pIntervalMinorDivisorContext = pContext;
735 break;
736 case XML_PTACTION_SYMBOL:
738 sal_Int32 nSymbolType = sAttrValue.toInt32();
739 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
740 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) );
742 if( nSymbolType >= 0 )
744 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL ));
745 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
746 switch( nSymbolType )
748 // SYMBOL0
749 case 0:
750 // "square" has an awkward token name
751 eToken = XML_GRADIENTSTYLE_SQUARE;
752 break;
753 // SYMBOL1
754 case 1:
755 eToken = XML_DIAMOND;
756 break;
757 // SYMBOL2
758 case 2:
759 eToken = XML_ARROW_DOWN;
760 break;
761 // SYMBOL3
762 case 3:
763 eToken = XML_ARROW_UP;
764 break;
765 // SYMBOL4
766 case 4:
767 eToken = XML_ARROW_RIGHT;
768 break;
769 // SYMBOL5
770 case 5:
771 eToken = XML_ARROW_LEFT;
772 break;
773 // SYMBOL6
774 case 6:
775 eToken = XML_BOW_TIE;
776 break;
777 // SYMBOL7
778 case 7:
779 eToken = XML_HOURGLASS;
780 break;
781 default:
782 OSL_ENSURE( false, "invalid named symbol" );
783 break;
786 if( eToken != XML_TOKEN_INVALID )
788 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
789 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )),
790 GetXMLToken( eToken ));
793 else
795 switch( nSymbolType )
797 // NONE
798 case -3:
799 pContext->AddAttribute(
800 aNewAttrName, GetXMLToken( XML_NONE ));
801 break;
802 // AUTO
803 case -2:
804 pContext->AddAttribute(
805 aNewAttrName, GetXMLToken( XML_AUTOMATIC ));
806 break;
807 // BITMAPURL
808 case -1:
809 pContext->AddAttribute(
810 aNewAttrName, GetXMLToken( XML_IMAGE ));
811 break;
812 default:
813 OSL_ENSURE( false, "invalid symbol type" );
814 pContext->AddAttribute(
815 aNewAttrName, GetXMLToken( XML_NONE ));
816 break;
820 break;
821 case XML_PTACTION_SYMBOL_IMAGE_NAME:
823 // create an xlink:href element for URI attribute
824 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext(
825 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey(
826 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE )));
828 OUString aAttrValue( sAttrValue );
829 if( GetTransformer().ConvertURIToOASIS( aAttrValue, sal_True ))
831 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue );
832 pContext->AddContent( pSymbolImageContext );
835 break;
837 // #i25616#
838 case XML_PTACTION_TRANSPARENCY :
840 OUString aAttrValue( sAttrValue );
841 GetTransformer().NegPercent(aAttrValue);
842 pContext->AddAttribute( XML_NAMESPACE_DRAW,
843 XML_OPACITY,
844 aAttrValue );
845 pContext->AddAttribute( XML_NAMESPACE_DRAW,
846 XML_IMAGE_OPACITY,
847 aAttrValue );
849 break;
851 case XML_PTACTION_BREAK_INSIDE:
853 pContext->AddAttribute(
854 XML_NAMESPACE_FO, XML_KEEP_TOGETHER,
855 GetXMLToken(
856 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID )
857 ? XML_ALWAYS
858 : XML_AUTO ) );
860 break;
861 case XML_ATACTION_CAPTION_ESCAPE_OOO:
863 OUString aAttrValue( sAttrValue );
864 if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 )
866 sal_Int32 nValue = 0;
867 SvXMLUnitConverter::convertPercent( nValue, sAttrValue );
868 if( nValue )
870 nValue /= 100;
871 rtl::OUStringBuffer aOut;
872 SvXMLUnitConverter::convertPercent( aOut, nValue );
873 aAttrValue = aOut.makeStringAndClear();
876 else
878 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
881 pContext->AddAttribute( sAttrName, aAttrValue );
883 break;
884 case XML_ATACTION_MOVE_PROTECT:
885 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE );
886 pProtectContext = pContext;
887 break;
888 case XML_ATACTION_SIZE_PROTECT:
889 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE );
890 pProtectContext = pContext;
891 break;
892 case XML_ATACTION_PROTECT:
893 aProtectAttrValue = sAttrValue;
894 pProtectContext = pContext;
895 break;
896 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values
898 // --> OD 2005-05-13 #i49139#
899 aDrawMirrorAttrValue =
900 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE )
901 ? XML_HORIZONTAL : XML_NONE );
902 bExistDrawMirror = sal_True;
903 pMirrorContext = pContext;
904 // <--
906 break;
907 // --> OD 2005-05-12 #i49139#
908 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values
910 SvXMLTokenEnumerator aTokenEnum( sAttrValue );
911 OUString aToken;
912 while( aTokenEnum.getNextToken( aToken ) )
914 if ( aStyleMirrorAttrValue.getLength() > 0 )
916 aStyleMirrorAttrValue += rtl::OUString::createFromAscii( " " );
919 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) )
921 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_EVEN );
923 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) )
925 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_ODD );
927 else
929 aStyleMirrorAttrValue += aToken;
932 bExistStyleMirror = sal_True;
933 pMirrorContext = pContext;
935 break;
936 // <--
937 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage
939 double fValue = sAttrValue.toDouble();
940 sal_Int32 nValue = (sal_Int32)((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) );
942 rtl::OUStringBuffer aOut;
943 SvXMLUnitConverter::convertPercent( aOut, nValue );
944 OUString aAttrValue( aOut.makeStringAndClear() );
945 pContext->AddAttribute( sAttrName, aAttrValue );
947 break;
948 case XML_ATACTION_OPACITY_FIX:
950 sal_Int32 nValue;
951 if( sAttrValue.indexOf( sal_Unicode('%') ) != -1 )
953 SvXMLUnitConverter::convertPercent( nValue, sAttrValue );
955 else
957 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 );
959 nValue = 100 - nValue;
961 rtl::OUStringBuffer aOut;
962 SvXMLUnitConverter::convertPercent( aOut, nValue );
963 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() );
965 break;
966 default:
967 OSL_ENSURE( !this, "unknown action" );
968 break;
972 // --> OD 2005-05-13 #i49139#
973 if ( bExistStyleMirror )
975 pMirrorContext->AddAttribute(
976 GetTransformer().GetNamespaceMap().GetQNameByKey(
977 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
978 aStyleMirrorAttrValue);
980 else if ( bExistDrawMirror )
982 pMirrorContext->AddAttribute(
983 GetTransformer().GetNamespaceMap().GetQNameByKey(
984 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
985 aDrawMirrorAttrValue);
987 // <--
989 if( bMoveProtect || bSizeProtect || aProtectAttrValue.getLength() )
991 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) )
992 aProtectAttrValue = OUString();
994 const OUString& rPosition = GetXMLToken( XML_POSITION );
995 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) )
997 if( aProtectAttrValue.getLength() )
998 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) );
999 aProtectAttrValue += rPosition;
1002 const OUString& rSize = GetXMLToken( XML_SIZE );
1003 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) )
1005 if( aProtectAttrValue.getLength() )
1006 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) );
1007 aProtectAttrValue += rSize;
1010 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue );
1013 if( pIntervalMinorDivisorContext )
1015 if( fIntervalMinor != 0.0 )
1017 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >(
1018 ::rtl::math::round( fIntervalMajor / fIntervalMinor ));
1020 ::rtl::OUStringBuffer aBuf;
1021 SvXMLUnitConverter::convertNumber( aBuf, nIntervalMinorDivisor );
1022 pIntervalMinorDivisorContext->AddAttribute(
1023 GetTransformer().GetNamespaceMap().GetQNameByKey(
1024 XML_NAMESPACE_CHART,
1025 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )),
1026 aBuf.makeStringAndClear());
1031 void XMLPropertiesOOoTContext_Impl::EndElement()
1033 if( !m_bPersistent )
1034 Export();
1037 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& )
1039 // ignore them
1042 void XMLPropertiesOOoTContext_Impl::Export()
1045 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; i++ )
1047 if( m_aPropContexts[i].is() )
1048 m_aPropContexts[i]->Export();
1052 sal_Bool XMLPropertiesOOoTContext_Impl::IsPersistent() const
1054 return m_bPersistent;
1058 //------------------------------------------------------------------------------
1060 TYPEINIT1( XMLStyleOOoTContext, XMLPersElemContentTContext );
1062 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp,
1063 const OUString& rQName,
1064 XMLFamilyType eT,
1065 sal_Bool bPersistent ) :
1066 XMLPersElemContentTContext( rImp, rQName ),
1067 m_eFamily( eT ),
1068 m_bPersistent( bPersistent )
1072 XMLStyleOOoTContext::XMLStyleOOoTContext(
1073 XMLTransformerBase& rImp,
1074 const OUString& rQName,
1075 XMLFamilyType eT,
1076 sal_uInt16 nPrefix,
1077 ::xmloff::token::XMLTokenEnum eToken,
1078 sal_Bool bPersistent ) :
1079 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
1080 m_eFamily( eT ),
1081 m_bPersistent( bPersistent )
1085 XMLStyleOOoTContext::~XMLStyleOOoTContext()
1089 XMLTransformerContext *XMLStyleOOoTContext::CreateChildContext(
1090 sal_uInt16 nPrefix,
1091 const OUString& rLocalName,
1092 const OUString& rQName,
1093 const Reference< XAttributeList >& rAttrList )
1095 XMLTransformerContext *pContext = 0;
1097 if( XML_NAMESPACE_STYLE == nPrefix &&
1098 IsXMLToken( rLocalName, XML_PROPERTIES ) )
1100 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END )
1102 OSL_ENSURE( !this, "unexpected properties element" );
1103 pContext = m_bPersistent
1104 ? XMLPersElemContentTContext::CreateChildContext(
1105 nPrefix, rLocalName, rQName, rAttrList )
1106 : XMLTransformerContext::CreateChildContext(
1107 nPrefix, rLocalName, rQName, rAttrList );
1109 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END )
1111 sal_uInt16 nActionMap =
1112 aAttrActionMaps[aPropTypes[m_eFamily][0]];
1113 if( nActionMap < MAX_OOO_PROP_ACTIONS )
1115 pContext = new XMLPropertiesOOoTContext_Impl(
1116 GetTransformer(), rQName,
1117 aPropTypes[m_eFamily], m_bPersistent );
1119 else
1121 if( m_bPersistent )
1122 pContext = new XMLPersElemContentTContext(
1123 GetTransformer(), rQName,
1124 XML_NAMESPACE_STYLE,
1125 aPropTokens[aPropTypes[m_eFamily][0]] );
1126 else
1127 pContext = new XMLRenameElemTransformerContext(
1128 GetTransformer(), rQName,
1129 XML_NAMESPACE_STYLE,
1130 aPropTokens[aPropTypes[m_eFamily][0]] );
1133 else
1135 pContext = new XMLPropertiesOOoTContext_Impl(
1136 GetTransformer(), rQName,
1137 aPropTypes[m_eFamily], m_bPersistent);
1140 if( m_bPersistent )
1141 AddContent( pContext );
1143 else
1145 pContext = m_bPersistent
1146 ? XMLPersElemContentTContext::CreateChildContext(
1147 nPrefix, rLocalName, rQName, rAttrList )
1148 : XMLTransformerContext::CreateChildContext(
1149 nPrefix, rLocalName, rQName, rAttrList );
1152 return pContext;
1155 void XMLStyleOOoTContext::StartElement(
1156 const Reference< XAttributeList >& rAttrList )
1158 XMLTransformerActions *pActions =
1159 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS );
1160 OSL_ENSURE( pActions, "go no actions" );
1162 Reference< XAttributeList > xAttrList( rAttrList );
1163 XMLMutableAttributeList *pMutableAttrList = 0;
1164 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1165 for( sal_Int16 i=0; i < nAttrCount; i++ )
1167 const OUString sAttrName = xAttrList->getNameByIndex( i );
1168 OUString aLocalName;
1169 sal_uInt16 nPrefix =
1170 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
1171 &aLocalName );
1172 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
1173 XMLTransformerActions::const_iterator aIter =
1174 pActions->find( aKey );
1175 if( !(aIter == pActions->end() ) )
1177 if( !pMutableAttrList )
1179 pMutableAttrList =
1180 new XMLMutableAttributeList( xAttrList );
1181 xAttrList = pMutableAttrList;
1183 const OUString sAttrValue = xAttrList->getValueByIndex( i );
1184 switch( (*aIter).second.m_nActionType )
1186 case XML_ATACTION_STYLE_FAMILY:
1188 sal_Bool bControl = sal_False;
1189 if( XML_FAMILY_TYPE_END == m_eFamily )
1191 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) )
1192 m_eFamily = XML_FAMILY_TYPE_GRAPHIC;
1193 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) )
1194 m_eFamily = XML_FAMILY_TYPE_PRESENTATION;
1195 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) )
1196 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE;
1197 else if( IsXMLToken( sAttrValue, XML_TEXT) )
1198 m_eFamily = XML_FAMILY_TYPE_TEXT;
1199 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) )
1200 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1201 else if( IsXMLToken( sAttrValue, XML_RUBY) )
1202 m_eFamily = XML_FAMILY_TYPE_RUBY;
1203 else if( IsXMLToken( sAttrValue, XML_SECTION) )
1204 m_eFamily = XML_FAMILY_TYPE_SECTION;
1205 else if( IsXMLToken( sAttrValue, XML_TABLE) )
1206 m_eFamily = XML_FAMILY_TYPE_TABLE;
1207 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) )
1208 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN;
1209 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) )
1210 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW;
1211 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) )
1212 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL;
1213 else if( IsXMLToken( sAttrValue, XML_CHART) )
1214 m_eFamily = XML_FAMILY_TYPE_CHART;
1215 else if( IsXMLToken( sAttrValue, XML_CONTROL) )
1217 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1218 bControl = sal_True;
1221 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily )
1223 pMutableAttrList->SetValueByIndex( i,
1224 GetXMLToken( XML_GRAPHIC ) );
1226 else if( bControl )
1228 pMutableAttrList->SetValueByIndex( i,
1229 GetXMLToken( XML_PARAGRAPH ) );
1232 break;
1233 case XML_ATACTION_INCH2IN:
1235 OUString aAttrValue( sAttrValue );
1236 if( XMLTransformerBase::ReplaceSingleInchWithIn(
1237 aAttrValue ) )
1238 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1240 break;
1241 case XML_ATACTION_ENCODE_STYLE_NAME:
1243 OUString aAttrValue( sAttrValue );
1244 if( GetTransformer().EncodeStyleName(aAttrValue) )
1246 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1247 OUString aNewAttrQName(
1248 GetTransformer().GetNamespaceMap().
1249 GetQNameByKey(
1250 nPrefix, ::xmloff::token::GetXMLToken(
1251 XML_DISPLAY_NAME ) ) );
1252 pMutableAttrList->AddAttribute( aNewAttrQName,
1253 sAttrValue );
1256 break;
1257 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
1259 OUString aAttrValue( sAttrValue );
1260 if( GetTransformer().EncodeStyleName(aAttrValue) )
1261 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1263 break;
1264 case XML_ATACTION_NEG_PERCENT:
1266 OUString aAttrValue( sAttrValue );
1267 if( GetTransformer().NegPercent(aAttrValue) )
1268 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1270 break;
1271 case XML_ATACTION_URI_OOO:
1273 OUString aAttrValue( sAttrValue );
1274 if( GetTransformer().ConvertURIToOASIS( aAttrValue,
1275 static_cast< sal_Bool >((*aIter).second.m_nParam1)))
1276 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1278 break;
1279 default:
1280 OSL_ENSURE( !this, "unknown action" );
1281 break;
1285 if( XML_FAMILY_TYPE_END == m_eFamily )
1286 m_eFamily = XML_FAMILY_TYPE_TEXT;
1287 if( m_bPersistent )
1288 XMLPersElemContentTContext::StartElement( xAttrList );
1289 else
1290 GetTransformer().GetDocHandler()->startElement( GetExportQName(),
1291 xAttrList );
1294 void XMLStyleOOoTContext::EndElement()
1296 if( m_bPersistent )
1297 XMLPersElemContentTContext::EndElement();
1298 else
1299 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
1302 void XMLStyleOOoTContext::Characters( const OUString& )
1304 // element content only:
1307 sal_Bool XMLStyleOOoTContext::IsPersistent() const
1309 return m_bPersistent;
1312 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions(
1313 sal_uInt16 nType )
1315 XMLTransformerActionInit *pInit = 0;
1317 switch( nType )
1319 case PROP_OOO_GRAPHIC_ATTR_ACTIONS:
1320 pInit = aGraphicPropertyOOoAttrActionTable;
1321 break;
1322 case PROP_OOO_GRAPHIC_ELEM_ACTIONS:
1323 pInit = aGraphicPropertyOOoElemActionTable;
1324 break;
1325 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS:
1326 pInit = aDrawingPagePropertyOOoAttrActionTable;
1327 break;
1328 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS:
1329 pInit = aPageLayoutPropertyOOoAttrActionTable;
1330 break;
1331 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS:
1332 pInit = aHeaderFooterPropertyOOoAttrActionTable;
1333 break;
1334 case PROP_OOO_TEXT_ATTR_ACTIONS:
1335 pInit = aTextPropertyOOoAttrActionTable;
1336 break;
1337 case PROP_OOO_TEXT_ELEM_ACTIONS:
1338 pInit = aTextPropertyOOoElemActionTable;
1339 break;
1340 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS:
1341 pInit = aParagraphPropertyOOoAttrActionTable;
1342 break;
1343 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS:
1344 pInit = aParagraphPropertyOOoElemActionTable;
1345 break;
1346 case PROP_OOO_SECTION_ATTR_ACTIONS:
1347 pInit = aSectionPropertyOOoAttrActionTable;
1348 break;
1349 case PROP_OOO_TABLE_ATTR_ACTIONS:
1350 pInit = aTablePropertyOOoAttrActionTable;
1351 break;
1352 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS:
1353 pInit = aTableColumnPropertyOOoAttrActionTable;
1354 break;
1355 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS:
1356 pInit = aTableRowPropertyOOoAttrActionTable;
1357 break;
1358 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS:
1359 pInit = aTableCellPropertyOOoAttrActionTable;
1360 break;
1361 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS:
1362 pInit = aTableCellPropertyOOoElemActionTable;
1363 break;
1364 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS:
1365 pInit = aListLevelPropertyOOoAttrActionTable;
1366 break;
1367 case PROP_OOO_CHART_ATTR_ACTIONS:
1368 pInit = aChartPropertyOOoAttrActionTable;
1369 break;
1370 case PROP_OOO_CHART_ELEM_ACTIONS:
1371 pInit = aChartPropertyOOoElemActionTable;
1372 break;
1375 XMLTransformerActions *pActions = 0;
1376 if( pInit )
1377 pActions = new XMLTransformerActions( pInit );
1379 return pActions;