Update ooo320-m1
[ooovba.git] / framework / source / uiconfiguration / graphicnameaccess.cxx
blob658d18df015eb13a1797eb9da288c47e176dfa03
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: graphicnameaccess.cxx,v $
10 * $Revision: 1.5.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
33 #include <uiconfiguration/graphicnameaccess.hxx>
35 //_________________________________________________________________________________________________________________
36 // interface includes
37 //_________________________________________________________________________________________________________________
39 //_________________________________________________________________________________________________________________
40 // other includes
41 //_________________________________________________________________________________________________________________
43 #include <comphelper/sequence.hxx>
45 using namespace ::com::sun::star;
47 namespace framework
50 GraphicNameAccess::GraphicNameAccess()
54 GraphicNameAccess::~GraphicNameAccess()
58 void GraphicNameAccess::addElement( const rtl::OUString& rName, const uno::Reference< graphic::XGraphic >& rElement )
60 m_aNameToElementMap.insert( NameGraphicHashMap::value_type( rName, rElement ));
63 // XNameAccess
64 uno::Any SAL_CALL GraphicNameAccess::getByName( const ::rtl::OUString& aName )
65 throw( container::NoSuchElementException,
66 lang::WrappedTargetException,
67 uno::RuntimeException)
69 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
70 if ( pIter != m_aNameToElementMap.end() )
71 return uno::makeAny( pIter->second );
72 else
73 throw container::NoSuchElementException();
76 uno::Sequence< ::rtl::OUString > SAL_CALL GraphicNameAccess::getElementNames()
77 throw(::com::sun::star::uno::RuntimeException)
79 if ( m_aSeq.getLength() == 0 )
81 uno::Sequence< rtl::OUString > aSeq( m_aNameToElementMap.size() );
82 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.begin();
83 sal_Int32 i( 0);
84 while ( pIter != m_aNameToElementMap.end())
86 aSeq[i++] = pIter->first;
87 ++pIter;
89 m_aSeq = aSeq;
92 return m_aSeq;
95 sal_Bool SAL_CALL GraphicNameAccess::hasByName( const ::rtl::OUString& aName )
96 throw(::com::sun::star::uno::RuntimeException)
98 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
99 return ( pIter != m_aNameToElementMap.end() );
102 // XElementAccess
103 sal_Bool SAL_CALL GraphicNameAccess::hasElements()
104 throw( uno::RuntimeException )
106 return ( !m_aNameToElementMap.empty() );
109 uno::Type SAL_CALL GraphicNameAccess::getElementType()
110 throw( uno::RuntimeException )
112 return ::getCppuType( (const uno::Reference< graphic::XGraphic > *)NULL );
115 } // namespace framework