/src/libreoffice/svl/source/items/ilstitem.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <com/sun/star/script/Converter.hpp> |
21 | | |
22 | | #include <comphelper/processfactory.hxx> |
23 | | #include <comphelper/sequence.hxx> |
24 | | |
25 | | #include <svl/ilstitem.hxx> |
26 | | |
27 | | |
28 | 0 | SfxPoolItem* SfxIntegerListItem::CreateDefault() { return new SfxIntegerListItem; } |
29 | | |
30 | | SfxIntegerListItem::SfxIntegerListItem() |
31 | 0 | : SfxPoolItem(0) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, ::std::vector < sal_Int32 >&& rList ) |
36 | 0 | : SfxPoolItem( which ) |
37 | 0 | , m_aList( std::move(rList) ) |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const css::uno::Sequence < sal_Int32 >& rList ) |
42 | 0 | : SfxPoolItem( which ) |
43 | 0 | { |
44 | 0 | comphelper::sequenceToContainer(m_aList, rList); |
45 | 0 | } |
46 | | |
47 | | SfxIntegerListItem::~SfxIntegerListItem() |
48 | 0 | { |
49 | 0 | } |
50 | | |
51 | | bool SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const |
52 | 0 | { |
53 | 0 | if ( !SfxPoolItem::operator==(rPoolItem) ) |
54 | 0 | return false; |
55 | | |
56 | 0 | const SfxIntegerListItem & rItem = static_cast<const SfxIntegerListItem&>(rPoolItem); |
57 | 0 | return rItem.m_aList == m_aList; |
58 | 0 | } |
59 | | |
60 | | SfxIntegerListItem* SfxIntegerListItem::Clone( SfxItemPool * ) const |
61 | 0 | { |
62 | 0 | return new SfxIntegerListItem( *this ); |
63 | 0 | } |
64 | | |
65 | | bool SfxIntegerListItem::PutValue ( const css::uno::Any& rVal, sal_uInt8 ) |
66 | 0 | { |
67 | 0 | css::uno::Reference < css::script::XTypeConverter > xConverter |
68 | 0 | ( css::script::Converter::create(::comphelper::getProcessComponentContext()) ); |
69 | 0 | css::uno::Any aNew; |
70 | 0 | try { aNew = xConverter->convertTo( rVal, cppu::UnoType<css::uno::Sequence < sal_Int32 >>::get() ); } |
71 | 0 | catch (css::uno::Exception&) |
72 | 0 | { |
73 | 0 | return true; |
74 | 0 | } |
75 | | |
76 | 0 | css::uno::Sequence<sal_Int32> aTempSeq; |
77 | 0 | bool bRet = aNew >>= aTempSeq; |
78 | 0 | if (bRet) |
79 | 0 | m_aList = comphelper::sequenceToContainer<std::vector<sal_Int32>>(aTempSeq); |
80 | 0 | return bRet; |
81 | 0 | } |
82 | | |
83 | | bool SfxIntegerListItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const |
84 | 0 | { |
85 | 0 | rVal <<= comphelper::containerToSequence(m_aList); |
86 | 0 | return true; |
87 | 0 | } |
88 | | |
89 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |