Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "ChartOASISTContext.hxx"
30 : : #include "MutableAttrList.hxx"
31 : : #include "xmloff/xmlnmspe.hxx"
32 : : #include "ActionMapTypesOASIS.hxx"
33 : : #include "AttrTransformerAction.hxx"
34 : : #include "TransformerActions.hxx"
35 : : #include "TransformerBase.hxx"
36 : :
37 : : using ::rtl::OUString;
38 : :
39 : : using namespace ::com::sun::star::uno;
40 : : using namespace ::com::sun::star::xml::sax;
41 : : using namespace ::xmloff::token;
42 : :
43 : : // -----------------------------------------------------------------------------
44 : :
45 [ # # ][ # # ]: 0 : TYPEINIT1( XMLChartOASISTransformerContext, XMLTransformerContext );
46 : :
47 : 0 : XMLChartOASISTransformerContext::XMLChartOASISTransformerContext(
48 : : XMLTransformerBase& rImp,
49 : : const OUString& rQName ) :
50 : 0 : XMLTransformerContext( rImp, rQName )
51 : : {
52 : 0 : }
53 : :
54 : 0 : XMLChartOASISTransformerContext::~XMLChartOASISTransformerContext()
55 : : {
56 [ # # ]: 0 : }
57 : :
58 : 0 : void XMLChartOASISTransformerContext::StartElement(
59 : : const Reference< XAttributeList >& rAttrList )
60 : : {
61 : : XMLTransformerActions *pActions =
62 [ # # ]: 0 : GetTransformer().GetUserDefinedActions( OASIS_CHART_ACTIONS );
63 : : OSL_ENSURE( pActions, "go no actions" );
64 : :
65 : 0 : OUString aAddInName;
66 : 0 : Reference< XAttributeList > xAttrList( rAttrList );
67 : 0 : XMLMutableAttributeList *pMutableAttrList = 0;
68 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ # # ]
69 [ # # ]: 0 : for( sal_Int16 i=0; i < nAttrCount; i++ )
70 : : {
71 [ # # ][ # # ]: 0 : const OUString& rAttrName = xAttrList->getNameByIndex( i );
72 : 0 : OUString aLocalName;
73 : : sal_uInt16 nPrefix =
74 : 0 : GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
75 [ # # ]: 0 : &aLocalName );
76 : 0 : XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
77 : : XMLTransformerActions::const_iterator aIter =
78 [ # # ]: 0 : pActions->find( aKey );
79 [ # # ][ # # ]: 0 : if( !(aIter == pActions->end() ) )
80 : : {
81 [ # # ]: 0 : if( !pMutableAttrList )
82 : : {
83 : : pMutableAttrList =
84 [ # # ]: 0 : new XMLMutableAttributeList( xAttrList );
85 [ # # ][ # # ]: 0 : xAttrList = pMutableAttrList;
86 : : }
87 [ # # ][ # # ]: 0 : const OUString& rAttrValue = xAttrList->getValueByIndex( i );
88 [ # # ]: 0 : switch( (*aIter).second.m_nActionType )
[ # # # # ]
89 : : {
90 : : case XML_ATACTION_IN2INCH:
91 : : {
92 : 0 : OUString aAttrValue( rAttrValue );
93 [ # # ]: 0 : if( XMLTransformerBase::ReplaceSingleInWithInch(
94 [ # # ]: 0 : aAttrValue ) )
95 [ # # ]: 0 : pMutableAttrList->SetValueByIndex( i, aAttrValue );
96 : : }
97 : 0 : break;
98 : : case XML_ATACTION_DECODE_STYLE_NAME_REF:
99 : : {
100 : 0 : OUString aAttrValue( rAttrValue );
101 [ # # ][ # # ]: 0 : if( GetTransformer().DecodeStyleName(aAttrValue) )
102 [ # # ]: 0 : pMutableAttrList->SetValueByIndex( i, aAttrValue );
103 : : }
104 : 0 : break;
105 : : case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX:
106 : : OSL_ENSURE( IsXMLToken( aLocalName, XML_CLASS ),
107 : : "unexpected class token" );
108 : : {
109 : 0 : OUString aChartClass;
110 : : sal_uInt16 nValuePrefix =
111 : 0 : GetTransformer().GetNamespaceMap().GetKeyByAttrName(
112 : : rAttrValue,
113 [ # # ]: 0 : &aChartClass );
114 [ # # ]: 0 : if( XML_NAMESPACE_CHART == nValuePrefix )
115 : : {
116 [ # # ]: 0 : pMutableAttrList->SetValueByIndex( i, aChartClass );
117 : : }
118 [ # # ]: 0 : else if ( XML_NAMESPACE_OOO == nValuePrefix )
119 : : {
120 : : pMutableAttrList->SetValueByIndex( i,
121 [ # # ][ # # ]: 0 : GetXMLToken(XML_ADD_IN ) );
122 : 0 : aAddInName = aChartClass;
123 : 0 : }
124 : : }
125 : 0 : break;
126 : : default:
127 : : OSL_ENSURE( !this, "unknown action" );
128 : 0 : break;
129 : 0 : }
130 : : }
131 : 0 : }
132 : :
133 [ # # ]: 0 : if( !aAddInName.isEmpty() )
134 : : {
135 : 0 : OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
136 : : XML_NAMESPACE_CHART,
137 [ # # # # ]: 0 : GetXMLToken( XML_ADD_IN_NAME ) ) );
138 [ # # ]: 0 : pMutableAttrList->AddAttribute( aAttrQName, aAddInName );
139 : : }
140 : :
141 [ # # ]: 0 : XMLTransformerContext::StartElement( xAttrList );
142 : 0 : }
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|