xref: /aoo41x/main/svl/source/items/ilstitem.cxx (revision 40df464e)
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_svl.hxx"
26 #include <com/sun/star/script/XTypeConverter.hpp>
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 
29 #include <comphelper/processfactory.hxx>
30 
31 #include <svl/ilstitem.hxx>
32 
33 #define _SVSTDARR_ULONGS
34 #include <svl/svstdarr.hxx>
35 
36 TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem);
37 
SfxIntegerListItem()38 SfxIntegerListItem::SfxIntegerListItem()
39 {
40 }
41 
SfxIntegerListItem(sal_uInt16 which,const SvULongs & rList)42 SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const SvULongs& rList )
43     : SfxPoolItem( which )
44 {
45     m_aList.realloc( rList.Count() );
46     for ( sal_uInt16 n=0; n<rList.Count(); n++ )
47         m_aList[n] = rList[n];
48 }
49 
SfxIntegerListItem(const SfxIntegerListItem & rItem)50 SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem& rItem )
51     : SfxPoolItem( rItem )
52 {
53     m_aList = rItem.m_aList;
54 }
55 
~SfxIntegerListItem()56 SfxIntegerListItem::~SfxIntegerListItem()
57 {
58 }
59 
operator ==(const SfxPoolItem & rPoolItem) const60 int SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const
61 {
62     if ( !rPoolItem.ISA( SfxIntegerListItem ) )
63         return sal_False;
64 
65     const SfxIntegerListItem rItem = (const SfxIntegerListItem&) rPoolItem;
66     return rItem.m_aList == m_aList;
67 }
68 
Clone(SfxItemPool *) const69 SfxPoolItem* SfxIntegerListItem::Clone( SfxItemPool * ) const
70 {
71     return new SfxIntegerListItem( *this );
72 }
73 
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)74 sal_Bool SfxIntegerListItem::PutValue  ( const com::sun::star::uno::Any& rVal, sal_uInt8 )
75 {
76     ::com::sun::star::uno::Reference < ::com::sun::star::script::XTypeConverter > xConverter
77             ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
78             ::com::sun::star::uno::UNO_QUERY );
79     ::com::sun::star::uno::Any aNew;
80     try { aNew = xConverter->convertTo( rVal, ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int32 >*)0) ); }
81     catch (::com::sun::star::uno::Exception&)
82     {
83         return sal_False;
84     }
85 
86     return ( aNew >>= m_aList );
87 }
88 
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const89 sal_Bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const
90 {
91     rVal <<= m_aList;
92     return sal_True;
93 }
94 
GetList(SvULongs & rList) const95 void SfxIntegerListItem::GetList( SvULongs& rList ) const
96 {
97     for ( sal_Int32 n=0; n<m_aList.getLength(); n++ )
98         rList.Insert( m_aList[n], sal::static_int_cast< sal_uInt16 >(n) );
99 }
100