/src/libreoffice/include/svl/itemiter.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 | | #ifndef INCLUDED_SVL_ITEMITER_HXX |
20 | | #define INCLUDED_SVL_ITEMITER_HXX |
21 | | |
22 | | #include <svl/svldllapi.h> |
23 | | #include <svl/itemset.hxx> |
24 | | |
25 | | class SfxPoolItem; |
26 | | |
27 | | class SVL_DLLPUBLIC SfxItemIter |
28 | | { |
29 | | const SfxItemSet& m_rSet; |
30 | | PoolItemMap::const_iterator maCurrent; |
31 | | |
32 | | public: |
33 | | SfxItemIter(const SfxItemSet& rSet) |
34 | 54.5M | : m_rSet(rSet) |
35 | 54.5M | , maCurrent(rSet.m_aPoolItemMap.begin()) |
36 | 54.5M | { |
37 | | #ifdef DBG_UTIL |
38 | | const_cast<SfxItemSet&>(m_rSet).m_nRegisteredSfxItemIter++; |
39 | | #endif |
40 | 54.5M | } |
41 | | |
42 | | #ifdef DBG_UTIL |
43 | | ~SfxItemIter() { const_cast<SfxItemSet&>(m_rSet).m_nRegisteredSfxItemIter--; } |
44 | | #endif |
45 | | |
46 | | const SfxPoolItem* GetCurItem() const |
47 | 165M | { |
48 | 165M | assert(!IsAtEnd()); |
49 | 165M | return maCurrent->second; |
50 | 165M | } |
51 | | |
52 | | sal_uInt16 GetCurWhich() const |
53 | 6.16M | { |
54 | 6.16M | assert(!IsAtEnd()); |
55 | 6.16M | return maCurrent->first; |
56 | 6.16M | } |
57 | | |
58 | | const SfxPoolItem* NextItem() |
59 | 192k | { |
60 | 192k | maCurrent++; |
61 | 192k | if (IsAtEnd()) |
62 | 28.0k | return nullptr; |
63 | 164k | else |
64 | 164k | return GetCurItem(); |
65 | 192k | } |
66 | | |
67 | | void Next() |
68 | 155M | { |
69 | 155M | assert(!IsAtEnd()); |
70 | 155M | maCurrent++; |
71 | 155M | } |
72 | | |
73 | 222M | bool IsAtEnd() const { return maCurrent == m_rSet.m_aPoolItemMap.end(); } |
74 | | |
75 | | SfxItemState GetItemState(bool bSrchInParent = true, |
76 | | const SfxPoolItem** ppItem = nullptr) const; |
77 | | }; |
78 | | |
79 | | #endif |
80 | | |
81 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |