nss: upgrade to release 3.73
[LibreOffice.git] / hwpfilter / source / attributes.cxx
blob1c0712b0f9ab46749d934e9336c5d57ed1cba2f8
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 <vector>
23 #include "attributes.hxx"
25 namespace {
27 struct TagAttribute
29 TagAttribute( const OUString &rName, const OUString &rType , const OUString &rValue )
30 : sName(rName), sType(rType), sValue(rValue)
34 OUString sName;
35 OUString sType;
36 OUString sValue;
41 struct AttributeListImpl_impl
43 AttributeListImpl_impl()
45 // performance improvement during adding
46 vecAttribute.reserve(20);
48 std::vector<struct TagAttribute> vecAttribute;
51 sal_Int16 SAL_CALL AttributeListImpl::getLength()
53 return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
57 AttributeListImpl::AttributeListImpl( const AttributeListImpl &r )
58 : cppu::WeakImplHelper<css::xml::sax::XAttributeList>( r ),
59 m_pImpl( new AttributeListImpl_impl )
61 *m_pImpl = *(r.m_pImpl);
65 OUString AttributeListImpl::getNameByIndex(sal_Int16 i)
67 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
68 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
70 return m_pImpl->vecAttribute[i].sName;
72 return OUString();
76 OUString AttributeListImpl::getTypeByIndex(sal_Int16 i)
78 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
79 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
81 return m_pImpl->vecAttribute[i].sType;
83 return OUString();
87 OUString AttributeListImpl::getValueByIndex(sal_Int16 i)
89 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
90 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
92 return m_pImpl->vecAttribute[i].sValue;
94 return OUString();
99 OUString AttributeListImpl::getTypeByName( const OUString& sName )
101 for (auto const& elem : m_pImpl->vecAttribute)
103 if( elem.sName == sName )
105 return elem.sType;
108 return OUString();
112 OUString AttributeListImpl::getValueByName(const OUString& sName)
114 for (auto const& elem : m_pImpl->vecAttribute)
116 if( elem.sName == sName )
118 return elem.sValue;
121 return OUString();
125 AttributeListImpl::AttributeListImpl()
126 : m_pImpl( new AttributeListImpl_impl )
131 AttributeListImpl::~AttributeListImpl()
136 void AttributeListImpl::addAttribute( const OUString &sName ,
137 const OUString &sType ,
138 const OUString &sValue )
140 m_pImpl->vecAttribute.emplace_back( sName , sType , sValue );
144 void AttributeListImpl::clear()
146 std::vector<struct TagAttribute> dummy;
147 m_pImpl->vecAttribute.swap( dummy );
149 assert( ! getLength() );
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */