Update ooo320-m1
[ooovba.git] / xmloff / source / transform / ChartOOoTContext.cxx
blobdea76f27b2fb4b0fa8c81df97f8c5f7bbcdcbc06
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartOOoTContext.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include "ChartOOoTContext.hxx"
34 #include "MutableAttrList.hxx"
35 #include "xmlnmspe.hxx"
36 #ifndef _XMLOFF_ACTIONMAPTYPESOOo_HXX
37 #include "ActionMapTypesOOo.hxx"
38 #endif
39 #include "AttrTransformerAction.hxx"
40 #include "TransformerActions.hxx"
41 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
42 #include "TransformerBase.hxx"
43 #endif
45 using ::rtl::OUString;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::xml::sax;
49 using namespace ::xmloff::token;
51 // -----------------------------------------------------------------------------
53 TYPEINIT1( XMLChartOOoTransformerContext, XMLTransformerContext );
55 XMLChartOOoTransformerContext::XMLChartOOoTransformerContext(
56 XMLTransformerBase& rImp,
57 const OUString& rQName ) :
58 XMLTransformerContext( rImp, rQName )
62 XMLChartOOoTransformerContext::~XMLChartOOoTransformerContext()
66 void XMLChartOOoTransformerContext::StartElement(
67 const Reference< XAttributeList >& rAttrList )
69 XMLTransformerActions *pActions =
70 GetTransformer().GetUserDefinedActions( OOO_CHART_ACTIONS );
71 OSL_ENSURE( pActions, "go no actions" );
73 sal_Int16 nClassName = -1;
74 OUString aAddInName;
75 Reference< XAttributeList > xAttrList( rAttrList );
76 XMLMutableAttributeList *pMutableAttrList = 0;
77 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
78 for( sal_Int16 i=0; i < nAttrCount; i++ )
80 const OUString& rAttrName = xAttrList->getNameByIndex( i );
81 OUString aLocalName;
82 sal_uInt16 nPrefix =
83 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
84 &aLocalName );
85 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
86 XMLTransformerActions::const_iterator aIter =
87 pActions->find( aKey );
88 if( !(aIter == pActions->end() ) )
90 if( !pMutableAttrList )
92 pMutableAttrList =
93 new XMLMutableAttributeList( xAttrList );
94 xAttrList = pMutableAttrList;
96 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
97 switch( (*aIter).second.m_nActionType )
99 case XML_ATACTION_INCH2IN:
101 OUString aAttrValue( rAttrValue );
102 if( XMLTransformerBase::ReplaceSingleInchWithIn(
103 aAttrValue ) )
104 pMutableAttrList->SetValueByIndex( i, aAttrValue );
106 break;
107 case XML_ATACTION_ENCODE_STYLE_NAME_REF:
109 OUString aAttrValue( rAttrValue );
110 if( GetTransformer().EncodeStyleName(aAttrValue) )
111 pMutableAttrList->SetValueByIndex( i, aAttrValue );
113 break;
114 case XML_ATACTION_ADD_NAMESPACE_PREFIX:
115 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_CLASS ),
116 "unexpected class token" );
117 if( ::xmloff::token::IsXMLToken( rAttrValue, XML_ADD_IN ) )
119 nClassName = i;
121 else
123 OUString aAttrValue( rAttrValue );
124 sal_uInt16 nValPrefix =
125 static_cast<sal_uInt16>((*aIter).second.m_nParam1);
126 if( GetTransformer().AddNamespacePrefix( aAttrValue,
127 nValPrefix ) )
128 pMutableAttrList->SetValueByIndex( i, aAttrValue );
130 break;
131 case XML_ATACTION_REMOVE:
132 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_ADD_IN_NAME ),
133 "unexpected class token" );
134 aAddInName = rAttrValue;
135 pMutableAttrList->RemoveAttributeByIndex( i );
136 --i;
137 --nAttrCount;
138 break;
139 default:
140 OSL_ENSURE( !this, "unknown action" );
141 break;
146 if( nClassName != -1 && aAddInName.getLength() > 0 )
148 GetTransformer().AddNamespacePrefix( aAddInName, XML_NAMESPACE_OOO );
149 pMutableAttrList->SetValueByIndex( nClassName, aAddInName );
152 XMLTransformerContext::StartElement( xAttrList );