LibreOffice Module xmloff (master) 1
StyleOASISTContext.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
23#include <rtl/ustrbuf.hxx>
24#include <osl/diagnose.h>
27#include <xmloff/xmltoken.hxx>
29#include "PropType.hxx"
30#include "DeepTContext.hxx"
31#include "TransformerBase.hxx"
34#include "MutableAttrList.hxx"
37#include <xmloff/xmluconv.hxx>
38
39using namespace ::xmloff::token;
40using namespace ::com::sun::star::uno;
41using namespace ::com::sun::star::xml::sax;
42
44{
59};
60
62{
63 css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList;
64
66 bool const m_bControlStyle;
67
68public:
69
70 void SetQNameAndPropType( const OUString& rQName,
71 XMLPropType ePropType )
72 {
73 m_ePropType = ePropType;
75 };
76
78 const OUString& rQName,
79 XMLPropType eP,
80 bool _bControlStyle );
81
82 virtual void StartElement( const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
83
84 virtual void Export() override;
85
86 static XMLPropType GetPropType( std::u16string_view rLocalName );
87
88 static OUString const & MergeUnderline( XMLTokenEnum eUnderline,
89 bool bBold, bool bDouble );
90 static OUString const & MergeLineThrough( XMLTokenEnum eLineThrough,
91 bool bBold, bool bDouble,
92 sal_Unicode c );
93};
94
96 XMLTransformerBase& rImp, const OUString& rQName, XMLPropType eP,
97 bool _bControlStyle ) :
100 m_ePropType( eP ),
101 m_bControlStyle( _bControlStyle )
102{
103}
104
106 const Reference< XAttributeList >& rAttrList )
107{
108 XMLTransformerActions *pActions = nullptr;
109 sal_uInt16 nActionMap = aAttrActionMaps[m_ePropType];
110 if( nActionMap < MAX_OASIS_PROP_ACTIONS )
111 {
112 pActions = GetTransformer().GetUserDefinedActions( nActionMap );
113 OSL_ENSURE( pActions, "go no actions" );
114 }
115
116 if( pActions )
117 {
119 if( !m_xAttrList.is() )
120 {
121 pAttrList = new XMLMutableAttributeList();
122 m_xAttrList = pAttrList;
123 }
124 else
125 {
126 pAttrList =
127 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() );
128 }
129
130 XMLTokenEnum eUnderline = XML_TOKEN_END;
131 bool bBoldUnderline = false, bDoubleUnderline = false;
132 XMLTokenEnum eLineThrough = XML_TOKEN_END;
133 bool bBoldLineThrough = false, bDoubleLineThrough = false;
134 sal_Unicode cLineThroughChar = 0;
135
136 bool bIntervalMinorFound = false;
137 double fIntervalMajor = 0.0;
138 sal_Int32 nIntervalMinorDivisor = 0;
139
140 // #i25616#
141 OUString aOpacityValueRemember;
142 OUString aImageOpacityValueRemember;
143
144 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
145 for( sal_Int16 i=0; i < nAttrCount; i++ )
146 {
147 const OUString& rAttrName = rAttrList->getNameByIndex( i );
148 const OUString& rAttrValue = rAttrList->getValueByIndex( i );
149 OUString aLocalName;
150 sal_uInt16 nPrefix =
152 &aLocalName );
153
154 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
155 XMLTransformerActions::const_iterator aIter =
156 pActions->find( aKey );
157 if( aIter != pActions->end() )
158 {
159 switch( (*aIter).second.m_nActionType )
160 {
162 break;
164 pAttrList->AddAttribute( rAttrName, rAttrValue );
165 break;
167 {
168 OUString aNewAttrQName(
169 GetTransformer().GetNamespaceMap().GetQNameByKey(
170 (*aIter).second.GetQNamePrefixFromParam1(),
172 (*aIter).second.GetQNameTokenFromParam1()) ) );
173 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
174 }
175 break;
177 {
178 OUString aAttrValue( rAttrValue );
180 aAttrValue );
181 pAttrList->AddAttribute( rAttrName, aAttrValue );
182 }
183 break;
185 {
186 OUString aAttrValue( rAttrValue );
188 aAttrValue );
189 pAttrList->AddAttribute( rAttrName, aAttrValue );
190 }
191 break;
193 {
194 OUString aAttrValue( rAttrValue );
196 pAttrList->AddAttribute( rAttrName, aAttrValue );
197 }
198 break;
200 {
201 OUString aNewAttrQName(
202 GetTransformer().GetNamespaceMap().GetQNameByKey(
203 (*aIter).second.GetQNamePrefixFromParam1(),
205 (*aIter).second.GetQNameTokenFromParam1()) ) );
206 OUString aAttrValue( rAttrValue );
208 pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
209 }
210 break;
212 {
213 OUString aAttrValue( rAttrValue );
215 pAttrList->AddAttribute( rAttrName, aAttrValue );
216 }
217 break;
219 {
220 OUString aNewAttrQName(
221 GetTransformer().GetNamespaceMap().GetQNameByKey(
222 (*aIter).second.GetQNamePrefixFromParam1(),
224 (*aIter).second.GetQNameTokenFromParam1()) ) );
225 OUString aAttrValue( rAttrValue );
227 pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
228 }
229 break;
231 {
232 bool bWordMode =
233 IsXMLToken( rAttrValue, XML_SKIP_WHITE_SPACE );
234 OUString aAttrQName(
235 GetTransformer().GetNamespaceMap().GetQNameByKey(
238 sal_Int16 nIndex =
239 pAttrList->GetIndexByName( aAttrQName );
240 if( -1 != nIndex )
241 {
242 if( bWordMode )
243 {
244 const OUString& rOldValue =
245 pAttrList->getValueByIndex( nIndex );
246 if( !IsXMLToken( rOldValue, XML_TRUE ) )
247 {
248 pAttrList->SetValueByIndex( nIndex,
250 }
251 }
252 }
253 else
254 {
255 const OUString& aAttrValue( GetXMLToken( bWordMode
256 ? XML_FALSE
257 : XML_TRUE ) );
258 pAttrList->AddAttribute( aAttrQName, aAttrValue );
259 }
260 }
261 break;
263 {
264 const OUString& aAttrValue( GetXMLToken(
265 IsXMLToken( rAttrValue, XML_ALWAYS )
266 ? XML_TRUE
267 : XML_FALSE) );
268 pAttrList->AddAttribute( rAttrName, aAttrValue );
269 }
270 break;
272 if( IsXMLToken( rAttrValue, XML_BOLD ) )
273 bBoldUnderline = true;
274 break;
276 if( IsXMLToken( rAttrValue, XML_DOUBLE ) )
277 bDoubleUnderline = true;
278 break;
280 eUnderline = GetTransformer().GetToken( rAttrValue );
281 break;
283 if( IsXMLToken( rAttrValue, XML_BOLD ) )
284 bBoldLineThrough = true;
285 break;
287 if( IsXMLToken( rAttrValue, XML_DOUBLE ) )
288 bDoubleLineThrough = true;
289 break;
291 eLineThrough = GetTransformer().GetToken( rAttrValue );
292 break;
294 if( !rAttrValue.isEmpty() )
295 cLineThroughChar = rAttrValue[0];
296 break;
298 {
299 // 0: none (default)
300 sal_Int32 nSplineType = 0;
301 if( IsXMLToken( rAttrValue, XML_CUBIC_SPLINE ))
302 nSplineType = 1;
303 else if( IsXMLToken( rAttrValue, XML_B_SPLINE ))
304 nSplineType = 2;
305
306 pAttrList->AddAttribute(
307 GetTransformer().GetNamespaceMap().GetQNameByKey(
310 OUString::number( nSplineType ));
311 }
312 break;
314 pAttrList->AddAttribute( rAttrName, rAttrValue );
315 ::sax::Converter::convertDouble(fIntervalMajor, rAttrValue);
316 break;
318 ::sax::Converter::convertNumber(nIntervalMinorDivisor, rAttrValue);
319 bIntervalMinorFound = true;
320 break;
322 {
323 // if symbol_type is "named-symbol" the "symbol"
324 // property is set in the action XML_OPTACTION_SYMBOL_NAME
325 sal_Int32 nSymbolType = 0;
326 if( IsXMLToken( rAttrValue, XML_NONE ))
327 nSymbolType = -3;
328 else if( IsXMLToken( rAttrValue, XML_AUTOMATIC ))
329 nSymbolType = -2;
330 else if( IsXMLToken( rAttrValue, XML_IMAGE ))
331 nSymbolType = -1;
332
333 if( nSymbolType < 0 )
334 pAttrList->AddAttribute(
335 GetTransformer().GetNamespaceMap().GetQNameByKey(
338 OUString::number( nSymbolType ));
339 }
340 break;
342 {
343 // assume "symbol-type" == "named-symbol"
344 sal_Int32 nSymbolType = -3; // NONE
345 // "square" just has an awkward token-name
346 if( IsXMLToken( rAttrValue, XML_GRADIENTSTYLE_SQUARE ))
347 nSymbolType = 0;
348 else if( IsXMLToken( rAttrValue, XML_DIAMOND ))
349 nSymbolType = 1;
350 else if( IsXMLToken( rAttrValue, XML_ARROW_DOWN ))
351 nSymbolType = 2;
352 else if( IsXMLToken( rAttrValue, XML_ARROW_UP ))
353 nSymbolType = 3;
354 else if( IsXMLToken( rAttrValue, XML_ARROW_RIGHT ))
355 nSymbolType = 4;
356 else if( IsXMLToken( rAttrValue, XML_ARROW_LEFT ))
357 nSymbolType = 5;
358 else if( IsXMLToken( rAttrValue, XML_BOW_TIE ))
359 nSymbolType = 6;
360 else if( IsXMLToken( rAttrValue, XML_HOURGLASS ))
361 nSymbolType = 7;
362 else if( IsXMLToken( rAttrValue, XML_CIRCLE ))
363 nSymbolType = 8;
364 else if( IsXMLToken( rAttrValue, XML_STAR ))
365 nSymbolType = 9;
366 else if( IsXMLToken( rAttrValue, XML_X ))
367 nSymbolType = 10;
368 else if( IsXMLToken( rAttrValue, XML_PLUS ))
369 nSymbolType = 11;
370 else if( IsXMLToken( rAttrValue, XML_ASTERISK ))
371 nSymbolType = 12;
372 else if( IsXMLToken( rAttrValue, XML_HORIZONTAL_BAR ))
373 nSymbolType = 13;
374 else if( IsXMLToken( rAttrValue, XML_VERTICAL_BAR ))
375 nSymbolType = 14;
376
377 if( nSymbolType >= 0 )
378 pAttrList->AddAttribute(
379 GetTransformer().GetNamespaceMap().GetQNameByKey(
382 OUString::number( nSymbolType ));
383 }
384 break;
385 // #i25616#
387 aOpacityValueRemember = rAttrValue;
388 XMLTransformerBase::NegPercent(aOpacityValueRemember);
389 break;
390
391 // #i25616#
393 aImageOpacityValueRemember = rAttrValue;
394 XMLTransformerBase::NegPercent(aImageOpacityValueRemember);
395 break;
396
398 pAttrList->AddAttribute(
399 GetTransformer().GetNamespaceMap().GetQNameByKey(
402 IsXMLToken( rAttrValue, XML_ALWAYS )
404 : XML_AUTO ) );
405 break;
406
408 if ( m_bControlStyle )
409 {
410 OUString aNewAttrQName(
411 GetTransformer().GetNamespaceMap().GetQNameByKey(
414 XML_TEXT_ALIGN ) ) );
415 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
416 }
417 else
418 {
419 OUString aNewAttrQName(
420 GetTransformer().GetNamespaceMap().GetQNameByKey(
423 XML_TEXT_ALIGN ) ) );
424 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
425 }
426 break;
427
429 {
430 OUString aAttrValue( rAttrValue );
431 if( aAttrValue.indexOf( '%' ) != -1 )
432 {
433 sal_Int32 nValue = 0;
435 if( nValue )
436 {
437 nValue *= 100;
438 OUStringBuffer aOut;
440 aAttrValue = aOut.makeStringAndClear();
441 }
442 }
443 else
444 {
446 }
447
448 pAttrList->AddAttribute( rAttrName, aAttrValue );
449 }
450 break;
451
453 {
454 pAttrList->AddAttribute( rAttrName, rAttrValue );
455
456 if( rAttrValue.indexOf( GetXMLToken( XML_SIZE ) ) != -1 )
457 pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
460
461 if( rAttrValue.indexOf( GetXMLToken( XML_POSITION ) ) != -1 )
462 pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
465 }
466 break;
467
468 case XML_ATACTION_DRAW_MIRROR_OASIS: // renames style:mirror to draw:mirror and adapts values
469 {
470 // keep original for writer graphic objects
471 // Adapts attribute values (#i49139#)
472 OUStringBuffer aNewAttrValue;
473 SvXMLTokenEnumerator aTokenEnum( rAttrValue );
474 std::u16string_view aToken;
475 while( aTokenEnum.getNextToken( aToken ) )
476 {
477 if ( !aNewAttrValue.isEmpty() )
478 {
479 aNewAttrValue.append(" ");
480 }
481
482 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_EVEN ) )
483 {
484 aNewAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_LEFT_PAGES ));
485 }
486 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_ODD ) )
487 {
488 aNewAttrValue.append(GetXMLToken( XML_HORIZONTAL_ON_RIGHT_PAGES ));
489 }
490 else
491 {
492 aNewAttrValue.append(aToken);
493 }
494 }
495 pAttrList->AddAttribute( rAttrName, aNewAttrValue.makeStringAndClear() );
496
497 // create old draw:mirror for drawing graphic objects
498 const OUString& aAttrValue( GetXMLToken( IsXMLToken( rAttrValue, XML_HORIZONTAL ) ? XML_TRUE : XML_FALSE ) );
499 pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
501 GetXMLToken( XML_MIRROR )), aAttrValue );
502 }
503 break;
504 case XML_ATACTION_GAMMA_OASIS: // converts percentage value to double
505 {
506 sal_Int32 nValue;
508 const double fValue = static_cast<double>(nValue) / 100.0;
509 pAttrList->AddAttribute( rAttrName, OUString::number( fValue ) );
510 }
511 break;
513 {
514 sal_Int32 nValue;
515 if( rAttrValue.indexOf( '%' ) != -1 )
516 {
518 }
519 else
520 {
521 nValue = sal_Int32( rAttrValue.toDouble() * 100.0 );
522 }
523 nValue = 100 - nValue;
524
525 OUStringBuffer aOut;
527 pAttrList->AddAttribute( rAttrName, aOut.makeStringAndClear() );
528 }
529 break;
530 default:
531 OSL_ENSURE( false, "unknown action" );
532 break;
533 }
534 }
535 else
536 {
537 pAttrList->AddAttribute( rAttrName, rAttrValue );
538 }
539 }
540 if( XML_TOKEN_END != eUnderline )
541 pAttrList->AddAttribute(
542 GetTransformer().GetNamespaceMap().GetQNameByKey(
545 MergeUnderline( eUnderline, bBoldUnderline,
546 bDoubleUnderline ) );
547 if( XML_TOKEN_END != eLineThrough )
548 pAttrList->AddAttribute(
549 GetTransformer().GetNamespaceMap().GetQNameByKey(
552 MergeLineThrough( eLineThrough, bBoldLineThrough,
553 bDoubleLineThrough, cLineThroughChar ) );
554 if( bIntervalMinorFound )
555 {
556 double fIntervalMinor = 0.0;
557 if( nIntervalMinorDivisor != 0)
558 fIntervalMinor = fIntervalMajor / static_cast< double >( nIntervalMinorDivisor );
559
560 OUStringBuffer aBuf;
561 ::sax::Converter::convertDouble( aBuf, fIntervalMinor );
562 pAttrList->AddAttribute(
563 GetTransformer().GetNamespaceMap().GetQNameByKey(
566 aBuf.makeStringAndClear());
567 }
568
569 // #i25616#
570 if(!aOpacityValueRemember.isEmpty() || !aImageOpacityValueRemember.isEmpty())
571 {
572 pAttrList->AddAttribute(
573 GetTransformer().GetNamespaceMap().GetQNameByKey(
576 !aImageOpacityValueRemember.isEmpty()
577 ? aImageOpacityValueRemember : aOpacityValueRemember );
578 }
579 }
580 else
581 {
582 if( !m_xAttrList.is() )
583 {
584 m_xAttrList = new XMLMutableAttributeList( rAttrList, true );
585 }
586 else
587 {
588 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
589 ->AppendAttributeList( rAttrList );
590 }
591 }
592}
593
595{
598 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
599}
600
602{
604 if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
605 eProp = XML_PROP_TYPE_GRAPHIC;
606 else if( IsXMLToken( rLocalName, XML_DRAWING_PAGE_PROPERTIES ) )
608 else if( IsXMLToken( rLocalName, XML_PAGE_LAYOUT_PROPERTIES ) )
610 else if( IsXMLToken( rLocalName, XML_HEADER_FOOTER_PROPERTIES ) )
612 else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
613 eProp = XML_PROP_TYPE_TEXT;
614 else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
616 else if( IsXMLToken( rLocalName, XML_RUBY_PROPERTIES ) )
617 eProp = XML_PROP_TYPE_RUBY;
618 else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
619 eProp = XML_PROP_TYPE_SECTION;
620 else if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
621 eProp = XML_PROP_TYPE_TABLE;
622 else if( IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) )
624 else if( IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
626 else if( IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) )
628 else if( IsXMLToken( rLocalName, XML_LIST_LEVEL_PROPERTIES ) )
630 else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
631 eProp = XML_PROP_TYPE_CHART;
632
633 return eProp;
634}
635
637 XMLTokenEnum eUnderline, bool bBold, bool bDouble )
638{
639 if( bDouble )
640 {
641 switch( eUnderline )
642 {
643 case XML_WAVE:
644 eUnderline = XML_DOUBLE_WAVE;
645 break;
646 default:
647 eUnderline = XML_DOUBLE;
648 break;
649 }
650 }
651 else if( bBold )
652 {
653 switch( eUnderline )
654 {
655 case XML_NONE:
656 case XML_SOLID:
657 eUnderline = XML_BOLD;
658 break;
659 case XML_DOTTED:
660 eUnderline = XML_BOLD_DOTTED;
661 break;
662 case XML_DASH:
663 eUnderline = XML_BOLD_DASH;
664 break;
665 case XML_LONG_DASH:
666 eUnderline = XML_BOLD_LONG_DASH;
667 break;
668 case XML_DOT_DASH:
669 eUnderline = XML_BOLD_DOT_DASH;
670 break;
671 case XML_DOT_DOT_DASH:
672 eUnderline = XML_BOLD_DOT_DOT_DASH;
673 break;
674 case XML_WAVE:
675 eUnderline = XML_BOLD_WAVE;
676 break;
677 default:
678 OSL_FAIL( "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
679 break;
680 }
681 }
682 else
683 {
684 switch( eUnderline )
685 {
686 case XML_SOLID:
687 eUnderline = XML_SINGLE;
688 break;
689 case XML_NONE:
690 eUnderline = XML_NONE;
691 break;
692 default:
693 OSL_FAIL( "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
694 break;
695 }
696 }
697
698 return GetXMLToken( eUnderline );
699}
700
702 XMLTokenEnum eLineThrough, bool bBold, bool bDouble,
703 sal_Unicode c )
704{
705 if( c )
706 eLineThrough = c=='/' ? XML_SLASH : XML_uX;
707 else if( bDouble )
708 eLineThrough = XML_DOUBLE_LINE;
709 else if( bBold )
710 eLineThrough = XML_THICK_LINE;
711 else if( XML_NONE != eLineThrough )
712 eLineThrough = XML_SINGLE_LINE;
713
714 return GetXMLToken( eLineThrough );
715}
716
718 const OUString& rQName, bool bPersistent)
719 : XMLPersElemContentTContext(rImp, rQName)
720 , m_bPersistent(bPersistent)
721 , m_bControlStyle(false)
722{
723}
724
726 XMLTransformerBase& rImp, const OUString& rQName,
727 sal_uInt16 nPrefix, ::xmloff::token::XMLTokenEnum eToken,
728 bool bPersistent)
729 : XMLPersElemContentTContext(rImp, rQName, nPrefix, eToken)
730 , m_bPersistent(bPersistent)
731 , m_bControlStyle(false)
732{
733}
734
736{
737}
738
740 sal_uInt16 nPrefix,
741 const OUString& rLocalName,
742 const OUString& rQName,
743 const Reference< XAttributeList >& rAttrList )
744{
746
747 if( XML_NAMESPACE_STYLE == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
748 {
749 XMLPropType ePropType =
751 if( XML_PROP_TYPE_END != ePropType )
752 {
753 // if no properties context exist start a new one.
754 if( !m_xPropContext.is() )
756 GetTransformer(), rQName, ePropType, m_bControlStyle );
757 else
758 m_xPropContext->SetQNameAndPropType( rQName, ePropType );
759 pContext = m_xPropContext;
760 }
761 }
762 if( !pContext.is() )
763 {
764 // if a properties context exist close it
765 if( m_xPropContext.is() && !m_bPersistent )
766 {
767 m_xPropContext->Export();
768 m_xPropContext = nullptr;
769 }
770
771 pContext = m_bPersistent
773 nPrefix, rLocalName, rQName, rAttrList )
775 nPrefix, rLocalName, rQName, rAttrList );
776 }
777
778 return pContext;
779}
780
782 const Reference< XAttributeList >& rAttrList )
783{
784 XMLTransformerActions *pActions =
786 OSL_ENSURE( pActions, "go no actions" );
787
788 Reference< XAttributeList > xAttrList( rAttrList );
790 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
791 sal_Int16 nFamilyAttr = -1;
792 m_bControlStyle = false;
793
794 for( sal_Int16 i=0; i < nAttrCount; i++ )
795 {
796 const OUString& rAttrName = xAttrList->getNameByIndex( i );
797 OUString aLocalName;
798 sal_uInt16 nPrefix =
800 &aLocalName );
801 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
802 XMLTransformerActions::const_iterator aIter =
803 pActions->find( aKey );
804 if( aIter != pActions->end() )
805 {
806 if( !pMutableAttrList )
807 {
808 pMutableAttrList =
809 new XMLMutableAttributeList( xAttrList );
810 xAttrList = pMutableAttrList;
811 }
812 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
813 switch( (*aIter).second.m_nActionType )
814 {
816 if( IsXMLToken( rAttrValue, XML_GRAPHIC ) )
817 {
818 pMutableAttrList->SetValueByIndex(
820 }
821 else
822 {
823 if( IsXMLToken( rAttrValue, XML_PARAGRAPH ) )
824 nFamilyAttr = i;
825 }
826
827 break;
830 pMutableAttrList->RemoveAttributeByIndex( i );
831 --i;
832 --nAttrCount;
833 break;
835 m_bControlStyle = rAttrValue.startsWith( "ctrl" );
836 [[fallthrough]];
838 {
839 OUString aAttrValue( rAttrValue );
841 pMutableAttrList->SetValueByIndex( i, aAttrValue );
842 }
843 break;
845 {
846 OUString aAttrValue( rAttrValue );
848 aAttrValue ) )
849 pMutableAttrList->SetValueByIndex( i, aAttrValue );
850 }
851 break;
853 {
854 OUString aAttrValue( rAttrValue );
855 if( XMLTransformerBase::NegPercent(aAttrValue) )
856 pMutableAttrList->SetValueByIndex( i, aAttrValue );
857 }
858 break;
860 {
861 OUString aAttrValue( rAttrValue );
862 if( GetTransformer().ConvertURIToOOo( aAttrValue,
863 static_cast< bool >((*aIter).second.m_nParam1)))
864 pMutableAttrList->SetValueByIndex( i, aAttrValue );
865 }
866 break;
867 default:
868 OSL_ENSURE( false, "unknown action" );
869 break;
870 }
871 }
872 }
873
874 if( m_bControlStyle && nFamilyAttr != -1 )
875 pMutableAttrList->SetValueByIndex( nFamilyAttr, GetXMLToken( XML_CONTROL ) );
876
877 if( m_bPersistent )
879 else
880 GetTransformer().GetDocHandler()->startElement( GetExportQName(), xAttrList );
881}
882
884{
885 if( m_bPersistent )
886 {
888 }
889 else
890 {
891 // if a properties context exist close it
892 if( m_xPropContext.is() )
893 {
894 m_xPropContext->Export();
895 m_xPropContext = nullptr;
896 }
897 GetTransformer().GetDocHandler()->endElement( GetExportQName() );
898 }
899}
900
902{
903 // element content only:
904}
905
907{
908 if( m_xPropContext.is() )
909 m_xPropContext->Export();
911}
912
914{
915 return m_bPersistent;
916}
917
919 sal_uInt16 nType )
920{
921 XMLTransformerActionInit const *pInit = nullptr;
922
923 switch( nType )
924 {
927 break;
930 break;
933 break;
936 break;
939 break;
942 break;
945 break;
948 break;
951 break;
954 break;
957 break;
960 break;
963 break;
964 }
965
966 XMLTransformerActions *pActions = nullptr;
967 if( pInit )
968 pActions = new XMLTransformerActions( pInit );
969
970 return pActions;
971}
972
973/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ PROP_OASIS_SECTION_ATTR_ACTIONS
@ PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS
@ PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS
@ PROP_OASIS_TABLE_ROW_ATTR_ACTIONS
@ PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS
@ PROP_OASIS_PARAGRAPH_ATTR_ACTIONS
@ PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS
@ PROP_OASIS_GRAPHIC_ATTR_ACTIONS
@ OASIS_STYLE_ACTIONS
@ PROP_OASIS_TABLE_CELL_ATTR_ACTIONS
@ PROP_OASIS_TABLE_ATTR_ACTIONS
@ PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS
@ PROP_OASIS_TEXT_ATTR_ACTIONS
@ PROP_OASIS_CHART_ATTR_ACTIONS
@ MAX_OASIS_PROP_ACTIONS
@ XML_ATACTION_DECODE_STYLE_NAME_REF
@ XML_ATACTION_RENAME_DECODE_STYLE_NAME_REF
@ XML_ATACTION_IN2INCH
@ XML_ATACTION_REMOVE
@ XML_ATACTION_DECODE_STYLE_NAME
@ XML_ATACTION_INS2INCHS
@ XML_ATACTION_RENAME_NEG_PERCENT
@ XML_ATACTION_DRAW_MIRROR_OASIS
@ XML_ATACTION_GAMMA_OASIS
@ XML_ATACTION_OPACITY_FIX
@ XML_ATACTION_URI_OASIS
@ XML_ATACTION_RENAME
@ XML_ATACTION_STYLE_FAMILY
@ XML_ATACTION_STYLE_DISPLAY_NAME
@ XML_ATACTION_COPY
@ XML_ATACTION_NEG_PERCENT
XMLPropType
Definition: PropType.hxx:23
@ XML_PROP_TYPE_TABLE_ROW
Definition: PropType.hxx:34
@ XML_PROP_TYPE_PAGE_LAYOUT
Definition: PropType.hxx:26
@ XML_PROP_TYPE_TEXT
Definition: PropType.hxx:28
@ XML_PROP_TYPE_RUBY
Definition: PropType.hxx:30
@ XML_PROP_TYPE_TABLE_COLUMN
Definition: PropType.hxx:33
@ XML_PROP_TYPE_SECTION
Definition: PropType.hxx:31
@ XML_PROP_TYPE_TABLE_CELL
Definition: PropType.hxx:35
@ XML_PROP_TYPE_TABLE
Definition: PropType.hxx:32
@ XML_PROP_TYPE_CHART
Definition: PropType.hxx:37
@ XML_PROP_TYPE_PARAGRAPH
Definition: PropType.hxx:29
@ XML_PROP_TYPE_LIST_LEVEL
Definition: PropType.hxx:36
@ XML_PROP_TYPE_GRAPHIC
Definition: PropType.hxx:24
@ XML_PROP_TYPE_HEADER_FOOTER
Definition: PropType.hxx:27
@ XML_PROP_TYPE_DRAWING_PAGE
Definition: PropType.hxx:25
@ XML_PROP_TYPE_END
Definition: PropType.hxx:38
XMLTransformerActionInit const aTableColumnPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aPageLayoutPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aHeaderFooterPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aGraphicPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aSectionPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aListLevelPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aParagraphPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aDrawingPagePropertyOASISAttrActionTable[]
XMLTransformerActionInit const aChartPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTableRowPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTableCellPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTextPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTablePropertyOASISAttrActionTable[]
@ XML_OPTACTION_SYMBOL_NAME
@ XML_OPTACTION_INTERPOLATION
@ XML_OPTACTION_INTERVAL_MINOR_DIVISOR
@ XML_ATACTION_CAPTION_ESCAPE_OASIS
@ XML_OPTACTION_LINE_MODE
@ XML_OPTACTION_SYMBOL_TYPE
@ XML_OPTACTION_LINETHROUGH_STYLE
@ XML_OPTACTION_KEEP_WITH_NEXT
@ XML_OPTACTION_LINETHROUGH_TEXT
@ XML_OPTACTION_CONTROL_TEXT_ALIGN
@ XML_OPTACTION_UNDERLINE_WIDTH
@ XML_OPTACTION_INTERVAL_MAJOR
@ XML_OPTACTION_UNDERLINE_TYPE
@ XML_ATACTION_DECODE_PROTECT
@ XML_OPTACTION_OPACITY
@ XML_OPTACTION_LINETHROUGH_TYPE
@ XML_OPTACTION_LINETHROUGH_WIDTH
@ XML_OPTACTION_IMAGE_OPACITY
@ XML_OPTACTION_UNDERLINE_STYLE
@ XML_OPTACTION_KEEP_TOGETHER
const sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END]
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
bool getNextToken(std::u16string_view &rToken)
Definition: xmluconv.cxx:527
const OUString & GetExportQName() const
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void EndElement() override
virtual void ExportContent() override
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList
virtual void Export() override
static XMLPropType GetPropType(std::u16string_view rLocalName)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
void SetQNameAndPropType(const OUString &rQName, XMLPropType ePropType)
static OUString const & MergeUnderline(XMLTokenEnum eUnderline, bool bBold, bool bDouble)
static OUString const & MergeLineThrough(XMLTokenEnum eLineThrough, bool bBold, bool bDouble, sal_Unicode c)
XMLPropertiesTContext_Impl(XMLTransformerBase &rTransformer, const OUString &rQName, XMLPropType eP, bool _bControlStyle)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual ~XMLStyleOASISTContext() override
::rtl::Reference< XMLPropertiesTContext_Impl > m_xPropContext
virtual void EndElement() override
static XMLTransformerActions * CreateTransformerActions(sal_uInt16 nType)
virtual bool IsPersistent() const override
virtual void ExportContent() override
XMLStyleOASISTContext(XMLTransformerBase &rTransformer, const OUString &rQName, bool bPersistent)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void Characters(const OUString &rChars) override
virtual XMLTransformerActions * GetUserDefinedActions(sal_uInt16 n)
static bool DecodeStyleName(OUString &rName)
SvXMLNamespaceMap & GetNamespaceMap()
static bool ReplaceInWithInch(OUString &rValue)
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
static bool ReplaceSingleInWithInch(OUString &rValue)
::xmloff::token::XMLTokenEnum GetToken(const OUString &rStr) const
static bool NegPercent(OUString &rValue)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
void SetQName(const OUString &rQName)
XMLTransformerBase & GetTransformer()
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
sal_Int16 nValue
sal_Int32 nIndex
aBuf
int i
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ XML_TABLE_CELL_PROPERTIES
Definition: xmltoken.hxx:2627
@ XML_LIST_LEVEL_PROPERTIES
Definition: xmltoken.hxx:2628
@ XML_DRAWING_PAGE_PROPERTIES
Definition: xmltoken.hxx:2617
@ XML_GRADIENTSTYLE_SQUARE
Definition: xmltoken.hxx:985
@ XML_HEADER_FOOTER_PROPERTIES
Definition: xmltoken.hxx:2619
@ XML_HORIZONTAL_ON_RIGHT_PAGES
Definition: xmltoken.hxx:1034
@ XML_HORIZONTAL_ON_LEFT_PAGES
Definition: xmltoken.hxx:1033
@ XML_SECTION_PROPERTIES
Definition: xmltoken.hxx:2623
@ XML_TABLE_COLUMN_PROPERTIES
Definition: xmltoken.hxx:2625
@ XML_COLUMNSPLIT_AVOID
Definition: xmltoken.hxx:473
@ XML_PARAGRAPH_PROPERTIES
Definition: xmltoken.hxx:2621
@ XML_GRAPHIC_PROPERTIES
Definition: xmltoken.hxx:2616
@ XML_HORIZONTAL_ON_EVEN
Definition: xmltoken.hxx:3124
@ XML_PAGE_LAYOUT_PROPERTIES
Definition: xmltoken.hxx:2618
@ XML_TABLE_ROW_PROPERTIES
Definition: xmltoken.hxx:2626
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3573
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3517
QPRO_FUNC_TYPE nType
sal_uInt16 sal_Unicode
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr sal_uInt16 XML_NAMESPACE_FO
XMLTokenEnum eToken
Definition: xmltoken.cxx:40