fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / hwpfilter / source / attributes.cxx
bloba5749e8e0dd7451ac747fa95ca199d4178c3eb01
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 struct TagAttribute
27 TagAttribute( const OUString &rName, const OUString &rType , const OUString &rValue )
29 sName = rName;
30 sType = rType;
31 sValue = rValue;
34 OUString sName;
35 OUString sType;
36 OUString sValue;
39 struct AttributeListImpl_impl
41 AttributeListImpl_impl()
43 // performance improvement during adding
44 vecAttribute.reserve(20);
46 std::vector<struct TagAttribute> vecAttribute;
49 sal_Int16 SAL_CALL AttributeListImpl::getLength() throw (RuntimeException, std::exception)
51 return (sal_Int16)m_pImpl->vecAttribute.size();
55 AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) :
56 cppu::WeakImplHelper1<com::sun::star::xml::sax::XAttributeList>( r )
58 m_pImpl = new AttributeListImpl_impl;
59 *m_pImpl = *(r.m_pImpl);
63 OUString AttributeListImpl::getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
65 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
66 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
68 return m_pImpl->vecAttribute[i].sName;
70 return OUString();
74 OUString AttributeListImpl::getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
76 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
77 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
79 return m_pImpl->vecAttribute[i].sType;
81 return OUString();
85 OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
87 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
88 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
90 return m_pImpl->vecAttribute[i].sValue;
92 return OUString();
97 OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException, std::exception)
99 std::vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
101 for (; ii != m_pImpl->vecAttribute.end(); ++ii)
103 if( (*ii).sName == sName )
105 return (*ii).sType;
108 return OUString();
112 OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException, std::exception)
114 std::vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
116 for (; ii != m_pImpl->vecAttribute.end(); ++ii)
118 if( (*ii).sName == sName )
120 return (*ii).sValue;
123 return OUString();
127 AttributeListImpl::AttributeListImpl()
129 m_pImpl = new AttributeListImpl_impl;
133 AttributeListImpl::~AttributeListImpl()
135 delete m_pImpl;
139 void AttributeListImpl::addAttribute( const OUString &sName ,
140 const OUString &sType ,
141 const OUString &sValue )
143 m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
147 void AttributeListImpl::clear()
149 std::vector<struct TagAttribute> dummy;
150 m_pImpl->vecAttribute.swap( dummy );
152 assert( ! getLength() );
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */