Branch data Line data Source code
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 "NameContainer.hxx"
22 : :
23 : : #include <com/sun/star/uno/Any.hxx>
24 : :
25 : : using namespace ::com::sun::star;
26 : : using ::com::sun::star::uno::Sequence;
27 : : using ::com::sun::star::uno::Any;
28 : : using ::rtl::OUString;
29 : :
30 : :
31 : : //.............................................................................
32 : : namespace chart
33 : : {
34 : : //.............................................................................
35 : :
36 : 56 : uno::Reference< container::XNameContainer > createNameContainer(
37 : : const ::com::sun::star::uno::Type& rType, const rtl::OUString& rServicename, const rtl::OUString& rImplementationName )
38 : : {
39 [ + - ][ + - ]: 56 : return new NameContainer( rType, rServicename, rImplementationName );
40 : : }
41 : :
42 : 56 : NameContainer::NameContainer( const ::com::sun::star::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
43 : : : m_aType( rType )
44 : : , m_aServicename( rServicename )
45 : : , m_aImplementationName( rImplementationName )
46 [ + - ]: 56 : , m_aMap()
47 : : {
48 : 56 : }
49 : :
50 : 0 : NameContainer::NameContainer(
51 : : const NameContainer & rOther )
52 : : : impl::NameContainer_Base()
53 : : , m_aType( rOther.m_aType )
54 : : , m_aServicename( rOther.m_aServicename )
55 : : , m_aImplementationName( rOther.m_aImplementationName )
56 [ # # ]: 0 : , m_aMap( rOther.m_aMap )
57 : : {
58 : 0 : }
59 : :
60 : 56 : NameContainer::~NameContainer()
61 : : {
62 [ - + ]: 112 : }
63 : :
64 : : //XServiceInfo
65 : 0 : OUString SAL_CALL NameContainer::getImplementationName()
66 : : throw( ::com::sun::star::uno::RuntimeException )
67 : : {
68 : 0 : return m_aImplementationName;
69 : : }
70 : :
71 : 0 : sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
72 : : throw( ::com::sun::star::uno::RuntimeException )
73 : : {
74 [ # # ]: 0 : Sequence< OUString > aSNL = getSupportedServiceNames();
75 [ # # ]: 0 : const OUString* pArray = aSNL.getArray();
76 [ # # ]: 0 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
77 : : {
78 [ # # ]: 0 : if( pArray[ i ] == ServiceName )
79 : 0 : return sal_True;
80 : : }
81 [ # # ]: 0 : return sal_False;
82 : : }
83 : :
84 : 0 : Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames()
85 : : throw( ::com::sun::star::uno::RuntimeException )
86 : : {
87 : 0 : Sequence< OUString > aSNS( 1 );
88 [ # # ]: 0 : aSNS.getArray()[ 0 ] = m_aServicename;
89 : 0 : return aSNS;
90 : : }
91 : :
92 : : //-----------------------------------------------------------------
93 : : //-----------------------------------------------------------------
94 : : //-----------------------------------------------------------------
95 : :
96 : : // XNameContainer
97 : 0 : void SAL_CALL NameContainer::insertByName( const OUString& rName, const Any& rElement )
98 : : throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
99 : : {
100 [ # # ][ # # ]: 0 : if( m_aMap.find( rName ) != m_aMap.end() )
101 [ # # ]: 0 : throw container::ElementExistException();
102 [ # # ]: 0 : m_aMap.insert( tContentMap::value_type( rName, rElement ));
103 : 0 : }
104 : :
105 : :
106 : :
107 : 0 : void SAL_CALL NameContainer::removeByName( const OUString& Name )
108 : : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
109 : : {
110 [ # # ]: 0 : tContentMap::iterator aIt( m_aMap.find( Name ));
111 [ # # ]: 0 : if( aIt == m_aMap.end())
112 [ # # ]: 0 : throw container::NoSuchElementException();
113 [ # # ]: 0 : m_aMap.erase( aIt );
114 : 0 : }
115 : :
116 : : // XNameReplace
117 : 0 : void SAL_CALL NameContainer::replaceByName( const OUString& rName, const Any& rElement )
118 : : throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
119 : : {
120 [ # # ]: 0 : tContentMap::iterator aIt( m_aMap.find( rName ));
121 [ # # ]: 0 : if( aIt == m_aMap.end() )
122 [ # # ]: 0 : throw container::NoSuchElementException();
123 : 0 : aIt->second = rElement;
124 : 0 : }
125 : :
126 : : // XNameAccess
127 : 0 : Any SAL_CALL NameContainer::getByName( const OUString& rName )
128 : : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
129 : : {
130 [ # # ]: 0 : tContentMap::iterator aIter( m_aMap.find( rName ) );
131 [ # # ]: 0 : if( aIter == m_aMap.end() )
132 [ # # ]: 0 : throw container::NoSuchElementException();
133 : 0 : return aIter->second;
134 : : }
135 : :
136 : 27 : Sequence< OUString > SAL_CALL NameContainer::getElementNames()
137 : : throw( uno::RuntimeException )
138 : : {
139 : 27 : sal_Int32 nCount = m_aMap.size();
140 : 27 : Sequence< OUString > aSeq(nCount);
141 : 27 : sal_Int32 nN = 0;
142 [ - + ][ # # ]: 27 : for( tContentMap::iterator aIter = m_aMap.begin(); aIter != m_aMap.end() && nN < nCount; ++aIter, ++nN )
[ + - ][ - + ]
143 [ # # ]: 0 : aSeq[nN]=aIter->first;
144 : 27 : return aSeq;
145 : : }
146 : :
147 : 0 : sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName )
148 : : throw( uno::RuntimeException )
149 : : {
150 [ # # ]: 0 : return ( m_aMap.find( rName ) != m_aMap.end() );
151 : : }
152 : :
153 : : // XElementAccess
154 : 0 : sal_Bool SAL_CALL NameContainer::hasElements()
155 : : throw( uno::RuntimeException )
156 : : {
157 : 0 : return ! m_aMap.empty();
158 : : }
159 : :
160 : 0 : uno::Type SAL_CALL NameContainer::getElementType()
161 : : throw( uno::RuntimeException )
162 : : {
163 : 0 : return m_aType;
164 : : }
165 : :
166 : : // XCloneable
167 : 0 : uno::Reference< util::XCloneable > SAL_CALL NameContainer::createClone()
168 : : throw ( uno::RuntimeException )
169 : : {
170 [ # # ][ # # ]: 0 : return uno::Reference< util::XCloneable >( new NameContainer( *this ));
171 : : }
172 : :
173 : : //.............................................................................
174 : : } //namespace chart
175 : : //.............................................................................
176 : :
177 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|