1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/script/Converter.hpp>
21 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <comphelper/processfactory.hxx>
25 #include <svl/ilstitem.hxx>
27 TYPEINIT1_AUTOFACTORY(SfxIntegerListItem
, SfxPoolItem
);
29 SfxIntegerListItem::SfxIntegerListItem()
33 SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which
, const ::std::vector
< sal_Int32
>& rList
)
34 : SfxPoolItem( which
)
36 m_aList
.realloc( rList
.size() );
37 for ( sal_uInt16 n
=0; n
<rList
.size(); ++n
)
38 m_aList
[n
] = rList
[n
];
41 SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which
, const ::com::sun::star::uno::Sequence
< sal_Int32
>& rList
)
42 : SfxPoolItem( which
)
44 m_aList
.realloc( rList
.getLength() );
45 for ( sal_Int32 n
=0; n
<rList
.getLength(); ++n
)
46 m_aList
[n
] = rList
[n
];
49 SfxIntegerListItem::SfxIntegerListItem( const SfxIntegerListItem
& rItem
)
50 : SfxPoolItem( rItem
)
52 m_aList
= rItem
.m_aList
;
55 SfxIntegerListItem::~SfxIntegerListItem()
59 int SfxIntegerListItem::operator==( const SfxPoolItem
& rPoolItem
) const
61 if ( !rPoolItem
.ISA( SfxIntegerListItem
) )
64 const SfxIntegerListItem rItem
= (const SfxIntegerListItem
&) rPoolItem
;
65 return rItem
.m_aList
== m_aList
;
68 SfxPoolItem
* SfxIntegerListItem::Clone( SfxItemPool
* ) const
70 return new SfxIntegerListItem( *this );
73 bool SfxIntegerListItem::PutValue ( const com::sun::star::uno::Any
& rVal
, sal_uInt8
)
75 ::com::sun::star::uno::Reference
< ::com::sun::star::script::XTypeConverter
> xConverter
76 ( ::com::sun::star::script::Converter::create(::comphelper::getProcessComponentContext()) );
77 ::com::sun::star::uno::Any aNew
;
78 try { aNew
= xConverter
->convertTo( rVal
, ::getCppuType((const ::com::sun::star::uno::Sequence
< sal_Int32
>*)0) ); }
79 catch (::com::sun::star::uno::Exception
&)
84 return ( aNew
>>= m_aList
);
87 bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any
& rVal
, sal_uInt8
) const
93 void SfxIntegerListItem::GetList( ::std::vector
< sal_Int32
>& rList
) const
95 rList
.reserve( m_aList
.getLength() );
96 for ( sal_Int32 n
=0; n
<m_aList
.getLength(); ++n
)
97 rList
.push_back( m_aList
[n
] );
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */