1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "NameContainer.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir /*
30cdf0e10cSrcweir //SvXMLUnitConverter
31cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
32cdf0e10cSrcweir */
33cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
37cdf0e10cSrcweir using ::com::sun::star::uno::Any;
38cdf0e10cSrcweir using ::rtl::OUString;
39cdf0e10cSrcweir
40cdf0e10cSrcweir
41cdf0e10cSrcweir //.............................................................................
42cdf0e10cSrcweir namespace chart
43cdf0e10cSrcweir {
44cdf0e10cSrcweir //.............................................................................
45cdf0e10cSrcweir
createNameContainer(const::com::sun::star::uno::Type & rType,const rtl::OUString & rServicename,const rtl::OUString & rImplementationName)46cdf0e10cSrcweir uno::Reference< container::XNameContainer > createNameContainer(
47cdf0e10cSrcweir const ::com::sun::star::uno::Type& rType, const rtl::OUString& rServicename, const rtl::OUString& rImplementationName )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir return new NameContainer( rType, rServicename, rImplementationName );
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
NameContainer(const::com::sun::star::uno::Type & rType,const OUString & rServicename,const OUString & rImplementationName)52cdf0e10cSrcweir NameContainer::NameContainer( const ::com::sun::star::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName )
53cdf0e10cSrcweir : m_aType( rType )
54cdf0e10cSrcweir , m_aServicename( rServicename )
55cdf0e10cSrcweir , m_aImplementationName( rImplementationName )
56cdf0e10cSrcweir , m_aMap()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
NameContainer(const NameContainer & rOther)60cdf0e10cSrcweir NameContainer::NameContainer(
61cdf0e10cSrcweir const NameContainer & rOther )
62cdf0e10cSrcweir : impl::NameContainer_Base()
63cdf0e10cSrcweir , m_aType( rOther.m_aType )
64cdf0e10cSrcweir , m_aServicename( rOther.m_aServicename )
65cdf0e10cSrcweir , m_aImplementationName( rOther.m_aImplementationName )
66cdf0e10cSrcweir , m_aMap( rOther.m_aMap )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
~NameContainer()70cdf0e10cSrcweir NameContainer::~NameContainer()
71cdf0e10cSrcweir {
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir //XServiceInfo
getImplementationName()75cdf0e10cSrcweir OUString SAL_CALL NameContainer::getImplementationName()
76cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir return m_aImplementationName;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
supportsService(const OUString & ServiceName)81cdf0e10cSrcweir sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName )
82cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir Sequence< OUString > aSNL = getSupportedServiceNames();
85cdf0e10cSrcweir const OUString* pArray = aSNL.getArray();
86cdf0e10cSrcweir for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir if( pArray[ i ] == ServiceName )
89cdf0e10cSrcweir return sal_True;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir return sal_False;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
getSupportedServiceNames()94cdf0e10cSrcweir Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames()
95cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir Sequence< OUString > aSNS( 1 );
98cdf0e10cSrcweir aSNS.getArray()[ 0 ] = m_aServicename;
99cdf0e10cSrcweir return aSNS;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir //-----------------------------------------------------------------
103cdf0e10cSrcweir //-----------------------------------------------------------------
104cdf0e10cSrcweir //-----------------------------------------------------------------
105cdf0e10cSrcweir
106cdf0e10cSrcweir // XNameContainer
insertByName(const OUString & rName,const Any & rElement)107cdf0e10cSrcweir void SAL_CALL NameContainer::insertByName( const OUString& rName, const Any& rElement )
108cdf0e10cSrcweir throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if( m_aMap.find( rName ) != m_aMap.end() )
111cdf0e10cSrcweir throw container::ElementExistException();
112cdf0e10cSrcweir m_aMap.insert( tContentMap::value_type( rName, rElement ));
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir
116cdf0e10cSrcweir
removeByName(const OUString & Name)117cdf0e10cSrcweir void SAL_CALL NameContainer::removeByName( const OUString& Name )
118cdf0e10cSrcweir throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir tContentMap::iterator aIt( m_aMap.find( Name ));
121cdf0e10cSrcweir if( aIt == m_aMap.end())
122cdf0e10cSrcweir throw container::NoSuchElementException();
123cdf0e10cSrcweir m_aMap.erase( aIt );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // XNameReplace
replaceByName(const OUString & rName,const Any & rElement)127cdf0e10cSrcweir void SAL_CALL NameContainer::replaceByName( const OUString& rName, const Any& rElement )
128cdf0e10cSrcweir throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir tContentMap::iterator aIt( m_aMap.find( rName ));
131cdf0e10cSrcweir if( aIt == m_aMap.end() )
132cdf0e10cSrcweir throw container::NoSuchElementException();
133cdf0e10cSrcweir aIt->second = rElement;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir // XNameAccess
getByName(const OUString & rName)137cdf0e10cSrcweir Any SAL_CALL NameContainer::getByName( const OUString& rName )
138cdf0e10cSrcweir throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir tContentMap::iterator aIter( m_aMap.find( rName ) );
141cdf0e10cSrcweir if( aIter == m_aMap.end() )
142cdf0e10cSrcweir throw container::NoSuchElementException();
143cdf0e10cSrcweir return aIter->second;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
getElementNames()146cdf0e10cSrcweir Sequence< OUString > SAL_CALL NameContainer::getElementNames()
147cdf0e10cSrcweir throw( uno::RuntimeException )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir sal_Int32 nCount = m_aMap.size();
150cdf0e10cSrcweir Sequence< OUString > aSeq(nCount);
151cdf0e10cSrcweir sal_Int32 nN = 0;
152cdf0e10cSrcweir for( tContentMap::iterator aIter = m_aMap.begin(); aIter != m_aMap.end(), nN < nCount; aIter++, nN++ )
153cdf0e10cSrcweir aSeq[nN]=aIter->first;
154cdf0e10cSrcweir return aSeq;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
hasByName(const OUString & rName)157cdf0e10cSrcweir sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName )
158cdf0e10cSrcweir throw( uno::RuntimeException )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir return ( m_aMap.find( rName ) != m_aMap.end() );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir // XElementAccess
hasElements()164cdf0e10cSrcweir sal_Bool SAL_CALL NameContainer::hasElements()
165cdf0e10cSrcweir throw( uno::RuntimeException )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir return ! m_aMap.empty();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
getElementType()170cdf0e10cSrcweir uno::Type SAL_CALL NameContainer::getElementType()
171cdf0e10cSrcweir throw( uno::RuntimeException )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir return m_aType;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir // XCloneable
createClone()177cdf0e10cSrcweir uno::Reference< util::XCloneable > SAL_CALL NameContainer::createClone()
178cdf0e10cSrcweir throw ( uno::RuntimeException )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir return uno::Reference< util::XCloneable >( new NameContainer( *this ));
181cdf0e10cSrcweir }
182cdf0e10cSrcweir
183cdf0e10cSrcweir //.............................................................................
184cdf0e10cSrcweir } //namespace chart
185cdf0e10cSrcweir //.............................................................................
186