merged tag ooo/OOO330_m14
[LibreOffice.git] / framework / source / uiconfiguration / graphicnameaccess.cxx
blob3ba90227b2f545a49cf394ae748af0517f81513b
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_framework.hxx"
30 #include <uiconfiguration/graphicnameaccess.hxx>
32 //_________________________________________________________________________________________________________________
33 // interface includes
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
37 // other includes
38 //_________________________________________________________________________________________________________________
40 #include <comphelper/sequence.hxx>
42 using namespace ::com::sun::star;
44 namespace framework
47 GraphicNameAccess::GraphicNameAccess()
51 GraphicNameAccess::~GraphicNameAccess()
55 void GraphicNameAccess::addElement( const rtl::OUString& rName, const uno::Reference< graphic::XGraphic >& rElement )
57 m_aNameToElementMap.insert( NameGraphicHashMap::value_type( rName, rElement ));
60 // XNameAccess
61 uno::Any SAL_CALL GraphicNameAccess::getByName( const ::rtl::OUString& aName )
62 throw( container::NoSuchElementException,
63 lang::WrappedTargetException,
64 uno::RuntimeException)
66 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
67 if ( pIter != m_aNameToElementMap.end() )
68 return uno::makeAny( pIter->second );
69 else
70 throw container::NoSuchElementException();
73 uno::Sequence< ::rtl::OUString > SAL_CALL GraphicNameAccess::getElementNames()
74 throw(::com::sun::star::uno::RuntimeException)
76 if ( m_aSeq.getLength() == 0 )
78 uno::Sequence< rtl::OUString > aSeq( m_aNameToElementMap.size() );
79 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.begin();
80 sal_Int32 i( 0);
81 while ( pIter != m_aNameToElementMap.end())
83 aSeq[i++] = pIter->first;
84 ++pIter;
86 m_aSeq = aSeq;
89 return m_aSeq;
92 sal_Bool SAL_CALL GraphicNameAccess::hasByName( const ::rtl::OUString& aName )
93 throw(::com::sun::star::uno::RuntimeException)
95 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName );
96 return ( pIter != m_aNameToElementMap.end() );
99 // XElementAccess
100 sal_Bool SAL_CALL GraphicNameAccess::hasElements()
101 throw( uno::RuntimeException )
103 return ( !m_aNameToElementMap.empty() );
106 uno::Type SAL_CALL GraphicNameAccess::getElementType()
107 throw( uno::RuntimeException )
109 return ::getCppuType( (const uno::Reference< graphic::XGraphic > *)NULL );
112 } // namespace framework