[Libreoffice-commits] core.git: 3 commits - include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Feb 5 06:56:04 UTC 2018
include/svx/gallery1.hxx | 9 ++--
include/svx/sdr/contact/objectcontact.hxx | 3 +
svx/source/engine3d/view3d.cxx | 57 +++++++++---------------------
svx/source/gallery2/gallery1.cxx | 25 ++++---------
svx/source/sdr/contact/objectcontact.cxx | 10 +----
5 files changed, 37 insertions(+), 67 deletions(-)
New commits:
commit ea385c1a9f3a9faaa0f3e2408082bfe914b2518d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jan 30 10:44:05 2018 +0200
loplugin:useuniqueptr in E3dDepthNeighbour
Change-Id: I14be7edea88e980c065db25a0195a84dad087e93
Reviewed-on: https://gerrit.libreoffice.org/49210
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 8f06e623118e..c25a3b7afc08 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -999,14 +999,12 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
struct E3dDepthNeighbour
{
- E3dDepthNeighbour* mpNext;
E3dExtrudeObj* mpObj;
basegfx::B2DPolyPolygon maPreparedPolyPolygon;
- E3dDepthNeighbour()
- : mpNext(nullptr),
- mpObj(nullptr),
- maPreparedPolyPolygon()
+ E3dDepthNeighbour(E3dExtrudeObj* pObj, basegfx::B2DPolyPolygon const & rPreparedPolyPolygon)
+ : mpObj(pObj),
+ maPreparedPolyPolygon(rPreparedPolyPolygon)
{
}
};
@@ -1014,23 +1012,12 @@ struct E3dDepthNeighbour
struct E3dDepthLayer
{
E3dDepthLayer* mpDown;
- E3dDepthNeighbour* mpNext;
+ std::vector<E3dDepthNeighbour> mvNeighbours;
E3dDepthLayer()
- : mpDown(nullptr),
- mpNext(nullptr)
+ : mpDown(nullptr)
{
}
-
- ~E3dDepthLayer()
- {
- while(mpNext)
- {
- E3dDepthNeighbour* pSucc = mpNext->mpNext;
- delete mpNext;
- mpNext = pSucc;
- }
- }
};
void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
@@ -1060,23 +1047,23 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
{
// do we have overlap with an object of this layer?
bool bOverlap(false);
- E3dDepthNeighbour* pAct = pLayer->mpNext;
+ auto itAct = pLayer->mvNeighbours.begin();
- while(!bOverlap && pAct)
+ while(!bOverlap && itAct != pLayer->mvNeighbours.end())
{
- // do pAct->mpObj and pExtrudeObj overlap? Check by
+ // do itAct->mpObj and pExtrudeObj overlap? Check by
// using logical AND clipping
const basegfx::B2DPolyPolygon aAndPolyPolygon(
basegfx::utils::solvePolygonOperationAnd(
aExtrudePoly,
- pAct->maPreparedPolyPolygon));
+ itAct->maPreparedPolyPolygon));
bOverlap = (0 != aAndPolyPolygon.count());
if(bOverlap)
{
// second criteria: is another fillstyle or color used?
- const SfxItemSet& rCompareSet = pAct->mpObj->GetMergedItemSet();
+ const SfxItemSet& rCompareSet = itAct->mpObj->GetMergedItemSet();
drawing::FillStyle eCompareFillStyle = rCompareSet.Get(XATTR_FILLSTYLE).GetValue();
@@ -1098,7 +1085,7 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
}
}
- pAct = pAct->mpNext;
+ ++itAct;
}
if(bOverlap)
@@ -1107,18 +1094,12 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
pLayer->mpDown = new E3dDepthLayer;
pLayer = pLayer->mpDown;
nNumLayers++;
- pLayer->mpNext = new E3dDepthNeighbour;
- pLayer->mpNext->mpObj = pExtrudeObj;
- pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly;
+ pLayer->mvNeighbours.emplace_back(pExtrudeObj, aExtrudePoly);
}
else
{
// no, add to current layer
- E3dDepthNeighbour* pNewNext = new E3dDepthNeighbour;
- pNewNext->mpObj = pExtrudeObj;
- pNewNext->maPreparedPolyPolygon = aExtrudePoly;
- pNewNext->mpNext = pLayer->mpNext;
- pLayer->mpNext = pNewNext;
+ pLayer->mvNeighbours.emplace(pLayer->mvNeighbours.begin(), pExtrudeObj, aExtrudePoly);
}
}
else
@@ -1127,9 +1108,7 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
pBaseLayer = new E3dDepthLayer;
pLayer = pBaseLayer;
nNumLayers++;
- pLayer->mpNext = new E3dDepthNeighbour;
- pLayer->mpNext->mpObj = pExtrudeObj;
- pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly;
+ pLayer->mvNeighbours.emplace_back(pExtrudeObj, aExtrudePoly);
}
}
}
@@ -1145,15 +1124,15 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth)
while(pLayer)
{
// move along layer
- E3dDepthNeighbour* pAct = pLayer->mpNext;
+ auto itAct = pLayer->mvNeighbours.begin();
- while(pAct)
+ while(itAct != pLayer->mvNeighbours.end())
{
// adapt extrude value
- pAct->mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5)));
+ itAct->mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5)));
// next
- pAct = pAct->mpNext;
+ ++itAct;
}
// next layer
commit 25baf8b7e3f0a7e7bef552cba919eb3b24a81a19
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jan 30 10:32:42 2018 +0200
loplugin:useuniqueptr in ObjectContact
Change-Id: I89104fe93bbb2db4ca7c092784583eac6fbdda08
Reviewed-on: https://gerrit.libreoffice.org/49209
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/sdr/contact/objectcontact.hxx b/include/svx/sdr/contact/objectcontact.hxx
index 4722a4f376e9..d2bf55036946 100644
--- a/include/svx/sdr/contact/objectcontact.hxx
+++ b/include/svx/sdr/contact/objectcontact.hxx
@@ -23,6 +23,7 @@
#include <svx/sdr/animation/objectanimator.hxx>
#include <svx/svxdllapi.h>
#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <memory>
class SdrLayerIDSet;
namespace tools { class Rectangle; }
@@ -67,7 +68,7 @@ private:
sdr::animation::primitiveAnimator maPrimitiveAnimator;
// the EventHandler for e.g. asynchronious loading of graphics
- sdr::event::TimerEventHandler* mpEventHandler;
+ std::unique_ptr<sdr::event::TimerEventHandler> mpEventHandler;
// The redirector. If set it is used to pipe all supported calls
// to the redirector
diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx
index 9afa1bd6ed2c..8085cc0e3721 100644
--- a/svx/source/sdr/contact/objectcontact.cxx
+++ b/svx/source/sdr/contact/objectcontact.cxx
@@ -66,12 +66,8 @@ ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE
DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
// delete the EventHandler. This will destroy all still contained events.
- if(mpEventHandler)
- {
- // If there are still Events registered, something has went wrong
- delete mpEventHandler;
- mpEventHandler = nullptr;
- }
+ mpEventHandler.reset();
+ // If there are still Events registered, something has went wrong
}
// LazyInvalidate request. Default implementation directly handles
@@ -151,7 +147,7 @@ sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
{
if(!HasEventHandler())
{
- const_cast< ObjectContact* >(this)->mpEventHandler = new sdr::event::TimerEventHandler();
+ const_cast< ObjectContact* >(this)->mpEventHandler.reset( new sdr::event::TimerEventHandler() );
}
return *mpEventHandler;
}
commit 9d6e774f51998deadae429061715f92a7af1b0b0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jan 30 10:29:26 2018 +0200
loplugin:useuniqueptr in Gallery
Change-Id: Ia12805bff0403fe260786360233be677ef91f710
Reviewed-on: https://gerrit.libreoffice.org/49208
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index 932e7c4dc8d5..66474d17180b 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -26,6 +26,7 @@
#include <tools/urlobj.hxx>
#include <cstdio>
+#include <memory>
#include <vector>
class SvStream;
@@ -78,8 +79,6 @@ public:
void SetId( sal_uInt32 nNewId, bool bResetThemeName );
};
-typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
-
class SfxListener;
class GalleryTheme;
class GalleryThemeCacheEntry;
@@ -95,7 +94,7 @@ class SVX_DLLPUBLIC Gallery : public SfxBroadcaster
private:
- GalleryThemeList aThemeList;
+ std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
GalleryCacheThemeList aThemeCache;
INetURLObject aRelURL;
INetURLObject aUserURL;
@@ -111,6 +110,8 @@ private:
Gallery( const OUString& rMultiPath );
virtual ~Gallery() override;
+ Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
+ Gallery( Gallery const & ) = delete; // MSVC2015 workaround
public:
@@ -118,7 +119,7 @@ public:
SAL_DLLPRIVATE size_t GetThemeCount() const { return aThemeList.size(); }
SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
- { return nPos < aThemeList.size() ? aThemeList[ nPos ] : nullptr; }
+ { return nPos < aThemeList.size() ? aThemeList[ nPos ].get() : nullptr; }
SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( const OUString& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
bool HasTheme( const OUString& rThemeName );
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 219ced254d44..3d3107296a9b 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -259,10 +259,6 @@ Gallery::Gallery( const OUString& rMultiPath )
Gallery::~Gallery()
{
- // erase theme list
- for (GalleryThemeEntry* p : aThemeList)
- delete p;
- aThemeList.clear();
}
Gallery* Gallery::GetGalleryInstance()
@@ -478,7 +474,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO
GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
if( pEntry )
- aThemeList.push_back( pEntry );
+ aThemeList.emplace_back( pEntry );
}
}
catch( const ucb::ContentCreationException& )
@@ -508,16 +504,14 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO
GalleryThemeEntry* Gallery::ImplGetThemeEntry( const OUString& rThemeName )
{
- GalleryThemeEntry* pFound = nullptr;
-
if( !rThemeName.isEmpty() )
{
- for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
+ for ( size_t i = 0, n = aThemeList.size(); i < n; ++i )
if( rThemeName == aThemeList[ i ]->GetThemeName() )
- pFound = aThemeList[ i ];
+ return aThemeList[ i ].get();
}
- return pFound;
+ return nullptr;
}
OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const
@@ -526,7 +520,7 @@ OUString Gallery::GetThemeName( sal_uInt32 nThemeId ) const
for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i )
{
- GalleryThemeEntry* pEntry = aThemeList[ i ];
+ GalleryThemeEntry* pEntry = aThemeList[ i ].get();
if( nThemeId == pEntry->GetId() )
pFound = pEntry;
}
@@ -616,7 +610,7 @@ bool Gallery::CreateTheme( const OUString& rThemeName )
true, aURL, rThemeName,
false, true, 0, false );
- aThemeList.push_back( pNewEntry );
+ aThemeList.emplace_back( pNewEntry );
delete new GalleryTheme( this, pNewEntry );
Broadcast( GalleryHint( GalleryHintType::THEME_CREATED, rThemeName ) );
bRet = true;
@@ -673,11 +667,10 @@ bool Gallery::RemoveTheme( const OUString& rThemeName )
KillFile( aStrURL );
}
- GalleryThemeList::const_iterator aEnd = aThemeList.end();
- for ( GalleryThemeList::iterator it = aThemeList.begin(); it != aEnd; ++it )
+ auto aEnd = aThemeList.end();
+ for ( auto it = aThemeList.begin(); it != aEnd; ++it )
{
- if ( pThemeEntry == *it ) {
- delete pThemeEntry;
+ if ( pThemeEntry == it->get() ) {
aThemeList.erase( it );
break;
}
More information about the Libreoffice-commits
mailing list