Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/tools/NameContainer.cxx
Line
Count
Source
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 <NameContainer.hxx>
21
22
#include <com/sun/star/uno/Any.hxx>
23
24
#include <comphelper/sequence.hxx>
25
#include <cppuhelper/supportsservice.hxx>
26
27
using namespace ::com::sun::star;
28
using ::com::sun::star::uno::Sequence;
29
using ::com::sun::star::uno::Any;
30
31
namespace chart
32
{
33
34
35
NameContainer::NameContainer()
36
0
{
37
0
}
38
39
NameContainer::NameContainer( const NameContainer & rOther )
40
0
    : impl::NameContainer_Base(rOther)
41
0
    , m_aMap( rOther.m_aMap )
42
0
{
43
0
}
44
45
NameContainer::~NameContainer()
46
0
{
47
0
}
48
49
//XServiceInfo
50
OUString SAL_CALL NameContainer::getImplementationName()
51
0
{
52
0
    return u"com.sun.star.comp.chart.XMLNameSpaceMap"_ustr;
53
0
}
54
55
sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
56
0
{
57
0
    return cppu::supportsService(this, ServiceName);
58
0
}
59
60
Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames()
61
0
{
62
0
    return { u"com.sun.star.xml.NamespaceMap"_ustr };
63
0
}
64
65
// XNameContainer
66
void SAL_CALL NameContainer::insertByName( const OUString& rName, const Any& rElement )
67
0
{
68
0
    if( m_aMap.contains( rName ))
69
0
        throw container::ElementExistException();
70
0
    m_aMap.emplace( rName, rElement );
71
0
}
72
73
void SAL_CALL NameContainer::removeByName( const OUString& Name )
74
0
{
75
0
    tContentMap::iterator aIt( m_aMap.find( Name ));
76
0
    if( aIt == m_aMap.end())
77
0
        throw container::NoSuchElementException();
78
0
    m_aMap.erase( aIt );
79
0
}
80
81
// XNameReplace
82
void SAL_CALL NameContainer::replaceByName( const OUString& rName, const Any& rElement )
83
0
{
84
0
    tContentMap::iterator aIt( m_aMap.find( rName ));
85
0
    if( aIt == m_aMap.end() )
86
0
        throw container::NoSuchElementException();
87
0
    aIt->second = rElement;
88
0
}
89
90
// XNameAccess
91
Any SAL_CALL NameContainer::getByName( const OUString& rName )
92
0
{
93
0
    tContentMap::iterator aIter( m_aMap.find( rName ) );
94
0
    if( aIter == m_aMap.end() )
95
0
        throw container::NoSuchElementException();
96
0
    return aIter->second;
97
0
}
98
99
Sequence< OUString > SAL_CALL NameContainer::getElementNames()
100
0
{
101
0
    return comphelper::mapKeysToSequence(m_aMap);
102
0
}
103
104
sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName )
105
0
{
106
0
    return m_aMap.contains( rName );
107
0
}
108
109
// XElementAccess
110
sal_Bool SAL_CALL NameContainer::hasElements()
111
0
{
112
0
    return ! m_aMap.empty();
113
0
}
114
115
uno::Type SAL_CALL NameContainer::getElementType()
116
0
{
117
0
    return ::cppu::UnoType<OUString>::get();
118
0
}
119
120
// XCloneable
121
uno::Reference< util::XCloneable > SAL_CALL NameContainer::createClone()
122
0
{
123
0
    return uno::Reference< util::XCloneable >( new NameContainer( *this ));
124
0
}
125
126
} //namespace chart
127
128
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */