Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/comphelper/source/property/ChainablePropertySetInfo.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 <comphelper/ChainablePropertySetInfo.hxx>
21
#include <sal/log.hxx>
22
23
using ::comphelper::PropertyInfo;
24
using ::comphelper::ChainablePropertySetInfo;
25
using ::com::sun::star::uno::Sequence;
26
using ::com::sun::star::beans::Property;
27
using ::com::sun::star::beans::UnknownPropertyException;
28
29
ChainablePropertySetInfo::ChainablePropertySetInfo( PropertyInfo const * pMap )
30
28.9k
{
31
654k
    for( ; !pMap->maName.isEmpty(); ++pMap )
32
625k
    {
33
625k
        SAL_WARN_IF(
34
625k
            maMap.contains(pMap->maName),
35
625k
            "comphelper", "Duplicate property name \"" << pMap->maName << "\"");
36
625k
        maMap[pMap->maName] = pMap;
37
625k
    }
38
28.9k
}
39
40
ChainablePropertySetInfo::~ChainablePropertySetInfo()
41
    noexcept
42
28.9k
{
43
28.9k
}
44
45
void ChainablePropertySetInfo::remove( const OUString& aName )
46
0
{
47
0
    maMap.erase ( aName );
48
0
    if ( maProperties.hasElements() )
49
0
         maProperties.realloc( 0 );
50
0
}
51
52
Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties()
53
0
{
54
0
    sal_Int32 nSize = maMap.size();
55
0
    if( maProperties.getLength() != nSize )
56
0
    {
57
0
        maProperties.realloc ( nSize );
58
0
        Property* pProperties = maProperties.getArray();
59
60
0
        for (auto const& elem : maMap)
61
0
        {
62
0
            PropertyInfo const * pInfo = elem.second;
63
64
0
            pProperties->Name = pInfo->maName;
65
0
            pProperties->Handle = pInfo->mnHandle;
66
0
            pProperties->Type = pInfo->maType;
67
0
            pProperties->Attributes = pInfo->mnAttributes;
68
0
            ++pProperties;
69
0
        }
70
0
    }
71
0
    return maProperties;
72
0
}
73
74
Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const OUString& rName )
75
0
{
76
0
    PropertyInfoHash::iterator aIter = maMap.find( rName );
77
78
0
    if ( maMap.end() == aIter )
79
0
        throw UnknownPropertyException( rName, *this );
80
81
0
    PropertyInfo const *pInfo = (*aIter).second;
82
0
    Property aProperty;
83
0
    aProperty.Name   = pInfo->maName;
84
0
    aProperty.Handle = pInfo->mnHandle;
85
0
    aProperty.Type = pInfo->maType;
86
0
    aProperty.Attributes = pInfo->mnAttributes;
87
0
    return aProperty;
88
0
}
89
90
sal_Bool SAL_CALL ChainablePropertySetInfo::hasPropertyByName( const OUString& rName )
91
0
{
92
0
    return maMap.contains( rName );
93
0
}
94
95
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */