diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-08-16 22:15:49 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-08-17 00:19:07 +0200 |
commit | 7e7a83b73dad2a9a2c73826f61a81c4c774d2c9d (patch) | |
tree | 4fd17082583cc9de618f1c00c972e2e4e5dd7b9a /svl/source | |
parent | 253df56952654a571abc76c5ced8af0e2ad72698 (diff) |
SfxItemPool: detect duplicate SlotId mappings
... to prevent problems like fdo#66827.
Sadly the EditEngineItemPool has loads of duplicate slotids already...
Change-Id: I737d71519ce4af06c81f7ecf183cfa6c367026db
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/items/itempool.cxx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 50e47cb90b76..83e2e12655ab 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -28,6 +28,53 @@ #include "poolio.hxx" +#if OSL_DEBUG_LEVEL > 0 +#include <map> + +static void +lcl_CheckSlots2(std::map<sal_uInt16, sal_uInt16> & rSlotMap, + SfxItemPool const& rPool, SfxItemInfo const* pInfos) +{ + if (!pInfos) + return; // may not be initialized yet + if (rPool.GetName() == "EditEngineItemPool") + return; // HACK: this one has loads of duplicates already, ignore it :( + sal_uInt16 const nFirst(rPool.GetFirstWhich()); + sal_uInt16 const nCount(rPool.GetLastWhich() - rPool.GetFirstWhich() + 1); + for (sal_uInt16 n = 0; n < nCount; ++n) + { + sal_uInt16 const nSlotId(pInfos[n]._nSID); + if (nSlotId != 0 + && nSlotId != 10883 // preexisting duplicate SID_ATTR_GRAF_CROP + && nSlotId != 10024) // preexisting duplicate SID_ATTR_BORDER_OUTER + { // check for duplicate slot-id mapping + std::map<sal_uInt16, sal_uInt16>::const_iterator const iter( + rSlotMap.find(nSlotId)); + sal_uInt16 const nWhich(nFirst + n); + if (iter != rSlotMap.end()) + { + SAL_WARN("svl", "SfxItemPool: duplicate SlotId " << nSlotId + << " mapped to " << iter->second << " and " << nWhich); + assert(false); + } + rSlotMap.insert(std::make_pair(nSlotId, nWhich)); + } + } +} + +#define CHECK_SLOTS() \ +do { \ + std::map<sal_uInt16, sal_uInt16> slotmap; \ + for (SfxItemPool * p = pImp->mpMaster; p; p = p->pImp->mpSecondary) \ + { \ + lcl_CheckSlots2(slotmap, *p, p->pItemInfos); \ + } \ +} while (false) + +#else +#define CHECK_SLOTS() do {} while (false) +#endif + void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser) { @@ -433,6 +480,14 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) // neuen Secondary-Pool merken pImp->mpSecondary = pPool; + + CHECK_SLOTS(); +} + +void SfxItemPool::SetItemInfos(SfxItemInfo const*const pInfos) +{ + pItemInfos = pInfos; + CHECK_SLOTS(); } // ----------------------------------------------------------------------- |