[Libreoffice-commits] core.git: 2 commits - filter/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Jun 11 06:26:44 UTC 2018
filter/source/xsltdialog/typedetectionimport.cxx | 19 ++++++++-----------
filter/source/xsltdialog/typedetectionimport.hxx | 7 +++----
filter/source/xsltdialog/xmlfiltertabdialog.cxx | 11 +++++------
filter/source/xsltdialog/xmlfiltertabdialog.hxx | 4 ++--
4 files changed, 18 insertions(+), 23 deletions(-)
New commits:
commit f2f9d431589d7a5d7636fee2a021bfed497cb861
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jun 4 15:06:17 2018 +0200
loplugin:useuniqueptr in XMLFilterTabDialog
Change-Id: Ic4bc1441802df3b62c1e8da69379f2677f243508
Reviewed-on: https://gerrit.libreoffice.org/55521
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.cxx b/filter/source/xsltdialog/xmlfiltertabdialog.cxx
index 2f8f5e306506..3d05f25f15e3 100644
--- a/filter/source/xsltdialog/xmlfiltertabdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltertabdialog.cxx
@@ -46,7 +46,7 @@ XMLFilterTabDialog::XMLFilterTabDialog(weld::Window *pParent,
, mpXSLTPage(new XMLFilterTabPageXSLT(m_xTabCtrl->get_page("transformation"), m_xDialog.get()))
{
mpOldInfo = pInfo;
- mpNewInfo = new filter_info_impl( *mpOldInfo );
+ mpNewInfo.reset( new filter_info_impl( *mpOldInfo ) );
OUString aTitle(m_xDialog->get_title());
aTitle = aTitle.replaceAll("%s", mpNewInfo->maFilterName);
@@ -54,19 +54,18 @@ XMLFilterTabDialog::XMLFilterTabDialog(weld::Window *pParent,
m_xOKBtn->connect_clicked( LINK( this, XMLFilterTabDialog, OkHdl ) );
- mpBasicPage->SetInfo( mpNewInfo );
- mpXSLTPage->SetInfo( mpNewInfo );
+ mpBasicPage->SetInfo( mpNewInfo.get() );
+ mpXSLTPage->SetInfo( mpNewInfo.get() );
}
XMLFilterTabDialog::~XMLFilterTabDialog()
{
- delete mpNewInfo;
}
bool XMLFilterTabDialog::onOk()
{
- mpXSLTPage->FillInfo( mpNewInfo );
- mpBasicPage->FillInfo( mpNewInfo );
+ mpXSLTPage->FillInfo( mpNewInfo.get() );
+ mpBasicPage->FillInfo( mpNewInfo.get() );
OString sErrorPage;
const char* pErrorId = nullptr;
diff --git a/filter/source/xsltdialog/xmlfiltertabdialog.hxx b/filter/source/xsltdialog/xmlfiltertabdialog.hxx
index 475a8c34225a..f6b6784eea8d 100644
--- a/filter/source/xsltdialog/xmlfiltertabdialog.hxx
+++ b/filter/source/xsltdialog/xmlfiltertabdialog.hxx
@@ -34,7 +34,7 @@ public:
bool onOk();
- filter_info_impl* getNewFilterInfo() const { return mpNewInfo;}
+ filter_info_impl* getNewFilterInfo() const { return mpNewInfo.get(); }
private:
css::uno::Reference< css::uno::XComponentContext > mxContext;
@@ -42,7 +42,7 @@ private:
DECL_LINK(OkHdl, weld::Button&, void);
const filter_info_impl* mpOldInfo;
- filter_info_impl* mpNewInfo;
+ std::unique_ptr<filter_info_impl> mpNewInfo;
std::unique_ptr<weld::Notebook> m_xTabCtrl;
std::unique_ptr<weld::Button> m_xOKBtn;
commit 8a6722f6453900424b21809bafb649a0592e7626
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jun 4 15:04:57 2018 +0200
loplugin:useuniqueptr in TypeDetectionImporter
Change-Id: I0bb696ccf8555fe597aaff1cb6ab74bf16d81731
Reviewed-on: https://gerrit.libreoffice.org/55520
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx
index 2fa37c8c40eb..fd9960e36726 100644
--- a/filter/source/xsltdialog/typedetectionimport.cxx
+++ b/filter/source/xsltdialog/typedetectionimport.cxx
@@ -70,16 +70,14 @@ void TypeDetectionImporter::fillFilterVector( XMLFilterVector& rFilters )
// create filter infos from imported filter nodes
for (auto const& filterNode : maFilterNodes)
{
- filter_info_impl* pFilter = createFilterForNode(filterNode);
+ filter_info_impl* pFilter = createFilterForNode(filterNode.get());
if( pFilter )
rFilters.push_back( pFilter );
-
- delete filterNode;
}
+ maFilterNodes.clear();
// now delete type nodes
- for (auto const& typeNode : maTypeNodes)
- delete typeNode;
+ maTypeNodes.clear();
}
static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rData )
@@ -115,11 +113,10 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD
Node* TypeDetectionImporter::findTypeNode( const OUString& rType )
{
- // now delete type nodes
- for (NodeVector::const_iterator aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter)
+ for (auto aIter(maTypeNodes.begin()), aEnd(maTypeNodes.end()); aIter != aEnd; ++aIter)
{
if( (*aIter)->maName == rType )
- return (*aIter);
+ return aIter->get();
}
return nullptr;
@@ -277,18 +274,18 @@ void SAL_CALL TypeDetectionImporter::endElement( const OUString& /* aName */ )
case e_Filter:
case e_Type:
{
- Node* pNode = new Node;
+ std::unique_ptr<Node> pNode(new Node);
pNode->maName = maNodeName;
pNode->maPropertyMap = maPropertyMap;
maPropertyMap.clear();
if( eCurrentState == e_Filter )
{
- maFilterNodes.push_back( pNode );
+ maFilterNodes.push_back( std::move(pNode) );
}
else
{
- maTypeNodes.push_back( pNode );
+ maTypeNodes.push_back( std::move(pNode) );
}
}
break;
diff --git a/filter/source/xsltdialog/typedetectionimport.hxx b/filter/source/xsltdialog/typedetectionimport.hxx
index 1af2b442c824..440e650db9ae 100644
--- a/filter/source/xsltdialog/typedetectionimport.hxx
+++ b/filter/source/xsltdialog/typedetectionimport.hxx
@@ -28,6 +28,7 @@
#include "xmlfilterjar.hxx"
#include <map>
+#include <memory>
#include <vector>
#include <stack>
@@ -56,8 +57,6 @@ struct Node
PropertyMap maPropertyMap;
};
-typedef std::vector< Node* > NodeVector;
-
class TypeDetectionImporter : public cppu::WeakImplHelper < css::xml::sax::XDocumentHandler >
{
public:
@@ -83,8 +82,8 @@ private:
std::stack< ImportState > maStack;
PropertyMap maPropertyMap;
- NodeVector maFilterNodes;
- NodeVector maTypeNodes;
+ std::vector< std::unique_ptr<Node> > maFilterNodes;
+ std::vector< std::unique_ptr<Node> > maTypeNodes;
OUString maValue;
OUString maNodeName;
More information about the Libreoffice-commits
mailing list