nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / transform / StyleOOoTContext.cxx
blob735d365068cadfec0eae655dd0c9f9ebab817255
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/SAXException.hpp>
21 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
22 #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 #include <sax/tools/converter.hxx>
26 #include <xmloff/namespacemap.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmlnamespace.hxx>
29 #include "PropType.hxx"
30 #include "DeepTContext.hxx"
31 #include "RenameElemTContext.hxx"
32 #include "ActionMapTypesOOo.hxx"
33 #include "MutableAttrList.hxx"
34 #include "TransformerActions.hxx"
35 #include "PropertyActionsOOo.hxx"
36 #include "TransformerBase.hxx"
38 #include "StyleOOoTContext.hxx"
39 #include <xmloff/xmluconv.hxx>
40 #include <rtl/math.hxx>
41 #include <rtl/ustrbuf.hxx>
42 #include <osl/diagnose.h>
43 #include <sal/log.hxx>
44 #include <array>
46 using namespace ::xmloff::token;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::xml::sax;
50 const sal_uInt16 MAX_PROP_TYPES = 4;
51 #define ENTRY4(a,b,c,d) \
52 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
53 XML_PROP_TYPE_##c, XML_PROP_TYPE_##d }
54 #define ENTRY3(a,b,c) \
55 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
56 XML_PROP_TYPE_##c, XML_PROP_TYPE_END }
57 #define ENTRY2(a,b) \
58 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \
59 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
60 #define ENTRY1(a) \
61 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##END, \
62 XML_PROP_TYPE_END, XML_PROP_TYPE_END }
64 const std::array<XMLPropType,MAX_PROP_TYPES> aPropTypes[XML_FAMILY_TYPE_END] =
66 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_GRAPHIC,
67 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PRESENTATION,
68 ENTRY1( DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE,
69 ENTRY1( END ), // XML_FAMILY_TYPE_MASTER_PAGE
70 ENTRY1( PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT,
71 ENTRY1( HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER
72 ENTRY1( TEXT ), // XML_FAMILY_TYPE_TEXT,
73 ENTRY2( PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PARAGRAPH,
74 ENTRY1( RUBY ), //XML_FAMILY_TYPE_RUBY,
75 ENTRY1( SECTION ), // XML_FAMILY_TYPE_SECTION,
76 ENTRY1( TABLE ), // XML_FAMILY_TYPE_TABLE,
77 ENTRY1( TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN,
78 ENTRY1( TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW,
79 ENTRY3( TABLE_CELL, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_TABLE_CELL,
80 ENTRY1( LIST_LEVEL ), // XML_FAMILY_TYPE_LIST,
81 ENTRY4( CHART, GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_CHART,
82 ENTRY1( TEXT ), // XML_FAMILY_TYPE_DATA,
83 ENTRY1( END ), // XML_FAMILY_TYPE_GRADIENT,
84 ENTRY1( END ), // XML_FAMILY_TYPE_HATCH,
85 ENTRY1( END ), // XML_FAMILY_TYPE_FILL_IMAGE,
86 ENTRY1( END ), // XML_FAMILY_TYPE_STROKE_DASH,
87 ENTRY1( END ), // XML_FAMILY_TYPE_MARKER,
90 const 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 const 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 const 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
144 namespace {
146 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
148 css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList;
150 public:
151 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
152 const OUString& rQName );
154 using XMLPersAttrListTContext::AddAttribute;
155 void AddAttribute( const OUString &sName ,
156 const OUString &sValue );
157 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken,
158 const OUString &sValue );
160 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
162 virtual void Export() override;
167 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
168 XMLTransformerBase& rImp,
169 const OUString& rQName ) :
170 XMLPersElemContentTContext( rImp, rQName ),
171 m_xAttrList( new XMLMutableAttributeList() )
175 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
176 const OUString &sName ,
177 const OUString &sValue )
179 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
180 ->AddAttribute( sName, sValue );
183 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
184 sal_uInt16 nPrefix, XMLTokenEnum eToken,
185 const OUString &sValue )
187 OUString sName(
188 GetTransformer().GetNamespaceMap().GetQNameByKey(
189 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) );
190 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
191 ->AddAttribute( sName, sValue );
194 void XMLTypedPropertiesOOoTContext_Impl::StartElement(
195 const Reference< XAttributeList >& )
197 // empty, ignore even the attribute list
200 void XMLTypedPropertiesOOoTContext_Impl::Export()
202 if( m_xAttrList->getLength() || HasElementContent() )
204 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList );
205 ExportContent();
206 GetTransformer().GetDocHandler()->endElement( GetQName() );
210 namespace {
212 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
214 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
215 m_aPropContexts[MAX_PROP_TYPES];
217 using XMLPropTypes = std::array<XMLPropType, MAX_PROP_TYPES>;
219 XMLPropTypes const & m_rPropTypes;
221 bool const m_bPersistent;
223 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction(
224 TransformerAction_Impl& rAction,
225 sal_uInt16 nPrefix, const OUString& rLocalName,
226 bool bElem );
228 XMLTypedPropertiesOOoTContext_Impl *GetPropContext(
229 XMLPropType eType );
231 public:
232 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
233 const OUString& rQName,
234 const XMLPropTypes& rTypes,
235 bool bPersistent );
237 rtl::Reference<XMLTransformerContext> CreateChildContext(
238 sal_uInt16 nPrefix,
239 const OUString& rLocalName,
240 const OUString& rQName,
241 const Reference< XAttributeList >& rAttrList ) override;
243 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
245 virtual void EndElement() override;
247 virtual void Characters( const OUString& rChars ) override;
249 virtual void Export() override;
251 virtual bool IsPersistent() const override;
256 XMLTypedPropertiesOOoTContext_Impl
257 *XMLPropertiesOOoTContext_Impl::GetPropContext(
258 XMLPropType eType )
260 sal_uInt16 nIndex = MAX_PROP_TYPES;
261 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ )
263 if( m_rPropTypes[i] == eType )
265 nIndex = i;
266 break;
269 if( MAX_PROP_TYPES == nIndex )
270 return nullptr;
272 if( !m_aPropContexts[nIndex].is() )
274 m_aPropContexts[nIndex] =
275 new XMLTypedPropertiesOOoTContext_Impl(
276 GetTransformer(),
277 GetTransformer().GetNamespaceMap().GetQNameByKey(
278 XML_NAMESPACE_STYLE,
279 ::xmloff::token::GetXMLToken(
280 aPropTokens[m_rPropTypes[nIndex]] ) ));
283 return m_aPropContexts[nIndex].get();
286 XMLTypedPropertiesOOoTContext_Impl
287 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction(
288 TransformerAction_Impl& rAction,
289 sal_uInt16 nPrefix, const OUString& rLocalName,
290 bool bElem )
292 rAction.m_nActionType = XML_ATACTION_COPY;
293 sal_uInt16 nIndex = 0;
295 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
296 sal_uInt16 i=0;
297 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i])
299 sal_uInt16 nActionMap =
300 (bElem ? aElemActionMaps : aAttrActionMaps)[m_rPropTypes[i]];
301 if( nActionMap < MAX_OOO_PROP_ACTIONS )
303 XMLTransformerActions *pActions =
304 GetTransformer().GetUserDefinedActions( nActionMap );
305 OSL_ENSURE( pActions, "go no actions" );
306 if( pActions )
308 XMLTransformerActions::const_iterator aIter =
309 pActions->find( aKey );
311 if( aIter != pActions->end() )
313 rAction = (*aIter).second;
314 nIndex = i;
315 break;
319 ++i;
322 #ifdef DBG_UTIL
323 if( !( XML_NAMESPACE_NONE == nPrefix ||
324 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
325 XML_PROP_TYPE_END==m_rPropTypes[1] ||
326 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i]) ) )
328 SAL_WARN("xmloff", "Didn't find property: "
329 << GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix )
330 << ":"
331 << rLocalName
332 << ", assuming <style:"
333 << ::xmloff::token::GetXMLToken( aPropTokens[m_rPropTypes[0]] )
334 << ">" );
336 #endif
338 if( !m_aPropContexts[nIndex].is() )
340 m_aPropContexts[nIndex] =
341 new XMLTypedPropertiesOOoTContext_Impl(
342 GetTransformer(),
343 GetTransformer().GetNamespaceMap().GetQNameByKey(
344 XML_NAMESPACE_STYLE,
345 ::xmloff::token::GetXMLToken(
346 aPropTokens[m_rPropTypes[nIndex]] ) ));
349 return m_aPropContexts[nIndex].get();
352 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl(
353 XMLTransformerBase& rImp,
354 const OUString& rQName,
355 const XMLPropTypes& rTypes,
356 bool bPersistent ) :
357 XMLTransformerContext( rImp, rQName ),
358 // remember the types that belong to the attribute and element lists
359 m_rPropTypes(rTypes),
360 m_bPersistent( bPersistent )
364 rtl::Reference<XMLTransformerContext> XMLPropertiesOOoTContext_Impl::CreateChildContext(
365 sal_uInt16 nPrefix,
366 const OUString& rLocalName,
367 const OUString& rQName,
368 const Reference< XAttributeList >& rAttrList )
370 TransformerAction_Impl aAction;
371 return GetPropContextAndAction( aAction, nPrefix, rLocalName, true )
372 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList );
375 void XMLPropertiesOOoTContext_Impl::StartElement(
376 const Reference< XAttributeList >& rAttrList )
378 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = nullptr;
379 double fIntervalMajor = 0.0;
380 double fIntervalMinor = 0.0;
381 bool bMoveProtect = false;
382 bool bSizeProtect = false;
383 OUString aProtectAttrValue;
384 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = nullptr;
386 /* Attribute <style:mirror> has to be priority over attribute <style:draw>.
387 The filter from OpenDocument file format to OpenOffice.org file format
388 produces styles with both attributes. (#i49139#)
390 bool bExistStyleMirror( false );
391 OUStringBuffer aStyleMirrorAttrValue;
392 bool bExistDrawMirror( false );
393 OUString aDrawMirrorAttrValue;
394 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( nullptr );
396 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
397 for( sal_Int16 i=0; i < nAttrCount; i++ )
399 const OUString sAttrName = rAttrList->getNameByIndex( i );
400 const OUString sAttrValue = rAttrList->getValueByIndex( i );
401 OUString aLocalName;
402 sal_uInt16 nPrefix =
403 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
404 &aLocalName );
405 TransformerAction_Impl aAction;
406 XMLTypedPropertiesOOoTContext_Impl *pContext =
407 GetPropContextAndAction( aAction, nPrefix, aLocalName, false );
408 switch( aAction.m_nActionType )
410 case XML_ATACTION_REMOVE:
411 break;
412 case XML_ATACTION_COPY:
413 pContext->AddAttribute( sAttrName, sAttrValue );
414 break;
415 case XML_ATACTION_COPY_DUPLICATE:
417 pContext->AddAttribute( sAttrName, sAttrValue );
418 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
419 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
420 if( pContext2 )
421 pContext2->AddAttribute( sAttrName, sAttrValue );
423 break;
424 case XML_ATACTION_RENAME:
426 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
427 aAction.GetQNameTokenFromParam1(),
428 sAttrValue );
430 break;
431 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
433 OUString aAttrValue( sAttrValue );
434 GetTransformer().EncodeStyleName(aAttrValue);
435 pContext->AddAttribute( sAttrName, aAttrValue );
437 break;
438 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
440 OUString aAttrValue( sAttrValue );
441 GetTransformer().EncodeStyleName(aAttrValue);
442 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
443 aAction.GetQNameTokenFromParam1(),
444 aAttrValue );
446 break;
447 case XML_ATACTION_NEG_PERCENT:
449 OUString aAttrValue( sAttrValue );
450 XMLTransformerBase::NegPercent(aAttrValue);
451 pContext->AddAttribute( sAttrName, aAttrValue );
453 break;
454 case XML_ATACTION_RENAME_NEG_PERCENT:
456 OUString aAttrValue( sAttrValue );
457 XMLTransformerBase::NegPercent(aAttrValue);
458 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
459 aAction.GetQNameTokenFromParam1(),
460 aAttrValue );
462 break;
463 case XML_ATACTION_INCH2IN:
465 OUString aAttrValue( sAttrValue );
466 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
467 pContext->AddAttribute( sAttrName, aAttrValue );
469 break;
470 case XML_ATACTION_INCH2IN_DUPLICATE:
472 OUString aAttrValue( sAttrValue );
473 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
474 pContext->AddAttribute( sAttrName, aAttrValue );
475 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
476 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
477 if( pContext2 )
478 pContext2->AddAttribute( sAttrName, aAttrValue );
480 break;
481 case XML_ATACTION_INCHS2INS:
483 OUString aAttrValue( sAttrValue );
484 XMLTransformerBase::ReplaceInchWithIn( aAttrValue );
485 pContext->AddAttribute( sAttrName, aAttrValue );
487 break;
488 case XML_PTACTION_LINE_MODE:
490 const OUString& aAttrValue( GetXMLToken(
491 IsXMLToken( sAttrValue, XML_TRUE )
492 ? XML_CONTINUOUS
493 : XML_SKIP_WHITE_SPACE) );
494 OUString aAttrQName(
495 GetTransformer().GetNamespaceMap().GetQNameByKey(
496 XML_NAMESPACE_STYLE,
497 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) );
498 pContext->AddAttribute( aAttrQName, aAttrValue );
500 aAttrQName =
501 GetTransformer().GetNamespaceMap().GetQNameByKey(
502 XML_NAMESPACE_STYLE,
503 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) );
504 pContext->AddAttribute( aAttrQName, aAttrValue );
506 break;
507 case XML_PTACTION_KEEP_WITH_NEXT:
509 const OUString& aAttrValue( GetXMLToken(
510 IsXMLToken( sAttrValue, XML_TRUE )
511 ? XML_ALWAYS
512 : XML_AUTO) );
513 pContext->AddAttribute( sAttrName, aAttrValue );
515 break;
516 case XML_PTACTION_UNDERLINE:
518 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
519 bool bBold = false, bDouble = false;
520 switch( eToken )
522 case XML_SINGLE:
523 eToken = XML_SOLID;
524 break;
525 case XML_DOUBLE:
526 eToken = XML_SOLID;
527 bDouble = true;
528 break;
529 case XML_BOLD:
530 eToken = XML_SOLID;
531 bBold = true;
532 break;
533 case XML_BOLD_DOTTED:
534 eToken = XML_DOTTED;
535 bBold = true;
536 break;
537 case XML_BOLD_DASH:
538 eToken = XML_DASH;
539 bBold = true;
540 break;
541 case XML_BOLD_LONG_DASH:
542 eToken = XML_LONG_DASH;
543 bBold = true;
544 break;
545 case XML_BOLD_DOT_DASH:
546 eToken = XML_DOT_DASH;
547 bBold = true;
548 break;
549 case XML_BOLD_DOT_DOT_DASH:
550 eToken = XML_DOT_DOT_DASH;
551 bBold = true;
552 break;
553 case XML_BOLD_WAVE:
554 eToken = XML_WAVE;
555 bBold = true;
556 break;
557 case XML_DOUBLE_WAVE:
558 eToken = XML_WAVE;
559 bDouble = true;
560 break;
561 case XML_NONE:
562 eToken = XML_NONE;
563 bDouble = false;
564 break;
565 default:
566 OSL_FAIL( "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" );
567 break;
569 pContext->AddAttribute(
570 GetTransformer().GetNamespaceMap().GetQNameByKey(
571 XML_NAMESPACE_STYLE,
572 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ),
573 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
574 : sAttrValue );
575 if( bDouble )
576 pContext->AddAttribute(
577 GetTransformer().GetNamespaceMap().GetQNameByKey(
578 XML_NAMESPACE_STYLE,
579 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ),
580 GetXMLToken( XML_DOUBLE ) );
581 if( bBold )
582 pContext->AddAttribute(
583 GetTransformer().GetNamespaceMap().GetQNameByKey(
584 XML_NAMESPACE_STYLE,
585 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ),
586 GetXMLToken( XML_BOLD ) );
588 break;
589 case XML_PTACTION_LINETHROUGH:
591 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
592 bool bBold = false, bDouble = false;
593 sal_Unicode c = 0;
594 switch( eToken )
596 case XML_SINGLE_LINE:
597 eToken = XML_SOLID;
598 break;
599 case XML_DOUBLE_LINE:
600 eToken = XML_SOLID;
601 bDouble = true;
602 break;
603 case XML_THICK_LINE:
604 eToken = XML_SOLID;
605 bBold = true;
606 break;
607 case XML_SLASH:
608 eToken = XML_SOLID;
609 c = '/';
610 break;
611 case XML_uX:
612 eToken = XML_SOLID;
613 c = 'X';
614 break;
615 default:
616 break;
618 pContext->AddAttribute(
619 GetTransformer().GetNamespaceMap().GetQNameByKey(
620 XML_NAMESPACE_STYLE,
621 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ),
622 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
623 : sAttrValue );
624 if( bDouble )
625 pContext->AddAttribute(
626 GetTransformer().GetNamespaceMap().GetQNameByKey(
627 XML_NAMESPACE_STYLE,
628 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ),
629 GetXMLToken( XML_DOUBLE ) );
630 if( bBold )
631 pContext->AddAttribute(
632 GetTransformer().GetNamespaceMap().GetQNameByKey(
633 XML_NAMESPACE_STYLE,
634 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ),
635 GetXMLToken( XML_BOLD ) );
636 if( c )
637 pContext->AddAttribute(
638 GetTransformer().GetNamespaceMap().GetQNameByKey(
639 XML_NAMESPACE_STYLE,
640 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ),
641 OUString( c ) );
643 break;
644 case XML_PTACTION_SPLINES:
646 sal_Int32 nSplineType = sAttrValue.toInt32();
647 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
648 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) );
650 switch( nSplineType )
652 // straight lines
653 case 0:
654 pContext->AddAttribute(
655 aNewAttrName, GetXMLToken( XML_NONE ));
656 break;
657 // cubic spline
658 case 1:
659 pContext->AddAttribute(
660 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE ));
661 break;
662 // B-spline
663 case 2:
664 pContext->AddAttribute(
665 aNewAttrName, GetXMLToken( XML_B_SPLINE ));
666 break;
668 default:
669 OSL_FAIL( "invalid spline type" );
670 pContext->AddAttribute(
671 aNewAttrName, GetXMLToken( XML_NONE ));
672 break;
675 break;
676 case XML_PTACTION_INTERVAL_MAJOR:
677 pContext->AddAttribute( sAttrName, sAttrValue );
678 ::sax::Converter::convertDouble( fIntervalMajor, sAttrValue );
679 break;
680 case XML_PTACTION_INTERVAL_MINOR:
681 ::sax::Converter::convertDouble( fIntervalMinor, sAttrValue );
682 pIntervalMinorDivisorContext = pContext;
683 break;
684 case XML_PTACTION_SYMBOL:
686 sal_Int32 nSymbolType = sAttrValue.toInt32();
687 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
688 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) );
690 if( nSymbolType >= 0 )
692 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL ));
693 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
694 switch( nSymbolType )
696 // SYMBOL0
697 case 0:
698 // "square" has an awkward token name
699 eToken = XML_GRADIENTSTYLE_SQUARE;
700 break;
701 // SYMBOL1
702 case 1:
703 eToken = XML_DIAMOND;
704 break;
705 // SYMBOL2
706 case 2:
707 eToken = XML_ARROW_DOWN;
708 break;
709 // SYMBOL3
710 case 3:
711 eToken = XML_ARROW_UP;
712 break;
713 // SYMBOL4
714 case 4:
715 eToken = XML_ARROW_RIGHT;
716 break;
717 // SYMBOL5
718 case 5:
719 eToken = XML_ARROW_LEFT;
720 break;
721 // SYMBOL6
722 case 6:
723 eToken = XML_BOW_TIE;
724 break;
725 // SYMBOL7
726 case 7:
727 eToken = XML_HOURGLASS;
728 break;
729 case 8:
730 eToken = XML_CIRCLE;
731 break;
732 case 9:
733 eToken = XML_STAR;
734 break;
735 case 10:
736 eToken = XML_X;
737 break;
738 case 11:
739 eToken = XML_PLUS;
740 break;
741 case 12:
742 eToken = XML_ASTERISK;
743 break;
744 case 13:
745 eToken = XML_HORIZONTAL_BAR;
746 break;
747 case 14:
748 eToken = XML_VERTICAL_BAR;
749 break;
750 default:
751 OSL_FAIL( "invalid named symbol" );
752 break;
755 if( eToken != XML_TOKEN_INVALID )
757 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
758 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )),
759 GetXMLToken( eToken ));
762 else
764 switch( nSymbolType )
766 // NONE
767 case -3:
768 pContext->AddAttribute(
769 aNewAttrName, GetXMLToken( XML_NONE ));
770 break;
771 // AUTO
772 case -2:
773 pContext->AddAttribute(
774 aNewAttrName, GetXMLToken( XML_AUTOMATIC ));
775 break;
776 // BITMAPURL
777 case -1:
778 pContext->AddAttribute(
779 aNewAttrName, GetXMLToken( XML_IMAGE ));
780 break;
781 default:
782 OSL_FAIL( "invalid symbol type" );
783 pContext->AddAttribute(
784 aNewAttrName, GetXMLToken( XML_NONE ));
785 break;
789 break;
790 case XML_PTACTION_SYMBOL_IMAGE_NAME:
792 // create an xlink:href element for URI attribute
793 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext(
794 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey(
795 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE )));
796 rtl::Reference<XMLTransformerContext> xSymbolImageContext(pSymbolImageContext);
798 OUString aAttrValue( sAttrValue );
799 if( GetTransformer().ConvertURIToOASIS( aAttrValue, true ))
801 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue );
802 pContext->AddContent(xSymbolImageContext);
805 break;
807 // #i25616#
808 case XML_PTACTION_TRANSPARENCY :
810 OUString aAttrValue( sAttrValue );
811 XMLTransformerBase::NegPercent(aAttrValue);
812 pContext->AddAttribute( XML_NAMESPACE_DRAW,
813 XML_OPACITY,
814 aAttrValue );
815 pContext->AddAttribute( XML_NAMESPACE_DRAW,
816 XML_IMAGE_OPACITY,
817 aAttrValue );
819 break;
821 case XML_PTACTION_BREAK_INSIDE:
823 pContext->AddAttribute(
824 XML_NAMESPACE_FO, XML_KEEP_TOGETHER,
825 GetXMLToken(
826 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID )
827 ? XML_ALWAYS
828 : XML_AUTO ) );
830 break;
831 case XML_ATACTION_CAPTION_ESCAPE_OOO:
833 OUString aAttrValue( sAttrValue );
834 if( aAttrValue.indexOf( '%' ) != -1 )
836 sal_Int32 nValue = 0;
837 ::sax::Converter::convertPercent( nValue, sAttrValue );
838 if( nValue )
840 nValue /= 100;
841 OUStringBuffer aOut;
842 ::sax::Converter::convertPercent( aOut, nValue );
843 aAttrValue = aOut.makeStringAndClear();
846 else
848 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
851 pContext->AddAttribute( sAttrName, aAttrValue );
853 break;
854 case XML_ATACTION_MOVE_PROTECT:
855 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE );
856 pProtectContext = pContext;
857 break;
858 case XML_ATACTION_SIZE_PROTECT:
859 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE );
860 pProtectContext = pContext;
861 break;
862 case XML_ATACTION_PROTECT:
863 aProtectAttrValue = sAttrValue;
864 pProtectContext = pContext;
865 break;
866 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values
868 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
869 aDrawMirrorAttrValue =
870 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE )
871 ? XML_HORIZONTAL : XML_NONE );
872 bExistDrawMirror = true;
873 pMirrorContext = pContext;
875 break;
876 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
877 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values
879 SvXMLTokenEnumerator aTokenEnum( sAttrValue );
880 OUString aToken;
881 while( aTokenEnum.getNextToken( aToken ) )
883 if ( !aStyleMirrorAttrValue.isEmpty() )
885 aStyleMirrorAttrValue.append(" ");
888 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) )
890 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_EVEN ));
892 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) )
894 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_ODD ));
896 else
898 aStyleMirrorAttrValue.append(aToken);
901 bExistStyleMirror = true;
902 pMirrorContext = pContext;
904 break;
905 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage
907 double fValue = sAttrValue.toDouble();
908 sal_Int32 nValue = static_cast<sal_Int32>((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) );
910 OUStringBuffer aOut;
911 ::sax::Converter::convertPercent( aOut, nValue );
912 OUString aAttrValue( aOut.makeStringAndClear() );
913 pContext->AddAttribute( sAttrName, aAttrValue );
915 break;
916 case XML_ATACTION_OPACITY_FIX:
918 sal_Int32 nValue;
919 if( sAttrValue.indexOf( '%' ) != -1 )
921 ::sax::Converter::convertPercent( nValue, sAttrValue );
923 else
925 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 );
927 nValue = 100 - nValue;
929 OUStringBuffer aOut;
930 ::sax::Converter::convertPercent( aOut, nValue );
931 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() );
933 break;
934 default:
935 OSL_ENSURE( false, "unknown action" );
936 break;
940 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
941 if ( bExistStyleMirror )
943 pMirrorContext->AddAttribute(
944 GetTransformer().GetNamespaceMap().GetQNameByKey(
945 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
946 aStyleMirrorAttrValue.makeStringAndClear());
948 else if ( bExistDrawMirror )
950 pMirrorContext->AddAttribute(
951 GetTransformer().GetNamespaceMap().GetQNameByKey(
952 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
953 aDrawMirrorAttrValue);
956 if (bMoveProtect || bSizeProtect || !aProtectAttrValue.isEmpty())
958 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) )
959 aProtectAttrValue.clear();
961 const OUString& rPosition = GetXMLToken( XML_POSITION );
962 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) )
964 if( !aProtectAttrValue.isEmpty() )
965 aProtectAttrValue += " ";
966 aProtectAttrValue += rPosition;
969 const OUString& rSize = GetXMLToken( XML_SIZE );
970 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) )
972 if( !aProtectAttrValue.isEmpty() )
973 aProtectAttrValue += " ";
974 aProtectAttrValue += rSize;
977 assert(pProtectContext && "coverity[var_deref_model] - pProtectContext should be assigned in a superset of the enclosing if condition entry logic");
978 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue );
981 if( !pIntervalMinorDivisorContext )
982 return;
984 if( fIntervalMinor != 0.0 )
986 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >(
987 ::rtl::math::round( fIntervalMajor / fIntervalMinor ));
989 pIntervalMinorDivisorContext->AddAttribute(
990 GetTransformer().GetNamespaceMap().GetQNameByKey(
991 XML_NAMESPACE_CHART,
992 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )),
993 OUString::number( nIntervalMinorDivisor ));
997 void XMLPropertiesOOoTContext_Impl::EndElement()
999 if( !m_bPersistent )
1000 Export();
1003 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& )
1005 // ignore them
1008 void XMLPropertiesOOoTContext_Impl::Export()
1011 for(rtl::Reference<XMLTypedPropertiesOOoTContext_Impl> & rPropContext : m_aPropContexts)
1013 if( rPropContext.is() )
1014 rPropContext->Export();
1018 bool XMLPropertiesOOoTContext_Impl::IsPersistent() const
1020 return m_bPersistent;
1023 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp,
1024 const OUString& rQName,
1025 XMLFamilyType eT,
1026 bool bPersistent ) :
1027 XMLPersElemContentTContext( rImp, rQName ),
1028 m_eFamily( eT ),
1029 m_bPersistent( bPersistent )
1033 XMLStyleOOoTContext::XMLStyleOOoTContext(
1034 XMLTransformerBase& rImp,
1035 const OUString& rQName,
1036 XMLFamilyType eT,
1037 sal_uInt16 nPrefix,
1038 ::xmloff::token::XMLTokenEnum eToken,
1039 bool bPersistent ) :
1040 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
1041 m_eFamily( eT ),
1042 m_bPersistent( bPersistent )
1046 XMLStyleOOoTContext::~XMLStyleOOoTContext()
1050 rtl::Reference<XMLTransformerContext> XMLStyleOOoTContext::CreateChildContext(
1051 sal_uInt16 nPrefix,
1052 const OUString& rLocalName,
1053 const OUString& rQName,
1054 const Reference< XAttributeList >& rAttrList )
1056 rtl::Reference<XMLTransformerContext> pContext;
1058 if( XML_NAMESPACE_STYLE == nPrefix &&
1059 IsXMLToken( rLocalName, XML_PROPERTIES ) )
1061 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END )
1063 OSL_ENSURE( false, "unexpected properties element" );
1064 pContext = m_bPersistent
1065 ? XMLPersElemContentTContext::CreateChildContext(
1066 nPrefix, rLocalName, rQName, rAttrList )
1067 : XMLTransformerContext::CreateChildContext(
1068 nPrefix, rLocalName, rQName, rAttrList );
1070 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END )
1072 sal_uInt16 nActionMap =
1073 aAttrActionMaps[aPropTypes[m_eFamily][0]];
1074 if( nActionMap < MAX_OOO_PROP_ACTIONS )
1076 pContext.set(new XMLPropertiesOOoTContext_Impl(
1077 GetTransformer(), rQName,
1078 aPropTypes[m_eFamily], m_bPersistent ));
1080 else
1082 if( m_bPersistent )
1083 pContext.set(new XMLPersElemContentTContext(
1084 GetTransformer(), rQName,
1085 XML_NAMESPACE_STYLE,
1086 aPropTokens[aPropTypes[m_eFamily][0]] ));
1087 else
1088 pContext.set(new XMLRenameElemTransformerContext(
1089 GetTransformer(), rQName,
1090 XML_NAMESPACE_STYLE,
1091 aPropTokens[aPropTypes[m_eFamily][0]] ));
1094 else
1096 pContext.set(new XMLPropertiesOOoTContext_Impl(
1097 GetTransformer(), rQName,
1098 aPropTypes[m_eFamily], m_bPersistent));
1101 if( m_bPersistent )
1102 AddContent( pContext );
1104 else
1106 pContext = m_bPersistent
1107 ? XMLPersElemContentTContext::CreateChildContext(
1108 nPrefix, rLocalName, rQName, rAttrList )
1109 : XMLTransformerContext::CreateChildContext(
1110 nPrefix, rLocalName, rQName, rAttrList );
1113 return pContext;
1116 void XMLStyleOOoTContext::StartElement(
1117 const Reference< XAttributeList >& rAttrList )
1119 XMLTransformerActions *pActions =
1120 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS );
1121 OSL_ENSURE( pActions, "go no actions" );
1123 Reference< XAttributeList > xAttrList( rAttrList );
1124 XMLMutableAttributeList *pMutableAttrList = nullptr;
1125 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1126 for( sal_Int16 i=0; i < nAttrCount; i++ )
1128 const OUString sAttrName = xAttrList->getNameByIndex( i );
1129 OUString aLocalName;
1130 sal_uInt16 nPrefix =
1131 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
1132 &aLocalName );
1133 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
1134 XMLTransformerActions::const_iterator aIter =
1135 pActions->find( aKey );
1136 if( aIter != pActions->end() )
1138 if( !pMutableAttrList )
1140 pMutableAttrList =
1141 new XMLMutableAttributeList( xAttrList );
1142 xAttrList = pMutableAttrList;
1144 const OUString sAttrValue = xAttrList->getValueByIndex( i );
1145 switch( (*aIter).second.m_nActionType )
1147 case XML_ATACTION_STYLE_FAMILY:
1149 bool bControl = false;
1150 if( XML_FAMILY_TYPE_END == m_eFamily )
1152 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) )
1153 m_eFamily = XML_FAMILY_TYPE_GRAPHIC;
1154 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) )
1155 m_eFamily = XML_FAMILY_TYPE_PRESENTATION;
1156 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) )
1157 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE;
1158 else if( IsXMLToken( sAttrValue, XML_TEXT) )
1159 m_eFamily = XML_FAMILY_TYPE_TEXT;
1160 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) )
1161 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1162 else if( IsXMLToken( sAttrValue, XML_RUBY) )
1163 m_eFamily = XML_FAMILY_TYPE_RUBY;
1164 else if( IsXMLToken( sAttrValue, XML_SECTION) )
1165 m_eFamily = XML_FAMILY_TYPE_SECTION;
1166 else if( IsXMLToken( sAttrValue, XML_TABLE) )
1167 m_eFamily = XML_FAMILY_TYPE_TABLE;
1168 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) )
1169 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN;
1170 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) )
1171 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW;
1172 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) )
1173 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL;
1174 else if( IsXMLToken( sAttrValue, XML_CHART) )
1175 m_eFamily = XML_FAMILY_TYPE_CHART;
1176 else if( IsXMLToken( sAttrValue, XML_CONTROL) )
1178 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1179 bControl = true;
1182 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily )
1184 pMutableAttrList->SetValueByIndex( i,
1185 GetXMLToken( XML_GRAPHIC ) );
1187 else if( bControl )
1189 pMutableAttrList->SetValueByIndex( i,
1190 GetXMLToken( XML_PARAGRAPH ) );
1193 break;
1194 case XML_ATACTION_INCH2IN:
1196 OUString aAttrValue( sAttrValue );
1197 if( XMLTransformerBase::ReplaceSingleInchWithIn(
1198 aAttrValue ) )
1199 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1201 break;
1202 case XML_ATACTION_ENCODE_STYLE_NAME:
1204 OUString aAttrValue( sAttrValue );
1205 if( GetTransformer().EncodeStyleName(aAttrValue) )
1207 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1208 OUString aNewAttrQName(
1209 GetTransformer().GetNamespaceMap().
1210 GetQNameByKey(
1211 nPrefix, ::xmloff::token::GetXMLToken(
1212 XML_DISPLAY_NAME ) ) );
1213 pMutableAttrList->AddAttribute( aNewAttrQName,
1214 sAttrValue );
1217 break;
1218 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
1220 OUString aAttrValue( sAttrValue );
1221 if( GetTransformer().EncodeStyleName(aAttrValue) )
1222 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1224 break;
1225 case XML_ATACTION_NEG_PERCENT:
1227 OUString aAttrValue( sAttrValue );
1228 if( XMLTransformerBase::NegPercent(aAttrValue) )
1229 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1231 break;
1232 case XML_ATACTION_URI_OOO:
1234 OUString aAttrValue( sAttrValue );
1235 if( GetTransformer().ConvertURIToOASIS( aAttrValue,
1236 static_cast< bool >((*aIter).second.m_nParam1)))
1237 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1239 break;
1240 default:
1241 OSL_ENSURE( false, "unknown action" );
1242 break;
1246 if( XML_FAMILY_TYPE_END == m_eFamily )
1247 m_eFamily = XML_FAMILY_TYPE_TEXT;
1248 if( m_bPersistent )
1249 XMLPersElemContentTContext::StartElement( xAttrList );
1250 else
1251 GetTransformer().GetDocHandler()->startElement( GetExportQName(), xAttrList );
1254 void XMLStyleOOoTContext::EndElement()
1256 if( m_bPersistent )
1257 XMLPersElemContentTContext::EndElement();
1258 else
1259 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
1262 void XMLStyleOOoTContext::Characters( const OUString& )
1264 // element content only:
1267 bool XMLStyleOOoTContext::IsPersistent() const
1269 return m_bPersistent;
1272 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions(
1273 sal_uInt16 nType )
1275 XMLTransformerActionInit const *pInit = nullptr;
1277 switch( nType )
1279 case PROP_OOO_GRAPHIC_ATTR_ACTIONS:
1280 pInit = aGraphicPropertyOOoAttrActionTable;
1281 break;
1282 case PROP_OOO_GRAPHIC_ELEM_ACTIONS:
1283 pInit = aGraphicPropertyOOoElemActionTable;
1284 break;
1285 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS:
1286 pInit = aDrawingPagePropertyOOoAttrActionTable;
1287 break;
1288 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS:
1289 pInit = aPageLayoutPropertyOOoAttrActionTable;
1290 break;
1291 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS:
1292 pInit = aHeaderFooterPropertyOOoAttrActionTable;
1293 break;
1294 case PROP_OOO_TEXT_ATTR_ACTIONS:
1295 pInit = aTextPropertyOOoAttrActionTable;
1296 break;
1297 case PROP_OOO_TEXT_ELEM_ACTIONS:
1298 pInit = aTextPropertyOOoElemActionTable;
1299 break;
1300 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS:
1301 pInit = aParagraphPropertyOOoAttrActionTable;
1302 break;
1303 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS:
1304 pInit = aParagraphPropertyOOoElemActionTable;
1305 break;
1306 case PROP_OOO_SECTION_ATTR_ACTIONS:
1307 pInit = aSectionPropertyOOoAttrActionTable;
1308 break;
1309 case PROP_OOO_TABLE_ATTR_ACTIONS:
1310 pInit = aTablePropertyOOoAttrActionTable;
1311 break;
1312 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS:
1313 pInit = aTableColumnPropertyOOoAttrActionTable;
1314 break;
1315 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS:
1316 pInit = aTableRowPropertyOOoAttrActionTable;
1317 break;
1318 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS:
1319 pInit = aTableCellPropertyOOoAttrActionTable;
1320 break;
1321 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS:
1322 pInit = aTableCellPropertyOOoElemActionTable;
1323 break;
1324 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS:
1325 pInit = aListLevelPropertyOOoAttrActionTable;
1326 break;
1327 case PROP_OOO_CHART_ATTR_ACTIONS:
1328 pInit = aChartPropertyOOoAttrActionTable;
1329 break;
1330 case PROP_OOO_CHART_ELEM_ACTIONS:
1331 pInit = aChartPropertyOOoElemActionTable;
1332 break;
1335 XMLTransformerActions *pActions = nullptr;
1336 if( pInit )
1337 pActions = new XMLTransformerActions( pInit );
1339 return pActions;
1342 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */