1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <NameContainer.hxx>
22 #include <com/sun/star/uno/Any.hxx>
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/supportsservice.hxx>
27 using namespace ::com::sun::star
;
28 using ::com::sun::star::uno::Sequence
;
29 using ::com::sun::star::uno::Any
;
35 NameContainer::NameContainer()
39 NameContainer::NameContainer( const NameContainer
& rOther
)
40 : impl::NameContainer_Base(rOther
)
41 , m_aMap( rOther
.m_aMap
)
45 NameContainer::~NameContainer()
50 OUString SAL_CALL
NameContainer::getImplementationName()
52 return "com.sun.star.comp.chart.XMLNameSpaceMap";
55 sal_Bool SAL_CALL
NameContainer::supportsService( const OUString
& ServiceName
)
57 return cppu::supportsService(this, ServiceName
);
60 Sequence
< OUString
> SAL_CALL
NameContainer::getSupportedServiceNames()
62 return { "com.sun.star.xml.NamespaceMap" };
66 void SAL_CALL
NameContainer::insertByName( const OUString
& rName
, const Any
& rElement
)
68 if( m_aMap
.find( rName
) != m_aMap
.end() )
69 throw container::ElementExistException();
70 m_aMap
.emplace( rName
, rElement
);
73 void SAL_CALL
NameContainer::removeByName( const OUString
& Name
)
75 tContentMap::iterator
aIt( m_aMap
.find( Name
));
76 if( aIt
== m_aMap
.end())
77 throw container::NoSuchElementException();
82 void SAL_CALL
NameContainer::replaceByName( const OUString
& rName
, const Any
& rElement
)
84 tContentMap::iterator
aIt( m_aMap
.find( rName
));
85 if( aIt
== m_aMap
.end() )
86 throw container::NoSuchElementException();
87 aIt
->second
= rElement
;
91 Any SAL_CALL
NameContainer::getByName( const OUString
& rName
)
93 tContentMap::iterator
aIter( m_aMap
.find( rName
) );
94 if( aIter
== m_aMap
.end() )
95 throw container::NoSuchElementException();
99 Sequence
< OUString
> SAL_CALL
NameContainer::getElementNames()
101 return comphelper::mapKeysToSequence(m_aMap
);
104 sal_Bool SAL_CALL
NameContainer::hasByName( const OUString
& rName
)
106 return ( m_aMap
.find( rName
) != m_aMap
.end() );
110 sal_Bool SAL_CALL
NameContainer::hasElements()
112 return ! m_aMap
.empty();
115 uno::Type SAL_CALL
NameContainer::getElementType()
117 return ::cppu::UnoType
<OUString
>::get();
121 uno::Reference
< util::XCloneable
> SAL_CALL
NameContainer::createClone()
123 return uno::Reference
< util::XCloneable
>( new NameContainer( *this ));
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */