diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-07-26 20:15:56 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-29 08:01:06 +0200 |
commit | be5fad6d0755e3d1e7ab5c9d4bfda8248b4e51d2 (patch) | |
tree | cee960173af9fc359792482397a8c67597328fc3 /include/svx | |
parent | 46f7dcc5f499892ef093147b3f739c258bbf6b81 (diff) |
tdf#161875 buffer NameOrIndex Items for fast Surrogates
Problem is that collecting the Items using the ItemSets and
PoolItemHolders is too expensive when used too often. For
read-only access it is okay to have the Items directly
registerd (for write access we *need* the ItemSets and
PoolItemHolders, see iterateItemSurrogates).
This is limited to Items which need to support surrogates,
but can further be limited to the here critical ones - the
ones derived from NameOrIndex.
This is done here by checking if the Item is a NameOrIndex
based one by adding a bool to the item that gets set in the
NameOrIndex constructor. If needed this can be changed,
e.g. by using besides the SFX_ITEMINFOFLAG_SUPPORT_SURROGATE
another flag signaling this.
Since only Items that are currently held by an ItemSet or a
PoolItemHolder get registered it is not necessary to change
the Item's RefCount in any way, doing that may lead (again,
we had that with directly set Items at the Pool in the past)
to long-living Items that only get cleaned-up when the pool/
document gets destructed.
This buffering is now SfxItemType-based, no longer using the
WhichID, so the result needs to be checked for WhichID
additionally - if needed (?).
All in all it's anyways a compromize, every usage of the
surrogate mechanism is a 'hack' in the sense that for lazy
reasons not the model data is traversed directly, but assumed
that all Items set at a pool/model *are* model/document data
(what is not always true).
CheckNamedItem does not need to be static, changed that.
Also all accesses to maRegisteredNameOrIndex *have* to
work on the MasterPool instance, same as buffered ItemSets
or PoolItemHolders, corrected that, too.
Number of instances in the buffer need to be counted, else
an instance will be removed too early: The same instance
of an Item can be referenced by multiple sets/holders,
so the first remove from the buffer would already remove
even when the Item is referenced multiple times. Added
that.
Added more asserts & made sure that all constructors/
destructors of SfxItemSet do take care of registering
Items for the surrogate mechanism as needed.
Change-Id: Ib33e7f0bd4abd32a3bb68278f33b0abb9a4754c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171084
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'include/svx')
-rw-r--r-- | include/svx/xit.hxx | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/include/svx/xit.hxx b/include/svx/xit.hxx index 5902424a7d05..7fd0fbd09327 100644 --- a/include/svx/xit.hxx +++ b/include/svx/xit.hxx @@ -55,12 +55,11 @@ public: bool IsIndex() const { return (m_nPalIndex >= 0); } sal_Int32 GetPalIndex() const { return m_nPalIndex; } - /** this static checks if the given NameOrIndex item has a unique name for its value. + /** this checks if the given NameOrIndex item has a unique name for its value. The returned String is a unique name for an item with this value in both given pools. - Argument pPool2 can be null. If returned string equals NameOrIndex->GetName(), the name was already unique. */ - static OUString CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults ); + OUString CheckNamedItem(const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults) const; void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; |