LibreOffice Module comphelper (master)  1
propertysequence.hxx
Go to the documentation of this file.
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 
10 #ifndef INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
11 #define INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
12 
13 #include <utility>
14 #include <initializer_list>
15 #include <com/sun/star/uno/Any.hxx>
16 #include <com/sun/star/uno/Sequence.hxx>
17 #include <com/sun/star/beans/PropertyValue.hpp>
18 
19 namespace comphelper
20 {
22  inline css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(
23  ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
24  {
25  css::uno::Sequence< css::beans::PropertyValue> vResult{static_cast<sal_Int32>(vInit.size())};
26  size_t nCount{0};
27  for(const auto& aEntry : vInit)
28  {
29  vResult[nCount].Name = aEntry.first;
30  vResult[nCount].Handle = -1;
31  vResult[nCount].Value = aEntry.second;
32  // State is default-initialized to DIRECT_VALUE
33  ++nCount;
34  }
35  return vResult;
36  }
37 
42  inline css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(
43  ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
44  {
45  css::uno::Sequence<css::uno::Any> vResult{static_cast<sal_Int32>(vInit.size())};
46  size_t nCount{0};
47  for(const auto& aEntry : vInit)
48  {
49  vResult[nCount] <<= css::beans::PropertyValue(aEntry.first, -1, aEntry.second, css::beans::PropertyState_DIRECT_VALUE);
50  ++nCount;
51  }
52  return vResult;
53  }
54 } // namespace comphelper
55 
56 
57 #endif // INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
58 
59 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Init list for property sequences.
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
Init list for property sequences that wrap the PropertyValues in Anys.