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