Kaydet (Commit) 3908064e authored tarafından Matteo Casalin's avatar Matteo Casalin

Simplify sdr::properties::ItemChangeBroadcaster

Change-Id: Ie731294b6490165cf208335e7ec404a35f8a6a95
üst 3be7c158
......@@ -21,11 +21,11 @@
#define INCLUDED_SVX_INC_SDR_PROPERTIES_ITEMSETTOOLS_HXX
#include <sal/types.h>
#include <vcl/region.hxx>
#include <tools/gen.hxx>
#include <vector>
class SdrObject;
class SfxItemSet;
namespace tools { class Rectangle; }
class Fraction;
// class to remember broadcast start positions
......@@ -35,21 +35,19 @@ namespace sdr
{
class ItemChangeBroadcaster
{
bool mbSingleRect;
union {
RectangleVector* mpRectangleVector;
tools::Rectangle* mpRectangle;
};
std::vector< tools::Rectangle > maRectangles;
public:
explicit ItemChangeBroadcaster(const SdrObject& rObj);
~ItemChangeBroadcaster();
sal_uInt32 GetRectangleCount() const
{
return mbSingleRect ? 1 : mpRectangleVector->size();
return maRectangles.size();
}
const tools::Rectangle& GetRectangle(sal_uInt32 nIndex) const
{
return maRectangles[nIndex];
}
const tools::Rectangle& GetRectangle(sal_uInt32 nIndex) const;
};
} // end of namespace properties
} // end of namespace sdr
......
......@@ -38,8 +38,7 @@ namespace sdr
if (const SdrObjGroup* pGroupObj = dynamic_cast<const SdrObjGroup*>(&rObj))
{
SdrObjListIter aIter(*pGroupObj, SdrIterMode::DeepNoGroups);
mpRectangleVector = new RectangleVector;
mpRectangleVector->reserve(aIter.Count());
maRectangles.reserve(aIter.Count());
while(aIter.IsMore())
{
......@@ -47,40 +46,13 @@ namespace sdr
if(pObj)
{
mpRectangleVector->push_back(pObj->GetLastBoundRect());
maRectangles.push_back(pObj->GetLastBoundRect());
}
}
mbSingleRect = false;
}
else
{
mpRectangle = new tools::Rectangle(rObj.GetLastBoundRect());
mbSingleRect = true;
}
}
ItemChangeBroadcaster::~ItemChangeBroadcaster()
{
if (!mbSingleRect)
{
delete mpRectangleVector;
}
else
{
delete mpRectangle;
}
}
const tools::Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const
{
if (!mbSingleRect)
{
return (*mpRectangleVector)[nIndex];
}
else
{
return *mpRectangle;
maRectangles.push_back(rObj.GetLastBoundRect());
}
}
} // end of namespace properties
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment