summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-02-19 14:50:37 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2024-02-19 20:04:34 +0100
commit9bd2012df77da01b9ee30b25698237fb45673f49 (patch)
treec2f6b38b9b275f5a25092f58f96d8bccd16553be
parentthese symbols no longer need to be public (diff)
downloadcore-9bd2012df77da01b9ee30b25698237fb45673f49.tar.gz
core-9bd2012df77da01b9ee30b25698237fb45673f49.zip
ITEM: Speedup SlotIDToWhichID translations
With ItemInfoPackages we now can have a buffered, static global translation table from SlotIDs to WhichIDs since the ItemInfoStatic used already contains all the needed information. Register that in registerItemInfoPackage at the Pool and use it for lookup. That speeds up the lookup from O(n) to O(1). Since that lookup is used in UI and UNO API implementations this has positive effect on load/safe, but also all interactive stuff in the whole office. NOTE: I tried to use a merged version of that translation table in the parent pool, but this shows double SlotIDs, what is no wonder since that's what those are used for: To get different WhichIDs for a SlotID in Item handling. This *might* prevent getting rid of the chanined Pools at all - sadly. The returned WhichID directly depends on which Pool the function(s) GetWhichIDFromSlotID and GetTrueWhichIDFromSlotID are called. NOTE: Very strange is that the parameter 'bDeep' in that functions is *not* passed down to the call to the secondary Pool - probably an error, but risky to fix, that may change already the behaviour :-( Change-Id: Iea77ffad0f6a5401ab74fea0bbfc2589c66680ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163597 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx3
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.cxx2
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx2
-rw-r--r--editeng/source/editeng/eerdll.cxx2
-rw-r--r--extensions/source/propctrlr/fontdialog.cxx2
-rw-r--r--include/svl/itempool.hxx13
-rw-r--r--reportdesign/source/ui/misc/UITools.cxx2
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx4
-rw-r--r--sc/source/core/data/docpool.cxx2
-rw-r--r--sc/source/ui/app/msgpool.cxx3
-rw-r--r--sfx2/source/explorer/nochaos.cxx2
-rw-r--r--svl/qa/unit/items/stylepool.cxx5
-rw-r--r--svl/source/items/itempool.cxx49
-rw-r--r--svl/source/items/itemset.cxx48
-rw-r--r--svl/source/items/poolitem.cxx32
-rw-r--r--svx/source/dialog/imapwnd.cxx2
-rw-r--r--svx/source/svdraw/svdattr.cxx2
-rw-r--r--sw/source/core/bastyp/init.cxx2
-rw-r--r--sw/source/core/unocore/unoevent.cxx6
19 files changed, 133 insertions, 50 deletions
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index e11e46ba2b8d..e28bb97f81db 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -182,8 +182,9 @@ static ItemInfoPackage& getItemInfoPackageChart()
{ SCHATTR_DATA_TABLE_KEYS, new SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, false), 0, SFX_ITEMINFOFLAG_NONE }
}};
- public:
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+ public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
};
diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx
index 67cf6298f247..7c4d6d7145d8 100644
--- a/dbaccess/source/ui/dlg/dbadmin.cxx
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -339,6 +339,8 @@ static ItemInfoPackage& getItemInfoPackageAdminDlg()
{ DSID_POSTGRES_PORTNUMBER, new SfxInt32Item(DSID_POSTGRES_PORTNUMBER, 5432), 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageAdminDlg()
{
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 2a9747c01e5a..55e7f709f7b2 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -763,6 +763,8 @@ static ItemInfoPackage& getItemInfoPackageColumnFormatDialog()
{ SBA_ATTR_ALIGN_HOR_JUSTIFY, new SvxHorJustifyItem(SvxCellHorJustify::Standard, SBA_ATTR_ALIGN_HOR_JUSTIFY), SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEMINFOFLAG_NONE },
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx
index ab6495c8a804..732c85ee18cd 100644
--- a/editeng/source/editeng/eerdll.cxx
+++ b/editeng/source/editeng/eerdll.cxx
@@ -160,6 +160,8 @@ ItemInfoPackage& getItemInfoPackageEditEngine()
{ EE_FEATURE_FIELD, new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD ), SID_FIELD, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageEditEngine()
{
diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx
index c84f13f9047d..78dd50c8475d 100644
--- a/extensions/source/propctrlr/fontdialog.cxx
+++ b/extensions/source/propctrlr/fontdialog.cxx
@@ -527,6 +527,8 @@ namespace pcr
{ FontItemIds::CFID_FONTLIST, nullptr, SID_ATTR_CHAR_FONTLIST, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 5e30e83780c1..5b4c7c7465db 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -105,6 +105,8 @@ public:
virtual const SfxPoolItem* getItem() const override { return m_pItem; }
};
+typedef std::unordered_map<sal_uInt16, sal_uInt16> SlotIDToWhichIDMap;
+
class SVL_DLLPUBLIC ItemInfoPackage
{
protected:
@@ -113,6 +115,11 @@ protected:
// takes ownership of the item
static void setItemAtItemInfoStatic(SfxPoolItem* pItem, ItemInfoStatic& rItemInfo) { rItemInfo.setItem(pItem); }
+private:
+ // mechanism for buffered SlotIDToWhichIDMap
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const = 0;
+ mutable SlotIDToWhichIDMap maSlotIDToWhichIDMap;
+
public:
ItemInfoPackage() = default;
virtual ~ItemInfoPackage() = default;
@@ -120,6 +127,7 @@ public:
virtual size_t size() const = 0;
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& rPool) = 0;
virtual const ItemInfo& getExistingItemInfo(size_t /*nIndex*/);
+ const SlotIDToWhichIDMap& getSlotIDToWhichIDMap() const;
};
typedef std::unordered_set<SfxItemSet*> registeredSfxItemSets;
@@ -161,6 +169,7 @@ class SVL_DLLPUBLIC SfxItemPool : public salhelper::SimpleReferenceObject
itemInfoVector maItemInfos;
userItemInfos maUserItemInfos;
+ const SlotIDToWhichIDMap* mpSlotIDToWhichIDMap;
public:
void registerItemInfoPackage(
@@ -319,9 +328,7 @@ public:
bool NeedsSurrogateSupport(sal_uInt16 nWhich) const
{ return CheckItemInfoFlag(nWhich, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE); }
- // tries to translate back from SlotID to WhichID. That may be
- // expensive, it needs to linearly iterate over SfxItemInfo
- // to evtl. find if a SlotID is defined for a WhichID
+ // tries to translate back from SlotID to WhichID.
// If none is defined, return nSlot.
// If nSlot is not a SlotID, return nSlot.
sal_uInt16 GetWhichIDFromSlotID(sal_uInt16 nSlot, bool bDeep = true) const;
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index f961c54296d1..e346606fd2ea 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -623,6 +623,8 @@ static ItemInfoPackage& getItemInfoPackageOpenCharDlg()
{ ITEMID_WEIGHT_COMPLEX , new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT_COMPLEX), SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 468d078b4a0c..1f580869a4b3 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -2359,6 +2359,8 @@ static ItemInfoPackage& getItemInfoPackageOpenPageDlg()
{ RPTUI_ID_METRIC, nullptr, SID_ATTR_METRIC, SFX_ITEMINFOFLAG_NONE },
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageOpenPageDlg()
{
@@ -4181,6 +4183,8 @@ static ItemInfoPackage& getItemInfoPackageOpenZoomDlg()
{ SID_ATTR_ZOOM, new SvxZoomItem, 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 416a1d5885ec..f23a6087256c 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -190,6 +190,8 @@ static ItemInfoPackage& getItemInfoPackageScDocument()
{ ATTR_HIDDEN, new SfxBoolItem( ATTR_HIDDEN, false ), 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageScDocument()
{
diff --git a/sc/source/ui/app/msgpool.cxx b/sc/source/ui/app/msgpool.cxx
index d778d04f380f..88d720077b64 100644
--- a/sc/source/ui/app/msgpool.cxx
+++ b/sc/source/ui/app/msgpool.cxx
@@ -41,8 +41,9 @@ static ItemInfoPackage& getItemInfoPackageScMessage()
{ SCITEM_USERLIST, new ScUserListItem(SCITEM_USERLIST ), SID_SCUSERLISTS, SFX_ITEMINFOFLAG_NONE }
}};
- public:
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+ public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
};
diff --git a/sfx2/source/explorer/nochaos.cxx b/sfx2/source/explorer/nochaos.cxx
index 3fb582a3d43d..ebed6cc8e17e 100644
--- a/sfx2/source/explorer/nochaos.cxx
+++ b/sfx2/source/explorer/nochaos.cxx
@@ -73,6 +73,8 @@ static ItemInfoPackage& getItemInfoPackageNoChaos()
{ WID_CHAOS_START, new SfxStringItem(WID_CHAOS_START, OUString()), 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
diff --git a/svl/qa/unit/items/stylepool.cxx b/svl/qa/unit/items/stylepool.cxx
index c77a152a0f7d..8ba33c1931de 100644
--- a/svl/qa/unit/items/stylepool.cxx
+++ b/svl/qa/unit/items/stylepool.cxx
@@ -29,6 +29,11 @@ ItemInfoPackage& getItemInfoPackageTest()
ItemInfoArrayTest maItemInfos{ { // m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags
{ 1, new SfxStringItem(1), 2, SFX_ITEMINFOFLAG_NONE } } };
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override
+ {
+ return maItemInfos[nIndex];
+ }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 19eb792dc85f..54a348251944 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -197,6 +197,28 @@ ItemInfoUser::~ItemInfoUser()
implCleanupItemEntry(m_pItem);
}
+const SlotIDToWhichIDMap& ItemInfoPackage::getSlotIDToWhichIDMap() const
+{
+ if (maSlotIDToWhichIDMap.empty())
+ {
+ // will be filled only once per office runtime
+ for (size_t a(0); a < size(); a++)
+ {
+ const ItemInfoStatic& rCandidate(getItemInfoStatic(a));
+ if (0 != rCandidate.getSlotID())
+ {
+#ifdef DBG_UTIL
+ if (maSlotIDToWhichIDMap.find(rCandidate.getSlotID()) != maSlotIDToWhichIDMap.end())
+ assert(false && "ITEM: SlotID used double in ItemInfoPackage (!)");
+#endif
+ maSlotIDToWhichIDMap[rCandidate.getSlotID()] = rCandidate.getWhich();
+ }
+ }
+ }
+
+ return maSlotIDToWhichIDMap;
+}
+
const ItemInfo& ItemInfoPackage::getExistingItemInfo(size_t /*nIndex*/)
{
static ItemInfoStatic EMPTY(0, nullptr, 0, 0);
@@ -236,6 +258,9 @@ void SfxItemPool::registerItemInfoPackage(
mnStart = maItemInfos.front()->getWhich();
mnEnd = maItemInfos.back()->getWhich();
+ // set mapper for fast SlotIDToWhichID conversion
+ mpSlotIDToWhichIDMap = &rPackage.getSlotIDToWhichIDMap();
+
#ifdef DBG_UTIL
for (size_t a(1); a < maItemInfos.size(); a++)
if (maItemInfos[a-1]->getWhich() + 1 != maItemInfos[a]->getWhich())
@@ -462,6 +487,7 @@ SfxItemPool::SfxItemPool(const OUString& rName) /* Pool name to identify in the
, mbShutdownHintSent(false)
, maItemInfos()
, maUserItemInfos()
+, mpSlotIDToWhichIDMap(nullptr)
{
eDefMetric = MapUnit::MapTwip;
}
@@ -486,6 +512,7 @@ SfxItemPool::SfxItemPool(const SfxItemPool& rPool) // Copy from this instance
, mbShutdownHintSent(false)
, maItemInfos(rPool.maItemInfos)
, maUserItemInfos(rPool.maUserItemInfos)
+, mpSlotIDToWhichIDMap(rPool.mpSlotIDToWhichIDMap)
{
// DynamicDefaults and UserDefaults need to be cloned for the new Pool
for (itemInfoVector::iterator aInfo(maItemInfos.begin()); aInfo != maItemInfos.end(); aInfo++)
@@ -861,13 +888,12 @@ sal_uInt16 SfxItemPool::GetWhichIDFromSlotID(sal_uInt16 nSlotId, bool bDeep) con
if (!IsSlot(nSlotId))
return nSlotId;
- for (auto& rInfo : maItemInfos)
+ if (nullptr != mpSlotIDToWhichIDMap)
{
- assert(nullptr != rInfo && "ITEM: access error to Defaults in Pool (!)");
- if (nSlotId == rInfo->getSlotID())
- {
- return rInfo->getWhich();
- }
+ // use the static global translation table -> near linear access time
+ SlotIDToWhichIDMap::const_iterator aHit(mpSlotIDToWhichIDMap->find(nSlotId));
+ if (aHit != mpSlotIDToWhichIDMap->end())
+ return aHit->second;
}
if (mpSecondary && bDeep)
@@ -899,13 +925,12 @@ sal_uInt16 SfxItemPool::GetTrueWhichIDFromSlotID( sal_uInt16 nSlotId, bool bDeep
if (!IsSlot(nSlotId))
return 0;
- for (auto& rInfo : maItemInfos)
+ if (nullptr != mpSlotIDToWhichIDMap)
{
- assert(nullptr != rInfo && "ITEM: access error to Defaults in Pool (!)");
- if (nSlotId == rInfo->getSlotID())
- {
- return rInfo->getWhich();
- }
+ // use the static global translation table -> near linear access time
+ SlotIDToWhichIDMap::const_iterator aHit(mpSlotIDToWhichIDMap->find(nSlotId));
+ if (aHit != mpSlotIDToWhichIDMap->end())
+ return aHit->second;
}
if (mpSecondary && bDeep)
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index c23a537b6227..23f8a1e201ee 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -485,18 +485,19 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
// just use/return nullptr
return nullptr;
- if (IsInvalidItem(pSource))
- // SfxItemState::DONTCARE aka INVALID_POOL_ITEM
- // just use pSource which equals INVALID_POOL_ITEM
- return pSource;
+ // if (IsInvalidItem(pSource))
+ // // SfxItemState::DONTCARE aka INVALID_POOL_ITEM
+ // // just use pSource which equals INVALID_POOL_ITEM
+ // return pSource;
- if (IsDisabledItem(pSource))
- // SfxItemState::DISABLED aka DISABLED_POOL_ITEM
- // just use pSource which equals DISABLED_POOL_ITEM
- return pSource;
+ // if (IsDisabledItem(pSource))
+ // // SfxItemState::DISABLED aka DISABLED_POOL_ITEM
+ // // just use pSource which equals DISABLED_POOL_ITEM
+ // return pSource;
if (pSource->isStaticDefault())
// static default Items can just be used without RefCounting
+ // NOTE: This now includes IsInvalidItem/IsDisabledItem
return pSource;
if (0 == pSource->Which())
@@ -679,25 +680,19 @@ void implCleanupItemEntry(SfxPoolItem const* pSource)
// no entry, done
return;
- if (IsInvalidItem(pSource))
- // SfxItemState::DONTCARE aka INVALID_POOL_ITEM
- // nothing to do for invalid item entries
- return;
+ // if (IsInvalidItem(pSource))
+ // // SfxItemState::DONTCARE aka INVALID_POOL_ITEM
+ // // nothing to do for invalid item entries
+ // return;
- if (IsDisabledItem(pSource))
- // SfxItemState::DONTCARE aka DISABLED_POOL_ITEM
- // nothing to do for disabled item entries
- return;
+ // if (IsDisabledItem(pSource))
+ // // SfxItemState::DONTCARE aka DISABLED_POOL_ITEM
+ // // nothing to do for disabled item entries
+ // return;
if (pSource->isStaticDefault())
// static default Items can just be used without RefCounting
- return;
-
- if (pSource->isDynamicDefault())
- // dynamic default Items can only be used without RefCounting
- // when same pool. this is already checked at implCreateItemEntry,
- // so it would have been cloned (and would no longer have this
- // flag). So we can just return here
+ // NOTE: This now includes IsInvalidItem/IsDisabledItem
return;
if (0 == pSource->Which())
@@ -709,6 +704,13 @@ void implCleanupItemEntry(SfxPoolItem const* pSource)
return;
}
+ if (pSource->isDynamicDefault())
+ // dynamic default Items can only be used without RefCounting
+ // when same pool. this is already checked at implCreateItemEntry,
+ // so it would have been cloned (and would no longer have this
+ // flag). So we can just return here
+ return;
+
if (SfxItemPool::IsSlot(pSource->Which()))
{
// SlotItems are cloned, so delete
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index 4ec0a5a2cd25..de207ef9db25 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -466,9 +466,8 @@
//////////////////////////////////////////////////////////////////////////////
#ifdef DBG_UTIL
-static size_t nAllocatedSfxPoolItemCount(0);
+// static size_t nAllocatedSfxPoolItemCount(0);
static size_t nUsedSfxPoolItemCount(0);
-size_t getAllocatedSfxPoolItemCount() { return nAllocatedSfxPoolItemCount; }
size_t getUsedSfxPoolItemCount() { return nUsedSfxPoolItemCount; }
static std::unordered_set<const SfxPoolItem*>& incarnatedSfxPoolItems()
{
@@ -476,14 +475,28 @@ static std::unordered_set<const SfxPoolItem*>& incarnatedSfxPoolItems()
static std::unordered_set<const SfxPoolItem*> items;
return items;
}
+size_t getAllocatedSfxPoolItemCount()
+{
+ size_t aRetval(0);
+
+ // count globally allocated Items. Exclude Static/DynamicDefaults to
+ // get the number without the PoolDefaultItems that will be freed with
+ // the Pool. This also excludes the two InvalidOrDisabledItem's used
+ // for INVALID_POOL_ITEM/DISABLED_POOL_ITEM
+ for (const auto& rCandidate : incarnatedSfxPoolItems())
+ if (!rCandidate->isStaticDefault() && !rCandidate->isDynamicDefault())
+ aRetval++;
+ return aRetval;
+}
void listAllocatedSfxPoolItems()
{
SAL_INFO("svl.items", "ITEM: List of still allocated SfxPoolItems:");
for (const auto& rCandidate : incarnatedSfxPoolItems())
{
- SAL_INFO("svl.items", " ITEM: WhichID: " << rCandidate->Which() << " SerialNumber: "
- << rCandidate->getSerialNumber()
- << " Class: " << typeid(*rCandidate).name());
+ if (!rCandidate->isStaticDefault() && !rCandidate->isDynamicDefault())
+ SAL_INFO("svl.items", " ITEM: WhichID: " << rCandidate->Which() << " SerialNumber: "
+ << rCandidate->getSerialNumber()
+ << " Class: " << typeid(*rCandidate).name());
}
}
#endif
@@ -518,7 +531,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
#endif
{
#ifdef DBG_UTIL
- nAllocatedSfxPoolItemCount++;
+ // nAllocatedSfxPoolItemCount++;
nUsedSfxPoolItemCount++;
incarnatedSfxPoolItems().insert(this);
#endif
@@ -528,7 +541,7 @@ SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich)
SfxPoolItem::~SfxPoolItem()
{
#ifdef DBG_UTIL
- nAllocatedSfxPoolItemCount--;
+ // nAllocatedSfxPoolItemCount--;
incarnatedSfxPoolItems().erase(this);
m_bDeleted = true;
#endif
@@ -707,6 +720,11 @@ class InvalidOrDisabledItem final : public SfxPoolItem
{
virtual bool operator==(const SfxPoolItem&) const override { return true; }
virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; }
+
+public:
+ // make it StaticDefaultItem to process similar to these
+ // which is plausible (never change and are not allowed to)
+ InvalidOrDisabledItem() { setStaticDefault(); }
};
InvalidOrDisabledItem aInvalidItem;
InvalidOrDisabledItem aDisabledItem;
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index f645a4789f24..4c401c42d712 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -61,6 +61,8 @@ static ItemInfoPackage& getItemInfoPackageIMapWindow()
{ SID_ATTR_MACROITEM, new SvxMacroItem(SID_ATTR_MACROITEM), 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
virtual size_t size() const override { return maItemInfos.size(); }
virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 7fac9abec9e7..19a55c3e810a 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -437,6 +437,8 @@ static ItemInfoPackage& getItemInfoPackageSdr()
{ SDRATTR_EDGEOOXMLCURVE, new SfxBoolItem(SDRATTR_EDGEOOXMLCURVE, false), 0, SFX_ITEMINFOFLAG_NONE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageSdr()
{
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 35efce864431..246e5ec48447 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -460,6 +460,8 @@ ItemInfoPackage& getItemInfoPackageSwAttributes()
{ RES_UNKNOWNATR_CONTAINER, new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER ), 0, SFX_ITEMINFOFLAG_SUPPORT_SURROGATE }
}};
+ virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
+
public:
ItemInfoPackageSwAttributes()
{
diff --git a/sw/source/core/unocore/unoevent.cxx b/sw/source/core/unocore/unoevent.cxx
index 09b1a089f8fb..fa722b0e8e26 100644
--- a/sw/source/core/unocore/unoevent.cxx
+++ b/sw/source/core/unocore/unoevent.cxx
@@ -212,12 +212,12 @@ void SwFrameStyleEventDescriptor::setMacroItem(const SvxMacroItem& rItem)
m_rStyle.SetItem(RES_FRMMACRO, rItem);
}
-const SvxMacroItem aEmptyMacroItem(RES_FRMMACRO);
-
const SvxMacroItem& SwFrameStyleEventDescriptor::getMacroItem()
{
const SfxPoolItem* pItem(m_rStyle.GetItem(RES_FRMMACRO));
- return pItem ? static_cast<const SvxMacroItem&>(*pItem) : aEmptyMacroItem;
+ return pItem ?
+ static_cast<const SvxMacroItem&>(*pItem) :
+ *GetDfltAttr(RES_FRMMACRO);
}
OUString SwFrameStyleEventDescriptor::getImplementationName()