[Libreoffice-commits] core.git: 2 commits - include/svl svl/source
Michael Stahl
mstahl at redhat.com
Fri Aug 16 15:22:06 PDT 2013
include/svl/itempool.hxx | 16 ------------
svl/source/items/itempool.cxx | 55 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 15 deletions(-)
New commits:
commit 7e7a83b73dad2a9a2c73826f61a81c4c774d2c9d
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Aug 16 22:15:49 2013 +0200
SfxItemPool: detect duplicate SlotId mappings
... to prevent problems like fdo#66827.
Sadly the EditEngineItemPool has loads of duplicate slotids already...
Change-Id: I737d71519ce4af06c81f7ecf183cfa6c367026db
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index b50bcb2..6eddcba 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -213,8 +213,7 @@ public:
bool IsItemFlag( sal_uInt16 nWhich, sal_uInt16 nFlag ) const;
bool IsItemFlag( const SfxPoolItem &rItem, sal_uInt16 nFlag ) const
{ return IsItemFlag( rItem.Which(), nFlag ); }
- void SetItemInfos( const SfxItemInfo *pInfos )
- { pItemInfos = pInfos; }
+ void SetItemInfos( const SfxItemInfo *pInfos );
sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const;
sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const;
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 50e47cb..83e2e12 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();
}
// -----------------------------------------------------------------------
commit 253df56952654a571abc76c5ced8af0e2ad72698
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Aug 16 21:46:58 2013 +0200
svl: remove unused SFX_ITEM_USERFLAG[0-B]
Change-Id: Iffc767630a8d30bd684fd03ece66cee5cd38a022
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 80c1faf..b50bcb2 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -41,19 +41,6 @@ DBG_NAMEEX(SfxItemPool)
#define SFX_ITEM_POOLABLE 0x0001
#define SFX_ITEM_NOT_POOLABLE 0x0002
-#define SFX_ITEM_USERFLAG0 0x0100
-#define SFX_ITEM_USERFLAG1 0x0200
-#define SFX_ITEM_USERFLAG2 0x0400
-#define SFX_ITEM_USERFLAG3 0x0800
-#define SFX_ITEM_USERFLAG4 0x1000
-#define SFX_ITEM_USERFLAG5 0x2000
-#define SFX_ITEM_USERFLAG6 0x4000
-#define SFX_ITEM_USERFLAG7 0x8000
-#define SFX_ITEM_USERFLAG8 0x0010
-#define SFX_ITEM_USERFLAG9 0x0020
-#define SFX_ITEM_USERFLAGA 0x0040
-#define SFX_ITEM_USERFLAGB 0x0080
-
//====================================================================
struct SfxItemInfo
More information about the Libreoffice-commits
mailing list