Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svl/whiter.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
#pragma once
20
21
#include <svl/svldllapi.h>
22
#include <svl/whichranges.hxx>
23
#include <svl/itemset.hxx>
24
25
/**
26
 * Iterates over the which ids and the pool items arrays together (which are stored in parallel arrays).
27
 * Primarily so that we can call GetItemSet on the SfxItemSet and pass in a hint, which avoids
28
 * searching the array the SfxItemSet, which speeds up GetItemState greatly.
29
 */
30
class SVL_DLLPUBLIC SfxWhichIter
31
{
32
    const SfxItemSet& m_rItemSet;
33
    const WhichPair* m_pCurrentWhichPair;
34
    sal_uInt16 m_nOffsetFromStartOfCurrentWhichPair;
35
36
public:
37
    SfxWhichIter(const SfxItemSet& rSet)
38
222M
        : m_rItemSet(rSet)
39
222M
        , m_pCurrentWhichPair(rSet.m_aWhichRanges.begin())
40
222M
        , m_nOffsetFromStartOfCurrentWhichPair(0)
41
222M
    {
42
222M
    }
43
44
    sal_uInt16 GetCurWhich() const;
45
    sal_uInt16 NextWhich();
46
    sal_uInt16 FirstWhich();
47
48
    SfxItemState GetItemState(bool bSrchInParent = true, const SfxPoolItem** ppItem = nullptr) const
49
2.97G
    {
50
2.97G
        const sal_uInt16 nWhich(GetCurWhich());
51
2.97G
        if (0 == nWhich)
52
0
            return SfxItemState::UNKNOWN;
53
2.97G
        return m_rItemSet.GetItemState_ForWhichID(SfxItemState::UNKNOWN, nWhich, bSrchInParent,
54
2.97G
                                                  ppItem);
55
2.97G
    }
56
57
    void ClearItem()
58
0
    {
59
0
        const sal_uInt16 nWhich(GetCurWhich());
60
0
        if (0 == nWhich)
61
0
            return;
62
0
        const_cast<SfxItemSet&>(m_rItemSet).ClearSingleItem_ForWhichID(nWhich);
63
0
    }
64
};
65
66
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */