Kaydet (Commit) 09cfe07c authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SdrDragMethod

Change-Id: I73411368b55d53e83f45e0347663036f1f72c066
Reviewed-on: https://gerrit.libreoffice.org/53752Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 72ec9cc3
...@@ -142,7 +142,7 @@ void DragMethod_PieSegment::createSdrDragEntries() ...@@ -142,7 +142,7 @@ void DragMethod_PieSegment::createSdrDragEntries()
if( pObj && pPV ) if( pObj && pPV )
{ {
const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly()); const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly());
addSdrDragEntry(new SdrDragEntryPolyPolygon(aNewPolyPolygon)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aNewPolyPolygon)));
} }
} }
} //namespace chart } //namespace chart
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <svx/svddrgv.hxx> #include <svx/svddrgv.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/objectcontact.hxx>
#include <memory>
class SdrDragView; class SdrDragView;
class SdrDragStat; class SdrDragStat;
...@@ -113,7 +114,7 @@ public: ...@@ -113,7 +114,7 @@ public:
class SVX_DLLPUBLIC SdrDragMethod class SVX_DLLPUBLIC SdrDragMethod
{ {
private: private:
std::vector< SdrDragEntry* > maSdrDragEntries; std::vector< std::unique_ptr<SdrDragEntry> > maSdrDragEntries;
sdr::overlay::OverlayObjectList maOverlayObjectList; sdr::overlay::OverlayObjectList maOverlayObjectList;
SdrDragView& mrSdrDragView; SdrDragView& mrSdrDragView;
...@@ -124,7 +125,7 @@ private: ...@@ -124,7 +125,7 @@ private:
protected: protected:
// access for derivated classes to maSdrDragEntries // access for derivated classes to maSdrDragEntries
void clearSdrDragEntries(); void clearSdrDragEntries();
void addSdrDragEntry(SdrDragEntry* pNew); void addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew);
virtual void createSdrDragEntries(); virtual void createSdrDragEntries();
virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact); virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact);
......
...@@ -106,7 +106,7 @@ void PathDragMove::createSdrDragEntries() ...@@ -106,7 +106,7 @@ void PathDragMove::createSdrDragEntries()
if(maPathPolyPolygon.count()) if(maPathPolyPolygon.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
} }
} }
...@@ -167,7 +167,7 @@ void PathDragResize::createSdrDragEntries() ...@@ -167,7 +167,7 @@ void PathDragResize::createSdrDragEntries()
if(maPathPolyPolygon.count()) if(maPathPolyPolygon.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
} }
} }
...@@ -221,7 +221,7 @@ void PathDragObjOwn::createSdrDragEntries() ...@@ -221,7 +221,7 @@ void PathDragObjOwn::createSdrDragEntries()
if(maPathPolyPolygon.count()) if(maPathPolyPolygon.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(maPathPolyPolygon)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(maPathPolyPolygon)));
} }
} }
......
...@@ -306,20 +306,13 @@ basegfx::B2DRange SdrDragMethod::getCurrentRange() const ...@@ -306,20 +306,13 @@ basegfx::B2DRange SdrDragMethod::getCurrentRange() const
void SdrDragMethod::clearSdrDragEntries() void SdrDragMethod::clearSdrDragEntries()
{ {
for(SdrDragEntry* p : maSdrDragEntries)
{
delete p;
}
maSdrDragEntries.clear(); maSdrDragEntries.clear();
} }
void SdrDragMethod::addSdrDragEntry(SdrDragEntry* pNew) void SdrDragMethod::addSdrDragEntry(std::unique_ptr<SdrDragEntry> pNew)
{ {
if(pNew) assert(pNew);
{ maSdrDragEntries.push_back(std::move(pNew));
maSdrDragEntries.push_back(pNew);
}
} }
void SdrDragMethod::createSdrDragEntries() void SdrDragMethod::createSdrDragEntries()
...@@ -352,7 +345,7 @@ void SdrDragMethod::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, s ...@@ -352,7 +345,7 @@ void SdrDragMethod::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, s
{ {
// add full object drag; Clone() at the object has to work // add full object drag; Clone() at the object has to work
// for this // for this
addSdrDragEntry(new SdrDragEntrySdrObject(rOriginal, rObjectContact, true/*bModify*/)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(rOriginal, rObjectContact, true/*bModify*/)));
} }
void SdrDragMethod::createSdrDragEntries_SolidDrag() void SdrDragMethod::createSdrDragEntries_SolidDrag()
...@@ -404,7 +397,7 @@ void SdrDragMethod::createSdrDragEntries_SolidDrag() ...@@ -404,7 +397,7 @@ void SdrDragMethod::createSdrDragEntries_SolidDrag()
// when dragging a 50% transparent copy of a filled or not filled object without // when dragging a 50% transparent copy of a filled or not filled object without
// outline, this is normally hard to see. Add extra wireframe in that case. This // outline, this is normally hard to see. Add extra wireframe in that case. This
// works nice e.g. with text frames etc. // works nice e.g. with text frames etc.
addSdrDragEntry(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly())); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly())));
} }
} }
} }
...@@ -458,7 +451,7 @@ void SdrDragMethod::createSdrDragEntries_PolygonDrag() ...@@ -458,7 +451,7 @@ void SdrDragMethod::createSdrDragEntries_PolygonDrag()
if(aResult.count()) if(aResult.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(aResult)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aResult)));
} }
} }
...@@ -504,7 +497,7 @@ void SdrDragMethod::createSdrDragEntries_PointDrag() ...@@ -504,7 +497,7 @@ void SdrDragMethod::createSdrDragEntries_PointDrag()
if(!aPositions.empty()) if(!aPositions.empty())
{ {
addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, true)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, true)));
} }
} }
...@@ -546,7 +539,7 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag() ...@@ -546,7 +539,7 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag()
if(!aPositions.empty()) if(!aPositions.empty())
{ {
addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, false)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPointGlueDrag(aPositions, false)));
} }
} }
...@@ -691,7 +684,7 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay ...@@ -691,7 +684,7 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay
// clone, remember edges // clone, remember edges
for(auto const & a: maSdrDragEntries) for(auto const & a: maSdrDragEntries)
{ {
SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(a); SdrDragEntrySdrObject* pSdrDragEntrySdrObject = dynamic_cast< SdrDragEntrySdrObject*>(a.get());
if(pSdrDragEntrySdrObject) if(pSdrDragEntrySdrObject)
{ {
...@@ -746,22 +739,19 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay ...@@ -746,22 +739,19 @@ void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay
drawinglayer::primitive2d::Primitive2DContainer aResult; drawinglayer::primitive2d::Primitive2DContainer aResult;
drawinglayer::primitive2d::Primitive2DContainer aResultTransparent; drawinglayer::primitive2d::Primitive2DContainer aResultTransparent;
for(SdrDragEntry* pCandidate: maSdrDragEntries) for(auto & pCandidate: maSdrDragEntries)
{ {
if(pCandidate) const drawinglayer::primitive2d::Primitive2DContainer aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
{
const drawinglayer::primitive2d::Primitive2DContainer aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
if(!aCandidateResult.empty()) if(!aCandidateResult.empty())
{
if(pCandidate->getAddToTransparent())
{ {
if(pCandidate->getAddToTransparent()) aResultTransparent.append(aCandidateResult);
{ }
aResultTransparent.append(aCandidateResult); else
} {
else aResult.append(aCandidateResult);
{
aResult.append(aCandidateResult);
}
} }
} }
} }
...@@ -1175,7 +1165,7 @@ void SdrDragObjOwn::createSdrDragEntries() ...@@ -1175,7 +1165,7 @@ void SdrDragObjOwn::createSdrDragEntries()
if(pPV && pPV->PageWindowCount()) if(pPV && pPV->PageWindowCount())
{ {
sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact(); sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact();
addSdrDragEntry(new SdrDragEntrySdrObject(*mpClone, rOC, false)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(*mpClone, rOC, false)));
// potentially no wireframe needed, full drag works // potentially no wireframe needed, full drag works
bAddWireframe = false; bAddWireframe = false;
...@@ -1208,7 +1198,7 @@ void SdrDragObjOwn::createSdrDragEntries() ...@@ -1208,7 +1198,7 @@ void SdrDragObjOwn::createSdrDragEntries()
if(aDragPolyPolygon.count()) if(aDragPolyPolygon.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragPolyPolygon)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragPolyPolygon)));
} }
} }
} }
...@@ -1462,7 +1452,7 @@ void SdrDragMove::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr ...@@ -1462,7 +1452,7 @@ void SdrDragMove::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr
// here we want the complete primitive sequence without visible clippings // here we want the complete primitive sequence without visible clippings
rObjectContact.resetViewPort(); rObjectContact.resetViewPort();
addSdrDragEntry(new SdrDragEntryPrimitive2DSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo))); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPrimitive2DSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo))));
} }
void SdrDragMove::applyCurrentTransformationToSdrObject(SdrObject& rTarget) void SdrDragMove::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
...@@ -2887,7 +2877,7 @@ void SdrDragCrook::createSdrDragEntries() ...@@ -2887,7 +2877,7 @@ void SdrDragCrook::createSdrDragEntries()
if(aDragRaster.count()) if(aDragRaster.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
} }
} }
...@@ -3420,7 +3410,7 @@ void SdrDragDistort::createSdrDragEntries() ...@@ -3420,7 +3410,7 @@ void SdrDragDistort::createSdrDragEntries()
if(aDragRaster.count()) if(aDragRaster.count())
{ {
addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster)); addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aDragRaster)));
} }
} }
......
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