1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "ChartOASISTContext.hxx"
21 #include "MutableAttrList.hxx"
22 #include "xmloff/xmlnmspe.hxx"
23 #include "ActionMapTypesOASIS.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( XMLChartOASISTransformerContext
, XMLTransformerContext
);
37 XMLChartOASISTransformerContext::XMLChartOASISTransformerContext(
38 XMLTransformerBase
& rImp
,
39 const OUString
& rQName
) :
40 XMLTransformerContext( rImp
, rQName
)
44 XMLChartOASISTransformerContext::~XMLChartOASISTransformerContext()
48 void XMLChartOASISTransformerContext::StartElement(
49 const Reference
< XAttributeList
>& rAttrList
)
51 XMLTransformerActions
*pActions
=
52 GetTransformer().GetUserDefinedActions( OASIS_CHART_ACTIONS
);
53 OSL_ENSURE( pActions
, "go no actions" );
56 Reference
< XAttributeList
> xAttrList( rAttrList
);
57 XMLMutableAttributeList
*pMutableAttrList
= 0;
58 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
59 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
61 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
64 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
66 XMLTransformerActions::key_type
aKey( nPrefix
, aLocalName
);
67 XMLTransformerActions::const_iterator aIter
=
68 pActions
->find( aKey
);
69 if( !(aIter
== pActions
->end() ) )
71 if( !pMutableAttrList
)
74 new XMLMutableAttributeList( xAttrList
);
75 xAttrList
= pMutableAttrList
;
77 const OUString
& rAttrValue
= xAttrList
->getValueByIndex( i
);
78 switch( (*aIter
).second
.m_nActionType
)
80 case XML_ATACTION_IN2INCH
:
82 OUString
aAttrValue( rAttrValue
);
83 if( XMLTransformerBase::ReplaceSingleInWithInch(
85 pMutableAttrList
->SetValueByIndex( i
, aAttrValue
);
88 case XML_ATACTION_DECODE_STYLE_NAME_REF
:
90 OUString
aAttrValue( rAttrValue
);
91 if( GetTransformer().DecodeStyleName(aAttrValue
) )
92 pMutableAttrList
->SetValueByIndex( i
, aAttrValue
);
95 case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX
:
96 OSL_ENSURE( IsXMLToken( aLocalName
, XML_CLASS
),
97 "unexpected class token" );
100 sal_uInt16 nValuePrefix
=
101 GetTransformer().GetNamespaceMap().GetKeyByAttrName(
104 if( XML_NAMESPACE_CHART
== nValuePrefix
)
106 pMutableAttrList
->SetValueByIndex( i
, aChartClass
);
108 else if ( XML_NAMESPACE_OOO
== nValuePrefix
)
110 pMutableAttrList
->SetValueByIndex( i
,
111 GetXMLToken(XML_ADD_IN
) );
112 aAddInName
= aChartClass
;
117 OSL_ENSURE( !this, "unknown action" );
123 if( !aAddInName
.isEmpty() )
125 OUString
aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
127 GetXMLToken( XML_ADD_IN_NAME
) ) );
128 pMutableAttrList
->AddAttribute( aAttrQName
, aAddInName
);
131 XMLTransformerContext::StartElement( xAttrList
);
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */