bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / transform / ChartOOoTContext.cxx
blobde86f2895b0f530c4bec776be34f89807fb02bc8
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 "ChartOOoTContext.hxx"
21 #include "MutableAttrList.hxx"
22 #include "xmloff/xmlnmspe.hxx"
23 #include "ActionMapTypesOOo.hxx"
24 #include "AttrTransformerAction.hxx"
25 #include "TransformerActions.hxx"
26 #include "TransformerBase.hxx"
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::xml::sax;
31 using namespace ::xmloff::token;
33 // -----------------------------------------------------------------------------
35 TYPEINIT1( XMLChartOOoTransformerContext, XMLTransformerContext );
37 XMLChartOOoTransformerContext::XMLChartOOoTransformerContext(
38 XMLTransformerBase& rImp,
39 const OUString& rQName ) :
40 XMLTransformerContext( rImp, rQName )
44 XMLChartOOoTransformerContext::~XMLChartOOoTransformerContext()
48 void XMLChartOOoTransformerContext::StartElement(
49 const Reference< XAttributeList >& rAttrList )
51 XMLTransformerActions *pActions =
52 GetTransformer().GetUserDefinedActions( OOO_CHART_ACTIONS );
53 OSL_ENSURE( pActions, "go no actions" );
55 sal_Int16 nClassName = -1;
56 OUString aAddInName;
57 Reference< XAttributeList > xAttrList( rAttrList );
58 XMLMutableAttributeList *pMutableAttrList = 0;
59 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
60 for( sal_Int16 i=0; i < nAttrCount; i++ )
62 const OUString& rAttrName = xAttrList->getNameByIndex( i );
63 OUString aLocalName;
64 sal_uInt16 nPrefix =
65 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
66 &aLocalName );
67 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
68 XMLTransformerActions::const_iterator aIter =
69 pActions->find( aKey );
70 if( !(aIter == pActions->end() ) )
72 if( !pMutableAttrList )
74 pMutableAttrList =
75 new XMLMutableAttributeList( xAttrList );
76 xAttrList = pMutableAttrList;
78 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
79 switch( (*aIter).second.m_nActionType )
81 case XML_ATACTION_INCH2IN:
83 OUString aAttrValue( rAttrValue );
84 if( XMLTransformerBase::ReplaceSingleInchWithIn(
85 aAttrValue ) )
86 pMutableAttrList->SetValueByIndex( i, aAttrValue );
88 break;
89 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
91 OUString aAttrValue( rAttrValue );
92 if( GetTransformer().EncodeStyleName(aAttrValue) )
93 pMutableAttrList->SetValueByIndex( i, aAttrValue );
95 break;
96 case XML_ATACTION_ADD_NAMESPACE_PREFIX:
97 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_CLASS ),
98 "unexpected class token" );
99 if( ::xmloff::token::IsXMLToken( rAttrValue, XML_ADD_IN ) )
101 nClassName = i;
103 else
105 OUString aAttrValue( rAttrValue );
106 sal_uInt16 nValPrefix =
107 static_cast<sal_uInt16>((*aIter).second.m_nParam1);
108 if( GetTransformer().AddNamespacePrefix( aAttrValue,
109 nValPrefix ) )
110 pMutableAttrList->SetValueByIndex( i, aAttrValue );
112 break;
113 case XML_ATACTION_REMOVE:
114 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_ADD_IN_NAME ),
115 "unexpected class token" );
116 aAddInName = rAttrValue;
117 pMutableAttrList->RemoveAttributeByIndex( i );
118 --i;
119 --nAttrCount;
120 break;
121 default:
122 OSL_ENSURE( !this, "unknown action" );
123 break;
128 if( nClassName != -1 && !aAddInName.isEmpty() )
130 GetTransformer().AddNamespacePrefix( aAddInName, XML_NAMESPACE_OOO );
131 pMutableAttrList->SetValueByIndex( nClassName, aAddInName );
134 XMLTransformerContext::StartElement( xAttrList );
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */