tdf#164627 docx export: consolidate getWordCompatibilityMode()
[LibreOffice.git] / xmloff / source / transform / StyleOOoTContext.cxx
blob490baa5b4905a21e1f4b36b1fdf42fdc33158e4f
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/XDocumentHandler.hpp>
22 #include <sax/tools/converter.hxx>
24 #include <xmloff/namespacemap.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include "PropType.hxx"
28 #include "DeepTContext.hxx"
29 #include "RenameElemTContext.hxx"
30 #include "ActionMapTypesOOo.hxx"
31 #include "MutableAttrList.hxx"
32 #include "TransformerActions.hxx"
33 #include "PropertyActionsOOo.hxx"
34 #include "TransformerBase.hxx"
36 #include "StyleOOoTContext.hxx"
37 #include <xmloff/xmluconv.hxx>
38 #include <rtl/math.hxx>
39 #include <rtl/ustrbuf.hxx>
40 #include <osl/diagnose.h>
41 #include <sal/log.hxx>
42 #include <array>
44 using namespace ::xmloff::token;
45 using namespace ::com::sun::star::uno;
46 using namespace ::com::sun::star::xml::sax;
48 const sal_uInt16 MAX_PROP_TYPES = 4;
49 #define ENTRY4(a,b,c,d) \
50 { a, b, c, d }
51 #define ENTRY3(a,b,c) \
52 { a, b, c, XML_PROP_TYPE_END }
53 #define ENTRY2(a,b) \
54 { a, b, XML_PROP_TYPE_END, XML_PROP_TYPE_END }
55 #define ENTRY1(a) \
56 { a, XML_PROP_TYPE_END, XML_PROP_TYPE_END, XML_PROP_TYPE_END }
58 const std::array<XMLPropType,MAX_PROP_TYPES> aPropTypes[XML_FAMILY_TYPE_END] =
60 ENTRY3( XML_PROP_TYPE_GRAPHIC, XML_PROP_TYPE_PARAGRAPH, XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_GRAPHIC,
61 ENTRY3( XML_PROP_TYPE_GRAPHIC, XML_PROP_TYPE_PARAGRAPH, XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_PRESENTATION,
62 ENTRY1( XML_PROP_TYPE_DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE,
63 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_MASTER_PAGE
64 ENTRY1( XML_PROP_TYPE_PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT,
65 ENTRY1( XML_PROP_TYPE_HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER
66 ENTRY1( XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_TEXT,
67 ENTRY2( XML_PROP_TYPE_PARAGRAPH, XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_PARAGRAPH,
68 ENTRY1( XML_PROP_TYPE_RUBY ), // XML_FAMILY_TYPE_RUBY,
69 ENTRY1( XML_PROP_TYPE_SECTION ), // XML_FAMILY_TYPE_SECTION,
70 ENTRY1( XML_PROP_TYPE_TABLE ), // XML_FAMILY_TYPE_TABLE,
71 ENTRY1( XML_PROP_TYPE_TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN,
72 ENTRY1( XML_PROP_TYPE_TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW,
73 ENTRY3( XML_PROP_TYPE_TABLE_CELL, XML_PROP_TYPE_PARAGRAPH, XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_TABLE_CELL,
74 ENTRY1( XML_PROP_TYPE_LIST_LEVEL ), // XML_FAMILY_TYPE_LIST,
75 ENTRY4( XML_PROP_TYPE_CHART, XML_PROP_TYPE_GRAPHIC, XML_PROP_TYPE_PARAGRAPH, XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_CHART,
76 ENTRY1( XML_PROP_TYPE_TEXT ), // XML_FAMILY_TYPE_DATA,
77 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_GRADIENT,
78 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_HATCH,
79 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_FILL_IMAGE,
80 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_STROKE_DASH,
81 ENTRY1( XML_PROP_TYPE_END ), // XML_FAMILY_TYPE_MARKER,
84 const XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] =
86 XML_GRAPHIC_PROPERTIES,
87 XML_DRAWING_PAGE_PROPERTIES,
88 XML_PAGE_LAYOUT_PROPERTIES,
89 XML_HEADER_FOOTER_PROPERTIES,
90 XML_TEXT_PROPERTIES,
91 XML_PARAGRAPH_PROPERTIES,
92 XML_RUBY_PROPERTIES,
93 XML_SECTION_PROPERTIES,
94 XML_TABLE_PROPERTIES,
95 XML_TABLE_COLUMN_PROPERTIES,
96 XML_TABLE_ROW_PROPERTIES,
97 XML_TABLE_CELL_PROPERTIES,
98 XML_LIST_LEVEL_PROPERTIES,
99 XML_CHART_PROPERTIES
102 const sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] =
104 PROP_OOO_GRAPHIC_ATTR_ACTIONS,
105 PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE
106 PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS,
107 PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS,
108 PROP_OOO_TEXT_ATTR_ACTIONS,
109 PROP_OOO_PARAGRAPH_ATTR_ACTIONS,
110 MAX_OOO_PROP_ACTIONS, // RUBY
111 PROP_OOO_SECTION_ATTR_ACTIONS,
112 PROP_OOO_TABLE_ATTR_ACTIONS,
113 PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS,
114 PROP_OOO_TABLE_ROW_ATTR_ACTIONS,
115 PROP_OOO_TABLE_CELL_ATTR_ACTIONS,
116 PROP_OOO_LIST_LEVEL_ATTR_ACTIONS,
117 PROP_OOO_CHART_ATTR_ACTIONS
120 const sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] =
122 PROP_OOO_GRAPHIC_ELEM_ACTIONS,
123 MAX_OOO_PROP_ACTIONS,
124 MAX_OOO_PROP_ACTIONS,
125 MAX_OOO_PROP_ACTIONS,
126 PROP_OOO_TEXT_ELEM_ACTIONS,
127 PROP_OOO_PARAGRAPH_ELEM_ACTIONS,
128 MAX_OOO_PROP_ACTIONS,
129 MAX_OOO_PROP_ACTIONS,
130 MAX_OOO_PROP_ACTIONS,
131 MAX_OOO_PROP_ACTIONS,
132 MAX_OOO_PROP_ACTIONS,
133 PROP_OOO_TABLE_CELL_ELEM_ACTIONS,
134 MAX_OOO_PROP_ACTIONS,
135 PROP_OOO_CHART_ELEM_ACTIONS
138 namespace {
140 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext
142 css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList;
144 public:
145 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
146 const OUString& rQName );
148 using XMLPersAttrListTContext::AddAttribute;
149 void AddAttribute( const OUString &sName ,
150 const OUString &sValue );
151 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken,
152 const OUString &sValue );
154 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
156 virtual void Export() override;
161 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl(
162 XMLTransformerBase& rImp,
163 const OUString& rQName ) :
164 XMLPersElemContentTContext( rImp, rQName ),
165 m_xAttrList( new XMLMutableAttributeList() )
169 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
170 const OUString &sName ,
171 const OUString &sValue )
173 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
174 ->AddAttribute( sName, sValue );
177 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute(
178 sal_uInt16 nPrefix, XMLTokenEnum eToken,
179 const OUString &sValue )
181 OUString sName(
182 GetTransformer().GetNamespaceMap().GetQNameByKey(
183 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) );
184 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
185 ->AddAttribute( sName, sValue );
188 void XMLTypedPropertiesOOoTContext_Impl::StartElement(
189 const Reference< XAttributeList >& )
191 // empty, ignore even the attribute list
194 void XMLTypedPropertiesOOoTContext_Impl::Export()
196 if( m_xAttrList->getLength() || HasElementContent() )
198 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList );
199 ExportContent();
200 GetTransformer().GetDocHandler()->endElement( GetQName() );
204 namespace {
206 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext
208 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl >
209 m_aPropContexts[MAX_PROP_TYPES];
211 using XMLPropTypes = std::array<XMLPropType, MAX_PROP_TYPES>;
213 XMLPropTypes const & m_rPropTypes;
215 bool const m_bPersistent;
217 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction(
218 TransformerAction_Impl& rAction,
219 sal_uInt16 nPrefix, const OUString& rLocalName,
220 bool bElem );
222 XMLTypedPropertiesOOoTContext_Impl *GetPropContext(
223 XMLPropType eType );
225 public:
226 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer,
227 const OUString& rQName,
228 const XMLPropTypes& rTypes,
229 bool bPersistent );
231 rtl::Reference<XMLTransformerContext> CreateChildContext(
232 sal_uInt16 nPrefix,
233 const OUString& rLocalName,
234 const OUString& rQName,
235 const Reference< XAttributeList >& rAttrList ) override;
237 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& rAttrList ) override;
239 virtual void EndElement() override;
241 virtual void Characters( const OUString& rChars ) override;
243 virtual void Export() override;
245 virtual bool IsPersistent() const override;
250 XMLTypedPropertiesOOoTContext_Impl
251 *XMLPropertiesOOoTContext_Impl::GetPropContext(
252 XMLPropType eType )
254 sal_uInt16 nIndex = MAX_PROP_TYPES;
255 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ )
257 if( m_rPropTypes[i] == eType )
259 nIndex = i;
260 break;
263 if( MAX_PROP_TYPES == nIndex )
264 return nullptr;
266 if( !m_aPropContexts[nIndex].is() )
268 m_aPropContexts[nIndex] =
269 new XMLTypedPropertiesOOoTContext_Impl(
270 GetTransformer(),
271 GetTransformer().GetNamespaceMap().GetQNameByKey(
272 XML_NAMESPACE_STYLE,
273 ::xmloff::token::GetXMLToken(
274 aPropTokens[m_rPropTypes[nIndex]] ) ));
277 return m_aPropContexts[nIndex].get();
280 XMLTypedPropertiesOOoTContext_Impl
281 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction(
282 TransformerAction_Impl& rAction,
283 sal_uInt16 nPrefix, const OUString& rLocalName,
284 bool bElem )
286 rAction.m_nActionType = XML_ATACTION_COPY;
287 sal_uInt16 nIndex = 0;
289 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
290 sal_uInt16 i=0;
291 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i])
293 sal_uInt16 nActionMap =
294 (bElem ? aElemActionMaps : aAttrActionMaps)[m_rPropTypes[i]];
295 if( nActionMap < MAX_OOO_PROP_ACTIONS )
297 XMLTransformerActions *pActions =
298 GetTransformer().GetUserDefinedActions( nActionMap );
299 OSL_ENSURE( pActions, "go no actions" );
300 if( pActions )
302 XMLTransformerActions::const_iterator aIter =
303 pActions->find( aKey );
305 if( aIter != pActions->end() )
307 rAction = (*aIter).second;
308 nIndex = i;
309 break;
313 ++i;
316 #ifdef DBG_UTIL
317 if( !( XML_NAMESPACE_NONE == nPrefix ||
318 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) ||
319 XML_PROP_TYPE_END==m_rPropTypes[1] ||
320 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_rPropTypes[i]) ) )
322 SAL_WARN("xmloff", "Didn't find property: "
323 << GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix )
324 << ":"
325 << rLocalName
326 << ", assuming <style:"
327 << ::xmloff::token::GetXMLToken( aPropTokens[m_rPropTypes[0]] )
328 << ">" );
330 #endif
332 if( !m_aPropContexts[nIndex].is() )
334 m_aPropContexts[nIndex] =
335 new XMLTypedPropertiesOOoTContext_Impl(
336 GetTransformer(),
337 GetTransformer().GetNamespaceMap().GetQNameByKey(
338 XML_NAMESPACE_STYLE,
339 ::xmloff::token::GetXMLToken(
340 aPropTokens[m_rPropTypes[nIndex]] ) ));
343 return m_aPropContexts[nIndex].get();
346 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl(
347 XMLTransformerBase& rImp,
348 const OUString& rQName,
349 const XMLPropTypes& rTypes,
350 bool bPersistent ) :
351 XMLTransformerContext( rImp, rQName ),
352 // remember the types that belong to the attribute and element lists
353 m_rPropTypes(rTypes),
354 m_bPersistent( bPersistent )
358 rtl::Reference<XMLTransformerContext> XMLPropertiesOOoTContext_Impl::CreateChildContext(
359 sal_uInt16 nPrefix,
360 const OUString& rLocalName,
361 const OUString& rQName,
362 const Reference< XAttributeList >& rAttrList )
364 TransformerAction_Impl aAction;
365 return GetPropContextAndAction( aAction, nPrefix, rLocalName, true )
366 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList );
369 void XMLPropertiesOOoTContext_Impl::StartElement(
370 const Reference< XAttributeList >& rAttrList )
372 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = nullptr;
373 double fIntervalMajor = 0.0;
374 double fIntervalMinor = 0.0;
375 bool bMoveProtect = false;
376 bool bSizeProtect = false;
377 OUString aProtectAttrValue;
378 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = nullptr;
380 /* Attribute <style:mirror> has to be priority over attribute <style:draw>.
381 The filter from OpenDocument file format to OpenOffice.org file format
382 produces styles with both attributes. (#i49139#)
384 bool bExistStyleMirror( false );
385 OUStringBuffer aStyleMirrorAttrValue;
386 bool bExistDrawMirror( false );
387 OUString aDrawMirrorAttrValue;
388 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( nullptr );
390 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
391 for( sal_Int16 i=0; i < nAttrCount; i++ )
393 const OUString sAttrName = rAttrList->getNameByIndex( i );
394 const OUString sAttrValue = rAttrList->getValueByIndex( i );
395 OUString aLocalName;
396 sal_uInt16 nPrefix =
397 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
398 &aLocalName );
399 TransformerAction_Impl aAction;
400 XMLTypedPropertiesOOoTContext_Impl *pContext =
401 GetPropContextAndAction( aAction, nPrefix, aLocalName, false );
402 switch( aAction.m_nActionType )
404 case XML_ATACTION_REMOVE:
405 break;
406 case XML_ATACTION_COPY:
407 pContext->AddAttribute( sAttrName, sAttrValue );
408 break;
409 case XML_ATACTION_COPY_DUPLICATE:
411 pContext->AddAttribute( sAttrName, sAttrValue );
412 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
413 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
414 if( pContext2 )
415 pContext2->AddAttribute( sAttrName, sAttrValue );
417 break;
418 case XML_ATACTION_RENAME:
420 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
421 aAction.GetQNameTokenFromParam1(),
422 sAttrValue );
424 break;
425 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
427 OUString aAttrValue( sAttrValue );
428 GetTransformer().EncodeStyleName(aAttrValue);
429 pContext->AddAttribute( sAttrName, aAttrValue );
431 break;
432 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
434 OUString aAttrValue( sAttrValue );
435 GetTransformer().EncodeStyleName(aAttrValue);
436 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
437 aAction.GetQNameTokenFromParam1(),
438 aAttrValue );
440 break;
441 case XML_ATACTION_NEG_PERCENT:
443 OUString aAttrValue( sAttrValue );
444 XMLTransformerBase::NegPercent(aAttrValue);
445 pContext->AddAttribute( sAttrName, aAttrValue );
447 break;
448 case XML_ATACTION_RENAME_NEG_PERCENT:
450 OUString aAttrValue( sAttrValue );
451 XMLTransformerBase::NegPercent(aAttrValue);
452 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(),
453 aAction.GetQNameTokenFromParam1(),
454 aAttrValue );
456 break;
457 case XML_ATACTION_INCH2IN:
459 OUString aAttrValue( sAttrValue );
460 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
461 pContext->AddAttribute( sAttrName, aAttrValue );
463 break;
464 case XML_ATACTION_INCH2IN_DUPLICATE:
466 OUString aAttrValue( sAttrValue );
467 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
468 pContext->AddAttribute( sAttrName, aAttrValue );
469 XMLTypedPropertiesOOoTContext_Impl *pContext2 =
470 GetPropContext( static_cast<XMLPropType>(aAction.m_nParam1) );
471 if( pContext2 )
472 pContext2->AddAttribute( sAttrName, aAttrValue );
474 break;
475 case XML_ATACTION_INCHS2INS:
477 OUString aAttrValue( sAttrValue );
478 XMLTransformerBase::ReplaceInchWithIn( aAttrValue );
479 pContext->AddAttribute( sAttrName, aAttrValue );
481 break;
482 case XML_PTACTION_LINE_MODE:
484 const OUString& aAttrValue( GetXMLToken(
485 IsXMLToken( sAttrValue, XML_TRUE )
486 ? XML_CONTINUOUS
487 : XML_SKIP_WHITE_SPACE) );
488 OUString aAttrQName(
489 GetTransformer().GetNamespaceMap().GetQNameByKey(
490 XML_NAMESPACE_STYLE,
491 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) );
492 pContext->AddAttribute( aAttrQName, aAttrValue );
494 aAttrQName =
495 GetTransformer().GetNamespaceMap().GetQNameByKey(
496 XML_NAMESPACE_STYLE,
497 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) );
498 pContext->AddAttribute( aAttrQName, aAttrValue );
500 break;
501 case XML_PTACTION_KEEP_WITH_NEXT:
503 const OUString& aAttrValue( GetXMLToken(
504 IsXMLToken( sAttrValue, XML_TRUE )
505 ? XML_ALWAYS
506 : XML_AUTO) );
507 pContext->AddAttribute( sAttrName, aAttrValue );
509 break;
510 case XML_PTACTION_UNDERLINE:
512 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
513 bool bBold = false, bDouble = false;
514 switch( eToken )
516 case XML_SINGLE:
517 eToken = XML_SOLID;
518 break;
519 case XML_DOUBLE:
520 eToken = XML_SOLID;
521 bDouble = true;
522 break;
523 case XML_BOLD:
524 eToken = XML_SOLID;
525 bBold = true;
526 break;
527 case XML_BOLD_DOTTED:
528 eToken = XML_DOTTED;
529 bBold = true;
530 break;
531 case XML_BOLD_DASH:
532 eToken = XML_DASH;
533 bBold = true;
534 break;
535 case XML_BOLD_LONG_DASH:
536 eToken = XML_LONG_DASH;
537 bBold = true;
538 break;
539 case XML_BOLD_DOT_DASH:
540 eToken = XML_DOT_DASH;
541 bBold = true;
542 break;
543 case XML_BOLD_DOT_DOT_DASH:
544 eToken = XML_DOT_DOT_DASH;
545 bBold = true;
546 break;
547 case XML_BOLD_WAVE:
548 eToken = XML_WAVE;
549 bBold = true;
550 break;
551 case XML_DOUBLE_WAVE:
552 eToken = XML_WAVE;
553 bDouble = true;
554 break;
555 case XML_NONE:
556 eToken = XML_NONE;
557 bDouble = false;
558 break;
559 default:
560 OSL_FAIL( "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" );
561 break;
563 pContext->AddAttribute(
564 GetTransformer().GetNamespaceMap().GetQNameByKey(
565 XML_NAMESPACE_STYLE,
566 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ),
567 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
568 : sAttrValue );
569 if( bDouble )
570 pContext->AddAttribute(
571 GetTransformer().GetNamespaceMap().GetQNameByKey(
572 XML_NAMESPACE_STYLE,
573 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ),
574 GetXMLToken( XML_DOUBLE ) );
575 if( bBold )
576 pContext->AddAttribute(
577 GetTransformer().GetNamespaceMap().GetQNameByKey(
578 XML_NAMESPACE_STYLE,
579 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ),
580 GetXMLToken( XML_BOLD ) );
582 break;
583 case XML_PTACTION_LINETHROUGH:
585 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue );
586 bool bBold = false, bDouble = false;
587 sal_Unicode c = 0;
588 switch( eToken )
590 case XML_SINGLE_LINE:
591 eToken = XML_SOLID;
592 break;
593 case XML_DOUBLE_LINE:
594 eToken = XML_SOLID;
595 bDouble = true;
596 break;
597 case XML_THICK_LINE:
598 eToken = XML_SOLID;
599 bBold = true;
600 break;
601 case XML_SLASH:
602 eToken = XML_SOLID;
603 c = '/';
604 break;
605 case XML_uX:
606 eToken = XML_SOLID;
607 c = 'X';
608 break;
609 default:
610 break;
612 pContext->AddAttribute(
613 GetTransformer().GetNamespaceMap().GetQNameByKey(
614 XML_NAMESPACE_STYLE,
615 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ),
616 eToken != XML_TOKEN_END ? GetXMLToken( eToken )
617 : sAttrValue );
618 if( bDouble )
619 pContext->AddAttribute(
620 GetTransformer().GetNamespaceMap().GetQNameByKey(
621 XML_NAMESPACE_STYLE,
622 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ),
623 GetXMLToken( XML_DOUBLE ) );
624 if( bBold )
625 pContext->AddAttribute(
626 GetTransformer().GetNamespaceMap().GetQNameByKey(
627 XML_NAMESPACE_STYLE,
628 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ),
629 GetXMLToken( XML_BOLD ) );
630 if( c )
631 pContext->AddAttribute(
632 GetTransformer().GetNamespaceMap().GetQNameByKey(
633 XML_NAMESPACE_STYLE,
634 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ),
635 OUString( c ) );
637 break;
638 case XML_PTACTION_SPLINES:
640 sal_Int32 nSplineType = sAttrValue.toInt32();
641 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
642 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) );
644 switch( nSplineType )
646 // straight lines
647 case 0:
648 pContext->AddAttribute(
649 aNewAttrName, GetXMLToken( XML_NONE ));
650 break;
651 // cubic spline
652 case 1:
653 pContext->AddAttribute(
654 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE ));
655 break;
656 // B-spline
657 case 2:
658 pContext->AddAttribute(
659 aNewAttrName, GetXMLToken( XML_B_SPLINE ));
660 break;
662 default:
663 OSL_FAIL( "invalid spline type" );
664 pContext->AddAttribute(
665 aNewAttrName, GetXMLToken( XML_NONE ));
666 break;
669 break;
670 case XML_PTACTION_INTERVAL_MAJOR:
671 pContext->AddAttribute( sAttrName, sAttrValue );
672 ::sax::Converter::convertDouble( fIntervalMajor, sAttrValue );
673 break;
674 case XML_PTACTION_INTERVAL_MINOR:
675 ::sax::Converter::convertDouble( fIntervalMinor, sAttrValue );
676 pIntervalMinorDivisorContext = pContext;
677 break;
678 case XML_PTACTION_SYMBOL:
680 sal_Int32 nSymbolType = sAttrValue.toInt32();
681 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey(
682 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) );
684 if( nSymbolType >= 0 )
686 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL ));
687 enum XMLTokenEnum eToken = XML_TOKEN_INVALID;
688 switch( nSymbolType )
690 // SYMBOL0
691 case 0:
692 // "square" has an awkward token name
693 eToken = XML_GRADIENTSTYLE_SQUARE;
694 break;
695 // SYMBOL1
696 case 1:
697 eToken = XML_DIAMOND;
698 break;
699 // SYMBOL2
700 case 2:
701 eToken = XML_ARROW_DOWN;
702 break;
703 // SYMBOL3
704 case 3:
705 eToken = XML_ARROW_UP;
706 break;
707 // SYMBOL4
708 case 4:
709 eToken = XML_ARROW_RIGHT;
710 break;
711 // SYMBOL5
712 case 5:
713 eToken = XML_ARROW_LEFT;
714 break;
715 // SYMBOL6
716 case 6:
717 eToken = XML_BOW_TIE;
718 break;
719 // SYMBOL7
720 case 7:
721 eToken = XML_HOURGLASS;
722 break;
723 case 8:
724 eToken = XML_CIRCLE;
725 break;
726 case 9:
727 eToken = XML_STAR;
728 break;
729 case 10:
730 eToken = XML_X;
731 break;
732 case 11:
733 eToken = XML_PLUS;
734 break;
735 case 12:
736 eToken = XML_ASTERISK;
737 break;
738 case 13:
739 eToken = XML_HORIZONTAL_BAR;
740 break;
741 case 14:
742 eToken = XML_VERTICAL_BAR;
743 break;
744 default:
745 OSL_FAIL( "invalid named symbol" );
746 break;
749 if( eToken != XML_TOKEN_INVALID )
751 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
752 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )),
753 GetXMLToken( eToken ));
756 else
758 switch( nSymbolType )
760 // NONE
761 case -3:
762 pContext->AddAttribute(
763 aNewAttrName, GetXMLToken( XML_NONE ));
764 break;
765 // AUTO
766 case -2:
767 pContext->AddAttribute(
768 aNewAttrName, GetXMLToken( XML_AUTOMATIC ));
769 break;
770 // BITMAPURL
771 case -1:
772 pContext->AddAttribute(
773 aNewAttrName, GetXMLToken( XML_IMAGE ));
774 break;
775 default:
776 OSL_FAIL( "invalid symbol type" );
777 pContext->AddAttribute(
778 aNewAttrName, GetXMLToken( XML_NONE ));
779 break;
783 break;
784 case XML_PTACTION_SYMBOL_IMAGE_NAME:
786 // create an xlink:href element for URI attribute
787 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext(
788 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey(
789 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE )));
790 rtl::Reference<XMLTransformerContext> xSymbolImageContext(pSymbolImageContext);
792 OUString aAttrValue( sAttrValue );
793 if( GetTransformer().ConvertURIToOASIS( aAttrValue, true ))
795 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue );
796 pContext->AddContent(xSymbolImageContext);
799 break;
801 // #i25616#
802 case XML_PTACTION_TRANSPARENCY :
804 OUString aAttrValue( sAttrValue );
805 XMLTransformerBase::NegPercent(aAttrValue);
806 pContext->AddAttribute( XML_NAMESPACE_DRAW,
807 XML_OPACITY,
808 aAttrValue );
809 pContext->AddAttribute( XML_NAMESPACE_DRAW,
810 XML_IMAGE_OPACITY,
811 aAttrValue );
813 break;
815 case XML_PTACTION_BREAK_INSIDE:
817 pContext->AddAttribute(
818 XML_NAMESPACE_FO, XML_KEEP_TOGETHER,
819 GetXMLToken(
820 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID )
821 ? XML_ALWAYS
822 : XML_AUTO ) );
824 break;
825 case XML_ATACTION_CAPTION_ESCAPE_OOO:
827 OUString aAttrValue( sAttrValue );
828 if( aAttrValue.indexOf( '%' ) != -1 )
830 sal_Int32 nValue = 0;
831 ::sax::Converter::convertPercent( nValue, sAttrValue );
832 if( nValue )
834 nValue /= 100;
835 OUStringBuffer aOut;
836 ::sax::Converter::convertPercent( aOut, nValue );
837 aAttrValue = aOut.makeStringAndClear();
840 else
842 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
845 pContext->AddAttribute( sAttrName, aAttrValue );
847 break;
848 case XML_ATACTION_MOVE_PROTECT:
849 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE );
850 pProtectContext = pContext;
851 break;
852 case XML_ATACTION_SIZE_PROTECT:
853 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE );
854 pProtectContext = pContext;
855 break;
856 case XML_ATACTION_PROTECT:
857 aProtectAttrValue = sAttrValue;
858 pProtectContext = pContext;
859 break;
860 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values
862 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
863 aDrawMirrorAttrValue =
864 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE )
865 ? XML_HORIZONTAL : XML_NONE );
866 bExistDrawMirror = true;
867 pMirrorContext = pContext;
869 break;
870 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
871 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values
873 SvXMLTokenEnumerator aTokenEnum( sAttrValue );
874 std::u16string_view aToken;
875 while( aTokenEnum.getNextToken( aToken ) )
877 if ( !aStyleMirrorAttrValue.isEmpty() )
879 aStyleMirrorAttrValue.append(" ");
882 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) )
884 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_EVEN ));
886 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) )
888 aStyleMirrorAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_ODD ));
890 else
892 aStyleMirrorAttrValue.append(aToken);
895 bExistStyleMirror = true;
896 pMirrorContext = pContext;
898 break;
899 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage
901 double fValue = sAttrValue.toDouble();
902 sal_Int32 nValue = static_cast<sal_Int32>((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) );
904 OUStringBuffer aOut;
905 ::sax::Converter::convertPercent( aOut, nValue );
906 OUString aAttrValue( aOut.makeStringAndClear() );
907 pContext->AddAttribute( sAttrName, aAttrValue );
909 break;
910 case XML_ATACTION_OPACITY_FIX:
912 sal_Int32 nValue;
913 if( sAttrValue.indexOf( '%' ) != -1 )
915 ::sax::Converter::convertPercent( nValue, sAttrValue );
917 else
919 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 );
921 nValue = 100 - nValue;
923 OUStringBuffer aOut;
924 ::sax::Converter::convertPercent( aOut, nValue );
925 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() );
927 break;
928 default:
929 OSL_ENSURE( false, "unknown action" );
930 break;
934 // OpenDocument file format: attribute value of <style:mirror> wrong (#i49139#)
935 if ( bExistStyleMirror )
937 pMirrorContext->AddAttribute(
938 GetTransformer().GetNamespaceMap().GetQNameByKey(
939 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
940 aStyleMirrorAttrValue.makeStringAndClear());
942 else if ( bExistDrawMirror )
944 pMirrorContext->AddAttribute(
945 GetTransformer().GetNamespaceMap().GetQNameByKey(
946 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ),
947 aDrawMirrorAttrValue);
950 if (bMoveProtect || bSizeProtect || !aProtectAttrValue.isEmpty())
952 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) )
953 aProtectAttrValue.clear();
955 const OUString& rPosition = GetXMLToken( XML_POSITION );
956 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) )
958 if( !aProtectAttrValue.isEmpty() )
959 aProtectAttrValue += " ";
960 aProtectAttrValue += rPosition;
963 const OUString& rSize = GetXMLToken( XML_SIZE );
964 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) )
966 if( !aProtectAttrValue.isEmpty() )
967 aProtectAttrValue += " ";
968 aProtectAttrValue += rSize;
971 assert(pProtectContext && "coverity[var_deref_model] - pProtectContext should be assigned in a superset of the enclosing if condition entry logic");
972 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue );
975 if( !pIntervalMinorDivisorContext )
976 return;
978 if( fIntervalMinor != 0.0 )
980 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >(
981 ::rtl::math::round( fIntervalMajor / fIntervalMinor ));
983 pIntervalMinorDivisorContext->AddAttribute(
984 GetTransformer().GetNamespaceMap().GetQNameByKey(
985 XML_NAMESPACE_CHART,
986 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )),
987 OUString::number( nIntervalMinorDivisor ));
991 void XMLPropertiesOOoTContext_Impl::EndElement()
993 if( !m_bPersistent )
994 Export();
997 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& )
999 // ignore them
1002 void XMLPropertiesOOoTContext_Impl::Export()
1005 for(rtl::Reference<XMLTypedPropertiesOOoTContext_Impl> & rPropContext : m_aPropContexts)
1007 if( rPropContext.is() )
1008 rPropContext->Export();
1012 bool XMLPropertiesOOoTContext_Impl::IsPersistent() const
1014 return m_bPersistent;
1017 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp,
1018 const OUString& rQName,
1019 XMLFamilyType eT,
1020 bool bPersistent ) :
1021 XMLPersElemContentTContext( rImp, rQName ),
1022 m_eFamily( eT ),
1023 m_bPersistent( bPersistent )
1027 XMLStyleOOoTContext::XMLStyleOOoTContext(
1028 XMLTransformerBase& rImp,
1029 const OUString& rQName,
1030 XMLFamilyType eT,
1031 sal_uInt16 nPrefix,
1032 ::xmloff::token::XMLTokenEnum eToken,
1033 bool bPersistent ) :
1034 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
1035 m_eFamily( eT ),
1036 m_bPersistent( bPersistent )
1040 XMLStyleOOoTContext::~XMLStyleOOoTContext()
1044 rtl::Reference<XMLTransformerContext> XMLStyleOOoTContext::CreateChildContext(
1045 sal_uInt16 nPrefix,
1046 const OUString& rLocalName,
1047 const OUString& rQName,
1048 const Reference< XAttributeList >& rAttrList )
1050 rtl::Reference<XMLTransformerContext> pContext;
1052 if( XML_NAMESPACE_STYLE == nPrefix &&
1053 IsXMLToken( rLocalName, XML_PROPERTIES ) )
1055 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END )
1057 OSL_ENSURE( false, "unexpected properties element" );
1058 pContext = m_bPersistent
1059 ? XMLPersElemContentTContext::CreateChildContext(
1060 nPrefix, rLocalName, rQName, rAttrList )
1061 : XMLTransformerContext::CreateChildContext(
1062 nPrefix, rLocalName, rQName, rAttrList );
1064 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END )
1066 sal_uInt16 nActionMap =
1067 aAttrActionMaps[aPropTypes[m_eFamily][0]];
1068 if( nActionMap < MAX_OOO_PROP_ACTIONS )
1070 pContext.set(new XMLPropertiesOOoTContext_Impl(
1071 GetTransformer(), rQName,
1072 aPropTypes[m_eFamily], m_bPersistent ));
1074 else
1076 if( m_bPersistent )
1077 pContext.set(new XMLPersElemContentTContext(
1078 GetTransformer(), rQName,
1079 XML_NAMESPACE_STYLE,
1080 aPropTokens[aPropTypes[m_eFamily][0]] ));
1081 else
1082 pContext.set(new XMLRenameElemTransformerContext(
1083 GetTransformer(), rQName,
1084 XML_NAMESPACE_STYLE,
1085 aPropTokens[aPropTypes[m_eFamily][0]] ));
1088 else
1090 pContext.set(new XMLPropertiesOOoTContext_Impl(
1091 GetTransformer(), rQName,
1092 aPropTypes[m_eFamily], m_bPersistent));
1095 if( m_bPersistent )
1096 AddContent( pContext );
1098 else
1100 pContext = m_bPersistent
1101 ? XMLPersElemContentTContext::CreateChildContext(
1102 nPrefix, rLocalName, rQName, rAttrList )
1103 : XMLTransformerContext::CreateChildContext(
1104 nPrefix, rLocalName, rQName, rAttrList );
1107 return pContext;
1110 void XMLStyleOOoTContext::StartElement(
1111 const Reference< XAttributeList >& rAttrList )
1113 XMLTransformerActions *pActions =
1114 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS );
1115 OSL_ENSURE( pActions, "go no actions" );
1117 Reference< XAttributeList > xAttrList( rAttrList );
1118 rtl::Reference<XMLMutableAttributeList> pMutableAttrList;
1119 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1120 for( sal_Int16 i=0; i < nAttrCount; i++ )
1122 const OUString sAttrName = xAttrList->getNameByIndex( i );
1123 OUString aLocalName;
1124 sal_uInt16 nPrefix =
1125 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName,
1126 &aLocalName );
1127 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
1128 XMLTransformerActions::const_iterator aIter =
1129 pActions->find( aKey );
1130 if( aIter != pActions->end() )
1132 if( !pMutableAttrList )
1134 pMutableAttrList =
1135 new XMLMutableAttributeList( xAttrList );
1136 xAttrList = pMutableAttrList;
1138 const OUString sAttrValue = xAttrList->getValueByIndex( i );
1139 switch( (*aIter).second.m_nActionType )
1141 case XML_ATACTION_STYLE_FAMILY:
1143 bool bControl = false;
1144 if( XML_FAMILY_TYPE_END == m_eFamily )
1146 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) )
1147 m_eFamily = XML_FAMILY_TYPE_GRAPHIC;
1148 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) )
1149 m_eFamily = XML_FAMILY_TYPE_PRESENTATION;
1150 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) )
1151 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE;
1152 else if( IsXMLToken( sAttrValue, XML_TEXT) )
1153 m_eFamily = XML_FAMILY_TYPE_TEXT;
1154 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) )
1155 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1156 else if( IsXMLToken( sAttrValue, XML_RUBY) )
1157 m_eFamily = XML_FAMILY_TYPE_RUBY;
1158 else if( IsXMLToken( sAttrValue, XML_SECTION) )
1159 m_eFamily = XML_FAMILY_TYPE_SECTION;
1160 else if( IsXMLToken( sAttrValue, XML_TABLE) )
1161 m_eFamily = XML_FAMILY_TYPE_TABLE;
1162 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) )
1163 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN;
1164 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) )
1165 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW;
1166 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) )
1167 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL;
1168 else if( IsXMLToken( sAttrValue, XML_CHART) )
1169 m_eFamily = XML_FAMILY_TYPE_CHART;
1170 else if( IsXMLToken( sAttrValue, XML_CONTROL) )
1172 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH;
1173 bControl = true;
1176 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily )
1178 pMutableAttrList->SetValueByIndex( i,
1179 GetXMLToken( XML_GRAPHIC ) );
1181 else if( bControl )
1183 pMutableAttrList->SetValueByIndex( i,
1184 GetXMLToken( XML_PARAGRAPH ) );
1187 break;
1188 case XML_ATACTION_INCH2IN:
1190 OUString aAttrValue( sAttrValue );
1191 if( XMLTransformerBase::ReplaceSingleInchWithIn(
1192 aAttrValue ) )
1193 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1195 break;
1196 case XML_ATACTION_ENCODE_STYLE_NAME:
1198 OUString aAttrValue( sAttrValue );
1199 if( GetTransformer().EncodeStyleName(aAttrValue) )
1201 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1202 OUString aNewAttrQName(
1203 GetTransformer().GetNamespaceMap().
1204 GetQNameByKey(
1205 nPrefix, ::xmloff::token::GetXMLToken(
1206 XML_DISPLAY_NAME ) ) );
1207 pMutableAttrList->AddAttribute( aNewAttrQName,
1208 sAttrValue );
1211 break;
1212 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
1214 OUString aAttrValue( sAttrValue );
1215 if( GetTransformer().EncodeStyleName(aAttrValue) )
1216 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1218 break;
1219 case XML_ATACTION_NEG_PERCENT:
1221 OUString aAttrValue( sAttrValue );
1222 if( XMLTransformerBase::NegPercent(aAttrValue) )
1223 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1225 break;
1226 case XML_ATACTION_URI_OOO:
1228 OUString aAttrValue( sAttrValue );
1229 if( GetTransformer().ConvertURIToOASIS( aAttrValue,
1230 static_cast< bool >((*aIter).second.m_nParam1)))
1231 pMutableAttrList->SetValueByIndex( i, aAttrValue );
1233 break;
1234 default:
1235 OSL_ENSURE( false, "unknown action" );
1236 break;
1240 if( XML_FAMILY_TYPE_END == m_eFamily )
1241 m_eFamily = XML_FAMILY_TYPE_TEXT;
1242 if( m_bPersistent )
1243 XMLPersElemContentTContext::StartElement( xAttrList );
1244 else
1245 GetTransformer().GetDocHandler()->startElement( GetExportQName(), xAttrList );
1248 void XMLStyleOOoTContext::EndElement()
1250 if( m_bPersistent )
1251 XMLPersElemContentTContext::EndElement();
1252 else
1253 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
1256 void XMLStyleOOoTContext::Characters( const OUString& )
1258 // element content only:
1261 bool XMLStyleOOoTContext::IsPersistent() const
1263 return m_bPersistent;
1266 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions(
1267 sal_uInt16 nType )
1269 XMLTransformerActionInit const *pInit = nullptr;
1271 switch( nType )
1273 case PROP_OOO_GRAPHIC_ATTR_ACTIONS:
1274 pInit = aGraphicPropertyOOoAttrActionTable;
1275 break;
1276 case PROP_OOO_GRAPHIC_ELEM_ACTIONS:
1277 pInit = aGraphicPropertyOOoElemActionTable;
1278 break;
1279 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS:
1280 pInit = aDrawingPagePropertyOOoAttrActionTable;
1281 break;
1282 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS:
1283 pInit = aPageLayoutPropertyOOoAttrActionTable;
1284 break;
1285 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS:
1286 pInit = aHeaderFooterPropertyOOoAttrActionTable;
1287 break;
1288 case PROP_OOO_TEXT_ATTR_ACTIONS:
1289 pInit = aTextPropertyOOoAttrActionTable;
1290 break;
1291 case PROP_OOO_TEXT_ELEM_ACTIONS:
1292 pInit = aTextPropertyOOoElemActionTable;
1293 break;
1294 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS:
1295 pInit = aParagraphPropertyOOoAttrActionTable;
1296 break;
1297 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS:
1298 pInit = aParagraphPropertyOOoElemActionTable;
1299 break;
1300 case PROP_OOO_SECTION_ATTR_ACTIONS:
1301 pInit = aSectionPropertyOOoAttrActionTable;
1302 break;
1303 case PROP_OOO_TABLE_ATTR_ACTIONS:
1304 pInit = aTablePropertyOOoAttrActionTable;
1305 break;
1306 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS:
1307 pInit = aTableColumnPropertyOOoAttrActionTable;
1308 break;
1309 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS:
1310 pInit = aTableRowPropertyOOoAttrActionTable;
1311 break;
1312 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS:
1313 pInit = aTableCellPropertyOOoAttrActionTable;
1314 break;
1315 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS:
1316 pInit = aTableCellPropertyOOoElemActionTable;
1317 break;
1318 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS:
1319 pInit = aListLevelPropertyOOoAttrActionTable;
1320 break;
1321 case PROP_OOO_CHART_ATTR_ACTIONS:
1322 pInit = aChartPropertyOOoAttrActionTable;
1323 break;
1324 case PROP_OOO_CHART_ELEM_ACTIONS:
1325 pInit = aChartPropertyOOoElemActionTable;
1326 break;
1329 XMLTransformerActions *pActions = nullptr;
1330 if( pInit )
1331 pActions = new XMLTransformerActions( pInit );
1333 return pActions;
1336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */