summaryrefslogtreecommitdiff
path: root/include/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-09 10:27:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 10:07:10 +0200
commit2757ee9fe610e253e4ccc37423fa420004d0f388 (patch)
treea5a505f12a1c17cfab2001c2cbf43bd721633f0f /include/svl
parentee2bd1ee97194f4d39d4d6ab95c9b926b5077cb8 (diff)
used std::map in SfxItemSet
instead of naked array SfxItemIter ended up needing to take copies of stuff because various code likes to iterate over the items and delete items inside the loop. The gdb pretty printer is no longer quite as pretty as it was before, but it still prints useful info. Change-Id: I59b07ea42f6b1c74798a15402970b9dbd8233dbe
Diffstat (limited to 'include/svl')
-rw-r--r--include/svl/itemiter.hxx32
-rw-r--r--include/svl/itemset.hxx10
2 files changed, 17 insertions, 25 deletions
diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx
index 30b6bd13d00d..b68730f245d6 100644
--- a/include/svl/itemiter.hxx
+++ b/include/svl/itemiter.hxx
@@ -21,6 +21,7 @@
#include <svl/svldllapi.h>
#include <svl/itemset.hxx>
+#include <vector>
class SfxPoolItem;
class SfxItemSet;
@@ -28,32 +29,23 @@ class SfxItemPool;
class SVL_DLLPUBLIC SfxItemIter
{
- const SfxItemSet& m_rSet;
- sal_uInt16 m_nStart;
- sal_uInt16 m_nEnd;
- sal_uInt16 m_nCurrent;
+ const SfxItemSet& m_rSet;
+ std::vector<sal_uInt16> m_keys;
+ std::vector<sal_uInt16>::const_iterator m_iter;
public:
SfxItemIter( const SfxItemSet& rSet );
~SfxItemIter();
/// get item, or null if no items
- const SfxPoolItem* FirstItem()
- {
- m_nCurrent = m_nStart;
- return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr;
- }
- const SfxPoolItem* GetCurItem()
- {
- return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr;
- }
- const SfxPoolItem* NextItem();
-
- bool IsAtEnd() const { return m_nCurrent == m_nEnd; }
-
- sal_uInt16 GetCurPos() const { return m_nCurrent; }
- sal_uInt16 GetFirstPos() const { return m_nStart; }
- sal_uInt16 GetLastPos() const { return m_nEnd; }
+ SfxPoolItem const * FirstItem();
+ SfxPoolItem const * GetCurItem();
+ SfxPoolItem const * NextItem();
+
+ bool IsAtEnd() const;
+ sal_uInt16 GetCurWhich() const { return *m_iter; }
+ sal_uInt16 GetFirstWhich() const { return *m_keys.begin(); }
+ sal_uInt16 GetLastWhich() const { return *m_keys.rbegin(); }
};
#endif
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index f327f92792eb..502c0ebc2c99 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -23,12 +23,13 @@
#include <cstdarg>
#include <svl/poolitem.hxx>
+#include <map>
class SfxItemPool;
class SfxPoolItem;
class SvStream;
-typedef SfxPoolItem const** SfxItemArray;
+typedef std::map<sal_uInt16, SfxPoolItem const *> SfxItemMap;
class SVL_DLLPUBLIC SfxItemSet
{
@@ -36,9 +37,8 @@ class SVL_DLLPUBLIC SfxItemSet
SfxItemPool* m_pPool; ///< pool that stores the items
const SfxItemSet* m_pParent; ///< derivation
- SfxItemArray m_pItems; ///< array of items
+ SfxItemMap m_aItems; ///< array of items
sal_uInt16* m_pWhichRanges; ///< array of Which Ranges
- sal_uInt16 m_nCount; ///< number of items
friend class SfxItemPoolCache;
friend class SfxAllItemSet;
@@ -50,7 +50,7 @@ private:
SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2);
public:
- SfxItemArray GetItems_Impl() const { return m_pItems; }
+ SfxItemMap const & GetItems_Impl() const { return m_aItems; }
private:
const SfxItemSet& operator=(const SfxItemSet &) = delete;
@@ -73,7 +73,7 @@ public:
virtual SfxItemSet * Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const;
// Get number of items
- sal_uInt16 Count() const { return m_nCount; }
+ sal_uInt16 Count() const { return m_aItems.size(); }
sal_uInt16 TotalCount() const;
const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const;