1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "NameContainer.hxx"
35 #include <xmloff/xmluconv.hxx>
37 #include <com/sun/star/uno/Any.hxx>
39 using namespace ::com::sun::star
;
40 using ::com::sun::star::uno::Sequence
;
41 using ::com::sun::star::uno::Any
;
42 using ::rtl::OUString
;
45 //.............................................................................
48 //.............................................................................
50 uno::Reference
< container::XNameContainer
> createNameContainer(
51 const ::com::sun::star::uno::Type
& rType
, const rtl::OUString
& rServicename
, const rtl::OUString
& rImplementationName
)
53 return new NameContainer( rType
, rServicename
, rImplementationName
);
56 NameContainer::NameContainer( const ::com::sun::star::uno::Type
& rType
, const OUString
& rServicename
, const OUString
& rImplementationName
)
58 , m_aServicename( rServicename
)
59 , m_aImplementationName( rImplementationName
)
64 NameContainer::NameContainer(
65 const NameContainer
& rOther
)
66 : impl::NameContainer_Base()
67 , m_aType( rOther
.m_aType
)
68 , m_aServicename( rOther
.m_aServicename
)
69 , m_aImplementationName( rOther
.m_aImplementationName
)
70 , m_aMap( rOther
.m_aMap
)
74 NameContainer::~NameContainer()
79 OUString SAL_CALL
NameContainer::getImplementationName()
80 throw( ::com::sun::star::uno::RuntimeException
)
82 return m_aImplementationName
;
85 sal_Bool SAL_CALL
NameContainer::supportsService( const OUString
& ServiceName
)
86 throw( ::com::sun::star::uno::RuntimeException
)
88 Sequence
< OUString
> aSNL
= getSupportedServiceNames();
89 const OUString
* pArray
= aSNL
.getArray();
90 for( sal_Int32 i
= 0; i
< aSNL
.getLength(); i
++ )
92 if( pArray
[ i
] == ServiceName
)
98 Sequence
< OUString
> SAL_CALL
NameContainer::getSupportedServiceNames()
99 throw( ::com::sun::star::uno::RuntimeException
)
101 Sequence
< OUString
> aSNS( 1 );
102 aSNS
.getArray()[ 0 ] = m_aServicename
;
106 //-----------------------------------------------------------------
107 //-----------------------------------------------------------------
108 //-----------------------------------------------------------------
111 void SAL_CALL
NameContainer::insertByName( const OUString
& rName
, const Any
& rElement
)
112 throw( lang::IllegalArgumentException
, container::ElementExistException
, lang::WrappedTargetException
, uno::RuntimeException
)
114 if( m_aMap
.find( rName
) != m_aMap
.end() )
115 throw container::ElementExistException();
116 m_aMap
.insert( tContentMap::value_type( rName
, rElement
));
121 void SAL_CALL
NameContainer::removeByName( const OUString
& Name
)
122 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
124 tContentMap::iterator
aIt( m_aMap
.find( Name
));
125 if( aIt
== m_aMap
.end())
126 throw container::NoSuchElementException();
131 void SAL_CALL
NameContainer::replaceByName( const OUString
& rName
, const Any
& rElement
)
132 throw( lang::IllegalArgumentException
, container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
134 tContentMap::iterator
aIt( m_aMap
.find( rName
));
135 if( aIt
== m_aMap
.end() )
136 throw container::NoSuchElementException();
137 aIt
->second
= rElement
;
141 Any SAL_CALL
NameContainer::getByName( const OUString
& rName
)
142 throw( container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
144 tContentMap::iterator
aIter( m_aMap
.find( rName
) );
145 if( aIter
== m_aMap
.end() )
146 throw container::NoSuchElementException();
147 return aIter
->second
;
150 Sequence
< OUString
> SAL_CALL
NameContainer::getElementNames()
151 throw( uno::RuntimeException
)
153 sal_Int32 nCount
= m_aMap
.size();
154 Sequence
< OUString
> aSeq(nCount
);
156 for( tContentMap::iterator aIter
= m_aMap
.begin(); aIter
!= m_aMap
.end(), nN
< nCount
; aIter
++, nN
++ )
157 aSeq
[nN
]=aIter
->first
;
161 sal_Bool SAL_CALL
NameContainer::hasByName( const OUString
& rName
)
162 throw( uno::RuntimeException
)
164 return ( m_aMap
.find( rName
) != m_aMap
.end() );
168 sal_Bool SAL_CALL
NameContainer::hasElements()
169 throw( uno::RuntimeException
)
171 return ! m_aMap
.empty();
174 uno::Type SAL_CALL
NameContainer::getElementType()
175 throw( uno::RuntimeException
)
181 uno::Reference
< util::XCloneable
> SAL_CALL
NameContainer::createClone()
182 throw ( uno::RuntimeException
)
184 return uno::Reference
< util::XCloneable
>( new NameContainer( *this ));
187 //.............................................................................
189 //.............................................................................