Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/comphelper/propertysequence.hxx
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
10
#ifndef INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
11
#define INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
12
13
#include <utility>
14
#include <algorithm>
15
#include <initializer_list>
16
#include <vector>
17
18
#include <com/sun/star/uno/Any.hxx>
19
#include <com/sun/star/uno/Sequence.hxx>
20
#include <com/sun/star/beans/PropertyValue.hpp>
21
22
#include <comphelper/comphelperdllapi.h>
23
24
namespace comphelper
25
{
26
    /// Init list for property sequences.
27
    inline css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(
28
        ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
29
294k
    {
30
294k
        css::uno::Sequence< css::beans::PropertyValue> vResult{static_cast<sal_Int32>(vInit.size())};
31
294k
        std::transform(vInit.begin(), vInit.end(), vResult.getArray(),
32
536k
                       [](const std::pair<OUString, css::uno::Any>& rInit) {
33
536k
                           return css::beans::PropertyValue(rInit.first, -1, rInit.second,
34
536k
                                                            css::beans::PropertyState_DIRECT_VALUE);
35
536k
                       });
36
294k
        return vResult;
37
294k
    }
38
39
    /// Init list for property sequences that wrap the PropertyValues in Anys.
40
    ///
41
    /// This is particularly useful for creation of sequences that are later
42
    /// unwrapped using comphelper::SequenceAsHashMap.
43
    inline css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(
44
        ::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
45
27.1k
    {
46
27.1k
        css::uno::Sequence<css::uno::Any> vResult{static_cast<sal_Int32>(vInit.size())};
47
27.1k
        std::transform(vInit.begin(), vInit.end(), vResult.getArray(),
48
27.1k
                       [](const std::pair<OUString, css::uno::Any>& rInit) {
49
27.1k
                           return css::uno::Any(
50
27.1k
                               css::beans::PropertyValue(rInit.first, -1, rInit.second,
51
27.1k
                                                         css::beans::PropertyState_DIRECT_VALUE));
52
27.1k
                       });
53
27.1k
        return vResult;
54
27.1k
    }
55
56
    COMPHELPER_DLLPUBLIC std::vector<css::beans::PropertyValue> JsonToPropertyValues(std::string_view rJson);
57
}   // namespace comphelper
58
59
60
#endif // INCLUDED_COMPHELPER_PROPERTYSEQUENCE_HXX
61
62
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */