Update ooo320-m1
[ooovba.git] / svtools / source / items1 / ilstitem.cxx
blob955cfa7b851c4873f8fe47670824222a6a09978e
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: ilstitem.cxx,v $
10 * $Revision: 1.8 $
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_svtools.hxx"
33 #include <com/sun/star/script/XTypeConverter.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <comphelper/processfactory.hxx>
38 #include <svtools/ilstitem.hxx>
40 #define _SVSTDARR_ULONGS
41 #include <svtools/svstdarr.hxx>
43 TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem);
45 SfxIntegerListItem::SfxIntegerListItem()
49 SfxIntegerListItem::SfxIntegerListItem( USHORT which, const SvULongs& rList )
50 : SfxPoolItem( which )
52 m_aList.realloc( rList.Count() );
53 for ( USHORT n=0; n<rList.Count(); n++ )
54 m_aList[n] = rList[n];
57 SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem& rItem )
58 : SfxPoolItem( rItem )
60 m_aList = rItem.m_aList;
63 SfxIntegerListItem::~SfxIntegerListItem()
67 int SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const
69 if ( !rPoolItem.ISA( SfxIntegerListItem ) )
70 return FALSE;
72 const SfxIntegerListItem rItem = (const SfxIntegerListItem&) rPoolItem;
73 return rItem.m_aList == m_aList;
76 SfxPoolItem* SfxIntegerListItem::Clone( SfxItemPool * ) const
78 return new SfxIntegerListItem( *this );
81 BOOL SfxIntegerListItem::PutValue ( const com::sun::star::uno::Any& rVal, BYTE )
83 ::com::sun::star::uno::Reference < ::com::sun::star::script::XTypeConverter > xConverter
84 ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
85 ::com::sun::star::uno::UNO_QUERY );
86 ::com::sun::star::uno::Any aNew;
87 try { aNew = xConverter->convertTo( rVal, ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int32 >*)0) ); }
88 catch (::com::sun::star::uno::Exception&)
90 return FALSE;
93 return ( aNew >>= m_aList );
96 BOOL SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE ) const
98 rVal <<= m_aList;
99 return TRUE;
102 void SfxIntegerListItem::GetList( SvULongs& rList ) const
104 for ( sal_Int32 n=0; n<m_aList.getLength(); n++ )
105 rList.Insert( m_aList[n], sal::static_int_cast< USHORT >(n) );