Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdsob.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
 * 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
#pragma once
21
22
#include <com/sun/star/uno/Any.hxx>
23
24
#include <svx/svxdllapi.h>
25
#include <svx/svdtypes.hxx>
26
27
/*
28
 Stores a bitfield of the layer values that have been set.
29
*/
30
31
class SVXCORE_DLLPUBLIC SdrLayerIDSet final
32
{
33
    // For now, have up to 256 layers
34
    sal_uInt8 m_aData[32];
35
36
public:
37
    explicit SdrLayerIDSet(bool bInitVal = false)
38
1.66M
    {
39
1.66M
        memset(m_aData, bInitVal ? 0xFF : 0x00, sizeof(m_aData));
40
1.66M
    }
41
42
    bool operator!=(const SdrLayerIDSet& rCmpSet) const
43
158k
    {
44
158k
        return (memcmp(m_aData, rCmpSet.m_aData, sizeof(m_aData))!=0);
45
158k
    }
46
47
    void Set(SdrLayerID a)
48
2.79M
    {
49
2.79M
        const sal_Int16 nId = a.get();
50
2.79M
        if (nId >= 0 && nId < 256)
51
2.79M
            m_aData[nId / 8] |= 1 << (nId % 8);
52
2.79M
    }
53
54
    void Clear(SdrLayerID a)
55
175k
    {
56
175k
        const sal_Int16 nId = a.get();
57
175k
        if (nId >= 0 && nId < 256)
58
175k
            m_aData[nId / 8] &= ~(1 << (nId % 8));
59
175k
    }
60
61
    void Set(SdrLayerID a, bool b)
62
492k
    {
63
492k
        if(b)
64
316k
            Set(a);
65
175k
        else
66
175k
            Clear(a);
67
492k
    }
68
69
    bool IsSet(SdrLayerID a) const
70
3.94M
    {
71
3.94M
        const sal_Int16 nId = a.get();
72
3.94M
        return nId >= 0 && nId < 256 && (m_aData[nId / 8] & 1 << nId % 8) != 0;
73
3.94M
    }
74
75
    void SetAll()
76
575k
    {
77
575k
        memset(m_aData, 0xFF, sizeof(m_aData));
78
575k
    }
79
80
    void ClearAll()
81
193k
    {
82
193k
        memset(m_aData, 0x00, sizeof(m_aData));
83
193k
    }
84
85
    bool IsEmpty() const;
86
87
    void operator&=(const SdrLayerIDSet& r2ndSet);
88
89
    // initialize this set with a UNO sequence of sal_Int8 (e.g. as stored in settings.xml)
90
    void PutValue(const css::uno::Any & rAny);
91
92
};
93
94
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */