xref: /aoo41x/main/svl/source/items/ilstitem.cxx (revision 40df464e)
1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*40df464eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*40df464eSAndrew Rist  * distributed with this work for additional information
6*40df464eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*40df464eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist  * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*40df464eSAndrew Rist  *
11*40df464eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*40df464eSAndrew Rist  *
13*40df464eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist  * software distributed under the License is distributed on an
15*40df464eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*40df464eSAndrew Rist  * specific language governing permissions and limitations
18*40df464eSAndrew Rist  * under the License.
19*40df464eSAndrew Rist  *
20*40df464eSAndrew Rist  *************************************************************/
21*40df464eSAndrew Rist 
22*40df464eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svl/ilstitem.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #define _SVSTDARR_ULONGS
34cdf0e10cSrcweir #include <svl/svstdarr.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem);
37cdf0e10cSrcweir 
SfxIntegerListItem()38cdf0e10cSrcweir SfxIntegerListItem::SfxIntegerListItem()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir }
41cdf0e10cSrcweir 
SfxIntegerListItem(sal_uInt16 which,const SvULongs & rList)42cdf0e10cSrcweir SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const SvULongs& rList )
43cdf0e10cSrcweir     : SfxPoolItem( which )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     m_aList.realloc( rList.Count() );
46cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<rList.Count(); n++ )
47cdf0e10cSrcweir         m_aList[n] = rList[n];
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
SfxIntegerListItem(const SfxIntegerListItem & rItem)50cdf0e10cSrcweir SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem& rItem )
51cdf0e10cSrcweir     : SfxPoolItem( rItem )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     m_aList = rItem.m_aList;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
~SfxIntegerListItem()56cdf0e10cSrcweir SfxIntegerListItem::~SfxIntegerListItem()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rPoolItem) const60cdf0e10cSrcweir int SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     if ( !rPoolItem.ISA( SfxIntegerListItem ) )
63cdf0e10cSrcweir         return sal_False;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     const SfxIntegerListItem rItem = (const SfxIntegerListItem&) rPoolItem;
66cdf0e10cSrcweir     return rItem.m_aList == m_aList;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
Clone(SfxItemPool *) const69cdf0e10cSrcweir SfxPoolItem* SfxIntegerListItem::Clone( SfxItemPool * ) const
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     return new SfxIntegerListItem( *this );
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)74cdf0e10cSrcweir sal_Bool SfxIntegerListItem::PutValue  ( const com::sun::star::uno::Any& rVal, sal_uInt8 )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     ::com::sun::star::uno::Reference < ::com::sun::star::script::XTypeConverter > xConverter
77cdf0e10cSrcweir             ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
78cdf0e10cSrcweir             ::com::sun::star::uno::UNO_QUERY );
79cdf0e10cSrcweir     ::com::sun::star::uno::Any aNew;
80cdf0e10cSrcweir     try { aNew = xConverter->convertTo( rVal, ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int32 >*)0) ); }
81cdf0e10cSrcweir     catch (::com::sun::star::uno::Exception&)
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir         return sal_False;
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     return ( aNew >>= m_aList );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const89cdf0e10cSrcweir sal_Bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     rVal <<= m_aList;
92cdf0e10cSrcweir     return sal_True;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
GetList(SvULongs & rList) const95cdf0e10cSrcweir void SfxIntegerListItem::GetList( SvULongs& rList ) const
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     for ( sal_Int32 n=0; n<m_aList.getLength(); n++ )
98cdf0e10cSrcweir         rList.Insert( m_aList[n], sal::static_int_cast< sal_uInt16 >(n) );
99cdf0e10cSrcweir }
100