Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/comphelper/source/property/propertysetinfo.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
21
#include <comphelper/propertysetinfo.hxx>
22
23
24
using namespace ::comphelper;
25
using namespace ::com::sun::star;
26
using namespace ::com::sun::star::uno;
27
using namespace ::com::sun::star::beans;
28
29
PropertySetInfo::PropertySetInfo() noexcept
30
3
{
31
3
}
32
33
PropertySetInfo::PropertySetInfo( std::span<const PropertyMapEntry> pMap ) noexcept
34
81.9k
{
35
81.9k
    maPropertyMap.reserve(pMap.size());
36
81.9k
    for (const auto & rEntry : pMap)
37
646k
    {
38
        // check for duplicates
39
646k
        assert(!maPropertyMap.contains(rEntry.maName));
40
        // Make sure there are no accidental empty entries left at the end of the array from
41
        // when this method used to take an empty-terminated array.
42
646k
        assert(!rEntry.maName.isEmpty());
43
44
646k
        maPropertyMap.emplace(rEntry.maName, &rEntry);
45
646k
    }
46
81.9k
}
47
48
PropertySetInfo::~PropertySetInfo() noexcept
49
81.9k
{
50
81.9k
}
51
52
void PropertySetInfo::add( std::span<PropertyMapEntry const> pMap ) noexcept
53
143
{
54
143
    maPropertyMap.reserve(maPropertyMap.size() + pMap.size());
55
143
    for (const auto & rEntry : pMap)
56
1.02k
    {
57
        // check for duplicates
58
1.02k
        assert(!maPropertyMap.contains(rEntry.maName));
59
        // Make sure there are no accidental empty entries left at the end of the array from
60
        // when this method used to take an empty-terminated array.
61
1.02k
        assert(!rEntry.maName.isEmpty());
62
63
1.02k
        maPropertyMap.emplace(rEntry.maName, &rEntry);
64
1.02k
    }
65
66
    // clear cache
67
143
    maProperties.realloc(0);
68
143
}
69
70
void PropertySetInfo::remove( const OUString& aName ) noexcept
71
2
{
72
2
    maPropertyMap.erase( aName );
73
2
    maProperties.realloc(0);
74
2
}
75
76
Sequence< css::beans::Property > SAL_CALL PropertySetInfo::getProperties()
77
69
{
78
    // maybe we have to generate the properties after
79
    // a change in the property map or at first call
80
    // to getProperties
81
69
    if( maProperties.size() != maPropertyMap.size() )
82
69
    {
83
69
        maProperties.realloc( maPropertyMap.size() );
84
69
        auto propIter = maProperties.getArray();
85
86
69
        for( const auto& rProperty : maPropertyMap )
87
2.82k
        {
88
2.82k
            PropertyMapEntry const * pEntry = rProperty.second;
89
90
2.82k
            propIter->Name = pEntry->maName;
91
2.82k
            propIter->Handle = pEntry->mnHandle;
92
2.82k
            propIter->Type = pEntry->maType;
93
2.82k
            propIter->Attributes = pEntry->mnAttributes;
94
95
2.82k
            ++propIter;
96
2.82k
        }
97
69
    }
98
69
    return maProperties;
99
69
}
100
101
Property SAL_CALL PropertySetInfo::getPropertyByName( const OUString& aName )
102
0
{
103
0
    PropertyMap::iterator aIter = maPropertyMap.find( aName );
104
105
0
    if( maPropertyMap.end() == aIter )
106
0
        throw UnknownPropertyException( aName );
107
108
0
    PropertyMapEntry const * pEntry = (*aIter).second;
109
110
0
    return Property( aName, pEntry->mnHandle, pEntry->maType, pEntry->mnAttributes );
111
0
}
112
113
sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName( const OUString& aName )
114
1.05M
{
115
1.05M
    return maPropertyMap.contains( aName );
116
1.05M
}
117
118
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */