LibreOffice Module hwpfilter (master) 1
attributes.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
21#include <assert.h>
22#include <utility>
23#include <vector>
24#include "attributes.hxx"
25
26namespace {
27
28struct TagAttribute
29{
30 TagAttribute( OUString aName, OUString aType, OUString aValue )
31 : sName(std::move(aName)), sType(std::move(aType)), sValue(std::move(aValue))
32 {
33 }
34
35 OUString sName;
36 OUString sType;
37 OUString sValue;
38};
39
40}
41
43{
45 {
46// performance improvement during adding
47 vecAttribute.reserve(20);
48 }
49 std::vector<struct TagAttribute> vecAttribute;
50};
51
52sal_Int16 SAL_CALL AttributeListImpl::getLength()
53{
54 return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
55}
56
57
59 : cppu::WeakImplHelper<css::xml::sax::XAttributeList>( r ),
61{
62 *m_pImpl = *(r.m_pImpl);
63}
64
65
67{
68 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
69 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
70 {
71 return m_pImpl->vecAttribute[i].sName;
72 }
73 return OUString();
74}
75
76
78{
79 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
80 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
81 {
82 return m_pImpl->vecAttribute[i].sType;
83 }
84 return OUString();
85}
86
87
89{
90 sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
91 if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
92 {
93 return m_pImpl->vecAttribute[i].sValue;
94 }
95 return OUString();
96
97}
98
99
100OUString AttributeListImpl::getTypeByName( const OUString& sName )
101{
102 for (auto const& elem : m_pImpl->vecAttribute)
103 {
104 if( elem.sName == sName )
105 {
106 return elem.sType;
107 }
108 }
109 return OUString();
110}
111
112
113OUString AttributeListImpl::getValueByName(const OUString& sName)
114{
115 for (auto const& elem : m_pImpl->vecAttribute)
116 {
117 if( elem.sName == sName )
118 {
119 return elem.sValue;
120 }
121 }
122 return OUString();
123}
124
125
128{
129}
130
131
133{
134}
135
136
137void AttributeListImpl::addAttribute( const OUString &sName ,
138const OUString &sType ,
139const OUString &sValue )
140{
141 m_pImpl->vecAttribute.emplace_back( sName , sType , sValue );
142}
143
144
146{
147 std::vector<struct TagAttribute>().swap(m_pImpl->vecAttribute);
148
149 assert( ! getLength() );
150}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) override
Definition: attributes.cxx:66
virtual OUString SAL_CALL getTypeByName(const OUString &aName) override
Definition: attributes.cxx:100
virtual ~AttributeListImpl() override
Definition: attributes.cxx:132
virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) override
Definition: attributes.cxx:88
std::unique_ptr< AttributeListImpl_impl > m_pImpl
Definition: attributes.hxx:55
virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) override
Definition: attributes.cxx:77
virtual OUString SAL_CALL getValueByName(const OUString &aName) override
Definition: attributes.cxx:113
void addAttribute(const OUString &sName, const OUString &sType, const OUString &sValue)
Definition: attributes.cxx:137
virtual sal_Int16 SAL_CALL getLength() override
Definition: attributes.cxx:52
OUString sName
OUString aName
int i
std::vector< struct TagAttribute > vecAttribute
Definition: attributes.cxx:49