LibreOffice Module xmloff (master) 1
MutableAttrList.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#include <sal/config.h>
21
24#include "MutableAttrList.hxx"
25
26
27using namespace ::com::sun::star::uno;
28using namespace ::com::sun::star::lang;
29using namespace ::com::sun::star::util;
30
32{
34 {
37 }
38
39 return m_pMutableAttrList.get();
40}
41
43 m_pMutableAttrList( new comphelper::AttributeList )
44{
46}
47
49 XAttributeList> & rAttrList, bool bClone ) :
50 m_xAttrList( rAttrList.is() ? rAttrList : new comphelper::AttributeList )
51{
52 if( bClone )
54}
55
56
58{
59 m_xAttrList = nullptr;
60}
61
63{
64 return m_xAttrList->getLength();
65}
66
67
68OUString SAL_CALL XMLMutableAttributeList::getNameByIndex(sal_Int16 i)
69{
70 return m_xAttrList->getNameByIndex( i );
71}
72
73
74OUString SAL_CALL XMLMutableAttributeList::getTypeByIndex(sal_Int16 i)
75{
76 return m_xAttrList->getTypeByIndex( i );
77}
78
79OUString SAL_CALL XMLMutableAttributeList::getValueByIndex(sal_Int16 i)
80{
81 return m_xAttrList->getValueByIndex( i );
82}
83
85 const OUString& rName )
86{
87 return m_xAttrList->getTypeByName( rName );
88}
89
91 const OUString& rName)
92{
93 return m_xAttrList->getValueByName( rName );
94}
95
96
97Reference< XCloneable > XMLMutableAttributeList::createClone()
98{
99 // A cloned list will be a read only list!
100 Reference< XCloneable > r = new comphelper::AttributeList( m_xAttrList );
101 return r;
102}
103
105 const OUString& rValue )
106{
108}
109
110void XMLMutableAttributeList::AddAttribute( const OUString &rName ,
111 const OUString &rValue )
112{
113 GetMutableAttrList()->AddAttribute( rName, rValue );
114}
115
117{
119}
120
122 const OUString& rNewName )
123{
125}
126
128 const Reference< css::xml::sax::XAttributeList >& r )
129{
131}
132
133sal_Int16 XMLMutableAttributeList::GetIndexByName( const OUString& rName ) const
134{
135 sal_Int16 nIndex = -1;
137 {
138 nIndex = m_pMutableAttrList->GetIndexByName( rName );
139 }
140 else
141 {
142 sal_Int16 nCount = m_xAttrList->getLength();
143 for( sal_Int16 i=0; nIndex==-1 && i<nCount ; ++i )
144 {
145 if( m_xAttrList->getNameByIndex(i) == rName )
146 nIndex = i;
147 }
148 }
149 return nIndex;
150}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) override
rtl::Reference< comphelper::AttributeList > m_pMutableAttrList
virtual ~XMLMutableAttributeList() override
virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) override
void AddAttribute(const OUString &sName, const OUString &sValue)
virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) override
virtual OUString SAL_CALL getValueByName(const OUString &aName) override
virtual OUString SAL_CALL getTypeByName(const OUString &aName) override
virtual sal_Int16 SAL_CALL getLength() override
sal_Int16 GetIndexByName(const OUString &rName) const
css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList
void RemoveAttributeByIndex(sal_Int16 i)
void AppendAttributeList(const css::uno::Reference< css::xml::sax::XAttributeList > &)
comphelper::AttributeList * GetMutableAttrList()
void RenameAttributeByIndex(sal_Int16 i, const OUString &rNewName)
void SetValueByIndex(sal_Int16 i, const OUString &rValue)
void RemoveAttributeByIndex(sal_Int16 i)
void RenameAttributeByIndex(sal_Int16 i, const OUString &rNewName)
void AppendAttributeList(const css::uno::Reference< css::xml::sax::XAttributeList > &)
void AddAttribute(const OUString &sName, const OUString &sValue)
void SetValueByIndex(sal_Int16 i, const OUString &rValue)
int nCount
sal_Int32 nIndex
int i