summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-19 09:11:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-19 11:28:41 +0000
commit968f6a7f0293c08a73807603f3cb294e4b50bad8 (patch)
treeace3fb5c260c8bbdc3f97c48499b5466f660a68c /xmlhelp
parentd3ff66999d924e832f8219c65ced0526f1a67f82 (diff)
new loplugin: useuniqueptr: unotools..xmlscript
Change-Id: I6966d44cff644112dd837adfe7d9c4f459457271 Reviewed-on: https://gerrit.libreoffice.org/33298 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx18
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx5
-rw-r--r--xmlhelp/source/cxxhelp/provider/db.cxx5
-rw-r--r--xmlhelp/source/cxxhelp/provider/db.hxx20
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx7
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.hxx6
-rw-r--r--xmlhelp/source/cxxhelp/provider/resultset.cxx1
-rw-r--r--xmlhelp/source/cxxhelp/provider/resultset.hxx2
-rw-r--r--xmlhelp/source/cxxhelp/provider/urlparameter.cxx31
9 files changed, 41 insertions, 54 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index d0c51b27ce54..8ae846f46ae0 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -953,7 +953,7 @@ void Databases::changeCSS(const OUString& newStyleSheet)
}
void Databases::cascadingStylesheet( const OUString& Language,
- char** buffer,
+ std::unique_ptr<char[]>& buffer,
int* byteCount )
{
if( ! m_pCustomCSSDoc )
@@ -1058,16 +1058,16 @@ void Databases::cascadingStylesheet( const OUString& Language,
}
*byteCount = m_nCustomCSSDocLength;
- *buffer = new char[ 1 + *byteCount ];
- (*buffer)[*byteCount] = 0;
- memcpy( *buffer,m_pCustomCSSDoc,m_nCustomCSSDocLength );
+ buffer.reset( new char[ 1 + *byteCount ] );
+ buffer[*byteCount] = 0;
+ memcpy( buffer.get(), m_pCustomCSSDoc, m_nCustomCSSDocLength );
}
void Databases::setActiveText( const OUString& Module,
const OUString& Language,
const OUString& Id,
- char** buffer,
+ std::unique_ptr<char[]>& buffer,
int* byteCount )
{
DataBaseIterator aDbIt( m_xContext, *this, Module, Language, true );
@@ -1112,14 +1112,14 @@ void Databases::setActiveText( const OUString& Module,
}
*byteCount = nSize;
- *buffer = new char[ 1 + nSize ];
- (*buffer)[nSize] = 0;
- memcpy( *buffer, pData, nSize );
+ buffer.reset( new char[ 1 + nSize ] );
+ buffer[nSize] = 0;
+ memcpy( buffer.get(), pData, nSize );
}
else
{
*byteCount = 0;
- *buffer = new char[1]; // Initialize with 1 to avoid compiler warnings
+ buffer.reset( new char[1] ); // Initialize with 1 to avoid compiler warnings
if( !bFoundAsEmpty )
m_aEmptyActiveTextSet.insert( id );
}
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index f725e74765d0..0e92ecd8393b 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
+#include <memory>
#include <set>
#include <unordered_map>
#include <unordered_set>
@@ -179,7 +180,7 @@ namespace chelp {
*/
void cascadingStylesheet( const OUString& Language,
- char** buffer,
+ std::unique_ptr<char[]>& buffer,
int* byteCount );
/**
@@ -195,7 +196,7 @@ namespace chelp {
void setActiveText( const OUString& Module,
const OUString& Language,
const OUString& Id,
- char** buffer,
+ std::unique_ptr<char[]>& buffer,
int* byteCount );
/**
diff --git a/xmlhelp/source/cxxhelp/provider/db.cxx b/xmlhelp/source/cxxhelp/provider/db.cxx
index c978b6e432b8..5d509f0e6d13 100644
--- a/xmlhelp/source/cxxhelp/provider/db.cxx
+++ b/xmlhelp/source/cxxhelp/provider/db.cxx
@@ -33,9 +33,8 @@ namespace helpdatafileproxy {
void HDFData::copyToBuffer( const char* pSrcData, int nSize )
{
m_nSize = nSize;
- delete [] m_pBuffer;
- m_pBuffer = new char[m_nSize+1];
- memcpy( m_pBuffer, pSrcData, m_nSize );
+ m_pBuffer.reset( new char[m_nSize+1] );
+ memcpy( m_pBuffer.get(), pSrcData, m_nSize );
m_pBuffer[m_nSize] = 0;
}
diff --git a/xmlhelp/source/cxxhelp/provider/db.hxx b/xmlhelp/source/cxxhelp/provider/db.hxx
index f21407993016..9343280b5299 100644
--- a/xmlhelp/source/cxxhelp/provider/db.hxx
+++ b/xmlhelp/source/cxxhelp/provider/db.hxx
@@ -23,6 +23,7 @@
#include <comphelper/fileurl.hxx>
#include <osl/diagnose.h>
#include <rtl/string.hxx>
+#include <memory>
#include <unordered_map>
namespace helpdatafileproxy {
@@ -31,23 +32,18 @@ namespace helpdatafileproxy {
{
friend class Hdf;
- int m_nSize;
- char* m_pBuffer;
+ int m_nSize;
+ std::unique_ptr<char[]> m_pBuffer;
void copyToBuffer( const char* pSrcData, int nSize );
public:
- HDFData()
- : m_nSize( 0 )
- , m_pBuffer( nullptr )
- {}
- ~HDFData()
- { delete [] m_pBuffer; }
-
- int getSize() const
+ HDFData() : m_nSize( 0 ) {}
+
+ int getSize() const
{ return m_nSize; }
- const char* getData() const
- { return m_pBuffer; }
+ const char* getData() const
+ { return m_pBuffer.get(); }
};
typedef std::unordered_map< OString,std::pair<int,int>,OStringHash > StringToValPosMap;
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index 56a14e48226e..de116e5f41b6 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -54,7 +54,6 @@ ContentProvider::ContentProvider( const uno::Reference< uno::XComponentContext >
// virtual
ContentProvider::~ContentProvider()
{
- delete m_pDatabases;
}
// XInterface methods.
@@ -206,7 +205,7 @@ ContentProvider::queryContent(
if ( xContent.is() )
return xContent;
- xContent = new Content( m_xContext, this, xCanonicId, m_pDatabases );
+ xContent = new Content( m_xContext, this, xCanonicId, m_pDatabases.get() );
// register new content
registerNewContent( xContent );
@@ -283,12 +282,12 @@ void ContentProvider::init()
bool showBasic = officecfg::Office::Common::Help::ShowBasic::get(
m_xContext);
- m_pDatabases = new Databases( showBasic,
+ m_pDatabases.reset( new Databases( showBasic,
instPath,
utl::ConfigManager::getProductName(),
productversion,
stylesheet,
- m_xContext );
+ m_xContext ) );
}
void ContentProvider::subst( OUString& instpath )
diff --git a/xmlhelp/source/cxxhelp/provider/provider.hxx b/xmlhelp/source/cxxhelp/provider/provider.hxx
index febcc464345a..530f7ab349a9 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.hxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.hxx
@@ -144,9 +144,9 @@ namespace chelp {
// Non-interface methods.
private:
- bool isInitialized;
- OUString m_aScheme;
- Databases* m_pDatabases;
+ bool isInitialized;
+ OUString m_aScheme;
+ std::unique_ptr<Databases> m_pDatabases;
css::uno::Reference<css::container::XContainer> m_xContainer;
// private methods
diff --git a/xmlhelp/source/cxxhelp/provider/resultset.cxx b/xmlhelp/source/cxxhelp/provider/resultset.cxx
index 67ad5df99739..c6983ebcf954 100644
--- a/xmlhelp/source/cxxhelp/provider/resultset.cxx
+++ b/xmlhelp/source/cxxhelp/provider/resultset.cxx
@@ -42,7 +42,6 @@ DynamicResultSet::DynamicResultSet(
DynamicResultSet::~DynamicResultSet()
{
- delete m_pFactory;
}
// Non-interface methods.
diff --git a/xmlhelp/source/cxxhelp/provider/resultset.hxx b/xmlhelp/source/cxxhelp/provider/resultset.hxx
index f8836985d4bd..943385976e54 100644
--- a/xmlhelp/source/cxxhelp/provider/resultset.hxx
+++ b/xmlhelp/source/cxxhelp/provider/resultset.hxx
@@ -31,7 +31,7 @@ namespace chelp {
class DynamicResultSet : public ::ucbhelper::ResultSetImplHelper
{
- ResultSetFactory* m_pFactory;
+ std::unique_ptr<ResultSetFactory> m_pFactory;
private:
virtual void initStatic() override;
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 8d9cd65c06b0..4a6f13d2c6f4 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -47,6 +47,8 @@
#include "urlparameter.hxx"
#include "databases.hxx"
+#include <memory>
+
using namespace cppu;
using namespace com::sun::star::io;
using namespace com::sun::star::uno;
@@ -303,8 +305,6 @@ public:
Databases* pDatatabases,
bool isRoot );
- virtual ~InputStreamTransformer() override;
-
virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException, std::exception ) override;
virtual void SAL_CALL acquire() throw() override;
virtual void SAL_CALL release() throw() override;
@@ -344,7 +344,7 @@ public:
void addToBuffer( const char* buffer,int len );
- sal_Int8 const * getData() const { return reinterpret_cast<sal_Int8 const *>(buffer); }
+ sal_Int8 const * getData() const { return reinterpret_cast<sal_Int8 const *>(buffer.get()); }
sal_Int32 getLen() const { return sal_Int32( len ); }
@@ -353,7 +353,7 @@ private:
osl::Mutex m_aMutex;
int len,pos;
- char *buffer;
+ std::unique_ptr<char[]> buffer;
};
@@ -739,18 +739,18 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
{
if( isRoot )
{
- delete[] buffer;
+ buffer.reset();
pDatabases->cascadingStylesheet( urlParam->get_language(),
- &buffer,
+ buffer,
&len );
}
else if( urlParam->isActive() )
{
- delete[] buffer;
+ buffer.reset();
pDatabases->setActiveText( urlParam->get_module(),
urlParam->get_language(),
urlParam->get_id(),
- &buffer,
+ buffer,
&len );
}
else
@@ -909,12 +909,6 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
}
-InputStreamTransformer::~InputStreamTransformer()
-{
- delete[] buffer;
-}
-
-
Any SAL_CALL InputStreamTransformer::queryInterface( const Type& rType ) throw( RuntimeException, std::exception )
{
Any aRet = ::cppu::queryInterface( rType,
@@ -1032,11 +1026,10 @@ void InputStreamTransformer::addToBuffer( const char* buffer_,int len_ )
{
osl::MutexGuard aGuard( m_aMutex );
- char* tmp = buffer;
- buffer = new char[ len+len_ ];
- memcpy( static_cast<void*>(buffer),static_cast<void*>(tmp),sal_uInt32( len ) );
- memcpy( static_cast<void*>(buffer+len),static_cast<void const *>(buffer_),sal_uInt32( len_ ) );
- delete[] tmp;
+ std::unique_ptr<char[]> tmp(buffer.release());
+ buffer.reset( new char[ len+len_ ] );
+ memcpy( static_cast<void*>(buffer.get()),static_cast<void*>(tmp.get()),sal_uInt32( len ) );
+ memcpy( static_cast<void*>(buffer.get()+len),static_cast<void const *>(buffer_),sal_uInt32( len_ ) );
len += len_;
}