summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-26 09:41:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-27 08:42:36 +0200
commit513ac8eb79e45de332d7ddab5b27c70578b904f1 (patch)
tree46f35b236d75651eb612a088e2cdfd48aa85a21c /xmlhelp
parent72b706d7def9e4805e35f3174170dad422b2e7f8 (diff)
loplugin:useuniqueptr in various
extending it to find places we can use std::unique_ptr on arrays Change-Id: I9feb1d12d738d6931e752ecb6dd51cbc1540c81b Reviewed-on: https://gerrit.libreoffice.org/39255 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.cxx27
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx3
2 files changed, 10 insertions, 20 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 407a9bd0c9b4..3fc71e0f87c1 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -127,8 +127,6 @@ Databases::Databases( bool showBasic,
Reference< uno::XComponentContext > const & xContext )
: m_xContext( xContext ),
m_bShowBasic(showBasic),
- m_nCustomCSSDocLength( 0 ),
- m_pCustomCSSDoc( nullptr ),
m_aCSS(styleSheet.toAsciiLowerCase()),
newProdName( "$[officename]" ),
newProdVersion( "$[officeversion]" ),
@@ -161,10 +159,6 @@ Databases::Databases( bool showBasic,
Databases::~Databases()
{
- // release stylesheet
-
- delete[] m_pCustomCSSDoc;
-
// unload the databases
{
@@ -945,15 +939,13 @@ Reference< XHierarchicalNameAccess > Databases::findJarFileForPath
void Databases::changeCSS(const OUString& newStyleSheet)
{
m_aCSS = newStyleSheet.toAsciiLowerCase();
- delete[] m_pCustomCSSDoc;
- m_pCustomCSSDoc = nullptr;
- m_nCustomCSSDocLength = 0;
+ m_vCustomCSSDoc.clear();
}
void Databases::cascadingStylesheet( const OUString& Language,
OStringBuffer& buffer )
{
- if( ! m_pCustomCSSDoc )
+ if( m_vCustomCSSDoc.empty() )
{
int retry = 2;
bool error = true;
@@ -1028,11 +1020,10 @@ void Databases::cascadingStylesheet( const OUString& Language,
{
sal_uInt64 nSize;
aFile.getSize( nSize );
- m_nCustomCSSDocLength = (int)nSize;
- m_pCustomCSSDoc = new char[ 1 + m_nCustomCSSDocLength ];
- m_pCustomCSSDoc[ m_nCustomCSSDocLength ] = 0;
- sal_uInt64 a = m_nCustomCSSDocLength,b = m_nCustomCSSDocLength;
- aFile.read( m_pCustomCSSDoc,a,b );
+ m_vCustomCSSDoc.resize( nSize + 1);
+ m_vCustomCSSDoc[nSize] = 0;
+ sal_uInt64 a = nSize,b = nSize;
+ aFile.read( m_vCustomCSSDoc.data(), a, b );
aFile.close();
error = false;
}
@@ -1049,12 +1040,12 @@ void Databases::cascadingStylesheet( const OUString& Language,
if( error )
{
- m_nCustomCSSDocLength = 0;
- m_pCustomCSSDoc = new char[ 1 ]; // Initialize with 1 to avoid gcc compiler warning
+ m_vCustomCSSDoc.clear();
}
}
- buffer.append( m_pCustomCSSDoc, m_nCustomCSSDocLength );
+ if (!m_vCustomCSSDoc.empty())
+ buffer.append( m_vCustomCSSDoc.data(), m_vCustomCSSDoc.size() - 1 );
}
void Databases::setActiveText( const OUString& Module,
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index 032a39d93848..9a6fd0296b49 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -235,8 +235,7 @@ namespace chelp {
bool m_bShowBasic;
- int m_nCustomCSSDocLength;
- char* m_pCustomCSSDoc;
+ std::vector<char> m_vCustomCSSDoc;
OUString m_aCSS;
enum {