Teach symstore more duplicated DLLs
[LibreOffice.git] / xmloff / source / transform / StyleOOoTContext.cxx
blob00f429ee721b6435851ad8eb831febb642eab8b3
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/nmspmap.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmlnmspe.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/ustrbuf.hxx>
41 #include <osl/diagnose.h>
42 #include <sal/log.hxx>
43 #include <array>
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 const std::array<XMLPropType,MAX_PROP_TYPES> aPropTypes[XML_FAMILY_TYPE_END] =
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,
89 static const XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] =
91 XML_GRAPHIC_PROPERTIES,
92 XML_DRAWING_PAGE_PROPERTIES,
93 XML_PAGE_LAYOUT_PROPERTIES,
94 XML_HEADER_FOOTER_PROPERTIES,
95 XML_TEXT_PROPERTIES,
96 XML_PARAGRAPH_PROPERTIES,
97 XML_RUBY_PROPERTIES,
98 XML_SECTION_PROPERTIES,
99 XML_TABLE_PROPERTIES,
100 XML_TABLE_COLUMN_PROPERTIES,
101 XML_TABLE_ROW_PROPERTIES,
102 XML_TABLE_CELL_PROPERTIES,
103 XML_LIST_LEVEL_PROPERTIES,
104 XML_CHART_PROPERTIES
107 static const sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] =
109 PROP_OOO_GRAPHIC_ATTR_ACTIONS,
110 PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE
111 PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS,
112 PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS,
113 PROP_OOO_TEXT_ATTR_ACTIONS,
114 PROP_OOO_PARAGRAPH_ATTR_ACTIONS,
115 MAX_OOO_PROP_ACTIONS, // RUBY
116 PROP_OOO_SECTION_ATTR_ACTIONS,
117 PROP_OOO_TABLE_ATTR_ACTIONS,
118 PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS,
119 PROP_OOO_TABLE_ROW_ATTR_ACTIONS,
120 PROP_OOO_TABLE_CELL_ATTR_ACTIONS,
121 PROP_OOO_LIST_LEVEL_ATTR_ACTIONS,
122 PROP_OOO_CHART_ATTR_ACTIONS
125 static const sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] =
127 PROP_OOO_GRAPHIC_ELEM_ACTIONS,
128 MAX_OOO_PROP_ACTIONS,
129 MAX_OOO_PROP_ACTIONS,
130 MAX_OOO_PROP_ACTIONS,
131 PROP_OOO_TEXT_ELEM_ACTIONS,
132 PROP_OOO_PARAGRAPH_ELEM_ACTIONS,
133 MAX_OOO_PROP_ACTIONS,
134 MAX_OOO_PROP_ACTIONS,
135 MAX_OOO_PROP_ACTIONS,
136 MAX_OOO_PROP_ACTIONS,
137 MAX_OOO_PROP_ACTIONS,
138 PROP_OOO_TABLE_CELL_ELEM_ACTIONS,
139 MAX_OOO_PROP_ACTIONS,
140 PROP_OOO_CHART_ELEM_ACTIONS
143 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
145 css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList;
147 public:
148 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
149 const OUString& rQName );
151 using XMLPersAttrListTContext::AddAttribute;
152 void AddAttribute( const OUString &sName ,
153 const OUString &sValue );
154 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken,
155 const OUString &sValue );
157 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
159 virtual void Export() override;
162 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
163 XMLTransformerBase& rImp,
164 const OUString& rQName ) :
165 XMLPersElemContentTContext( rImp, rQName ),
166 m_xAttrList( new XMLMutableAttributeList() )
170 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
171 const OUString &sName ,
172 const OUString &sValue )
174 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
175 ->AddAttribute( sName, sValue );
178 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
179 sal_uInt16 nPrefix, XMLTokenEnum eToken,
180 const OUString &sValue )
182 OUString sName(
183 GetTransformer().GetNamespaceMap().GetQNameByKey(
184 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) );
185 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
186 ->AddAttribute( sName, sValue );
189 void XMLTypedPropertiesOOoTContext_Impl::StartElement(
190 const Reference< XAttributeList >& )
192 // empty, ignore even the attribute list
195 void XMLTypedPropertiesOOoTContext_Impl::Export()
197 if( m_xAttrList->getLength() || HasElementContent() )
199 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList );
200 ExportContent();
201 GetTransformer().GetDocHandler()->endElement( GetQName() );
205 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
207 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
208 m_aPropContexts[MAX_PROP_TYPES];
210 using XMLPropTypes = std::array<XMLPropType, MAX_PROP_TYPES>;
212 XMLPropTypes const & m_rPropTypes;
214 bool const m_bPersistent;
216 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction(
217 TransformerAction_Impl& rAction,
218 sal_uInt16 nPrefix, const OUString& rLocalName,
219 bool bElem );
221 XMLTypedPropertiesOOoTContext_Impl *GetPropContext(
222 XMLPropType eType );
224 public:
225 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
226 const OUString& rQName,
227 const XMLPropTypes& rTypes,
228 bool bPersistent );
230 rtl::Reference<XMLTransformerContext> CreateChildContext(
231 sal_uInt16 nPrefix,
232 const OUString& rLocalName,
233 const OUString& rQName,
234 const Reference< XAttributeList >& rAttrList ) override;
236 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
238 virtual void EndElement() override;
240 virtual void Characters( const OUString& rChars ) override;
242 virtual void Export() override;
244 virtual bool IsPersistent() const override;
247 XMLTypedPropertiesOOoTContext_Impl
248 *XMLPropertiesOOoTContext_Impl::GetPropContext(
249 XMLPropType eType )
251 sal_uInt16 nIndex = MAX_PROP_TYPES;
252 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ )
254 if( m_rPropTypes[i] == eType )
256 nIndex = i;
257 break;
260 if( MAX_PROP_TYPES == nIndex )
261 return nullptr;
263 if( !m_aPropContexts[nIndex].is() )
265 m_aPropContexts[nIndex] =
266 new XMLTypedPropertiesOOoTContext_Impl(
267 GetTransformer(),
268 GetTransformer().GetNamespaceMap().GetQNameByKey(
269 XML_NAMESPACE_STYLE,
270 ::xmloff::token::GetXMLToken(
271 aPropTokens[m_rPropTypes[nIndex]] ) ));
274 return m_aPropContexts[nIndex].get();
277 XMLTypedPropertiesOOoTContext_Impl
278 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction(
279 TransformerAction_Impl& rAction,
280 sal_uInt16 nPrefix, const OUString& rLocalName,
281 bool bElem )
283 rAction.m_nActionType = XML_ATACTION_COPY;
284 sal_uInt16 nIndex = 0;
286 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
287 sal_uInt16 i=0;
288 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i])
290 sal_uInt16 nActionMap =
291 (bElem ? aElemActionMaps : aAttrActionMaps)[m_rPropTypes[i]];
292 if( nActionMap < MAX_OOO_PROP_ACTIONS )
294 XMLTransformerActions *pActions =
295 GetTransformer().GetUserDefinedActions( nActionMap );
296 OSL_ENSURE( pActions, "go no actions" );
297 if( pActions )
299 XMLTransformerActions::const_iterator aIter =
300 pActions->find( aKey );
302 if( aIter != pActions->end() )
304 rAction = (*aIter).second;
305 nIndex = i;
306 break;
310 ++i;
313 #ifdef DBG_UTIL
314 if( !( XML_NAMESPACE_NONE == nPrefix ||
315 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
316 XML_PROP_TYPE_END==m_rPropTypes[1] ||
317 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i]) ) )
319 SAL_WARN("xmloff", "Didn't find property: "
320 << GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix )
321 << ":"
322 << rLocalName
323 << ", assuming <style:"
324 << ::xmloff::token::GetXMLToken( aPropTokens[m_rPropTypes[0]] )
325 << ">" );
327 #endif
329 if( !m_aPropContexts[nIndex].is() )
331 m_aPropContexts[nIndex] =
332 new XMLTypedPropertiesOOoTContext_Impl(
333 GetTransformer(),
334 GetTransformer().GetNamespaceMap().GetQNameByKey(
335 XML_NAMESPACE_STYLE,
336 ::xmloff::token::GetXMLToken(
337 aPropTokens[m_rPropTypes[nIndex]] ) ));
340 return m_aPropContexts[nIndex].get();
343 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl(
344 XMLTransformerBase& rImp,
345 const OUString& rQName,
346 const XMLPropTypes& rTypes,
347 bool bPersistent ) :
348 XMLTransformerContext( rImp, rQName ),
349 // remember the types that belong to the attribute and element lists
350 m_rPropTypes(rTypes),
351 m_bPersistent( bPersistent )
355 rtl::Reference<XMLTransformerContext> XMLPropertiesOOoTContext_Impl::CreateChildContext(
356 sal_uInt16 nPrefix,
357 const OUString& rLocalName,
358 const OUString& rQName,
359 const Reference< XAttributeList >& rAttrList )
361 TransformerAction_Impl aAction;
362 return GetPropContextAndAction( aAction, nPrefix, rLocalName, true )
363 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList );
366 void XMLPropertiesOOoTContext_Impl::StartElement(
367 const Reference< XAttributeList >& rAttrList )
369 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = nullptr;
370 double fIntervalMajor = 0.0;
371 double fIntervalMinor = 0.0;
372 bool bMoveProtect = false;
373 bool bSizeProtect = false;
374 OUString aProtectAttrValue;
375 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = nullptr;
377 /* Attribute <style:mirror> has to be priority over attribute <style:draw>.
378 The filter from OpenDocument file format to OpenOffice.org file format
379 produces styles with both attributes. (#i49139#)
381 bool bExistStyleMirror( false );
382 OUStringBuffer aStyleMirrorAttrValue;
383 bool bExistDrawMirror( false );
384 OUString aDrawMirrorAttrValue;
385 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( nullptr );
387 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
388 for( sal_Int16 i=0; i < nAttrCount; i++ )
390 const OUString sAttrName = rAttrList->getNameByIndex( i );
391 const OUString sAttrValue = rAttrList->getValueByIndex( i );
392 OUString aLocalName;
393 sal_uInt16 nPrefix =
394 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
395 &aLocalName );
396 TransformerAction_Impl aAction;
397 XMLTypedPropertiesOOoTContext_Impl *pContext =
398 GetPropContextAndAction( aAction, nPrefix, aLocalName, false );
399 switch( aAction.m_nActionType )
401 case XML_ATACTION_REMOVE:
402 break;
403 case XML_ATACTION_COPY:
404 pContext->AddAttribute( sAttrName, sAttrValue );
405 break;
406 case XML_ATACTION_COPY_DUPLICATE:
408 pContext->AddAttribute( sAttrName, sAttrValue );
409 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
410 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
411 if( pContext2 )
412 pContext2->AddAttribute( sAttrName, sAttrValue );
414 break;
415 case XML_ATACTION_RENAME:
417 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
418 aAction.GetQNameTokenFromParam1(),
419 sAttrValue );
421 break;
422 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
424 OUString aAttrValue( sAttrValue );
425 GetTransformer().EncodeStyleName(aAttrValue);
426 pContext->AddAttribute( sAttrName, aAttrValue );
428 break;
429 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
431 OUString aAttrValue( sAttrValue );
432 GetTransformer().EncodeStyleName(aAttrValue);
433 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
434 aAction.GetQNameTokenFromParam1(),
435 aAttrValue );
437 break;
438 case XML_ATACTION_NEG_PERCENT:
440 OUString aAttrValue( sAttrValue );
441 XMLTransformerBase::NegPercent(aAttrValue);
442 pContext->AddAttribute( sAttrName, aAttrValue );
444 break;
445 case XML_ATACTION_RENAME_NEG_PERCENT:
447 OUString aAttrValue( sAttrValue );
448 XMLTransformerBase::NegPercent(aAttrValue);
449 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
450 aAction.GetQNameTokenFromParam1(),
451 aAttrValue );
453 break;
454 case XML_ATACTION_INCH2IN:
456 OUString aAttrValue( sAttrValue );
457 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
458 pContext->AddAttribute( sAttrName, aAttrValue );
460 break;
461 case XML_ATACTION_INCH2IN_DUPLICATE:
463 OUString aAttrValue( sAttrValue );
464 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
465 pContext->AddAttribute( sAttrName, aAttrValue );
466 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
467 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
468 if( pContext2 )
469 pContext2->AddAttribute( sAttrName, aAttrValue );
471 break;
472 case XML_ATACTION_INCHS2INS:
474 OUString aAttrValue( sAttrValue );
475 XMLTransformerBase::ReplaceInchWithIn( aAttrValue );
476 pContext->AddAttribute( sAttrName, aAttrValue );
478 break;
479 case XML_PTACTION_LINE_MODE:
481 const OUString& aAttrValue( GetXMLToken(
482 IsXMLToken( sAttrValue, XML_TRUE )
483 ? XML_CONTINUOUS
484 : XML_SKIP_WHITE_SPACE) );
485 OUString aAttrQName(
486 GetTransformer().GetNamespaceMap().GetQNameByKey(
487 XML_NAMESPACE_STYLE,
488 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) );
489 pContext->AddAttribute( aAttrQName, aAttrValue );
491 aAttrQName =
492 GetTransformer().GetNamespaceMap().GetQNameByKey(
493 XML_NAMESPACE_STYLE,
494 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) );
495 pContext->AddAttribute( aAttrQName, aAttrValue );
497 break;
498 case XML_PTACTION_KEEP_WITH_NEXT:
500 const OUString& aAttrValue( GetXMLToken(
501 IsXMLToken( sAttrValue, XML_TRUE )
502 ? XML_ALWAYS
503 : XML_AUTO) );
504 pContext->AddAttribute( sAttrName, aAttrValue );
506 break;
507 case XML_PTACTION_UNDERLINE:
509 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
510 bool bBold = false, bDouble = false;
511 switch( eToken )
513 case XML_SINGLE:
514 eToken = XML_SOLID;
515 break;
516 case XML_DOUBLE:
517 eToken = XML_SOLID;
518 bDouble = true;
519 break;
520 case XML_BOLD:
521 eToken = XML_SOLID;
522 bBold = true;
523 break;
524 case XML_BOLD_DOTTED:
525 eToken = XML_DOTTED;
526 bBold = true;
527 break;
528 case XML_BOLD_DASH:
529 eToken = XML_DASH;
530 bBold = true;
531 break;
532 case XML_BOLD_LONG_DASH:
533 eToken = XML_LONG_DASH;
534 bBold = true;
535 break;
536 case XML_BOLD_DOT_DASH:
537 eToken = XML_DOT_DASH;
538 bBold = true;
539 break;
540 case XML_BOLD_DOT_DOT_DASH:
541 eToken = XML_DOT_DOT_DASH;
542 bBold = true;
543 break;
544 case XML_BOLD_WAVE:
545 eToken = XML_WAVE;
546 bBold = true;
547 break;
548 case XML_DOUBLE_WAVE:
549 eToken = XML_WAVE;
550 bDouble = true;
551 break;
552 case XML_NONE:
553 eToken = XML_NONE;
554 bDouble = false;
555 break;
556 default:
557 OSL_FAIL( "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" );
558 break;
560 pContext->AddAttribute(
561 GetTransformer().GetNamespaceMap().GetQNameByKey(
562 XML_NAMESPACE_STYLE,
563 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ),
564 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
565 : sAttrValue );
566 if( bDouble )
567 pContext->AddAttribute(
568 GetTransformer().GetNamespaceMap().GetQNameByKey(
569 XML_NAMESPACE_STYLE,
570 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ),
571 GetXMLToken( XML_DOUBLE ) );
572 if( bBold )
573 pContext->AddAttribute(
574 GetTransformer().GetNamespaceMap().GetQNameByKey(
575 XML_NAMESPACE_STYLE,
576 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ),
577 GetXMLToken( XML_BOLD ) );
579 break;
580 case XML_PTACTION_LINETHROUGH:
582 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
583 bool bBold = false, bDouble = false;
584 sal_Unicode c = 0;
585 switch( eToken )
587 case XML_SINGLE_LINE:
588 eToken = XML_SOLID;
589 break;
590 case XML_DOUBLE_LINE:
591 eToken = XML_SOLID;
592 bDouble = true;
593 break;
594 case XML_THICK_LINE:
595 eToken = XML_SOLID;
596 bBold = true;
597 break;
598 case XML_SLASH:
599 eToken = XML_SOLID;
600 c = '/';
601 break;
602 case XML_uX:
603 eToken = XML_SOLID;
604 c = 'X';
605 break;
606 default:
607 break;
609 pContext->AddAttribute(
610 GetTransformer().GetNamespaceMap().GetQNameByKey(
611 XML_NAMESPACE_STYLE,
612 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ),
613 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
614 : sAttrValue );
615 if( bDouble )
616 pContext->AddAttribute(
617 GetTransformer().GetNamespaceMap().GetQNameByKey(
618 XML_NAMESPACE_STYLE,
619 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ),
620 GetXMLToken( XML_DOUBLE ) );
621 if( bBold )
622 pContext->AddAttribute(
623 GetTransformer().GetNamespaceMap().GetQNameByKey(
624 XML_NAMESPACE_STYLE,
625 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ),
626 GetXMLToken( XML_BOLD ) );
627 if( c )
628 pContext->AddAttribute(
629 GetTransformer().GetNamespaceMap().GetQNameByKey(
630 XML_NAMESPACE_STYLE,
631 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ),
632 OUString( c ) );
634 break;
635 case XML_PTACTION_SPLINES:
637 sal_Int32 nSplineType = sAttrValue.toInt32();
638 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
639 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) );
641 switch( nSplineType )
643 // straight lines
644 case 0:
645 pContext->AddAttribute(
646 aNewAttrName, GetXMLToken( XML_NONE ));
647 break;
648 // cubic spline
649 case 1:
650 pContext->AddAttribute(
651 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE ));
652 break;
653 // B-spline
654 case 2:
655 pContext->AddAttribute(
656 aNewAttrName, GetXMLToken( XML_B_SPLINE ));
657 break;
659 default:
660 OSL_FAIL( "invalid spline type" );
661 pContext->AddAttribute(
662 aNewAttrName, GetXMLToken( XML_NONE ));
663 break;
666 break;
667 case XML_PTACTION_INTERVAL_MAJOR:
668 pContext->AddAttribute( sAttrName, sAttrValue );
669 ::sax::Converter::convertDouble( fIntervalMajor, sAttrValue );
670 break;
671 case XML_PTACTION_INTERVAL_MINOR:
672 ::sax::Converter::convertDouble( fIntervalMinor, sAttrValue );
673 pIntervalMinorDivisorContext = pContext;
674 break;
675 case XML_PTACTION_SYMBOL:
677 sal_Int32 nSymbolType = sAttrValue.toInt32();
678 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
679 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) );
681 if( nSymbolType >= 0 )
683 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL ));
684 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
685 switch( nSymbolType )
687 // SYMBOL0
688 case 0:
689 // "square" has an awkward token name
690 eToken = XML_GRADIENTSTYLE_SQUARE;
691 break;
692 // SYMBOL1
693 case 1:
694 eToken = XML_DIAMOND;
695 break;
696 // SYMBOL2
697 case 2:
698 eToken = XML_ARROW_DOWN;
699 break;
700 // SYMBOL3
701 case 3:
702 eToken = XML_ARROW_UP;
703 break;
704 // SYMBOL4
705 case 4:
706 eToken = XML_ARROW_RIGHT;
707 break;
708 // SYMBOL5
709 case 5:
710 eToken = XML_ARROW_LEFT;
711 break;
712 // SYMBOL6
713 case 6:
714 eToken = XML_BOW_TIE;
715 break;
716 // SYMBOL7
717 case 7:
718 eToken = XML_HOURGLASS;
719 break;
720 case 8:
721 eToken = XML_CIRCLE;
722 break;
723 case 9:
724 eToken = XML_STAR;
725 break;
726 case 10:
727 eToken = XML_X;
728 break;
729 case 11:
730 eToken = XML_PLUS;
731 break;
732 case 12:
733 eToken = XML_ASTERISK;
734 break;
735 case 13:
736 eToken = XML_HORIZONTAL_BAR;
737 break;
738 case 14:
739 eToken = XML_VERTICAL_BAR;
740 break;
741 default:
742 OSL_FAIL( "invalid named symbol" );
743 break;
746 if( eToken != XML_TOKEN_INVALID )
748 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
749 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )),
750 GetXMLToken( eToken ));
753 else
755 switch( nSymbolType )
757 // NONE
758 case -3:
759 pContext->AddAttribute(
760 aNewAttrName, GetXMLToken( XML_NONE ));
761 break;
762 // AUTO
763 case -2:
764 pContext->AddAttribute(
765 aNewAttrName, GetXMLToken( XML_AUTOMATIC ));
766 break;
767 // BITMAPURL
768 case -1:
769 pContext->AddAttribute(
770 aNewAttrName, GetXMLToken( XML_IMAGE ));
771 break;
772 default:
773 OSL_FAIL( "invalid symbol type" );
774 pContext->AddAttribute(
775 aNewAttrName, GetXMLToken( XML_NONE ));
776 break;
780 break;
781 case XML_PTACTION_SYMBOL_IMAGE_NAME:
783 // create an xlink:href element for URI attribute
784 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext(
785 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey(
786 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE )));
787 rtl::Reference<XMLTransformerContext> xSymbolImageContext(pSymbolImageContext);
789 OUString aAttrValue( sAttrValue );
790 if( GetTransformer().ConvertURIToOASIS( aAttrValue, true ))
792 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue );
793 pContext->AddContent(xSymbolImageContext);
796 break;
798 // #i25616#
799 case XML_PTACTION_TRANSPARENCY :
801 OUString aAttrValue( sAttrValue );
802 XMLTransformerBase::NegPercent(aAttrValue);
803 pContext->AddAttribute( XML_NAMESPACE_DRAW,
804 XML_OPACITY,
805 aAttrValue );
806 pContext->AddAttribute( XML_NAMESPACE_DRAW,
807 XML_IMAGE_OPACITY,
808 aAttrValue );
810 break;
812 case XML_PTACTION_BREAK_INSIDE:
814 pContext->AddAttribute(
815 XML_NAMESPACE_FO, XML_KEEP_TOGETHER,
816 GetXMLToken(
817 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID )
818 ? XML_ALWAYS
819 : XML_AUTO ) );
821 break;
822 case XML_ATACTION_CAPTION_ESCAPE_OOO:
824 OUString aAttrValue( sAttrValue );
825 if( aAttrValue.indexOf( '%' ) != -1 )
827 sal_Int32 nValue = 0;
828 ::sax::Converter::convertPercent( nValue, sAttrValue );
829 if( nValue )
831 nValue /= 100;
832 OUStringBuffer aOut;
833 ::sax::Converter::convertPercent( aOut, nValue );
834 aAttrValue = aOut.makeStringAndClear();
837 else
839 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
842 pContext->AddAttribute( sAttrName, aAttrValue );
844 break;
845 case XML_ATACTION_MOVE_PROTECT:
846 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE );
847 pProtectContext = pContext;
848 break;
849 case XML_ATACTION_SIZE_PROTECT:
850 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE );
851 pProtectContext = pContext;
852 break;
853 case XML_ATACTION_PROTECT:
854 aProtectAttrValue = sAttrValue;
855 pProtectContext = pContext;
856 break;
857 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values
859 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
860 aDrawMirrorAttrValue =
861 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE )
862 ? XML_HORIZONTAL : XML_NONE );
863 bExistDrawMirror = true;
864 pMirrorContext = pContext;
866 break;
867 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
868 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values
870 SvXMLTokenEnumerator aTokenEnum( sAttrValue );
871 OUString aToken;
872 while( aTokenEnum.getNextToken( aToken ) )
874 if ( !aStyleMirrorAttrValue.isEmpty() )
876 aStyleMirrorAttrValue.append(" ");
879 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) )
881 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_EVEN ));
883 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) )
885 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_ODD ));
887 else
889 aStyleMirrorAttrValue.append(aToken);
892 bExistStyleMirror = true;
893 pMirrorContext = pContext;
895 break;
896 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage
898 double fValue = sAttrValue.toDouble();
899 sal_Int32 nValue = static_cast<sal_Int32>((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) );
901 OUStringBuffer aOut;
902 ::sax::Converter::convertPercent( aOut, nValue );
903 OUString aAttrValue( aOut.makeStringAndClear() );
904 pContext->AddAttribute( sAttrName, aAttrValue );
906 break;
907 case XML_ATACTION_OPACITY_FIX:
909 sal_Int32 nValue;
910 if( sAttrValue.indexOf( '%' ) != -1 )
912 ::sax::Converter::convertPercent( nValue, sAttrValue );
914 else
916 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 );
918 nValue = 100 - nValue;
920 OUStringBuffer aOut;
921 ::sax::Converter::convertPercent( aOut, nValue );
922 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() );
924 break;
925 default:
926 OSL_ENSURE( false, "unknown action" );
927 break;
931 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
932 if ( bExistStyleMirror )
934 pMirrorContext->AddAttribute(
935 GetTransformer().GetNamespaceMap().GetQNameByKey(
936 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
937 aStyleMirrorAttrValue.makeStringAndClear());
939 else if ( bExistDrawMirror )
941 pMirrorContext->AddAttribute(
942 GetTransformer().GetNamespaceMap().GetQNameByKey(
943 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
944 aDrawMirrorAttrValue);
947 if (bMoveProtect || bSizeProtect || !aProtectAttrValue.isEmpty())
949 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) )
950 aProtectAttrValue.clear();
952 const OUString& rPosition = GetXMLToken( XML_POSITION );
953 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) )
955 if( !aProtectAttrValue.isEmpty() )
956 aProtectAttrValue += " ";
957 aProtectAttrValue += rPosition;
960 const OUString& rSize = GetXMLToken( XML_SIZE );
961 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) )
963 if( !aProtectAttrValue.isEmpty() )
964 aProtectAttrValue += " ";
965 aProtectAttrValue += rSize;
968 assert(pProtectContext && "coverity[var_deref_model] - pProtectContext should be assigned in a superset of the enclosing if condition entry logic");
969 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue );
972 if( pIntervalMinorDivisorContext )
974 if( fIntervalMinor != 0.0 )
976 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >(
977 ::rtl::math::round( fIntervalMajor / fIntervalMinor ));
979 pIntervalMinorDivisorContext->AddAttribute(
980 GetTransformer().GetNamespaceMap().GetQNameByKey(
981 XML_NAMESPACE_CHART,
982 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )),
983 OUString::number( nIntervalMinorDivisor ));
988 void XMLPropertiesOOoTContext_Impl::EndElement()
990 if( !m_bPersistent )
991 Export();
994 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& )
996 // ignore them
999 void XMLPropertiesOOoTContext_Impl::Export()
1002 for(rtl::Reference<XMLTypedPropertiesOOoTContext_Impl> & rPropContext : m_aPropContexts)
1004 if( rPropContext.is() )
1005 rPropContext->Export();
1009 bool XMLPropertiesOOoTContext_Impl::IsPersistent() const
1011 return m_bPersistent;
1014 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp,
1015 const OUString& rQName,
1016 XMLFamilyType eT,
1017 bool bPersistent ) :
1018 XMLPersElemContentTContext( rImp, rQName ),
1019 m_eFamily( eT ),
1020 m_bPersistent( bPersistent )
1024 XMLStyleOOoTContext::XMLStyleOOoTContext(
1025 XMLTransformerBase& rImp,
1026 const OUString& rQName,
1027 XMLFamilyType eT,
1028 sal_uInt16 nPrefix,
1029 ::xmloff::token::XMLTokenEnum eToken,
1030 bool bPersistent ) :
1031 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
1032 m_eFamily( eT ),
1033 m_bPersistent( bPersistent )
1037 XMLStyleOOoTContext::~XMLStyleOOoTContext()
1041 rtl::Reference<XMLTransformerContext> XMLStyleOOoTContext::CreateChildContext(
1042 sal_uInt16 nPrefix,
1043 const OUString& rLocalName,
1044 const OUString& rQName,
1045 const Reference< XAttributeList >& rAttrList )
1047 rtl::Reference<XMLTransformerContext> pContext;
1049 if( XML_NAMESPACE_STYLE == nPrefix &&
1050 IsXMLToken( rLocalName, XML_PROPERTIES ) )
1052 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END )
1054 OSL_ENSURE( false, "unexpected properties element" );
1055 pContext = m_bPersistent
1056 ? XMLPersElemContentTContext::CreateChildContext(
1057 nPrefix, rLocalName, rQName, rAttrList )
1058 : XMLTransformerContext::CreateChildContext(
1059 nPrefix, rLocalName, rQName, rAttrList );
1061 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END )
1063 sal_uInt16 nActionMap =
1064 aAttrActionMaps[aPropTypes[m_eFamily][0]];
1065 if( nActionMap < MAX_OOO_PROP_ACTIONS )
1067 pContext.set(new XMLPropertiesOOoTContext_Impl(
1068 GetTransformer(), rQName,
1069 aPropTypes[m_eFamily], m_bPersistent ));
1071 else
1073 if( m_bPersistent )
1074 pContext.set(new XMLPersElemContentTContext(
1075 GetTransformer(), rQName,
1076 XML_NAMESPACE_STYLE,
1077 aPropTokens[aPropTypes[m_eFamily][0]] ));
1078 else
1079 pContext.set(new XMLRenameElemTransformerContext(
1080 GetTransformer(), rQName,
1081 XML_NAMESPACE_STYLE,
1082 aPropTokens[aPropTypes[m_eFamily][0]] ));
1085 else
1087 pContext.set(new XMLPropertiesOOoTContext_Impl(
1088 GetTransformer(), rQName,
1089 aPropTypes[m_eFamily], m_bPersistent));
1092 if( m_bPersistent )
1093 AddContent( pContext );
1095 else
1097 pContext = m_bPersistent
1098 ? XMLPersElemContentTContext::CreateChildContext(
1099 nPrefix, rLocalName, rQName, rAttrList )
1100 : XMLTransformerContext::CreateChildContext(
1101 nPrefix, rLocalName, rQName, rAttrList );
1104 return pContext;
1107 void XMLStyleOOoTContext::StartElement(
1108 const Reference< XAttributeList >& rAttrList )
1110 XMLTransformerActions *pActions =
1111 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS );
1112 OSL_ENSURE( pActions, "go no actions" );
1114 Reference< XAttributeList > xAttrList( rAttrList );
1115 XMLMutableAttributeList *pMutableAttrList = nullptr;
1116 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1117 for( sal_Int16 i=0; i < nAttrCount; i++ )
1119 const OUString sAttrName = xAttrList->getNameByIndex( i );
1120 OUString aLocalName;
1121 sal_uInt16 nPrefix =
1122 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
1123 &aLocalName );
1124 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
1125 XMLTransformerActions::const_iterator aIter =
1126 pActions->find( aKey );
1127 if( aIter != pActions->end() )
1129 if( !pMutableAttrList )
1131 pMutableAttrList =
1132 new XMLMutableAttributeList( xAttrList );
1133 xAttrList = pMutableAttrList;
1135 const OUString sAttrValue = xAttrList->getValueByIndex( i );
1136 switch( (*aIter).second.m_nActionType )
1138 case XML_ATACTION_STYLE_FAMILY:
1140 bool bControl = false;
1141 if( XML_FAMILY_TYPE_END == m_eFamily )
1143 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) )
1144 m_eFamily = XML_FAMILY_TYPE_GRAPHIC;
1145 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) )
1146 m_eFamily = XML_FAMILY_TYPE_PRESENTATION;
1147 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) )
1148 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE;
1149 else if( IsXMLToken( sAttrValue, XML_TEXT) )
1150 m_eFamily = XML_FAMILY_TYPE_TEXT;
1151 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) )
1152 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1153 else if( IsXMLToken( sAttrValue, XML_RUBY) )
1154 m_eFamily = XML_FAMILY_TYPE_RUBY;
1155 else if( IsXMLToken( sAttrValue, XML_SECTION) )
1156 m_eFamily = XML_FAMILY_TYPE_SECTION;
1157 else if( IsXMLToken( sAttrValue, XML_TABLE) )
1158 m_eFamily = XML_FAMILY_TYPE_TABLE;
1159 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) )
1160 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN;
1161 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) )
1162 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW;
1163 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) )
1164 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL;
1165 else if( IsXMLToken( sAttrValue, XML_CHART) )
1166 m_eFamily = XML_FAMILY_TYPE_CHART;
1167 else if( IsXMLToken( sAttrValue, XML_CONTROL) )
1169 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1170 bControl = true;
1173 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily )
1175 pMutableAttrList->SetValueByIndex( i,
1176 GetXMLToken( XML_GRAPHIC ) );
1178 else if( bControl )
1180 pMutableAttrList->SetValueByIndex( i,
1181 GetXMLToken( XML_PARAGRAPH ) );
1184 break;
1185 case XML_ATACTION_INCH2IN:
1187 OUString aAttrValue( sAttrValue );
1188 if( XMLTransformerBase::ReplaceSingleInchWithIn(
1189 aAttrValue ) )
1190 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1192 break;
1193 case XML_ATACTION_ENCODE_STYLE_NAME:
1195 OUString aAttrValue( sAttrValue );
1196 if( GetTransformer().EncodeStyleName(aAttrValue) )
1198 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1199 OUString aNewAttrQName(
1200 GetTransformer().GetNamespaceMap().
1201 GetQNameByKey(
1202 nPrefix, ::xmloff::token::GetXMLToken(
1203 XML_DISPLAY_NAME ) ) );
1204 pMutableAttrList->AddAttribute( aNewAttrQName,
1205 sAttrValue );
1208 break;
1209 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
1211 OUString aAttrValue( sAttrValue );
1212 if( GetTransformer().EncodeStyleName(aAttrValue) )
1213 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1215 break;
1216 case XML_ATACTION_NEG_PERCENT:
1218 OUString aAttrValue( sAttrValue );
1219 if( XMLTransformerBase::NegPercent(aAttrValue) )
1220 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1222 break;
1223 case XML_ATACTION_URI_OOO:
1225 OUString aAttrValue( sAttrValue );
1226 if( GetTransformer().ConvertURIToOASIS( aAttrValue,
1227 static_cast< bool >((*aIter).second.m_nParam1)))
1228 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1230 break;
1231 default:
1232 OSL_ENSURE( false, "unknown action" );
1233 break;
1237 if( XML_FAMILY_TYPE_END == m_eFamily )
1238 m_eFamily = XML_FAMILY_TYPE_TEXT;
1239 if( m_bPersistent )
1240 XMLPersElemContentTContext::StartElement( xAttrList );
1241 else
1242 GetTransformer().GetDocHandler()->startElement( GetExportQName(), xAttrList );
1245 void XMLStyleOOoTContext::EndElement()
1247 if( m_bPersistent )
1248 XMLPersElemContentTContext::EndElement();
1249 else
1250 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
1253 void XMLStyleOOoTContext::Characters( const OUString& )
1255 // element content only:
1258 bool XMLStyleOOoTContext::IsPersistent() const
1260 return m_bPersistent;
1263 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions(
1264 sal_uInt16 nType )
1266 XMLTransformerActionInit const *pInit = nullptr;
1268 switch( nType )
1270 case PROP_OOO_GRAPHIC_ATTR_ACTIONS:
1271 pInit = aGraphicPropertyOOoAttrActionTable;
1272 break;
1273 case PROP_OOO_GRAPHIC_ELEM_ACTIONS:
1274 pInit = aGraphicPropertyOOoElemActionTable;
1275 break;
1276 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS:
1277 pInit = aDrawingPagePropertyOOoAttrActionTable;
1278 break;
1279 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS:
1280 pInit = aPageLayoutPropertyOOoAttrActionTable;
1281 break;
1282 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS:
1283 pInit = aHeaderFooterPropertyOOoAttrActionTable;
1284 break;
1285 case PROP_OOO_TEXT_ATTR_ACTIONS:
1286 pInit = aTextPropertyOOoAttrActionTable;
1287 break;
1288 case PROP_OOO_TEXT_ELEM_ACTIONS:
1289 pInit = aTextPropertyOOoElemActionTable;
1290 break;
1291 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS:
1292 pInit = aParagraphPropertyOOoAttrActionTable;
1293 break;
1294 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS:
1295 pInit = aParagraphPropertyOOoElemActionTable;
1296 break;
1297 case PROP_OOO_SECTION_ATTR_ACTIONS:
1298 pInit = aSectionPropertyOOoAttrActionTable;
1299 break;
1300 case PROP_OOO_TABLE_ATTR_ACTIONS:
1301 pInit = aTablePropertyOOoAttrActionTable;
1302 break;
1303 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS:
1304 pInit = aTableColumnPropertyOOoAttrActionTable;
1305 break;
1306 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS:
1307 pInit = aTableRowPropertyOOoAttrActionTable;
1308 break;
1309 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS:
1310 pInit = aTableCellPropertyOOoAttrActionTable;
1311 break;
1312 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS:
1313 pInit = aTableCellPropertyOOoElemActionTable;
1314 break;
1315 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS:
1316 pInit = aListLevelPropertyOOoAttrActionTable;
1317 break;
1318 case PROP_OOO_CHART_ATTR_ACTIONS:
1319 pInit = aChartPropertyOOoAttrActionTable;
1320 break;
1321 case PROP_OOO_CHART_ELEM_ACTIONS:
1322 pInit = aChartPropertyOOoElemActionTable;
1323 break;
1326 XMLTransformerActions *pActions = nullptr;
1327 if( pInit )
1328 pActions = new XMLTransformerActions( pInit );
1330 return pActions;
1333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */