svx/inc/sdr/properties/itemsettools.hxx | 7 +++++-- svx/source/sdr/properties/itemsettools.cxx | 17 ++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-)
New commits: commit d9e6002b70eadd47fe70ff5ef53a55e5fa32d846 Author: Noel Grandin <[email protected]> Date: Thu Apr 13 12:04:36 2017 +0200 use union instead of void* vaguely more readable and typesafe Change-Id: I15e98034fb288756415913eff73bcaba4f2c0b9d Reviewed-on: https://gerrit.libreoffice.org/36659 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> 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 _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
