1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ChartOASISTContext.cxx,v $
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 "ChartOASISTContext.hxx"
34 #include "MutableAttrList.hxx"
35 #include "xmlnmspe.hxx"
36 #include "ActionMapTypesOASIS.hxx"
37 #include "AttrTransformerAction.hxx"
38 #include "TransformerActions.hxx"
39 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
40 #include "TransformerBase.hxx"
43 using ::rtl::OUString
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::xml::sax
;
47 using namespace ::xmloff::token
;
49 // -----------------------------------------------------------------------------
51 TYPEINIT1( XMLChartOASISTransformerContext
, XMLTransformerContext
);
53 XMLChartOASISTransformerContext::XMLChartOASISTransformerContext(
54 XMLTransformerBase
& rImp
,
55 const OUString
& rQName
) :
56 XMLTransformerContext( rImp
, rQName
)
60 XMLChartOASISTransformerContext::~XMLChartOASISTransformerContext()
64 void XMLChartOASISTransformerContext::StartElement(
65 const Reference
< XAttributeList
>& rAttrList
)
67 XMLTransformerActions
*pActions
=
68 GetTransformer().GetUserDefinedActions( OASIS_CHART_ACTIONS
);
69 OSL_ENSURE( pActions
, "go no actions" );
72 Reference
< XAttributeList
> xAttrList( rAttrList
);
73 XMLMutableAttributeList
*pMutableAttrList
= 0;
74 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
75 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
77 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
80 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName
,
82 XMLTransformerActions::key_type
aKey( nPrefix
, aLocalName
);
83 XMLTransformerActions::const_iterator aIter
=
84 pActions
->find( aKey
);
85 if( !(aIter
== pActions
->end() ) )
87 if( !pMutableAttrList
)
90 new XMLMutableAttributeList( xAttrList
);
91 xAttrList
= pMutableAttrList
;
93 const OUString
& rAttrValue
= xAttrList
->getValueByIndex( i
);
94 switch( (*aIter
).second
.m_nActionType
)
96 case XML_ATACTION_IN2INCH
:
98 OUString
aAttrValue( rAttrValue
);
99 if( XMLTransformerBase::ReplaceSingleInWithInch(
101 pMutableAttrList
->SetValueByIndex( i
, aAttrValue
);
104 case XML_ATACTION_DECODE_STYLE_NAME_REF
:
106 OUString
aAttrValue( rAttrValue
);
107 if( GetTransformer().DecodeStyleName(aAttrValue
) )
108 pMutableAttrList
->SetValueByIndex( i
, aAttrValue
);
111 case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX
:
112 OSL_ENSURE( IsXMLToken( aLocalName
, XML_CLASS
),
113 "unexpected class token" );
115 OUString aChartClass
;
116 sal_uInt16 nValuePrefix
=
117 GetTransformer().GetNamespaceMap().GetKeyByAttrName(
120 if( XML_NAMESPACE_CHART
== nValuePrefix
)
122 pMutableAttrList
->SetValueByIndex( i
, aChartClass
);
124 else if ( XML_NAMESPACE_OOO
== nValuePrefix
)
126 pMutableAttrList
->SetValueByIndex( i
,
127 GetXMLToken(XML_ADD_IN
) );
128 aAddInName
= aChartClass
;
133 OSL_ENSURE( !this, "unknown action" );
139 if( aAddInName
.getLength() > 0 )
141 OUString
aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
143 GetXMLToken( XML_ADD_IN_NAME
) ) );
144 pMutableAttrList
->AddAttribute( aAttrQName
, aAddInName
);
147 XMLTransformerContext::StartElement( xAttrList
);