1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_framework.hxx" 26 #include <uiconfiguration/graphicnameaccess.hxx> 27 28 //_________________________________________________________________________________________________________________ 29 // interface includes 30 //_________________________________________________________________________________________________________________ 31 32 //_________________________________________________________________________________________________________________ 33 // other includes 34 //_________________________________________________________________________________________________________________ 35 36 #include <comphelper/sequence.hxx> 37 38 using namespace ::com::sun::star; 39 40 namespace framework 41 { 42 GraphicNameAccess()43GraphicNameAccess::GraphicNameAccess() 44 { 45 } 46 ~GraphicNameAccess()47GraphicNameAccess::~GraphicNameAccess() 48 { 49 } 50 addElement(const rtl::OUString & rName,const uno::Reference<graphic::XGraphic> & rElement)51void GraphicNameAccess::addElement( const rtl::OUString& rName, const uno::Reference< graphic::XGraphic >& rElement ) 52 { 53 m_aNameToElementMap.insert( NameGraphicHashMap::value_type( rName, rElement )); 54 } 55 56 // XNameAccess getByName(const::rtl::OUString & aName)57uno::Any SAL_CALL GraphicNameAccess::getByName( const ::rtl::OUString& aName ) 58 { 59 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName ); 60 if ( pIter != m_aNameToElementMap.end() ) 61 return uno::makeAny( pIter->second ); 62 else 63 throw container::NoSuchElementException(); 64 } 65 getElementNames()66uno::Sequence< ::rtl::OUString > SAL_CALL GraphicNameAccess::getElementNames() 67 { 68 if ( m_aSeq.getLength() == 0 ) 69 { 70 uno::Sequence< rtl::OUString > aSeq( m_aNameToElementMap.size() ); 71 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.begin(); 72 sal_Int32 i( 0); 73 while ( pIter != m_aNameToElementMap.end()) 74 { 75 aSeq[i++] = pIter->first; 76 ++pIter; 77 } 78 m_aSeq = aSeq; 79 } 80 81 return m_aSeq; 82 } 83 hasByName(const::rtl::OUString & aName)84sal_Bool SAL_CALL GraphicNameAccess::hasByName( const ::rtl::OUString& aName ) 85 { 86 NameGraphicHashMap::const_iterator pIter = m_aNameToElementMap.find( aName ); 87 return ( pIter != m_aNameToElementMap.end() ); 88 } 89 90 // XElementAccess hasElements()91sal_Bool SAL_CALL GraphicNameAccess::hasElements() 92 { 93 return ( !m_aNameToElementMap.empty() ); 94 } 95 getElementType()96uno::Type SAL_CALL GraphicNameAccess::getElementType() 97 { 98 return ::getCppuType( (const uno::Reference< graphic::XGraphic > *)NULL ); 99 } 100 101 } // namespace framework 102