diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-13 12:04:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-19 11:05:39 +0200 |
commit | d9e6002b70eadd47fe70ff5ef53a55e5fa32d846 (patch) | |
tree | 6ef2c5649c746cd21ca6bf9fe095f37305660b6c /svx | |
parent | e9f0d8d02885eca619552b19eab30c1eade9e7ef (diff) |
use union instead of void*
vaguely more readable and typesafe
Change-Id: I15e98034fb288756415913eff73bcaba4f2c0b9d
Reviewed-on: https://gerrit.libreoffice.org/36659
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/sdr/properties/itemsettools.hxx | 7 | ||||
-rw-r--r-- | svx/source/sdr/properties/itemsettools.cxx | 17 |
2 files changed, 13 insertions, 11 deletions
diff --git a/svx/inc/sdr/properties/itemsettools.hxx b/svx/inc/sdr/properties/itemsettools.hxx index 0e1f760e0777..c9cb93261ad0 100644 --- a/svx/inc/sdr/properties/itemsettools.hxx +++ b/svx/inc/sdr/properties/itemsettools.hxx @@ -36,7 +36,10 @@ namespace sdr class ItemChangeBroadcaster { bool mbSingleRect; - void* mpData; + union { + RectangleVector* mpRectangleVector; + tools::Rectangle* mpRectangle; + }; public: explicit ItemChangeBroadcaster(const SdrObject& rObj); @@ -44,7 +47,7 @@ namespace sdr sal_uInt32 GetRectangleCount() const { - return mbSingleRect ? 1 : static_cast<RectangleVector*>(mpData)->size(); + return mbSingleRect ? 1 : mpRectangleVector->size(); } const tools::Rectangle& GetRectangle(sal_uInt32 nIndex) const; }; diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx index b3cc64875edc..c11c54dcf445 100644 --- a/svx/source/sdr/properties/itemsettools.cxx +++ b/svx/source/sdr/properties/itemsettools.cxx @@ -38,9 +38,8 @@ namespace sdr if (const SdrObjGroup* pGroupObj = dynamic_cast<const SdrObjGroup*>(&rObj)) { SdrObjListIter aIter(*pGroupObj, SdrIterMode::DeepNoGroups); - mpData = new RectangleVector; - DBG_ASSERT(mpData, "ItemChangeBroadcaster: No memory (!)"); - static_cast<RectangleVector*>(mpData)->reserve(aIter.Count()); + mpRectangleVector = new RectangleVector; + mpRectangleVector->reserve(aIter.Count()); while(aIter.IsMore()) { @@ -48,7 +47,7 @@ namespace sdr if(pObj) { - static_cast<RectangleVector*>(mpData)->push_back(pObj->GetLastBoundRect()); + mpRectangleVector->push_back(pObj->GetLastBoundRect()); } } @@ -56,7 +55,7 @@ namespace sdr } else { - mpData = new tools::Rectangle(rObj.GetLastBoundRect()); + mpRectangle = new tools::Rectangle(rObj.GetLastBoundRect()); mbSingleRect = true; } } @@ -65,11 +64,11 @@ namespace sdr { if (!mbSingleRect) { - delete static_cast<RectangleVector*>(mpData); + delete mpRectangleVector; } else { - delete static_cast<tools::Rectangle*>(mpData); + delete mpRectangle; } } @@ -77,11 +76,11 @@ namespace sdr { if (!mbSingleRect) { - return (*static_cast<RectangleVector*>(mpData))[nIndex]; + return (*mpRectangleVector)[nIndex]; } else { - return *static_cast<tools::Rectangle*>(mpData); + return *mpRectangle; } } } // end of namespace properties |