Kaydet (Commit) e57a0369 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in tools,stoc,unotools

Change-Id: Ia72b65577143623cedc7a40bc34f7fb897add097
Reviewed-on: https://gerrit.libreoffice.org/47726Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst cb5d79b5
......@@ -112,6 +112,11 @@ void UseUniquePtr::CheckForUnconditionalDelete(const CXXDestructorDecl* destruct
// @TODO it's sharing pointers with another class
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/inc/formulacell.hxx"))
continue;
// some weird stuff going on here around struct Entity
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sax/"))
continue;
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/sax/"))
continue;
report(
DiagnosticsEngine::Warning,
......
......@@ -23,6 +23,7 @@
#include <tools/stream.hxx>
#include <sal/types.h>
#include <vector>
#include <memory>
class INetMIMEMessage;
class SvStream;
......@@ -36,7 +37,8 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
sal_Char *pRead;
sal_Char *pWrite;
SvStream *pMsgStrm;
std::unique_ptr<SvStream>
pMsgStrm;
SvMemoryStream maMsgBuffer;
sal_Char *pMsgRead;
sal_Char *pMsgWrite;
......@@ -44,7 +46,7 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
bool done;
sal_uInt32 nChildIndex;
INetMIMEMessageStream *pChildStrm;
std::unique_ptr<INetMIMEMessageStream> pChildStrm;
INetMIMEMessageStream (const INetMIMEMessageStream& rStrm) = delete;
INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm) = delete;
......
......@@ -26,14 +26,13 @@
#include <vector>
#include <set>
typedef ::std::vector< Range* > ImpSelList;
#define SFX_ENDOFSELECTION SAL_MAX_INT32
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection
{
private:
ImpSelList aSels; // array of SV-selections
std::vector< Range >
aSels; // array of SV-selections
Range aTotRange; // total range of indexes
sal_Int32 nCurSubSel; // index in aSels of current selected index
sal_Int32 nCurIndex; // current selected entry
......@@ -72,7 +71,7 @@ public:
sal_Int32 NextSelected();
sal_Int32 GetRangeCount() const { return aSels.size(); }
const Range& GetRange( sal_Int32 nRange ) const { return *aSels[nRange]; }
const Range& GetRange( sal_Int32 nRange ) const { return aSels[nRange]; }
};
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringRangeEnumerator
......
......@@ -26,6 +26,7 @@
#include <vcl/errcode.hxx>
#include <rtl/string.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
class StreamData;
......@@ -143,7 +144,8 @@ private:
sal_uInt64 m_nActPos;
// buffer management
sal_uInt8* m_pRWBuf; ///< Points to read/write buffer
std::unique_ptr<sal_uInt8>
m_pRWBuf; ///< Points to read/write buffer
sal_uInt8* m_pBufPos; ///< m_pRWBuf + m_nBufActualPos
sal_uInt16 m_nBufSize; ///< Allocated size of buffer
sal_uInt16 m_nBufActualLen; ///< Length of used segment of puffer
......@@ -582,7 +584,8 @@ TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset) SAL_WARN_UNUSE
class TOOLS_DLLPUBLIC SvFileStream : public SvStream
{
private:
StreamData* pInstanceData;
std::unique_ptr<StreamData>
pInstanceData;
OUString aFilename;
#if defined(_WIN32)
sal_uInt16 nLockCounter;
......
......@@ -27,6 +27,7 @@
#include <unotools/collatorwrapper.hxx>
#include <i18nlangtag/lang.h>
#include <i18nlangtag/languagetag.hxx>
#include <memory>
/**
A wrapper of I18N wrappers. Using this is more expensive than using some
......@@ -50,9 +51,9 @@ private:
LanguageTag maLanguageTag;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
LocaleDataWrapper* pLocaleData;
CollatorWrapper* pCollator;
CollatorWrapper* pCaseCollator;
std::unique_ptr<LocaleDataWrapper> pLocaleData;
std::unique_ptr<CollatorWrapper> pCollator;
std::unique_ptr<CollatorWrapper> pCaseCollator;
void ImplNewLocaleData() const;
void ImplNewCollator( bool bCaseSensitive ) const;
......@@ -65,21 +66,21 @@ public:
{
if ( !pLocaleData )
ImplNewLocaleData();
return pLocaleData;
return pLocaleData.get();
}
/// case insensitive collator, simple IGNORE_CASE
const CollatorWrapper* getCollator() const
{
if ( !pCollator )
ImplNewCollator( false );
return pCollator;
return pCollator.get();
}
/// case sensitive collator
const CollatorWrapper* getCaseCollator() const
{
if ( !pCaseCollator )
ImplNewCollator( true );
return pCaseCollator;
return pCaseCollator.get();
}
};
......
......@@ -22,6 +22,7 @@
#include <unotools/unotoolsdllapi.h>
#include <tools/stream.hxx>
#include <memory>
namespace utl
{
......@@ -45,7 +46,8 @@ namespace utl
class UNOTOOLS_DLLPUBLIC TempFile
{
OUString aName;
SvStream* pStream;
std::unique_ptr<SvStream>
pStream;
bool bIsDirectory;
bool bKillingFileEnabled;
......
......@@ -197,7 +197,7 @@ class InterfaceIdlClassImpl
css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > > _xSuperClasses;
MemberInit * _pSortedMemberInit; // first methods, then attributes
std::unique_ptr<MemberInit[]> _pSortedMemberInit; // first methods, then attributes
OUString2Field _aName2Field;
OUString2Method _aName2Method;
sal_Int32 _nMethods;
......
......@@ -327,9 +327,9 @@ class IdlInterfaceMethodImpl
: public IdlMemberImpl
, public XIdlMethod
{
Sequence< Reference< XIdlClass > > * _pExceptionTypes;
Sequence< Reference< XIdlClass > > * _pParamTypes;
Sequence< ParamInfo > * _pParamInfos;
std::unique_ptr<Sequence< Reference< XIdlClass > >> _pExceptionTypes;
std::unique_ptr<Sequence< Reference< XIdlClass > >> _pParamTypes;
std::unique_ptr<Sequence< ParamInfo >> _pParamInfos;
public:
typelib_InterfaceMethodTypeDescription * getMethodTypeDescr() const
......@@ -338,11 +338,7 @@ public:
IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
: IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
, _pExceptionTypes( nullptr )
, _pParamTypes( nullptr )
, _pParamInfos( nullptr )
{}
virtual ~IdlInterfaceMethodImpl() override;
// XInterface
virtual Any SAL_CALL queryInterface( const Type & rType ) override;
......@@ -365,13 +361,6 @@ public:
virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) override;
};
IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl()
{
delete _pParamInfos;
delete _pParamTypes;
delete _pExceptionTypes;
}
// XInterface
Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
......@@ -452,8 +441,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
if (! _pExceptionTypes)
{
sal_Int32 nExc = getMethodTypeDescr()->nExceptions;
Sequence< Reference< XIdlClass > > * pTempExceptionTypes =
new Sequence< Reference< XIdlClass > >( nExc );
std::unique_ptr<Sequence< Reference< XIdlClass > >> pTempExceptionTypes(
new Sequence< Reference< XIdlClass > >( nExc ));
Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
typelib_TypeDescriptionReference ** ppExc =
......@@ -463,7 +452,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
while (nExc--)
pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
_pExceptionTypes = pTempExceptionTypes;
_pExceptionTypes = std::move(pTempExceptionTypes);
}
}
return *_pExceptionTypes;
......@@ -477,8 +466,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
if (! _pParamTypes)
{
sal_Int32 nParams = getMethodTypeDescr()->nParams;
Sequence< Reference< XIdlClass > > * pTempParamTypes =
new Sequence< Reference< XIdlClass > >( nParams );
std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
new Sequence< Reference< XIdlClass > >( nParams ));
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
typelib_MethodParameter * pTypelibParams =
......@@ -488,7 +477,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
while (nParams--)
pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
_pParamTypes = pTempParamTypes;
_pParamTypes = std::move(pTempParamTypes);
}
}
return *_pParamTypes;
......@@ -502,7 +491,7 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
if (! _pParamInfos)
{
sal_Int32 nParams = getMethodTypeDescr()->nParams;
Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams );
std::unique_ptr<Sequence< ParamInfo > > pTempParamInfos( new Sequence< ParamInfo >( nParams ) );
ParamInfo * pParamInfos = pTempParamInfos->getArray();
typelib_MethodParameter * pTypelibParams =
......@@ -526,8 +515,8 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
}
else // make also param types sequence if not already initialized
{
Sequence< Reference< XIdlClass > > * pTempParamTypes =
new Sequence< Reference< XIdlClass > >( nParams );
std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
new Sequence< Reference< XIdlClass > >( nParams ));
Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
IdlReflectionServiceImpl * pRefl = getReflection();
......@@ -544,10 +533,10 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
}
_pParamTypes = pTempParamTypes;
_pParamTypes = std::move(pTempParamTypes);
}
_pParamInfos = pTempParamInfos;
_pParamInfos = std::move(pTempParamInfos);
}
}
return *_pParamInfos;
......@@ -759,8 +748,6 @@ InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
{
for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
typelib_typedescription_release( _pSortedMemberInit[nPos].second );
delete [] _pSortedMemberInit;
}
......@@ -782,7 +769,7 @@ Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
void InterfaceIdlClassImpl::initMembers()
{
sal_Int32 nAll = getTypeDescr()->nAllMembers;
MemberInit * pSortedMemberInit = new MemberInit[nAll];
std::unique_ptr<MemberInit[]> pSortedMemberInit(new MemberInit[nAll]);
typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
......@@ -808,7 +795,7 @@ void InterfaceIdlClassImpl::initMembers()
pSortedMemberInit[nIndex].second = pTD;
}
_pSortedMemberInit = pSortedMemberInit;
_pSortedMemberInit = std::move(pSortedMemberInit);
}
sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
......
......@@ -79,7 +79,7 @@ int INetMIMEMessageStream::GetBodyLine(sal_Char* pData, sal_uInt32 nSize)
if (pSourceMsg->GetDocumentLB())
{
if (pMsgStrm == nullptr)
pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB());
pMsgStrm.reset(new SvStream (pSourceMsg->GetDocumentLB()));
sal_uInt32 nRead = pMsgStrm->ReadBytes(pWBuf, (pWEnd - pWBuf));
pWBuf += nRead;
......@@ -156,7 +156,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
nChildIndex++;
// Create child stream.
pChildStrm = new INetMIMEMessageStream(pChild, false);
pChildStrm.reset(new INetMIMEMessageStream(pChild, false));
if (pSourceMsg->IsMultipart())
{
......@@ -200,8 +200,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
else
{
// Cleanup exhausted child stream.
delete pChildStrm;
pChildStrm = nullptr;
pChildStrm.reset();
}
}
}
......@@ -248,8 +247,7 @@ INetMIMEMessageStream::INetMIMEMessageStream(
INetMIMEMessageStream::~INetMIMEMessageStream()
{
delete pChildStrm;
delete pMsgStrm;
pChildStrm.reset();
}
int INetMIMEMessageStream::Read(sal_Char* pData, sal_uInt32 nSize)
......
......@@ -368,8 +368,6 @@ SvStream::~SvStream()
{
if (m_xLockBytes.is())
Flush();
delete[] m_pRWBuf;
}
void SvStream::ClearError()
......@@ -407,7 +405,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
if (m_nBufSize)
{
delete[] m_pRWBuf;
m_pRWBuf.reset();
m_nBufFilePos += m_nBufActualPos;
}
......@@ -416,9 +414,9 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
m_nBufActualPos = 0;
m_nBufSize = nBufferSize;
if (m_nBufSize)
m_pRWBuf = new sal_uInt8[ m_nBufSize ];
m_pRWBuf.reset(new sal_uInt8[ m_nBufSize ]);
m_isConsistent = true;
m_pBufPos = m_pRWBuf;
m_pBufPos = m_pRWBuf.get();
m_isIoRead = m_isIoWrite = false;
if( !bDontSeek )
SeekPos( nActualFilePos );
......@@ -429,7 +427,7 @@ void SvStream::ClearBuffer()
m_nBufActualLen = 0;
m_nBufActualPos = 0;
m_nBufFilePos = 0;
m_pBufPos = m_pRWBuf;
m_pBufPos = m_pRWBuf.get();
m_isDirty = false;
m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
......@@ -809,7 +807,7 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
nActualPos -= nAbsPos;
}
m_pBufPos = m_pRWBuf + nActualPos;
m_pBufPos = m_pRWBuf.get() + nActualPos;
return Seek( nActualPos );
}
......@@ -1225,8 +1223,8 @@ void SvStream::FlushBuffer(bool isConsistent)
{
SeekPos(m_nBufFilePos);
if (m_nCryptMask)
CryptAndWriteBuffer(m_pRWBuf, m_nBufActualLen);
else if (PutData(m_pRWBuf, m_nBufActualLen) != m_nBufActualLen)
CryptAndWriteBuffer(m_pRWBuf.get(), m_nBufActualLen);
else if (PutData(m_pRWBuf.get(), m_nBufActualLen) != m_nBufActualLen)
SetError(SVSTREAM_WRITE_ERROR);
m_isDirty = false;
}
......@@ -1273,7 +1271,7 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
SeekPos(m_nBufFilePos + m_nBufActualPos);
m_nBufActualLen = 0;
m_pBufPos = m_pRWBuf;
m_pBufPos = m_pRWBuf.get();
nCount = GetData( pData, nCount );
if (m_nCryptMask)
EncryptBuffer(pData, nCount);
......@@ -1289,17 +1287,17 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
SeekPos(m_nBufFilePos);
// TODO: Typecast before GetData, sal_uInt16 nCountTmp
std::size_t nCountTmp = GetData( m_pRWBuf, m_nBufSize );
std::size_t nCountTmp = GetData( m_pRWBuf.get(), m_nBufSize );
if (m_nCryptMask)
EncryptBuffer(m_pRWBuf, nCountTmp);
EncryptBuffer(m_pRWBuf.get(), nCountTmp);
m_nBufActualLen = (sal_uInt16)nCountTmp;
if( nCount > nCountTmp )
{
nCount = nCountTmp; // trim count back, EOF see below
}
memcpy( pData, m_pRWBuf, (size_t)nCount );
memcpy( pData, m_pRWBuf.get(), (size_t)nCount );
m_nBufActualPos = (sal_uInt16)nCount;
m_pBufPos = m_pRWBuf + nCount;
m_pBufPos = m_pRWBuf.get() + nCount;
}
}
}
......@@ -1359,7 +1357,7 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
m_nBufFilePos += m_nBufActualPos;
m_nBufActualLen = 0;
m_nBufActualPos = 0;
m_pBufPos = m_pRWBuf;
m_pBufPos = m_pRWBuf.get();
SeekPos(m_nBufFilePos);
if (m_nCryptMask)
nCount = CryptAndWriteBuffer( pData, nCount );
......@@ -1370,12 +1368,12 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
else
{
// Copy block to buffer
memcpy( m_pRWBuf, pData, (size_t)nCount );
memcpy( m_pRWBuf.get(), pData, (size_t)nCount );
// Mind the order!
m_nBufFilePos += m_nBufActualPos;
m_nBufActualPos = (sal_uInt16)nCount;
m_pBufPos = m_pRWBuf + nCount;
m_pBufPos = m_pRWBuf.get() + nCount;
m_nBufActualLen = (sal_uInt16)nCount;
m_isDirty = true;
}
......@@ -1399,7 +1397,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
if (nFilePos >= m_nBufFilePos && nFilePos <= (m_nBufFilePos + m_nBufActualLen))
{
m_nBufActualPos = (sal_uInt16)(nFilePos - m_nBufFilePos);
m_pBufPos = m_pRWBuf + m_nBufActualPos;
m_pBufPos = m_pRWBuf.get() + m_nBufActualPos;
// Update m_nBufFree to avoid crash upon PutBack
m_nBufFree = m_nBufActualLen - m_nBufActualPos;
}
......@@ -1408,7 +1406,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
FlushBuffer(m_isConsistent);
m_nBufActualLen = 0;
m_nBufActualPos = 0;
m_pBufPos = m_pRWBuf;
m_pBufPos = m_pRWBuf.get();
m_nBufFilePos = SeekPos( nFilePos );
}
return m_nBufFilePos + m_nBufActualPos;
......@@ -1443,11 +1441,11 @@ void SvStream::RefreshBuffer()
{
FlushBuffer(m_isConsistent);
SeekPos(m_nBufFilePos);
m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf, m_nBufSize );
m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf.get(), m_nBufSize );
if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING)
m_nError = ERRCODE_NONE;
if (m_nCryptMask)
EncryptBuffer(m_pRWBuf, (std::size_t)m_nBufActualLen);
EncryptBuffer(m_pRWBuf.get(), (std::size_t)m_nBufActualLen);
m_isConsistent = true;
m_isIoRead = m_isIoWrite = false;
}
......
......@@ -273,7 +273,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nOpenMode )
{
bIsOpen = false;
m_isWritable = false;
pInstanceData = new StreamData;
pInstanceData.reset(new StreamData);
SetBufferSize( 1024 );
// convert URL to SystemPath, if necessary
......@@ -290,15 +290,13 @@ SvFileStream::SvFileStream()
{
bIsOpen = false;
m_isWritable = false;
pInstanceData = new StreamData;
pInstanceData.reset(new StreamData);
SetBufferSize( 1024 );
}
SvFileStream::~SvFileStream()
{
Close();
delete pInstanceData;
}
std::size_t SvFileStream::GetData( void* pData, std::size_t nSize )
......
......@@ -109,7 +109,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nMode )
bIsOpen = false;
nLockCounter = 0;
m_isWritable = false;
pInstanceData = new StreamData;
pInstanceData.reset( new StreamData );
SetBufferSize( 8192 );
// convert URL to SystemPath, if necessary
......@@ -125,7 +125,7 @@ SvFileStream::SvFileStream()
bIsOpen = false;
nLockCounter = 0;
m_isWritable = false;
pInstanceData = new StreamData;
pInstanceData.reset( new StreamData );
SetBufferSize( 8192 );
}
......@@ -133,7 +133,6 @@ SvFileStream::SvFileStream()
SvFileStream::~SvFileStream()
{
Close();
delete pInstanceData;
}
/// Does not check for EOF, makes isEof callable
......
......@@ -35,14 +35,11 @@ IntlWrapper::IntlWrapper(
IntlWrapper::~IntlWrapper()
{
delete pLocaleData;
delete pCollator;
delete pCaseCollator;
}
void IntlWrapper::ImplNewLocaleData() const
{
const_cast<IntlWrapper*>(this)->pLocaleData = new LocaleDataWrapper( m_xContext, maLanguageTag );
const_cast<IntlWrapper*>(this)->pLocaleData.reset( new LocaleDataWrapper( m_xContext, maLanguageTag ) );
}
void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const
......@@ -51,13 +48,13 @@ void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const
if ( bCaseSensitive )
{
p->loadDefaultCollator( maLanguageTag.getLocale(), 0 );
const_cast<IntlWrapper*>(this)->pCaseCollator = p;
const_cast<IntlWrapper*>(this)->pCaseCollator.reset(p);
}
else
{
p->loadDefaultCollator( maLanguageTag.getLocale(),
css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
const_cast<IntlWrapper*>(this)->pCollator = p;
const_cast<IntlWrapper*>(this)->pCollator.reset(p);
}
}
......
......@@ -32,6 +32,7 @@
#include <osl/nlsupport.h>
#include <vector>
#include <memory>
using namespace osl;
using namespace com::sun::star;
......@@ -45,9 +46,9 @@ std::weak_ptr<SvtSysLocale_Impl> g_pSysLocale;
class SvtSysLocale_Impl : public utl::ConfigurationListener
{
public:
SvtSysLocaleOptions aSysLocaleOptions;
LocaleDataWrapper* pLocaleData;
CharClass* pCharClass;
SvtSysLocaleOptions aSysLocaleOptions;
std::unique_ptr<LocaleDataWrapper> pLocaleData;
std::unique_ptr<CharClass> pCharClass;
SvtSysLocale_Impl();
virtual ~SvtSysLocale_Impl() override;
......@@ -61,7 +62,7 @@ private:
SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr)
{
pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() );
pLocaleData.reset(new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() ));
setDateAcceptancePatternsConfig();
// listen for further changes
......@@ -71,15 +72,13 @@ SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr)
SvtSysLocale_Impl::~SvtSysLocale_Impl()
{
aSysLocaleOptions.RemoveListener( this );
delete pCharClass;
delete pLocaleData;
}
CharClass* SvtSysLocale_Impl::GetCharClass()
{
if ( !pCharClass )
pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag() );
return pCharClass;
pCharClass.reset(new CharClass( aSysLocaleOptions.GetRealLanguageTag() ));
return pCharClass.get();
}
void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints nHint )
......@@ -151,7 +150,7 @@ const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const
const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const
{
return pImpl->pLocaleData;
return pImpl->pLocaleData.get();
}
const CharClass& SvtSysLocale::GetCharClass() const
......
......@@ -373,16 +373,15 @@ TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero,
}
TempFile::TempFile(TempFile && other):
aName(std::move(other.aName)), pStream(other.pStream), bIsDirectory(other.bIsDirectory),
aName(std::move(other.aName)), pStream(std::move(other.pStream)), bIsDirectory(other.bIsDirectory),
bKillingFileEnabled(other.bKillingFileEnabled)
{
other.pStream = nullptr;
other.bKillingFileEnabled = false;
}
TempFile::~TempFile()
{
delete pStream;
pStream.reset();
if ( bKillingFileEnabled )
{
if ( bIsDirectory )
......@@ -420,21 +419,17 @@ SvStream* TempFile::GetStream( StreamMode eMode )
if (!pStream)
{
if (!aName.isEmpty())
pStream = new SvFileStream(aName, eMode);
pStream.reset(new SvFileStream(aName, eMode));
else
pStream = new SvMemoryStream(nullptr, 0, eMode);
pStream.reset(new SvMemoryStream(nullptr, 0, eMode));
}
return pStream;
return pStream.get();
}
void TempFile::CloseStream()
{
if ( pStream )
{
delete pStream;
pStream = nullptr;
}
pStream.reset();
}
OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment