1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svl.hxx" 30 #include <com/sun/star/script/XTypeConverter.hpp> 31 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32 33 #include <comphelper/processfactory.hxx> 34 35 #include <svl/ilstitem.hxx> 36 37 #define _SVSTDARR_ULONGS 38 #include <svl/svstdarr.hxx> 39 40 TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem); 41 42 SfxIntegerListItem::SfxIntegerListItem() 43 { 44 } 45 46 SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const SvULongs& rList ) 47 : SfxPoolItem( which ) 48 { 49 m_aList.realloc( rList.Count() ); 50 for ( sal_uInt16 n=0; n<rList.Count(); n++ ) 51 m_aList[n] = rList[n]; 52 } 53 54 SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem& rItem ) 55 : SfxPoolItem( rItem ) 56 { 57 m_aList = rItem.m_aList; 58 } 59 60 SfxIntegerListItem::~SfxIntegerListItem() 61 { 62 } 63 64 int SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const 65 { 66 if ( !rPoolItem.ISA( SfxIntegerListItem ) ) 67 return sal_False; 68 69 const SfxIntegerListItem rItem = (const SfxIntegerListItem&) rPoolItem; 70 return rItem.m_aList == m_aList; 71 } 72 73 SfxPoolItem* SfxIntegerListItem::Clone( SfxItemPool * ) const 74 { 75 return new SfxIntegerListItem( *this ); 76 } 77 78 sal_Bool SfxIntegerListItem::PutValue ( const com::sun::star::uno::Any& rVal, sal_uInt8 ) 79 { 80 ::com::sun::star::uno::Reference < ::com::sun::star::script::XTypeConverter > xConverter 81 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")), 82 ::com::sun::star::uno::UNO_QUERY ); 83 ::com::sun::star::uno::Any aNew; 84 try { aNew = xConverter->convertTo( rVal, ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int32 >*)0) ); } 85 catch (::com::sun::star::uno::Exception&) 86 { 87 return sal_False; 88 } 89 90 return ( aNew >>= m_aList ); 91 } 92 93 sal_Bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const 94 { 95 rVal <<= m_aList; 96 return sal_True; 97 } 98 99 void SfxIntegerListItem::GetList( SvULongs& rList ) const 100 { 101 for ( sal_Int32 n=0; n<m_aList.getLength(); n++ ) 102 rList.Insert( m_aList[n], sal::static_int_cast< sal_uInt16 >(n) ); 103 } 104