LibreOffice Module xmloff (master) 1
ChartOASISTContext.cxx
Go to the documentation of this file.
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
21#include "MutableAttrList.hxx"
26#include "TransformerBase.hxx"
27#include <osl/diagnose.h>
28
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::xml::sax;
31using namespace ::xmloff::token;
32
35 const OUString& rQName ) :
36 XMLTransformerContext( rImp, rQName )
37{
38}
39
41{
42}
43
45 const Reference< XAttributeList >& rAttrList )
46{
47 XMLTransformerActions *pActions =
49 OSL_ENSURE( pActions, "go no actions" );
50
51 OUString aAddInName;
52 Reference< XAttributeList > xAttrList( rAttrList );
54 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
55 for( sal_Int16 i=0; i < nAttrCount; i++ )
56 {
57 const OUString& rAttrName = xAttrList->getNameByIndex( i );
58 OUString aLocalName;
59 sal_uInt16 nPrefix =
61 &aLocalName );
62 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
63 XMLTransformerActions::const_iterator aIter =
64 pActions->find( aKey );
65 if( aIter != pActions->end() )
66 {
67 if( !pMutableAttrList )
68 {
69 pMutableAttrList =
70 new XMLMutableAttributeList( xAttrList );
71 xAttrList = pMutableAttrList;
72 }
73 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
74 switch( (*aIter).second.m_nActionType )
75 {
77 {
78 OUString aAttrValue( rAttrValue );
80 aAttrValue ) )
81 pMutableAttrList->SetValueByIndex( i, aAttrValue );
82 }
83 break;
85 {
86 OUString aAttrValue( rAttrValue );
88 pMutableAttrList->SetValueByIndex( i, aAttrValue );
89 }
90 break;
92 OSL_ENSURE( IsXMLToken( aLocalName, XML_CLASS ),
93 "unexpected class token" );
94 {
95 OUString aChartClass;
96 sal_uInt16 nValuePrefix =
98 rAttrValue,
99 &aChartClass );
100 if( XML_NAMESPACE_CHART == nValuePrefix )
101 {
102 pMutableAttrList->SetValueByIndex( i, aChartClass );
103 }
104 else if ( XML_NAMESPACE_OOO == nValuePrefix )
105 {
106 pMutableAttrList->SetValueByIndex( i,
108 aAddInName = aChartClass;
109 }
110 }
111 break;
112 default:
113 OSL_ENSURE( false, "unknown action" );
114 break;
115 }
116 }
117 }
118
119 if( !aAddInName.isEmpty() )
120 {
121 OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
124 assert(pMutableAttrList && "coverity[var_deref_model] - pMutableAttrList should be assigned in a superset of the enclosing if condition entry logic");
125 pMutableAttrList->AddAttribute( aAttrQName, aAddInName );
126 }
127
129}
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ OASIS_CHART_ACTIONS
@ XML_ATACTION_DECODE_STYLE_NAME_REF
@ XML_ATACTION_IN2INCH
@ XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
XMLChartOASISTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual ~XMLChartOASISTransformerContext() override
virtual XMLTransformerActions * GetUserDefinedActions(sal_uInt16 n)
static bool DecodeStyleName(OUString &rName)
SvXMLNamespaceMap & GetNamespaceMap()
static bool ReplaceSingleInWithInch(OUString &rValue)
XMLTransformerBase & GetTransformer()
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
int i
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3575
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3519
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_OOO