CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / hwpfilter / source / attributes.cxx
blob3b24d45b0351719fc818c10b74f04402266b91c6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <assert.h>
22 #include <utility>
23 #include <vector>
24 #include "attributes.hxx"
26 namespace {
28 struct TagAttribute
30 TagAttribute( OUString aName, OUString aType, OUString aValue )
31 : sName(std::move(aName)), sType(std::move(aType)), sValue(std::move(aValue))
35 OUString sName;
36 OUString sType;
37 OUString sValue;
42 struct AttributeListImpl_impl
44 AttributeListImpl_impl()
46 // performance improvement during adding
47 vecAttribute.reserve(20);
49 std::vector<struct TagAttribute> vecAttribute;
52 sal_Int16 SAL_CALL AttributeListImpl::getLength()
54 return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
58 AttributeListImpl::AttributeListImpl( const AttributeListImpl &r )
59 : cppu::WeakImplHelper<css::xml::sax::XAttributeList>( r ),
60 m_pImpl( new AttributeListImpl_impl )
62 *m_pImpl = *(r.m_pImpl);
66 OUString AttributeListImpl::getNameByIndex(sal_Int16 i)
68 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
69 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
71 return m_pImpl->vecAttribute[i].sName;
73 return OUString();
77 OUString AttributeListImpl::getTypeByIndex(sal_Int16 i)
79 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
80 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
82 return m_pImpl->vecAttribute[i].sType;
84 return OUString();
88 OUString AttributeListImpl::getValueByIndex(sal_Int16 i)
90 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
91 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
93 return m_pImpl->vecAttribute[i].sValue;
95 return OUString();
100 OUString AttributeListImpl::getTypeByName( const OUString& sName )
102 for (auto const& elem : m_pImpl->vecAttribute)
104 if( elem.sName == sName )
106 return elem.sType;
109 return OUString();
113 OUString AttributeListImpl::getValueByName(const OUString& sName)
115 for (auto const& elem : m_pImpl->vecAttribute)
117 if( elem.sName == sName )
119 return elem.sValue;
122 return OUString();
126 AttributeListImpl::AttributeListImpl()
127 : m_pImpl( new AttributeListImpl_impl )
132 AttributeListImpl::~AttributeListImpl()
137 void AttributeListImpl::addAttribute( const OUString &sName ,
138 const OUString &sType ,
139 const OUString &sValue )
141 m_pImpl->vecAttribute.emplace_back( sName , sType , sValue );
145 void AttributeListImpl::clear()
147 std::vector<struct TagAttribute>().swap(m_pImpl->vecAttribute);
149 assert( ! getLength() );
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */