fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sax / source / expatwrap / attrlistimpl.cxx
blob0eba8f06217d94853b160639a083d130ef037139
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 .
20 #include "attrlistimpl.hxx"
22 #include <vector>
24 #include <cppuhelper/weak.hxx>
26 using namespace ::std;
27 using namespace ::cppu;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::util;
30 using namespace ::com::sun::star::xml::sax;
33 namespace sax_expatwrap {
34 struct TagAttribute
36 TagAttribute( const OUString &aName, const OUString &aType , const OUString &aValue )
38 this->sName = aName;
39 this->sType = aType;
40 this->sValue = aValue;
43 OUString sName;
44 OUString sType;
45 OUString sValue;
48 struct AttributeList_impl
50 AttributeList_impl()
52 // performance improvement during adding
53 vecAttribute.reserve(20);
55 vector<struct TagAttribute> vecAttribute;
60 sal_Int16 AttributeList::getLength() throw (RuntimeException, std::exception)
62 return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
66 AttributeList::AttributeList( const AttributeList &r ) :
67 cppu::WeakImplHelper2<XAttributeList, XCloneable>()
69 m_pImpl = new AttributeList_impl;
70 *m_pImpl = *(r.m_pImpl);
73 OUString AttributeList::getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
75 if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
76 return m_pImpl->vecAttribute[i].sName;
78 return OUString();
82 OUString AttributeList::getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
84 if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
85 return m_pImpl->vecAttribute[i].sType;
87 return OUString();
90 OUString AttributeList::getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
92 if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
93 return m_pImpl->vecAttribute[i].sValue;
95 return OUString();
99 OUString AttributeList::getTypeByName( const OUString& sName ) throw (RuntimeException, std::exception)
101 vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
103 for (; ii != m_pImpl->vecAttribute.end(); ++ii )
105 if( (*ii).sName == sName )
107 return (*ii).sType;
110 return OUString();
113 OUString AttributeList::getValueByName(const OUString& sName) throw (RuntimeException, std::exception)
115 vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
117 for (; ii != m_pImpl->vecAttribute.end(); ++ii)
119 if( (*ii).sName == sName )
121 return (*ii).sValue;
124 return OUString();
128 Reference< XCloneable > AttributeList::createClone() throw (RuntimeException, std::exception)
130 AttributeList *p = new AttributeList( *this );
131 return Reference< XCloneable > ( (XCloneable * ) p );
136 AttributeList::AttributeList()
138 m_pImpl = new AttributeList_impl;
143 AttributeList::~AttributeList()
145 delete m_pImpl;
149 void AttributeList::addAttribute( const OUString &sName ,
150 const OUString &sType ,
151 const OUString &sValue )
153 m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
156 void AttributeList::clear()
158 m_pImpl->vecAttribute.clear();
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */