[Libreoffice-commits] core.git: 2 commits - svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Jun 11 06:26:27 UTC 2018
svx/source/form/filtnav.cxx | 4 +--
svx/source/form/fmexpl.cxx | 37 +++++++++++++--------------------
svx/source/form/navigatortree.cxx | 4 +--
svx/source/form/navigatortreemodel.cxx | 4 +--
svx/source/inc/filtnav.hxx | 4 +--
svx/source/inc/fmexpl.hxx | 14 ++++++------
6 files changed, 30 insertions(+), 37 deletions(-)
New commits:
commit eec9f6c8b928de38dd9e683f46bfab00f3243048
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jun 4 15:01:43 2018 +0200
loplugin:useuniqueptr in FmEntryDataList
Change-Id: I7c9ec3bb26c6c329c66d684437bf934b9c2ad0e5
Reviewed-on: https://gerrit.libreoffice.org/55519
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
index 0ad2377088bb..8fec9e0f5798 100644
--- a/svx/source/form/fmexpl.cxx
+++ b/svx/source/form/fmexpl.cxx
@@ -132,41 +132,34 @@ FmEntryDataList::~FmEntryDataList()
}
-FmEntryData* FmEntryDataList::remove( FmEntryData* pItem )
+void FmEntryDataList::remove( FmEntryData* pItem )
{
- FmEntryDataBaseList::const_iterator aEnd = maEntryDataList.end();
- for ( FmEntryDataBaseList::iterator it = maEntryDataList.begin();
- it != aEnd;
- ++it
- )
+ auto aEnd = maEntryDataList.end();
+ for ( auto it = maEntryDataList.begin(); it != aEnd; ++it )
{
- if ( *it == pItem )
+ if ( it->get() == pItem )
{
maEntryDataList.erase( it );
- break;
+ return;
}
}
- return pItem;
+ assert(false);
}
-void FmEntryDataList::insert( FmEntryData* pItem, size_t Index )
+void FmEntryDataList::insert( std::unique_ptr<FmEntryData> pItem, size_t Index )
{
if ( Index < maEntryDataList.size() )
{
- FmEntryDataBaseList::iterator it = maEntryDataList.begin();
- ::std::advance( it, Index );
- maEntryDataList.insert( it, pItem );
+ maEntryDataList.insert( maEntryDataList.begin() + Index, std::move(pItem) );
}
else
- maEntryDataList.push_back( pItem );
+ maEntryDataList.push_back( std::move(pItem) );
}
void FmEntryDataList::clear()
{
- for (FmEntryData* p : maEntryDataList)
- delete p;
maEntryDataList.clear();
}
@@ -207,8 +200,8 @@ FmEntryData::FmEntryData( const FmEntryData& rEntryData )
for( size_t i = 0; i < nEntryCount; i++ )
{
pChildData = rEntryData.GetChildList()->at( i );
- FmEntryData* pNewChildData = pChildData->Clone();
- pChildList->insert( pNewChildData, size_t(-1) );
+ std::unique_ptr<FmEntryData> pNewChildData = pChildData->Clone();
+ pChildList->insert( std::move(pNewChildData), size_t(-1) );
}
m_xNormalizedIFace = rEntryData.m_xNormalizedIFace;
@@ -276,9 +269,9 @@ FmFormData::FmFormData( const FmFormData& rFormData )
}
-FmEntryData* FmFormData::Clone()
+std::unique_ptr<FmEntryData> FmFormData::Clone()
{
- return new FmFormData( *this );
+ return std::unique_ptr<FmEntryData>(new FmFormData( *this ));
}
@@ -325,9 +318,9 @@ FmControlData::FmControlData( const FmControlData& rControlData )
}
-FmEntryData* FmControlData::Clone()
+std::unique_ptr<FmEntryData> FmControlData::Clone()
{
- return new FmControlData( *this );
+ return std::unique_ptr<FmEntryData>(new FmControlData( *this ));
}
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 6d114087ac73..8f8101410bf5 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -1127,9 +1127,9 @@ namespace svxform
// give parent the new child
if (pTargetData)
- pTargetData->GetChildList()->insert( pCurrentUserData, nIndex );
+ pTargetData->GetChildList()->insert( std::unique_ptr<FmEntryData>(pCurrentUserData), nIndex );
else
- GetNavModel()->GetRootList()->insert( pCurrentUserData, nIndex );
+ GetNavModel()->GetRootList()->insert( std::unique_ptr<FmEntryData>(pCurrentUserData), nIndex );
// announce to myself and reselect
SvTreeListEntry* pNew = Insert( pCurrentUserData, nIndex );
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
index 01136bf189b0..9ae59cf81908 100644
--- a/svx/source/form/navigatortreemodel.cxx
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -333,9 +333,9 @@ namespace svxform
}
if (pFolder)
- pFolder->GetChildList()->insert( pEntry, nRelPos );
+ pFolder->GetChildList()->insert( std::unique_ptr<FmEntryData>(pEntry), nRelPos );
else
- GetRootList()->insert( pEntry, nRelPos );
+ GetRootList()->insert( std::unique_ptr<FmEntryData>(pEntry), nRelPos );
// notify UI
diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx
index f681edc26ffb..024b38edb775 100644
--- a/svx/source/inc/fmexpl.hxx
+++ b/svx/source/inc/fmexpl.hxx
@@ -167,7 +167,7 @@ public:
FmEntryDataList* GetChildList() const { return pChildList.get(); }
virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData );
- virtual FmEntryData* Clone() = 0;
+ virtual std::unique_ptr<FmEntryData> Clone() = 0;
// note that the interface returned is normalized, i.e. querying the given XInterface of the object
// for XInterface must return the interface itself.
@@ -193,18 +193,18 @@ typedef ::std::vector< FmEntryData* > FmEntryDataBaseList;
class FmEntryDataList final
{
private:
- FmEntryDataBaseList maEntryDataList;
+ std::vector< std::unique_ptr<FmEntryData> > maEntryDataList;
public:
FmEntryDataList();
~FmEntryDataList();
FmEntryData* at( size_t Index )
- { return ( Index < maEntryDataList.size() ) ? maEntryDataList[ Index ] : nullptr; }
+ { return maEntryDataList.at(Index).get(); }
size_t size() const { return maEntryDataList.size(); }
- FmEntryData* remove( FmEntryData* pItem );
- void insert( FmEntryData* pItem, size_t Index );
+ void remove( FmEntryData* pItem );
+ void insert( std::unique_ptr<FmEntryData> pItem, size_t Index );
void clear();
};
@@ -243,7 +243,7 @@ public:
const css::uno::Reference< css::form::XForm >& GetFormIface() const { return m_xForm; }
virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData ) override;
- virtual FmEntryData* Clone() override;
+ virtual std::unique_ptr<FmEntryData> Clone() override;
};
@@ -264,7 +264,7 @@ public:
const css::uno::Reference< css::form::XFormComponent >& GetFormComponent() const { return m_xFormComponent; }
virtual bool IsEqualWithoutChildren( FmEntryData* pEntryData ) override;
- virtual FmEntryData* Clone() override;
+ virtual std::unique_ptr<FmEntryData> Clone() override;
void ModelReplaced(const css::uno::Reference< css::form::XFormComponent >& _rxNew);
};
commit 32604a3da226a4e340d6e7844153e7d854fb7f2e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jun 4 14:33:06 2018 +0200
loplugin:useuniqueptr in FmFilterNavigator
Change-Id: I9a674cc87dc6aae4419389a7309304815ceb22ef
Reviewed-on: https://gerrit.libreoffice.org/55518
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
index 293dbc28c81c..b447531ebd77 100644
--- a/svx/source/form/filtnav.cxx
+++ b/svx/source/form/filtnav.cxx
@@ -1084,7 +1084,7 @@ FmFilterNavigator::FmFilterNavigator( vcl::Window* pParent )
Image(BitmapEx(RID_SVXBMP_EXPANDEDNODE))
);
- m_pModel = new FmFilterModel();
+ m_pModel.reset( new FmFilterModel() );
StartListening( *m_pModel );
EnableInplaceEditing( true );
@@ -1104,7 +1104,7 @@ FmFilterNavigator::~FmFilterNavigator()
void FmFilterNavigator::dispose()
{
EndListening( *m_pModel );
- delete m_pModel;
+ m_pModel.reset();
SvTreeListBox::dispose();
}
diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx
index 60f5095adf4d..0910a68b350d 100644
--- a/svx/source/inc/filtnav.hxx
+++ b/svx/source/inc/filtnav.hxx
@@ -231,7 +231,7 @@ class FmFilterNavigator final : public SvTreeListBox, public SfxListener
{
enum DROP_ACTION{ DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
- FmFilterModel* m_pModel;
+ std::unique_ptr<FmFilterModel> m_pModel;
SvTreeListEntry* m_pEditingCurrently;
OFilterExchangeHelper m_aControlExchange;
@@ -250,7 +250,7 @@ public:
const css::uno::Reference< css::container::XIndexAccess > & xControllers,
const css::uno::Reference< css::form::runtime::XFormController > & xCurrent
);
- const FmFilterModel* GetFilterModel() const {return m_pModel;}
+ const FmFilterModel* GetFilterModel() const {return m_pModel.get();}
private:
More information about the Libreoffice-commits
mailing list