Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svl/itempool.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 <config_options.h>
23
#include <rtl/ref.hxx>
24
#include <svl/poolitem.hxx>
25
#include <svl/svldllapi.h>
26
#include <svl/typedwhich.hxx>
27
#include <svl/whichranges.hxx>
28
#include <memory>
29
#include <vector>
30
#include <unordered_set>
31
#include <unordered_map>
32
#include <salhelper/simplereferenceobject.hxx>
33
#include <svl/SfxBroadcaster.hxx>
34
35
// flag definitions to be used for _nItemInfoFlags
36
// in SfxItemInfo
37
#define SFX_ITEMINFOFLAG_NONE               0x0000
38
39
// Defines if this Item needs to be registered at the pool
40
// to make it accessible for the GetItemSurrogates call. It
41
// will not be included when this flag is not set, but also
42
// needs no registration. There are SAL_INFO calls in the
43
// GetItemSurrogates impl that will mention that
44
1.61G
#define SFX_ITEMINFOFLAG_SUPPORT_SURROGATE  0x0001
45
46
class SfxItemSet;
47
48
class SVL_DLLPUBLIC ItemInfo
49
{
50
    sal_uInt16          m_nWhich;
51
    sal_uInt16          m_nSlotID;
52
    sal_uInt16          m_nItemInfoFlags;
53
54
public:
55
    ItemInfo(sal_uInt16 nWhich, sal_uInt16 nSlotID, sal_uInt16 nItemInfoFlags)
56
8.88k
    : m_nWhich(nWhich), m_nSlotID(nSlotID), m_nItemInfoFlags(nItemInfoFlags) {}
57
6.36M
    ItemInfo(const ItemInfo& rIemInfo) = default;
58
6.37M
    virtual ~ItemInfo() = default;
59
60
3.98M
    sal_uInt16 getWhich() const { return m_nWhich; }
61
    virtual const SfxPoolItem* getItem() const = 0;
62
3.13M
    sal_uInt16 getSlotID() const { return m_nSlotID; }
63
1.61G
    sal_uInt16 getItemInfoFlags() const { return m_nItemInfoFlags; }
64
};
65
66
class SVL_DLLPUBLIC ItemInfoStatic final : public ItemInfo
67
{
68
    friend class ItemInfoPackage;
69
    void setItem(SfxPoolItem* pItem)
70
227
    {
71
227
        if (nullptr != pItem)
72
227
            pItem->setStaticDefault();
73
227
        m_pItem.reset(pItem);
74
227
    }
75
76
    std::unique_ptr<const SfxPoolItem> m_pItem;
77
78
public:
79
    ItemInfoStatic(sal_uInt16 nWhich, SfxPoolItem* pItem, sal_uInt16 nSlotID, sal_uInt16 nItemInfoFlags)
80
8.88k
    : ItemInfo(nWhich, nSlotID, nItemInfoFlags)
81
8.88k
    , m_pItem(pItem) { if(nullptr != pItem) pItem->setStaticDefault(); }
82
83
1.02G
    virtual const SfxPoolItem* getItem() const override { return m_pItem.get(); }
84
};
85
86
class SVL_DLLPUBLIC ItemInfoDynamic final : public ItemInfo
87
{
88
    std::unique_ptr<const SfxPoolItem> m_pItem;
89
90
public:
91
    ItemInfoDynamic(const ItemInfo& rItemInfo, SfxPoolItem* pItem)
92
1.39M
    : ItemInfo(rItemInfo)
93
1.39M
    , m_pItem(pItem) { if(nullptr != pItem) pItem->setDynamicDefault(); }
94
95
8.22M
    virtual const SfxPoolItem* getItem() const override { return m_pItem.get(); }
96
};
97
98
class UNLESS_MERGELIBS(SVL_DLLPUBLIC) ItemInfoUser final : public ItemInfo
99
{
100
    const SfxPoolItem* m_pItem;
101
102
public:
103
    ItemInfoUser(const ItemInfo& rItemInfo, const SfxItemPool& rItemPool, const SfxPoolItem& rItem, bool bPassingOwnership = false);
104
    virtual ~ItemInfoUser();
105
106
164M
    virtual const SfxPoolItem* getItem() const override { return m_pItem; }
107
};
108
109
typedef std::unordered_map<sal_uInt16, sal_uInt16> SlotIDToWhichIDMap;
110
111
class SVL_DLLPUBLIC ItemInfoPackage
112
{
113
protected:
114
    // this is needed for on-demand creation of static entries in constructors
115
    // derived from ItemInfoPackage or implementations of ::getItemInfo(). This
116
    // takes ownership of the item
117
227
    static void setItemAtItemInfoStatic(SfxPoolItem* pItem, ItemInfoStatic& rItemInfo) { rItemInfo.setItem(pItem); }
118
119
private:
120
    // mechanism for buffered SlotIDToWhichIDMap
121
    virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const = 0;
122
    mutable SlotIDToWhichIDMap maSlotIDToWhichIDMap;
123
124
public:
125
102
    ItemInfoPackage() = default;
126
102
    virtual ~ItemInfoPackage() = default;
127
128
    virtual size_t size() const = 0;
129
    virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& rPool) = 0;
130
    virtual const ItemInfo& getExistingItemInfo(size_t /*nIndex*/);
131
    const SlotIDToWhichIDMap& getSlotIDToWhichIDMap() const;
132
};
133
134
typedef std::unordered_set<SfxItemSet*> registeredSfxItemSets;
135
class SfxPoolItemHolder;
136
typedef std::unordered_set<SfxPoolItemHolder*> registeredSfxPoolItemHolders;
137
typedef std::vector<const SfxPoolItem*> ItemSurrogates;
138
typedef std::unordered_map<sal_uInt16, const ItemInfo*> userItemInfos;
139
typedef std::vector<const ItemInfo*> itemInfoVector;
140
typedef std::unordered_map<const SfxPoolItem*, sal_uInt32> NameOrIndexContent;
141
typedef std::unordered_map<SfxItemType, NameOrIndexContent> registeredNameOrIndex;
142
143
/** Base class for providers of defaults of SfxPoolItems.
144
 *
145
 * The derived classes hold the concrete (const) instances which are referenced in several places
146
 * (usually within a single document).
147
 * This helps to lower the amount of calls to lifecycle methods, speeds up comparisons within a document
148
 * and facilitates loading and saving of attributes.
149
 */
150
class SVL_DLLPUBLIC SfxItemPool : public salhelper::SimpleReferenceObject
151
{
152
    friend class SfxItemSet;
153
    friend class SfxPoolItemHolder;
154
    friend class SfxAllItemSet;
155
156
    // allow ItemSetTooling to access
157
    friend SfxPoolItem const* implCreateItemEntry(const SfxItemPool&, SfxPoolItem const*, bool);
158
    friend void implCleanupItemEntry(SfxPoolItem const*);
159
160
    SfxBroadcaster                  aBC;
161
    OUString                        aName;
162
    SfxItemPool*                    mpMaster;
163
    rtl::Reference<SfxItemPool>     mpSecondary;
164
    mutable WhichRangesContainer    maPoolRanges;
165
    sal_uInt16                      mnStart;
166
    sal_uInt16                      mnEnd;
167
    MapUnit                         eDefMetric;
168
169
    registeredSfxItemSets maRegisteredSfxItemSets;
170
    registeredSfxPoolItemHolders maRegisteredSfxPoolItemHolders;
171
172
    // place to register all NameOrIndex Items that are either set in an
173
    // SfxItemSet or SfxPolItemHolder for this Model/Pool
174
    registeredNameOrIndex maRegisteredNameOrIndex;
175
176
    bool mbShutdownHintSent;
177
178
    itemInfoVector maItemInfos;
179
    userItemInfos maUserItemInfos;
180
    const SlotIDToWhichIDMap* mpSlotIDToWhichIDMap;
181
182
public:
183
    void registerItemInfoPackage(
184
        ItemInfoPackage& rPackage,
185
        const std::function<SfxPoolItem*(sal_uInt16)>& rCallback = std::function<SfxPoolItem*(sal_uInt16)>());
186
protected:
187
    const ItemInfo* impCheckItemInfoForClone(const ItemInfo* pInfo);
188
    void impClearUserDefault(const userItemInfos::iterator& rHit);
189
    void impCreateUserDefault(const SfxPoolItem& rItem);
190
private:
191
    void cleanupItemInfos();
192
193
private:
194
    sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const
195
2.53G
    {
196
2.53G
        if (IsInRange(nWhich))
197
2.53G
            return nWhich - mnStart;
198
2.53G
        assert(false && "missing bounds check before use");
199
0
        return 0;
200
2.53G
    }
201
0
    sal_uInt16 GetSize_Impl() const { return mnEnd - mnStart + 1; }
202
    SfxItemPool* getTargetPool(sal_uInt16 nWhich) const;
203
204
    // moved to private: use the access methods, e.g. NeedsSurrogateSupport
205
    SVL_DLLPRIVATE bool CheckItemInfoFlag(sal_uInt16 nWhich, sal_uInt16 nMask) const;
206
    SVL_DLLPRIVATE bool CheckItemInfoFlag_Impl(sal_uInt16 nPos, sal_uInt16 nMask) const
207
0
        { return maItemInfos[nPos]->getItemInfoFlags() & nMask; }
208
209
    void registerItemSet(SfxItemSet& rSet);
210
    void unregisterItemSet(SfxItemSet& rSet);
211
212
    void registerPoolItemHolder(SfxPoolItemHolder& rHolder);
213
    void unregisterPoolItemHolder(SfxPoolItemHolder& rHolder);
214
215
    void registerNameOrIndex(const SfxPoolItem& rItem);
216
    void unregisterNameOrIndex(const SfxPoolItem& rItem);
217
218
public:
219
    // for default SfxItemSet::CTOR, set default WhichRanges
220
    const WhichRangesContainer& GetMergedIdRanges() const;
221
222
protected:
223
    static inline void              AddRef(const SfxPoolItem& rItem);
224
    static inline sal_uInt32        ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n = 1);
225
226
public:
227
    SfxItemPool(const SfxItemPool &rPool);
228
    SfxItemPool(const OUString &rName);
229
    virtual ~SfxItemPool();
230
231
    SfxBroadcaster&                 BC();
232
233
    // UserDefaults: Every PoolDefault can be 'overloaded' with a user-defined
234
    // default. This is then owned by the pool. The read access is limited
235
    // to check the UserDefaults, so it *will* return nullptr if none is set
236
    void                            SetUserDefaultItem( const SfxPoolItem& );
237
    const SfxPoolItem*              GetUserDefaultItem( sal_uInt16 nWhich ) const;
238
    template<class T> const T*      GetUserDefaultItem( TypedWhichId<T> nWhich ) const
239
273k
    { return static_cast<const T*>(GetUserDefaultItem(sal_uInt16(nWhich))); }
SvxFontHeightItem const* SfxItemPool::GetUserDefaultItem<SvxFontHeightItem>(TypedWhichId<SvxFontHeightItem>) const
Line
Count
Source
239
136k
    { return static_cast<const T*>(GetUserDefaultItem(sal_uInt16(nWhich))); }
SvxNumBulletItem const* SfxItemPool::GetUserDefaultItem<SvxNumBulletItem>(TypedWhichId<SvxNumBulletItem>) const
Line
Count
Source
239
98.8k
    { return static_cast<const T*>(GetUserDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: SvxFontItem const* SfxItemPool::GetUserDefaultItem<SvxFontItem>(TypedWhichId<SvxFontItem>) const
Unexecuted instantiation: SvxColorItem const* SfxItemPool::GetUserDefaultItem<SvxColorItem>(TypedWhichId<SvxColorItem>) const
Unexecuted instantiation: SvxBrushItem const* SfxItemPool::GetUserDefaultItem<SvxBrushItem>(TypedWhichId<SvxBrushItem>) const
Unexecuted instantiation: SvxShadowItem const* SfxItemPool::GetUserDefaultItem<SvxShadowItem>(TypedWhichId<SvxShadowItem>) const
Unexecuted instantiation: SvxBoxItem const* SfxItemPool::GetUserDefaultItem<SvxBoxItem>(TypedWhichId<SvxBoxItem>) const
SvxTabStopItem const* SfxItemPool::GetUserDefaultItem<SvxTabStopItem>(TypedWhichId<SvxTabStopItem>) const
Line
Count
Source
239
3.18k
    { return static_cast<const T*>(GetUserDefaultItem(sal_uInt16(nWhich))); }
SvxFrameDirectionItem const* SfxItemPool::GetUserDefaultItem<SvxFrameDirectionItem>(TypedWhichId<SvxFrameDirectionItem>) const
Line
Count
Source
239
35.6k
    { return static_cast<const T*>(GetUserDefaultItem(sal_uInt16(nWhich))); }
240
    void                            ResetUserDefaultItem( sal_uInt16 nWhich );
241
242
    // PoolDefaults: Owned by the pool. The read access will only return
243
    // nullptr if the WhichID asked for is not in the range of the pool,
244
    // making the request invalid.
245
    const SfxPoolItem *             GetPoolDefaultItem(sal_uInt16 nWhich) const;
246
    template<class T> const T*      GetPoolDefaultItem( TypedWhichId<T> nWhich ) const
247
    { return static_cast<const T*>(GetPoolDefaultItem(sal_uInt16(nWhich))); }
248
249
    // UserOrPoolDefaults: Combination of UserDefaults and PoolDefaults.
250
    // UserDefaults will be preferred. If none is set for that WhichID,
251
    // the PoolDefault will be returned.
252
    // Note that read access will return a reference, but this will lead
253
    // to an asserted error when the given WhichID is not in the range of
254
    // the pool.
255
    const SfxPoolItem&              GetUserOrPoolDefaultItem( sal_uInt16 nWhich ) const;
256
    template<class T> const T&      GetUserOrPoolDefaultItem( TypedWhichId<T> nWhich ) const
257
344k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: ScMergeAttr const& SfxItemPool::GetUserOrPoolDefaultItem<ScMergeAttr>(TypedWhichId<ScMergeAttr>) const
SvxFontItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxFontItem>(TypedWhichId<SvxFontItem>) const
Line
Count
Source
257
45.3k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
SvxFontHeightItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxFontHeightItem>(TypedWhichId<SvxFontHeightItem>) const
Line
Count
Source
257
8
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
SvxWeightItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxWeightItem>(TypedWhichId<SvxWeightItem>) const
Line
Count
Source
257
8
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: SvxColorItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxColorItem>(TypedWhichId<SvxColorItem>) const
SvxBrushItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxBrushItem>(TypedWhichId<SvxBrushItem>) const
Line
Count
Source
257
4
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: SvxUnderlineItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxUnderlineItem>(TypedWhichId<SvxUnderlineItem>) const
Unexecuted instantiation: SvxOverlineItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxOverlineItem>(TypedWhichId<SvxOverlineItem>) const
SvxSetItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxSetItem>(TypedWhichId<SvxSetItem>) const
Line
Count
Source
257
162k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
SfxUInt16Item const& SfxItemPool::GetUserOrPoolDefaultItem<SfxUInt16Item>(TypedWhichId<SfxUInt16Item>) const
Line
Count
Source
257
81.6k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
ScPageScaleToItem const& SfxItemPool::GetUserOrPoolDefaultItem<ScPageScaleToItem>(TypedWhichId<ScPageScaleToItem>) const
Line
Count
Source
257
40.8k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: ScMergeFlagAttr const& SfxItemPool::GetUserOrPoolDefaultItem<ScMergeFlagAttr>(TypedWhichId<ScMergeFlagAttr>) const
Unexecuted instantiation: SvxShadowItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxShadowItem>(TypedWhichId<SvxShadowItem>) const
Unexecuted instantiation: SvxNumBulletItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxNumBulletItem>(TypedWhichId<SvxNumBulletItem>) const
Unexecuted instantiation: SvxPostureItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxPostureItem>(TypedWhichId<SvxPostureItem>) const
Unexecuted instantiation: SvxCrossedOutItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxCrossedOutItem>(TypedWhichId<SvxCrossedOutItem>) const
Unexecuted instantiation: SvxWordLineModeItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxWordLineModeItem>(TypedWhichId<SvxWordLineModeItem>) const
Unexecuted instantiation: XFillBmpTileItem const& SfxItemPool::GetUserOrPoolDefaultItem<XFillBmpTileItem>(TypedWhichId<XFillBmpTileItem>) const
XFillBmpStretchItem const& SfxItemPool::GetUserOrPoolDefaultItem<XFillBmpStretchItem>(TypedWhichId<XFillBmpStretchItem>) const
Line
Count
Source
257
6
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: SfxUInt32Item const& SfxItemPool::GetUserOrPoolDefaultItem<SfxUInt32Item>(TypedWhichId<SfxUInt32Item>) const
Unexecuted instantiation: SvxFrameDirectionItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxFrameDirectionItem>(TypedWhichId<SvxFrameDirectionItem>) const
SvxTabStopItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxTabStopItem>(TypedWhichId<SvxTabStopItem>) const
Line
Count
Source
257
14.3k
    { return static_cast<const T&>(GetUserOrPoolDefaultItem(sal_uInt16(nWhich))); }
Unexecuted instantiation: SvxLanguageItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxLanguageItem>(TypedWhichId<SvxLanguageItem>) const
Unexecuted instantiation: SvxAdjustItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxAdjustItem>(TypedWhichId<SvxAdjustItem>) const
Unexecuted instantiation: SvxEscapementItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxEscapementItem>(TypedWhichId<SvxEscapementItem>) const
Unexecuted instantiation: SvxLineSpacingItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxLineSpacingItem>(TypedWhichId<SvxLineSpacingItem>) const
Unexecuted instantiation: SvxCaseMapItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxCaseMapItem>(TypedWhichId<SvxCaseMapItem>) const
Unexecuted instantiation: SvxShadowedItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxShadowedItem>(TypedWhichId<SvxShadowedItem>) const
Unexecuted instantiation: SvxEmphasisMarkItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxEmphasisMarkItem>(TypedWhichId<SvxEmphasisMarkItem>) const
Unexecuted instantiation: SvxCharReliefItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxCharReliefItem>(TypedWhichId<SvxCharReliefItem>) const
Unexecuted instantiation: SvxContourItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxContourItem>(TypedWhichId<SvxContourItem>) const
Unexecuted instantiation: SvxNoHyphenItem const& SfxItemPool::GetUserOrPoolDefaultItem<SvxNoHyphenItem>(TypedWhichId<SvxNoHyphenItem>) const
258
259
    virtual MapUnit                 GetMetric( sal_uInt16 nWhich ) const;
260
    void                            SetDefaultMetric( MapUnit eNewMetric );
261
0
    MapUnit GetDefaultMetric() const { return eDefMetric; }
262
263
    /** Request string representation of pool items.
264
265
        This virtual function produces a string representation
266
        from the respective SfxItemPool subclass' known SfxPoolItems.
267
268
        Subclasses, please override this method, and handle
269
        SfxPoolItems that don't return useful/complete information on
270
        SfxPoolItem::GetPresentation()
271
272
        This baseclass yields the unmodified string representation of
273
        rItem.
274
275
        @param[in] rItem
276
        SfxPoolItem to query the string representation of
277
278
        @param[in] ePresent
279
        requested kind of representation - see SfxItemPresentation
280
281
        @param[in] eMetric
282
        requested unit of measure of the representation
283
284
        @param[out] rText
285
        string representation of 'rItem'
286
287
        @return true if it has a valid string representation
288
    */
289
    virtual bool                    GetPresentation( const SfxPoolItem& rItem,
290
                                                     MapUnit ePresentationMetric,
291
                                                     OUString& rText,
292
                                                     const IntlWrapper& rIntlWrapper ) const;
293
    virtual rtl::Reference<SfxItemPool> Clone() const;
294
0
    const OUString& GetName() const { return aName; }
295
296
public:
297
    // SurrogateData callback helper for iterateItemSurrogates
298
    class SurrogateData
299
    {
300
    public:
301
6.02k
        virtual ~SurrogateData() = default;
302
2.25k
        SurrogateData(const SurrogateData&) = default;
303
3.77k
        SurrogateData() = default;
304
305
        // read-access to Item
306
        virtual const SfxPoolItem& getItem() const = 0;
307
308
        // write-access when Item needs to be modified
309
        virtual const SfxPoolItem* setItem(std::unique_ptr<SfxPoolItem>) = 0;
310
    };
311
312
    // Iterate using a lambda/callback with read/write access to registered SfxPoolItems.
313
    // If you use this (look for current usages) inside the callback you may
314
    //   return true; // to continue callback (like 'continue')
315
    //   return false; // to end callbacks (like 'break')
316
    void iterateItemSurrogates(
317
        sal_uInt16 nWhich,
318
        const std::function<bool(SfxItemPool::SurrogateData& rData)>& rItemCallback) const;
319
320
    // Read-only access to registered SfxPoolItems
321
    // NOTE: In *no* case use const_cast and change those Items (!)
322
    // Read commit text for more information
323
    ItemSurrogates GetItemSurrogates(sal_uInt16 nWhich) const;
324
325
    // special version for read-only itemSurrogates for NameOrIndex Items
326
    ItemSurrogates GetItemSurrogatesForItem(const SfxPoolItem& rItem) const;
327
    ItemSurrogates GetItemSurrogatesForItem(SfxItemType eItemType) const;
328
329
0
    sal_uInt16 GetFirstWhich() const { return mnStart; }
330
0
    sal_uInt16 GetLastWhich() const { return mnEnd; }
331
5.91G
    bool IsInRange( sal_uInt16 nWhich ) const { return nWhich >= mnStart && nWhich <= mnEnd; }
332
333
    void                            SetSecondaryPool( SfxItemPool *pPool );
334
4.82M
    SfxItemPool* GetSecondaryPool() const { return mpSecondary.get(); }
335
    /* get the last pool by following the GetSecondaryPool chain */
336
    SfxItemPool*                    GetLastPoolInChain();
337
911M
    SfxItemPool* GetMasterPool() const { return mpMaster; }
338
    void sendShutdownHint();
339
340
    // syntactical sugar: direct call to not have to use the flag define
341
    // and make the intention clearer
342
    bool NeedsSurrogateSupport(sal_uInt16 nWhich) const
343
1.61G
        { return CheckItemInfoFlag(nWhich, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE); }
344
345
    // tries to translate back from SlotID to WhichID.
346
    // If none is defined, return nSlot.
347
    // If nSlot is not a SlotID, return nSlot.
348
    sal_uInt16 GetWhichIDFromSlotID(sal_uInt16 nSlot, bool bDeep = true) const;
349
    template<class T> TypedWhichId<T> GetWhichIDFromSlotID(TypedWhichId<T> nSlot, bool bDeep = true) const
350
0
     { return TypedWhichId<T>(GetWhichIDFromSlotID(sal_uInt16(nSlot), bDeep)); }
Unexecuted instantiation: TypedWhichId<SvxLanguageItem> SfxItemPool::GetWhichIDFromSlotID<SvxLanguageItem>(TypedWhichId<SvxLanguageItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxMacroItem> SfxItemPool::GetWhichIDFromSlotID<SvxMacroItem>(TypedWhichId<SvxMacroItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxFontItem> SfxItemPool::GetWhichIDFromSlotID<SvxFontItem>(TypedWhichId<SvxFontItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxBrushItem> SfxItemPool::GetWhichIDFromSlotID<SvxBrushItem>(TypedWhichId<SvxBrushItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxFormatKeepItem> SfxItemPool::GetWhichIDFromSlotID<SvxFormatKeepItem>(TypedWhichId<SvxFormatKeepItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxKerningItem> SfxItemPool::GetWhichIDFromSlotID<SvxKerningItem>(TypedWhichId<SvxKerningItem>, bool) const
Unexecuted instantiation: TypedWhichId<SfxStringItem> SfxItemPool::GetWhichIDFromSlotID<SfxStringItem>(TypedWhichId<SfxStringItem>, bool) const
Unexecuted instantiation: TypedWhichId<SwPaMItem> SfxItemPool::GetWhichIDFromSlotID<SwPaMItem>(TypedWhichId<SwPaMItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxColorItem> SfxItemPool::GetWhichIDFromSlotID<SvxColorItem>(TypedWhichId<SvxColorItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxSizeItem> SfxItemPool::GetWhichIDFromSlotID<SvxSizeItem>(TypedWhichId<SvxSizeItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxShadowItem> SfxItemPool::GetWhichIDFromSlotID<SvxShadowItem>(TypedWhichId<SvxShadowItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxFormatBreakItem> SfxItemPool::GetWhichIDFromSlotID<SvxFormatBreakItem>(TypedWhichId<SvxFormatBreakItem>, bool) const
Unexecuted instantiation: TypedWhichId<SwFormatPageDesc> SfxItemPool::GetWhichIDFromSlotID<SwFormatPageDesc>(TypedWhichId<SwFormatPageDesc>, bool) const
Unexecuted instantiation: TypedWhichId<SwFormatLayoutSplit> SfxItemPool::GetWhichIDFromSlotID<SwFormatLayoutSplit>(TypedWhichId<SwFormatLayoutSplit>, bool) const
Unexecuted instantiation: TypedWhichId<SvxFrameDirectionItem> SfxItemPool::GetWhichIDFromSlotID<SvxFrameDirectionItem>(TypedWhichId<SvxFrameDirectionItem>, bool) const
Unexecuted instantiation: TypedWhichId<SfxUInt32Item> SfxItemPool::GetWhichIDFromSlotID<SfxUInt32Item>(TypedWhichId<SfxUInt32Item>, bool) const
Unexecuted instantiation: TypedWhichId<SvxNumBulletItem> SfxItemPool::GetWhichIDFromSlotID<SvxNumBulletItem>(TypedWhichId<SvxNumBulletItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxLineSpacingItem> SfxItemPool::GetWhichIDFromSlotID<SvxLineSpacingItem>(TypedWhichId<SvxLineSpacingItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxLRSpaceItem> SfxItemPool::GetWhichIDFromSlotID<SvxLRSpaceItem>(TypedWhichId<SvxLRSpaceItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxULSpaceItem> SfxItemPool::GetWhichIDFromSlotID<SvxULSpaceItem>(TypedWhichId<SvxULSpaceItem>, bool) const
Unexecuted instantiation: TypedWhichId<SvxPaperBinItem> SfxItemPool::GetWhichIDFromSlotID<SvxPaperBinItem>(TypedWhichId<SvxPaperBinItem>, bool) const
351
352
    // get SlotID that may be registered in the SfxItemInfo for
353
    // the given WhichID.
354
    // If none is defined, return nWhich.
355
    // If nWhich is not a WhichID, return nWhich.
356
    sal_uInt16 GetSlotId( sal_uInt16 nWhich ) const;
357
358
    // same as GetWhichIDFromSlotID, but returns 0 in error cases, so:
359
    // If none is defined, return 0.
360
    // If nSlot is not a SlotID, return 0.
361
    sal_uInt16 GetTrueWhichIDFromSlotID( sal_uInt16 nSlot, bool bDeep = true ) const;
362
363
    // same as GetSlotId, but returns 0 in error cases, so:
364
    // If none is defined, return 0.
365
    // If nWhich is not a WhichID, return 0.
366
    sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich ) const;
367
368
120M
    static bool IsWhich(sal_uInt16 nId) { return nId && nId <= SFX_WHICH_MAX; }
369
3.56G
    static bool IsSlot(sal_uInt16 nId) { return nId && nId > SFX_WHICH_MAX; }
370
371
private:
372
    const SfxItemPool& operator=(const SfxItemPool &) = delete;
373
374
     //IDs below or equal are Which IDs, IDs above slot IDs
375
    static const sal_uInt16 SFX_WHICH_MAX = 4999;
376
};
377
378
// only the pool may manipulate the reference counts
379
inline void SfxItemPool::AddRef(const SfxPoolItem& rItem)
380
0
{
381
0
    rItem.AddRef();
382
0
}
383
384
// only the pool may manipulate the reference counts
385
inline sal_uInt32 SfxItemPool::ReleaseRef(const SfxPoolItem& rItem, sal_uInt32 n)
386
0
{
387
0
    return rItem.ReleaseRef(n);
388
0
}
389
390
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */