/src/libreoffice/xmloff/source/transform/ChartOASISTContext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include "ChartOASISTContext.hxx" |
21 | | #include "MutableAttrList.hxx" |
22 | | #include <xmloff/xmlnamespace.hxx> |
23 | | #include "ActionMapTypesOASIS.hxx" |
24 | | #include "AttrTransformerAction.hxx" |
25 | | #include "TransformerActions.hxx" |
26 | | #include "TransformerBase.hxx" |
27 | | #include <osl/diagnose.h> |
28 | | |
29 | | using namespace ::com::sun::star::uno; |
30 | | using namespace ::com::sun::star::xml::sax; |
31 | | using namespace ::xmloff::token; |
32 | | |
33 | | XMLChartOASISTransformerContext::XMLChartOASISTransformerContext( |
34 | | XMLTransformerBase& rImp, |
35 | | const OUString& rQName ) : |
36 | 0 | XMLTransformerContext( rImp, rQName ) |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | XMLChartOASISTransformerContext::~XMLChartOASISTransformerContext() |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | void XMLChartOASISTransformerContext::StartElement( |
45 | | const Reference< XAttributeList >& rAttrList ) |
46 | 0 | { |
47 | 0 | XMLTransformerActions *pActions = |
48 | 0 | GetTransformer().GetUserDefinedActions( OASIS_CHART_ACTIONS ); |
49 | 0 | OSL_ENSURE( pActions, "go no actions" ); |
50 | |
|
51 | 0 | OUString aAddInName; |
52 | 0 | Reference< XAttributeList > xAttrList( rAttrList ); |
53 | 0 | rtl::Reference<XMLMutableAttributeList> pMutableAttrList; |
54 | 0 | sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; |
55 | 0 | for( sal_Int16 i=0; i < nAttrCount; i++ ) |
56 | 0 | { |
57 | 0 | const OUString aAttrName = xAttrList->getNameByIndex( i ); |
58 | 0 | OUString aLocalName; |
59 | 0 | sal_uInt16 nPrefix = |
60 | 0 | GetTransformer().GetNamespaceMap().GetKeyByAttrName( aAttrName, |
61 | 0 | &aLocalName ); |
62 | 0 | XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); |
63 | 0 | XMLTransformerActions::const_iterator aIter = |
64 | 0 | pActions->find( aKey ); |
65 | 0 | if( aIter != pActions->end() ) |
66 | 0 | { |
67 | 0 | if( !pMutableAttrList ) |
68 | 0 | { |
69 | 0 | pMutableAttrList = |
70 | 0 | new XMLMutableAttributeList( xAttrList ); |
71 | 0 | xAttrList = pMutableAttrList; |
72 | 0 | } |
73 | 0 | const OUString aAttrValue = xAttrList->getValueByIndex( i ); |
74 | 0 | switch( (*aIter).second.m_nActionType ) |
75 | 0 | { |
76 | 0 | case XML_ATACTION_IN2INCH: |
77 | 0 | { |
78 | 0 | OUString aAttrValue2( aAttrValue ); |
79 | 0 | if( XMLTransformerBase::ReplaceSingleInWithInch( |
80 | 0 | aAttrValue2 ) ) |
81 | 0 | pMutableAttrList->SetValueByIndex( i, aAttrValue2 ); |
82 | 0 | } |
83 | 0 | break; |
84 | 0 | case XML_ATACTION_DECODE_STYLE_NAME_REF: |
85 | 0 | { |
86 | 0 | OUString aAttrValue2( aAttrValue ); |
87 | 0 | if( XMLTransformerBase::DecodeStyleName(aAttrValue2) ) |
88 | 0 | pMutableAttrList->SetValueByIndex( i, aAttrValue2 ); |
89 | 0 | } |
90 | 0 | break; |
91 | 0 | case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX: |
92 | 0 | OSL_ENSURE( IsXMLToken( aLocalName, XML_CLASS ), |
93 | 0 | "unexpected class token" ); |
94 | 0 | { |
95 | 0 | OUString aChartClass; |
96 | 0 | sal_uInt16 nValuePrefix = |
97 | 0 | GetTransformer().GetNamespaceMap().GetKeyByAttrName( |
98 | 0 | aAttrValue, |
99 | 0 | &aChartClass ); |
100 | 0 | if( XML_NAMESPACE_CHART == nValuePrefix ) |
101 | 0 | { |
102 | 0 | pMutableAttrList->SetValueByIndex( i, aChartClass ); |
103 | 0 | } |
104 | 0 | else if ( XML_NAMESPACE_OOO == nValuePrefix ) |
105 | 0 | { |
106 | 0 | pMutableAttrList->SetValueByIndex( i, |
107 | 0 | GetXMLToken(XML_ADD_IN ) ); |
108 | 0 | aAddInName = aChartClass; |
109 | 0 | } |
110 | 0 | } |
111 | 0 | break; |
112 | 0 | default: |
113 | 0 | OSL_ENSURE( false, "unknown action" ); |
114 | 0 | break; |
115 | 0 | } |
116 | 0 | } |
117 | 0 | } |
118 | | |
119 | 0 | if( !aAddInName.isEmpty() ) |
120 | 0 | { |
121 | 0 | OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey( |
122 | 0 | XML_NAMESPACE_CHART, |
123 | 0 | GetXMLToken( XML_ADD_IN_NAME ) ) ); |
124 | 0 | assert(pMutableAttrList && "pMutableAttrList should be assigned in a superset of the enclosing if condition entry logic"); |
125 | 0 | pMutableAttrList->AddAttribute( aAttrQName, aAddInName ); |
126 | 0 | } |
127 | |
|
128 | 0 | XMLTransformerContext::StartElement( xAttrList ); |
129 | 0 | } |
130 | | |
131 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |