bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / transform / StyleOOoTContext.cxx
blob5432f85e5d61d863d5889ee6fb244ab2674d1329
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/xml/sax/SAXParseException.hpp>
21 #include <com/sun/star/xml/sax/SAXException.hpp>
22 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
25 #include <sax/tools/converter.hxx>
27 #include <xmloff/nmspmap.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include "xmloff/xmlnmspe.hxx"
30 #include "PropType.hxx"
31 #include "DeepTContext.hxx"
32 #include "RenameElemTContext.hxx"
33 #include "ProcAttrTContext.hxx"
34 #include "ActionMapTypesOOo.hxx"
35 #include "MutableAttrList.hxx"
36 #include "TransformerActions.hxx"
37 #include "PropertyActionsOOo.hxx"
38 #include "TransformerBase.hxx"
40 #include "StyleOOoTContext.hxx"
41 #include <xmloff/xmluconv.hxx>
42 #include <rtl/ustrbuf.hxx>
43 #include <rtl/math.hxx>
45 using namespace ::xmloff::token;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::xml::sax;
49 const sal_uInt16 MAX_PROP_TYPES = 4;
50 #define ENTRY4(a,b,c,d) \
51 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
52 XML_PROP_TYPE_##c, XML_PROP_TYPE_##d }
53 #define ENTRY3(a,b,c) \
54 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
55 XML_PROP_TYPE_##c, XML_PROP_TYPE_END }
56 #define ENTRY2(a,b) \
57 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
58 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
59 #define ENTRY1(a) \
60 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##END, \
61 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
63 static XMLPropType aPropTypes[XML_FAMILY_TYPE_END][MAX_PROP_TYPES] =
65 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_GRAPHIC,
66 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PRESENTATION,
67 ENTRY1( DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE,
68 ENTRY1( END ), // XML_FAMILY_TYPE_MASTER_PAGE
69 ENTRY1( PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT,
70 ENTRY1( HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER
71 ENTRY1( TEXT ), // XML_FAMILY_TYPE_TEXT,
72 ENTRY2( PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PARAGRAPH,
73 ENTRY1( RUBY ), //XML_FAMILY_TYPE_RUBY,
74 ENTRY1( SECTION ), // XML_FAMILY_TYPE_SECTION,
75 ENTRY1( TABLE ), // XML_FAMILY_TYPE_TABLE,
76 ENTRY1( TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN,
77 ENTRY1( TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW,
78 ENTRY3( TABLE_CELL, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_TABLE_CELL,
79 ENTRY1( LIST_LEVEL ), // XML_FAMILY_TYPE_LIST,
80 ENTRY4( CHART, GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_CHART,
81 ENTRY1( TEXT ), // XML_FAMILY_TYPE_DATA,
82 ENTRY1( END ), // XML_FAMILY_TYPE_GRADIENT,
83 ENTRY1( END ), // XML_FAMILY_TYPE_HATCH,
84 ENTRY1( END ), // XML_FAMILY_TYPE_FILL_IMAGE,
85 ENTRY1( END ), // XML_FAMILY_TYPE_STROKE_DASH,
86 ENTRY1( END ), // XML_FAMILY_TYPE_MARKER,
87 ENTRY1( END ) // XML_FAMILY_TYPE_PRESENTATION_PAGE_LAYOUT,
90 static XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] =
92 XML_GRAPHIC_PROPERTIES,
93 XML_DRAWING_PAGE_PROPERTIES,
94 XML_PAGE_LAYOUT_PROPERTIES,
95 XML_HEADER_FOOTER_PROPERTIES,
96 XML_TEXT_PROPERTIES,
97 XML_PARAGRAPH_PROPERTIES,
98 XML_RUBY_PROPERTIES,
99 XML_SECTION_PROPERTIES,
100 XML_TABLE_PROPERTIES,
101 XML_TABLE_COLUMN_PROPERTIES,
102 XML_TABLE_ROW_PROPERTIES,
103 XML_TABLE_CELL_PROPERTIES,
104 XML_LIST_LEVEL_PROPERTIES,
105 XML_CHART_PROPERTIES
108 static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] =
110 PROP_OOO_GRAPHIC_ATTR_ACTIONS,
111 PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE
112 PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS,
113 PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS,
114 PROP_OOO_TEXT_ATTR_ACTIONS,
115 PROP_OOO_PARAGRAPH_ATTR_ACTIONS,
116 MAX_OOO_PROP_ACTIONS, // RUBY
117 PROP_OOO_SECTION_ATTR_ACTIONS,
118 PROP_OOO_TABLE_ATTR_ACTIONS,
119 PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS,
120 PROP_OOO_TABLE_ROW_ATTR_ACTIONS,
121 PROP_OOO_TABLE_CELL_ATTR_ACTIONS,
122 PROP_OOO_LIST_LEVEL_ATTR_ACTIONS,
123 PROP_OOO_CHART_ATTR_ACTIONS
126 static sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] =
128 PROP_OOO_GRAPHIC_ELEM_ACTIONS,
129 MAX_OOO_PROP_ACTIONS,
130 MAX_OOO_PROP_ACTIONS,
131 MAX_OOO_PROP_ACTIONS,
132 PROP_OOO_TEXT_ELEM_ACTIONS,
133 PROP_OOO_PARAGRAPH_ELEM_ACTIONS,
134 MAX_OOO_PROP_ACTIONS,
135 MAX_OOO_PROP_ACTIONS,
136 MAX_OOO_PROP_ACTIONS,
137 MAX_OOO_PROP_ACTIONS,
138 MAX_OOO_PROP_ACTIONS,
139 PROP_OOO_TABLE_CELL_ELEM_ACTIONS,
140 MAX_OOO_PROP_ACTIONS,
141 PROP_OOO_CHART_ELEM_ACTIONS
145 //------------------------------------------------------------------------------
147 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
149 ::com::sun::star::uno::Reference<
150 ::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
152 public:
154 TYPEINFO();
156 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
157 const OUString& rQName );
159 virtual ~XMLTypedPropertiesOOoTContext_Impl();
161 using XMLPersAttrListTContext::AddAttribute;
162 void AddAttribute( const OUString &sName ,
163 const OUString &sValue );
164 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken,
165 const OUString &sValue );
167 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList );
169 virtual void Export();
172 TYPEINIT1( XMLTypedPropertiesOOoTContext_Impl, XMLPersElemContentTContext );
174 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
175 XMLTransformerBase& rImp,
176 const OUString& rQName ) :
177 XMLPersElemContentTContext( rImp, rQName ),
178 m_xAttrList( new XMLMutableAttributeList() )
182 XMLTypedPropertiesOOoTContext_Impl::~XMLTypedPropertiesOOoTContext_Impl()
186 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
187 const OUString &sName ,
188 const OUString &sValue )
190 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
191 ->AddAttribute( sName, sValue );
194 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
195 sal_uInt16 nPrefix, XMLTokenEnum eToken,
196 const OUString &sValue )
198 OUString sName(
199 GetTransformer().GetNamespaceMap().GetQNameByKey(
200 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) );
201 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
202 ->AddAttribute( sName, sValue );
205 void XMLTypedPropertiesOOoTContext_Impl::StartElement(
206 const Reference< XAttributeList >& )
208 // empty, ignore even the attribute list
211 void XMLTypedPropertiesOOoTContext_Impl::Export()
213 if( m_xAttrList->getLength() || HasElementContent() )
215 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList );
216 ExportContent();
217 GetTransformer().GetDocHandler()->endElement( GetQName() );
221 //------------------------------------------------------------------------------
223 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
225 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
226 m_aPropContexts[MAX_PROP_TYPES];
228 typedef XMLPropType XMLPropTypes[MAX_PROP_TYPES];
230 XMLPropTypes m_aPropTypes;
232 sal_Bool m_bPersistent;
234 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction(
235 TransformerAction_Impl& rAction,
236 sal_uInt16 nPrefix, const OUString& rLocalName,
237 sal_Bool bElem );
239 XMLTypedPropertiesOOoTContext_Impl *GetPropContext(
240 XMLPropType eType );
243 public:
245 TYPEINFO();
247 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
248 const OUString& rQName,
249 XMLPropTypes& rTypes,
250 sal_Bool bPersistent );
252 virtual ~XMLPropertiesOOoTContext_Impl();
254 XMLTransformerContext *CreateChildContext(
255 sal_uInt16 nPrefix,
256 const OUString& rLocalName,
257 const OUString& rQName,
258 const Reference< XAttributeList >& rAttrList );
260 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList );
262 virtual void EndElement();
264 virtual void Characters( const OUString& rChars );
266 virtual void Export();
268 virtual sal_Bool IsPersistent() const;
271 TYPEINIT1( XMLPropertiesOOoTContext_Impl, XMLTransformerContext );
273 XMLTypedPropertiesOOoTContext_Impl
274 *XMLPropertiesOOoTContext_Impl::GetPropContext(
275 XMLPropType eType )
277 sal_uInt16 nIndex = MAX_PROP_TYPES;
278 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ )
280 if( m_aPropTypes[i] == eType )
282 nIndex = i;
283 break;
286 if( MAX_PROP_TYPES == nIndex )
287 return 0;
289 if( !m_aPropContexts[nIndex].is() )
291 m_aPropContexts[nIndex] =
292 new XMLTypedPropertiesOOoTContext_Impl(
293 GetTransformer(),
294 GetTransformer().GetNamespaceMap().GetQNameByKey(
295 XML_NAMESPACE_STYLE,
296 ::xmloff::token::GetXMLToken(
297 aPropTokens[m_aPropTypes[nIndex]] ) ));
300 return m_aPropContexts[nIndex].get();
304 XMLTypedPropertiesOOoTContext_Impl
305 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction(
306 TransformerAction_Impl& rAction,
307 sal_uInt16 nPrefix, const OUString& rLocalName,
308 sal_Bool bElem )
310 rAction.m_nActionType = XML_ATACTION_COPY;
311 sal_uInt16 nIndex = 0;
313 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
314 sal_uInt16 i=0;
315 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i])
317 sal_uInt16 nActionMap =
318 (bElem ? aElemActionMaps : aAttrActionMaps)[m_aPropTypes[i]];
319 if( nActionMap < MAX_OOO_PROP_ACTIONS )
321 XMLTransformerActions *pActions =
322 GetTransformer().GetUserDefinedActions( nActionMap );
323 OSL_ENSURE( pActions, "go no actions" );
324 if( pActions )
326 XMLTransformerActions::const_iterator aIter =
327 pActions->find( aKey );
329 if( !(aIter == pActions->end()) )
331 rAction = (*aIter).second;
332 nIndex = i;
333 break;
337 ++i;
340 #ifdef DBG_UTIL
341 if( !( XML_NAMESPACE_NONE == nPrefix ||
342 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
343 XML_PROP_TYPE_END==m_aPropTypes[1] ||
344 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) ) )
346 OString aTmp("Didnt't find property: ");
347 const OUString& rPrefix =
348 GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix );
349 aTmp += OString( rPrefix.getStr(), rPrefix.getLength(),
350 RTL_TEXTENCODING_ASCII_US );
351 aTmp += OString::valueOf( ':' );
352 aTmp += OString( rLocalName.getStr(), rLocalName.getLength(),
353 RTL_TEXTENCODING_ASCII_US );
354 aTmp += OString(", assuming <style:");
355 const OUString& rName =
356 ::xmloff::token::GetXMLToken( aPropTokens[m_aPropTypes[0]] );
357 aTmp += OString( rName.getStr(), rName.getLength(),
358 RTL_TEXTENCODING_ASCII_US );
359 aTmp += OString::valueOf( '>' );
361 OSL_FAIL(aTmp.getStr());
363 #endif
365 if( !m_aPropContexts[nIndex].is() )
367 m_aPropContexts[nIndex] =
368 new XMLTypedPropertiesOOoTContext_Impl(
369 GetTransformer(),
370 GetTransformer().GetNamespaceMap().GetQNameByKey(
371 XML_NAMESPACE_STYLE,
372 ::xmloff::token::GetXMLToken(
373 aPropTokens[m_aPropTypes[nIndex]] ) ));
376 return m_aPropContexts[nIndex].get();
379 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl(
380 XMLTransformerBase& rImp,
381 const OUString& rQName,
382 XMLPropTypes& rTypes,
383 sal_Bool bPersistent ) :
384 XMLTransformerContext( rImp, rQName ),
385 m_bPersistent( bPersistent )
387 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; ++i )
389 // remember the types that belong to the attribute and element lists
390 m_aPropTypes[i] = rTypes[i];
394 XMLPropertiesOOoTContext_Impl::~XMLPropertiesOOoTContext_Impl()
398 XMLTransformerContext *XMLPropertiesOOoTContext_Impl::CreateChildContext(
399 sal_uInt16 nPrefix,
400 const OUString& rLocalName,
401 const OUString& rQName,
402 const Reference< XAttributeList >& rAttrList )
404 TransformerAction_Impl aAction;
405 return GetPropContextAndAction( aAction, nPrefix, rLocalName, sal_True )
406 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList );
410 void XMLPropertiesOOoTContext_Impl::StartElement(
411 const Reference< XAttributeList >& rAttrList )
413 Reference< XAttributeList > xAttrList( rAttrList );
415 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = 0;
416 double fIntervalMajor = 0.0;
417 double fIntervalMinor = 0.0;
418 sal_Bool bMoveProtect = sal_False;
419 sal_Bool bSizeProtect = sal_False;
420 OUString aProtectAttrValue;
421 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = 0;
423 /* Attribute <style:mirror> has to be priority over attribute <style:draw>.
424 The filter from OpenDocument file format to OpenOffice.org file format
425 produces styles with both attributes. (#i49139#)
427 sal_Bool bExistStyleMirror( sal_False );
428 OUString aStyleMirrorAttrValue;
429 sal_Bool bExistDrawMirror( sal_False );
430 OUString aDrawMirrorAttrValue;
431 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( 0L );
433 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
434 for( sal_Int16 i=0; i < nAttrCount; i++ )
436 const OUString sAttrName = xAttrList->getNameByIndex( i );
437 const OUString sAttrValue = xAttrList->getValueByIndex( i );
438 OUString aLocalName;
439 sal_uInt16 nPrefix =
440 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
441 &aLocalName );
442 TransformerAction_Impl aAction;
443 XMLTypedPropertiesOOoTContext_Impl *pContext =
444 GetPropContextAndAction( aAction, nPrefix, aLocalName, sal_False );
445 switch( aAction.m_nActionType )
447 case XML_ATACTION_REMOVE:
448 break;
449 case XML_ATACTION_COPY:
450 pContext->AddAttribute( sAttrName, sAttrValue );
451 break;
452 case XML_ATACTION_COPY_DUPLICATE:
454 pContext->AddAttribute( sAttrName, sAttrValue );
455 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
456 GetPropContext( (XMLPropType)aAction.m_nParam1 );
457 if( pContext2 )
458 pContext2->AddAttribute( sAttrName, sAttrValue );
460 break;
461 case XML_ATACTION_RENAME:
463 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
464 aAction.GetQNameTokenFromParam1(),
465 sAttrValue );
467 break;
468 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
470 OUString aAttrValue( sAttrValue );
471 GetTransformer().EncodeStyleName(aAttrValue);
472 pContext->AddAttribute( sAttrName, aAttrValue );
474 break;
475 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
477 OUString aAttrValue( sAttrValue );
478 GetTransformer().EncodeStyleName(aAttrValue);
479 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
480 aAction.GetQNameTokenFromParam1(),
481 aAttrValue );
483 break;
484 case XML_ATACTION_NEG_PERCENT:
486 OUString aAttrValue( sAttrValue );
487 GetTransformer().NegPercent(aAttrValue);
488 pContext->AddAttribute( sAttrName, aAttrValue );
490 break;
491 case XML_ATACTION_RENAME_NEG_PERCENT:
493 OUString aAttrValue( sAttrValue );
494 GetTransformer().NegPercent(aAttrValue);
495 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
496 aAction.GetQNameTokenFromParam1(),
497 aAttrValue );
499 break;
500 case XML_ATACTION_INCH2IN:
502 OUString aAttrValue( sAttrValue );
503 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
504 pContext->AddAttribute( sAttrName, aAttrValue );
506 break;
507 case XML_ATACTION_INCH2IN_DUPLICATE:
509 OUString aAttrValue( sAttrValue );
510 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
511 pContext->AddAttribute( sAttrName, aAttrValue );
512 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
513 GetPropContext( (XMLPropType)aAction.m_nParam1 );
514 if( pContext2 )
515 pContext2->AddAttribute( sAttrName, aAttrValue );
517 break;
518 case XML_ATACTION_INCHS2INS:
520 OUString aAttrValue( sAttrValue );
521 XMLTransformerBase::ReplaceInchWithIn( aAttrValue );
522 pContext->AddAttribute( sAttrName, aAttrValue );
524 break;
525 case XML_PTACTION_LINE_MODE:
527 OUString aAttrValue( GetXMLToken(
528 IsXMLToken( sAttrValue, XML_TRUE )
529 ? XML_CONTINUOUS
530 : XML_SKIP_WHITE_SPACE) );
531 OUString aAttrQName(
532 GetTransformer().GetNamespaceMap().GetQNameByKey(
533 XML_NAMESPACE_STYLE,
534 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) );
535 pContext->AddAttribute( aAttrQName, aAttrValue );
537 aAttrQName =
538 GetTransformer().GetNamespaceMap().GetQNameByKey(
539 XML_NAMESPACE_STYLE,
540 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) );
541 pContext->AddAttribute( aAttrQName, aAttrValue );
543 break;
544 case XML_PTACTION_KEEP_WITH_NEXT:
546 OUString aAttrValue( GetXMLToken(
547 IsXMLToken( sAttrValue, XML_TRUE )
548 ? XML_ALWAYS
549 : XML_AUTO) );
550 pContext->AddAttribute( sAttrName, aAttrValue );
552 break;
553 case XML_PTACTION_UNDERLINE:
555 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
556 sal_Bool bBold = sal_False, bDouble = sal_False;
557 switch( eToken )
559 case XML_SINGLE:
560 eToken = XML_SOLID;
561 break;
562 case XML_DOUBLE:
563 eToken = XML_SOLID;
564 bDouble = sal_True;
565 break;
566 case XML_BOLD:
567 eToken = XML_SOLID;
568 bBold = sal_True;
569 break;
570 case XML_BOLD_DOTTED:
571 eToken = XML_DOTTED;
572 bBold = sal_True;
573 break;
574 case XML_BOLD_DASH:
575 eToken = XML_DASH;
576 bBold = sal_True;
577 break;
578 case XML_BOLD_LONG_DASH:
579 eToken = XML_LONG_DASH;
580 bBold = sal_True;
581 break;
582 case XML_BOLD_DOT_DASH:
583 eToken = XML_DOT_DASH;
584 bBold = sal_True;
585 break;
586 case XML_BOLD_DOT_DOT_DASH:
587 eToken = XML_DOT_DOT_DASH;
588 bBold = sal_True;
589 break;
590 case XML_BOLD_WAVE:
591 eToken = XML_WAVE;
592 bBold = sal_True;
593 break;
594 case XML_DOUBLE_WAVE:
595 eToken = XML_WAVE;
596 bDouble = sal_True;
597 break;
598 case XML_NONE:
599 eToken = XML_NONE;
600 bDouble = sal_False;
601 break;
602 default:
603 OSL_FAIL( "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" );
604 break;
606 pContext->AddAttribute(
607 GetTransformer().GetNamespaceMap().GetQNameByKey(
608 XML_NAMESPACE_STYLE,
609 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ),
610 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
611 : sAttrValue );
612 if( bDouble )
613 pContext->AddAttribute(
614 GetTransformer().GetNamespaceMap().GetQNameByKey(
615 XML_NAMESPACE_STYLE,
616 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ),
617 GetXMLToken( XML_DOUBLE ) );
618 if( bBold )
619 pContext->AddAttribute(
620 GetTransformer().GetNamespaceMap().GetQNameByKey(
621 XML_NAMESPACE_STYLE,
622 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ),
623 GetXMLToken( XML_BOLD ) );
625 break;
626 case XML_PTACTION_LINETHROUGH:
628 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
629 sal_Bool bBold = sal_False, bDouble = sal_False;
630 sal_Unicode c = 0;
631 switch( eToken )
633 case XML_SINGLE_LINE:
634 eToken = XML_SOLID;
635 break;
636 case XML_DOUBLE_LINE:
637 eToken = XML_SOLID;
638 bDouble = sal_True;
639 break;
640 case XML_THICK_LINE:
641 eToken = XML_SOLID;
642 bBold = sal_True;
643 break;
644 case XML_SLASH:
645 eToken = XML_SOLID;
646 c = '/';
647 break;
648 case XML_uX:
649 eToken = XML_SOLID;
650 c = 'X';
651 break;
652 default:
653 break;
655 pContext->AddAttribute(
656 GetTransformer().GetNamespaceMap().GetQNameByKey(
657 XML_NAMESPACE_STYLE,
658 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ),
659 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
660 : sAttrValue );
661 if( bDouble )
662 pContext->AddAttribute(
663 GetTransformer().GetNamespaceMap().GetQNameByKey(
664 XML_NAMESPACE_STYLE,
665 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ),
666 GetXMLToken( XML_DOUBLE ) );
667 if( bBold )
668 pContext->AddAttribute(
669 GetTransformer().GetNamespaceMap().GetQNameByKey(
670 XML_NAMESPACE_STYLE,
671 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ),
672 GetXMLToken( XML_BOLD ) );
673 if( c )
674 pContext->AddAttribute(
675 GetTransformer().GetNamespaceMap().GetQNameByKey(
676 XML_NAMESPACE_STYLE,
677 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ),
678 OUString::valueOf( c ) );
680 break;
681 case XML_PTACTION_SPLINES:
683 sal_Int32 nSplineType = sAttrValue.toInt32();
684 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
685 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) );
687 switch( nSplineType )
689 // straight lines
690 case 0:
691 pContext->AddAttribute(
692 aNewAttrName, GetXMLToken( XML_NONE ));
693 break;
694 // cubic spline
695 case 1:
696 pContext->AddAttribute(
697 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE ));
698 break;
699 // B-spline
700 case 2:
701 pContext->AddAttribute(
702 aNewAttrName, GetXMLToken( XML_B_SPLINE ));
703 break;
705 default:
706 OSL_FAIL( "invalid spline type" );
707 pContext->AddAttribute(
708 aNewAttrName, GetXMLToken( XML_NONE ));
709 break;
712 break;
713 case XML_PTACTION_INTERVAL_MAJOR:
714 pContext->AddAttribute( sAttrName, sAttrValue );
715 ::sax::Converter::convertDouble( fIntervalMajor, sAttrValue );
716 break;
717 case XML_PTACTION_INTERVAL_MINOR:
718 ::sax::Converter::convertDouble( fIntervalMinor, sAttrValue );
719 pIntervalMinorDivisorContext = pContext;
720 break;
721 case XML_PTACTION_SYMBOL:
723 sal_Int32 nSymbolType = sAttrValue.toInt32();
724 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
725 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) );
727 if( nSymbolType >= 0 )
729 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL ));
730 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
731 switch( nSymbolType )
733 // SYMBOL0
734 case 0:
735 // "square" has an awkward token name
736 eToken = XML_GRADIENTSTYLE_SQUARE;
737 break;
738 // SYMBOL1
739 case 1:
740 eToken = XML_DIAMOND;
741 break;
742 // SYMBOL2
743 case 2:
744 eToken = XML_ARROW_DOWN;
745 break;
746 // SYMBOL3
747 case 3:
748 eToken = XML_ARROW_UP;
749 break;
750 // SYMBOL4
751 case 4:
752 eToken = XML_ARROW_RIGHT;
753 break;
754 // SYMBOL5
755 case 5:
756 eToken = XML_ARROW_LEFT;
757 break;
758 // SYMBOL6
759 case 6:
760 eToken = XML_BOW_TIE;
761 break;
762 // SYMBOL7
763 case 7:
764 eToken = XML_HOURGLASS;
765 break;
766 case 8:
767 eToken = XML_CIRCLE;
768 break;
769 case 9:
770 eToken = XML_STAR;
771 break;
772 case 10:
773 eToken = XML_X;
774 break;
775 case 11:
776 eToken = XML_PLUS;
777 break;
778 case 12:
779 eToken = XML_ASTERISK;
780 break;
781 case 13:
782 eToken = XML_HORIZONTAL_BAR;
783 break;
784 case 14:
785 eToken = XML_VERTICAL_BAR;
786 break;
787 default:
788 OSL_FAIL( "invalid named symbol" );
789 break;
792 if( eToken != XML_TOKEN_INVALID )
794 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
795 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )),
796 GetXMLToken( eToken ));
799 else
801 switch( nSymbolType )
803 // NONE
804 case -3:
805 pContext->AddAttribute(
806 aNewAttrName, GetXMLToken( XML_NONE ));
807 break;
808 // AUTO
809 case -2:
810 pContext->AddAttribute(
811 aNewAttrName, GetXMLToken( XML_AUTOMATIC ));
812 break;
813 // BITMAPURL
814 case -1:
815 pContext->AddAttribute(
816 aNewAttrName, GetXMLToken( XML_IMAGE ));
817 break;
818 default:
819 OSL_FAIL( "invalid symbol type" );
820 pContext->AddAttribute(
821 aNewAttrName, GetXMLToken( XML_NONE ));
822 break;
826 break;
827 case XML_PTACTION_SYMBOL_IMAGE_NAME:
829 // create an xlink:href element for URI attribute
830 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext(
831 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey(
832 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE )));
834 OUString aAttrValue( sAttrValue );
835 if( GetTransformer().ConvertURIToOASIS( aAttrValue, sal_True ))
837 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue );
838 pContext->AddContent( pSymbolImageContext );
841 break;
843 // #i25616#
844 case XML_PTACTION_TRANSPARENCY :
846 OUString aAttrValue( sAttrValue );
847 GetTransformer().NegPercent(aAttrValue);
848 pContext->AddAttribute( XML_NAMESPACE_DRAW,
849 XML_OPACITY,
850 aAttrValue );
851 pContext->AddAttribute( XML_NAMESPACE_DRAW,
852 XML_IMAGE_OPACITY,
853 aAttrValue );
855 break;
857 case XML_PTACTION_BREAK_INSIDE:
859 pContext->AddAttribute(
860 XML_NAMESPACE_FO, XML_KEEP_TOGETHER,
861 GetXMLToken(
862 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID )
863 ? XML_ALWAYS
864 : XML_AUTO ) );
866 break;
867 case XML_ATACTION_CAPTION_ESCAPE_OOO:
869 OUString aAttrValue( sAttrValue );
870 if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 )
872 sal_Int32 nValue = 0;
873 ::sax::Converter::convertPercent( nValue, sAttrValue );
874 if( nValue )
876 nValue /= 100;
877 OUStringBuffer aOut;
878 ::sax::Converter::convertPercent( aOut, nValue );
879 aAttrValue = aOut.makeStringAndClear();
882 else
884 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
887 pContext->AddAttribute( sAttrName, aAttrValue );
889 break;
890 case XML_ATACTION_MOVE_PROTECT:
891 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE );
892 pProtectContext = pContext;
893 break;
894 case XML_ATACTION_SIZE_PROTECT:
895 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE );
896 pProtectContext = pContext;
897 break;
898 case XML_ATACTION_PROTECT:
899 aProtectAttrValue = sAttrValue;
900 pProtectContext = pContext;
901 break;
902 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values
904 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
905 aDrawMirrorAttrValue =
906 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE )
907 ? XML_HORIZONTAL : XML_NONE );
908 bExistDrawMirror = sal_True;
909 pMirrorContext = pContext;
911 break;
912 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
913 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values
915 SvXMLTokenEnumerator aTokenEnum( sAttrValue );
916 OUString aToken;
917 while( aTokenEnum.getNextToken( aToken ) )
919 if ( !aStyleMirrorAttrValue.isEmpty() )
921 aStyleMirrorAttrValue += OUString(" " );
924 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) )
926 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_EVEN );
928 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) )
930 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_ODD );
932 else
934 aStyleMirrorAttrValue += aToken;
937 bExistStyleMirror = sal_True;
938 pMirrorContext = pContext;
940 break;
941 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage
943 double fValue = sAttrValue.toDouble();
944 sal_Int32 nValue = (sal_Int32)((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) );
946 OUStringBuffer aOut;
947 ::sax::Converter::convertPercent( aOut, nValue );
948 OUString aAttrValue( aOut.makeStringAndClear() );
949 pContext->AddAttribute( sAttrName, aAttrValue );
951 break;
952 case XML_ATACTION_OPACITY_FIX:
954 sal_Int32 nValue;
955 if( sAttrValue.indexOf( sal_Unicode('%') ) != -1 )
957 ::sax::Converter::convertPercent( nValue, sAttrValue );
959 else
961 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 );
963 nValue = 100 - nValue;
965 OUStringBuffer aOut;
966 ::sax::Converter::convertPercent( aOut, nValue );
967 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() );
969 break;
970 default:
971 OSL_ENSURE( !this, "unknown action" );
972 break;
976 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
977 if ( bExistStyleMirror )
979 pMirrorContext->AddAttribute(
980 GetTransformer().GetNamespaceMap().GetQNameByKey(
981 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
982 aStyleMirrorAttrValue);
984 else if ( bExistDrawMirror )
986 pMirrorContext->AddAttribute(
987 GetTransformer().GetNamespaceMap().GetQNameByKey(
988 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
989 aDrawMirrorAttrValue);
992 if( bMoveProtect || bSizeProtect || !aProtectAttrValue.isEmpty() )
994 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) )
995 aProtectAttrValue = OUString();
997 const OUString& rPosition = GetXMLToken( XML_POSITION );
998 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) )
1000 if( !aProtectAttrValue.isEmpty() )
1001 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) );
1002 aProtectAttrValue += rPosition;
1005 const OUString& rSize = GetXMLToken( XML_SIZE );
1006 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) )
1008 if( !aProtectAttrValue.isEmpty() )
1009 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) );
1010 aProtectAttrValue += rSize;
1013 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue );
1016 if( pIntervalMinorDivisorContext )
1018 if( fIntervalMinor != 0.0 )
1020 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >(
1021 ::rtl::math::round( fIntervalMajor / fIntervalMinor ));
1023 OUStringBuffer aBuf;
1024 ::sax::Converter::convertNumber( aBuf, nIntervalMinorDivisor );
1025 pIntervalMinorDivisorContext->AddAttribute(
1026 GetTransformer().GetNamespaceMap().GetQNameByKey(
1027 XML_NAMESPACE_CHART,
1028 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )),
1029 aBuf.makeStringAndClear());
1034 void XMLPropertiesOOoTContext_Impl::EndElement()
1036 if( !m_bPersistent )
1037 Export();
1040 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& )
1042 // ignore them
1045 void XMLPropertiesOOoTContext_Impl::Export()
1048 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; i++ )
1050 if( m_aPropContexts[i].is() )
1051 m_aPropContexts[i]->Export();
1055 sal_Bool XMLPropertiesOOoTContext_Impl::IsPersistent() const
1057 return m_bPersistent;
1061 //------------------------------------------------------------------------------
1063 TYPEINIT1( XMLStyleOOoTContext, XMLPersElemContentTContext );
1065 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp,
1066 const OUString& rQName,
1067 XMLFamilyType eT,
1068 sal_Bool bPersistent ) :
1069 XMLPersElemContentTContext( rImp, rQName ),
1070 m_eFamily( eT ),
1071 m_bPersistent( bPersistent )
1075 XMLStyleOOoTContext::XMLStyleOOoTContext(
1076 XMLTransformerBase& rImp,
1077 const OUString& rQName,
1078 XMLFamilyType eT,
1079 sal_uInt16 nPrefix,
1080 ::xmloff::token::XMLTokenEnum eToken,
1081 sal_Bool bPersistent ) :
1082 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
1083 m_eFamily( eT ),
1084 m_bPersistent( bPersistent )
1088 XMLStyleOOoTContext::~XMLStyleOOoTContext()
1092 XMLTransformerContext *XMLStyleOOoTContext::CreateChildContext(
1093 sal_uInt16 nPrefix,
1094 const OUString& rLocalName,
1095 const OUString& rQName,
1096 const Reference< XAttributeList >& rAttrList )
1098 XMLTransformerContext *pContext = 0;
1100 if( XML_NAMESPACE_STYLE == nPrefix &&
1101 IsXMLToken( rLocalName, XML_PROPERTIES ) )
1103 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END )
1105 OSL_ENSURE( !this, "unexpected properties element" );
1106 pContext = m_bPersistent
1107 ? XMLPersElemContentTContext::CreateChildContext(
1108 nPrefix, rLocalName, rQName, rAttrList )
1109 : XMLTransformerContext::CreateChildContext(
1110 nPrefix, rLocalName, rQName, rAttrList );
1112 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END )
1114 sal_uInt16 nActionMap =
1115 aAttrActionMaps[aPropTypes[m_eFamily][0]];
1116 if( nActionMap < MAX_OOO_PROP_ACTIONS )
1118 pContext = new XMLPropertiesOOoTContext_Impl(
1119 GetTransformer(), rQName,
1120 aPropTypes[m_eFamily], m_bPersistent );
1122 else
1124 if( m_bPersistent )
1125 pContext = new XMLPersElemContentTContext(
1126 GetTransformer(), rQName,
1127 XML_NAMESPACE_STYLE,
1128 aPropTokens[aPropTypes[m_eFamily][0]] );
1129 else
1130 pContext = new XMLRenameElemTransformerContext(
1131 GetTransformer(), rQName,
1132 XML_NAMESPACE_STYLE,
1133 aPropTokens[aPropTypes[m_eFamily][0]] );
1136 else
1138 pContext = new XMLPropertiesOOoTContext_Impl(
1139 GetTransformer(), rQName,
1140 aPropTypes[m_eFamily], m_bPersistent);
1143 if( m_bPersistent )
1144 AddContent( pContext );
1146 else
1148 pContext = m_bPersistent
1149 ? XMLPersElemContentTContext::CreateChildContext(
1150 nPrefix, rLocalName, rQName, rAttrList )
1151 : XMLTransformerContext::CreateChildContext(
1152 nPrefix, rLocalName, rQName, rAttrList );
1155 return pContext;
1158 void XMLStyleOOoTContext::StartElement(
1159 const Reference< XAttributeList >& rAttrList )
1161 XMLTransformerActions *pActions =
1162 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS );
1163 OSL_ENSURE( pActions, "go no actions" );
1165 Reference< XAttributeList > xAttrList( rAttrList );
1166 XMLMutableAttributeList *pMutableAttrList = 0;
1167 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1168 for( sal_Int16 i=0; i < nAttrCount; i++ )
1170 const OUString sAttrName = xAttrList->getNameByIndex( i );
1171 OUString aLocalName;
1172 sal_uInt16 nPrefix =
1173 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
1174 &aLocalName );
1175 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
1176 XMLTransformerActions::const_iterator aIter =
1177 pActions->find( aKey );
1178 if( !(aIter == pActions->end() ) )
1180 if( !pMutableAttrList )
1182 pMutableAttrList =
1183 new XMLMutableAttributeList( xAttrList );
1184 xAttrList = pMutableAttrList;
1186 const OUString sAttrValue = xAttrList->getValueByIndex( i );
1187 switch( (*aIter).second.m_nActionType )
1189 case XML_ATACTION_STYLE_FAMILY:
1191 sal_Bool bControl = sal_False;
1192 if( XML_FAMILY_TYPE_END == m_eFamily )
1194 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) )
1195 m_eFamily = XML_FAMILY_TYPE_GRAPHIC;
1196 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) )
1197 m_eFamily = XML_FAMILY_TYPE_PRESENTATION;
1198 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) )
1199 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE;
1200 else if( IsXMLToken( sAttrValue, XML_TEXT) )
1201 m_eFamily = XML_FAMILY_TYPE_TEXT;
1202 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) )
1203 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1204 else if( IsXMLToken( sAttrValue, XML_RUBY) )
1205 m_eFamily = XML_FAMILY_TYPE_RUBY;
1206 else if( IsXMLToken( sAttrValue, XML_SECTION) )
1207 m_eFamily = XML_FAMILY_TYPE_SECTION;
1208 else if( IsXMLToken( sAttrValue, XML_TABLE) )
1209 m_eFamily = XML_FAMILY_TYPE_TABLE;
1210 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) )
1211 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN;
1212 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) )
1213 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW;
1214 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) )
1215 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL;
1216 else if( IsXMLToken( sAttrValue, XML_CHART) )
1217 m_eFamily = XML_FAMILY_TYPE_CHART;
1218 else if( IsXMLToken( sAttrValue, XML_CONTROL) )
1220 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1221 bControl = sal_True;
1224 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily )
1226 pMutableAttrList->SetValueByIndex( i,
1227 GetXMLToken( XML_GRAPHIC ) );
1229 else if( bControl )
1231 pMutableAttrList->SetValueByIndex( i,
1232 GetXMLToken( XML_PARAGRAPH ) );
1235 break;
1236 case XML_ATACTION_INCH2IN:
1238 OUString aAttrValue( sAttrValue );
1239 if( XMLTransformerBase::ReplaceSingleInchWithIn(
1240 aAttrValue ) )
1241 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1243 break;
1244 case XML_ATACTION_ENCODE_STYLE_NAME:
1246 OUString aAttrValue( sAttrValue );
1247 if( GetTransformer().EncodeStyleName(aAttrValue) )
1249 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1250 OUString aNewAttrQName(
1251 GetTransformer().GetNamespaceMap().
1252 GetQNameByKey(
1253 nPrefix, ::xmloff::token::GetXMLToken(
1254 XML_DISPLAY_NAME ) ) );
1255 pMutableAttrList->AddAttribute( aNewAttrQName,
1256 sAttrValue );
1259 break;
1260 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
1262 OUString aAttrValue( sAttrValue );
1263 if( GetTransformer().EncodeStyleName(aAttrValue) )
1264 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1266 break;
1267 case XML_ATACTION_NEG_PERCENT:
1269 OUString aAttrValue( sAttrValue );
1270 if( GetTransformer().NegPercent(aAttrValue) )
1271 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1273 break;
1274 case XML_ATACTION_URI_OOO:
1276 OUString aAttrValue( sAttrValue );
1277 if( GetTransformer().ConvertURIToOASIS( aAttrValue,
1278 static_cast< sal_Bool >((*aIter).second.m_nParam1)))
1279 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1281 break;
1282 default:
1283 OSL_ENSURE( !this, "unknown action" );
1284 break;
1288 if( XML_FAMILY_TYPE_END == m_eFamily )
1289 m_eFamily = XML_FAMILY_TYPE_TEXT;
1290 if( m_bPersistent )
1291 XMLPersElemContentTContext::StartElement( xAttrList );
1292 else
1293 GetTransformer().GetDocHandler()->startElement( GetExportQName(),
1294 xAttrList );
1297 void XMLStyleOOoTContext::EndElement()
1299 if( m_bPersistent )
1300 XMLPersElemContentTContext::EndElement();
1301 else
1302 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
1305 void XMLStyleOOoTContext::Characters( const OUString& )
1307 // element content only:
1310 sal_Bool XMLStyleOOoTContext::IsPersistent() const
1312 return m_bPersistent;
1315 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions(
1316 sal_uInt16 nType )
1318 XMLTransformerActionInit *pInit = 0;
1320 switch( nType )
1322 case PROP_OOO_GRAPHIC_ATTR_ACTIONS:
1323 pInit = aGraphicPropertyOOoAttrActionTable;
1324 break;
1325 case PROP_OOO_GRAPHIC_ELEM_ACTIONS:
1326 pInit = aGraphicPropertyOOoElemActionTable;
1327 break;
1328 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS:
1329 pInit = aDrawingPagePropertyOOoAttrActionTable;
1330 break;
1331 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS:
1332 pInit = aPageLayoutPropertyOOoAttrActionTable;
1333 break;
1334 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS:
1335 pInit = aHeaderFooterPropertyOOoAttrActionTable;
1336 break;
1337 case PROP_OOO_TEXT_ATTR_ACTIONS:
1338 pInit = aTextPropertyOOoAttrActionTable;
1339 break;
1340 case PROP_OOO_TEXT_ELEM_ACTIONS:
1341 pInit = aTextPropertyOOoElemActionTable;
1342 break;
1343 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS:
1344 pInit = aParagraphPropertyOOoAttrActionTable;
1345 break;
1346 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS:
1347 pInit = aParagraphPropertyOOoElemActionTable;
1348 break;
1349 case PROP_OOO_SECTION_ATTR_ACTIONS:
1350 pInit = aSectionPropertyOOoAttrActionTable;
1351 break;
1352 case PROP_OOO_TABLE_ATTR_ACTIONS:
1353 pInit = aTablePropertyOOoAttrActionTable;
1354 break;
1355 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS:
1356 pInit = aTableColumnPropertyOOoAttrActionTable;
1357 break;
1358 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS:
1359 pInit = aTableRowPropertyOOoAttrActionTable;
1360 break;
1361 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS:
1362 pInit = aTableCellPropertyOOoAttrActionTable;
1363 break;
1364 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS:
1365 pInit = aTableCellPropertyOOoElemActionTable;
1366 break;
1367 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS:
1368 pInit = aListLevelPropertyOOoAttrActionTable;
1369 break;
1370 case PROP_OOO_CHART_ATTR_ACTIONS:
1371 pInit = aChartPropertyOOoAttrActionTable;
1372 break;
1373 case PROP_OOO_CHART_ELEM_ACTIONS:
1374 pInit = aChartPropertyOOoElemActionTable;
1375 break;
1378 XMLTransformerActions *pActions = 0;
1379 if( pInit )
1380 pActions = new XMLTransformerActions( pInit );
1382 return pActions;
1385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */