LibreOffice Module xmloff (master) 1
ChartOOoTContext.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
20#include "ChartOOoTContext.hxx"
21#include "MutableAttrList.hxx"
23#include "ActionMapTypesOOo.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 sal_Int16 nClassName = -1;
52 OUString aAddInName;
53 Reference< XAttributeList > xAttrList( rAttrList );
55 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
56 for( sal_Int16 i=0; i < nAttrCount; i++ )
57 {
58 const OUString& rAttrName = xAttrList->getNameByIndex( i );
59 OUString aLocalName;
60 sal_uInt16 nPrefix =
62 &aLocalName );
63 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
64 XMLTransformerActions::const_iterator aIter =
65 pActions->find( aKey );
66 if( aIter != pActions->end() )
67 {
68 if( !pMutableAttrList )
69 {
70 pMutableAttrList =
71 new XMLMutableAttributeList( xAttrList );
72 xAttrList = pMutableAttrList;
73 }
74 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
75 switch( (*aIter).second.m_nActionType )
76 {
78 {
79 OUString aAttrValue( rAttrValue );
81 aAttrValue ) )
82 pMutableAttrList->SetValueByIndex( i, aAttrValue );
83 }
84 break;
86 {
87 OUString aAttrValue( rAttrValue );
88 if( GetTransformer().EncodeStyleName(aAttrValue) )
89 pMutableAttrList->SetValueByIndex( i, aAttrValue );
90 }
91 break;
93 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_CLASS ),
94 "unexpected class token" );
95 if( ::xmloff::token::IsXMLToken( rAttrValue, XML_ADD_IN ) )
96 {
97 nClassName = i;
98 }
99 else
100 {
101 OUString aAttrValue( rAttrValue );
102 sal_uInt16 nValPrefix =
103 static_cast<sal_uInt16>((*aIter).second.m_nParam1);
105 nValPrefix );
106 pMutableAttrList->SetValueByIndex( i, aAttrValue );
107 }
108 break;
110 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_ADD_IN_NAME ),
111 "unexpected class token" );
112 aAddInName = rAttrValue;
113 pMutableAttrList->RemoveAttributeByIndex( i );
114 --i;
115 --nAttrCount;
116 break;
117 default:
118 OSL_ENSURE( false, "unknown action" );
119 break;
120 }
121 }
122 }
123
124 if( nClassName != -1 && !aAddInName.isEmpty() )
125 {
127 pMutableAttrList->SetValueByIndex( nClassName, aAddInName );
128 }
129
131}
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ OOO_CHART_ACTIONS
@ XML_ATACTION_REMOVE
@ XML_ATACTION_ENCODE_STYLE_NAME_REF
@ XML_ATACTION_INCH2IN
@ XML_ATACTION_ADD_NAMESPACE_PREFIX
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
virtual ~XMLChartOOoTransformerContext() override
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
XMLChartOOoTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual XMLTransformerActions * GetUserDefinedActions(sal_uInt16 n)
void AddNamespacePrefix(OUString &rName, sal_uInt16 nPrefix) const
SvXMLNamespaceMap & GetNamespaceMap()
static bool ReplaceSingleInchWithIn(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:3597
constexpr sal_uInt16 XML_NAMESPACE_OOO