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

loplugin:useuniqueptr in XclExpChTrTabId

and write the buffer in one go in SaveCont

Change-Id: Id41bb132ff3b4176b1fcb1798d10191c3d45fffc
Reviewed-on: https://gerrit.libreoffice.org/57298
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 0f587b82
......@@ -319,10 +319,10 @@ public:
class XclExpChTrTabId : public ExcRecord
{
private:
sal_uInt16* pBuffer;
std::unique_ptr<sal_uInt16> pBuffer;
sal_uInt16 nTabCount;
void Clear() { delete[] pBuffer; pBuffer = nullptr; }
void Clear() { pBuffer.reset(); }
virtual void SaveCont( XclExpStream& rStrm ) override;
......
......@@ -609,8 +609,8 @@ void XclExpChTrTabIdBuffer::Remove()
XclExpChTrTabId::XclExpChTrTabId( const XclExpChTrTabIdBuffer& rBuffer )
: nTabCount( rBuffer.GetBufferCount() )
{
pBuffer = new sal_uInt16[ nTabCount ];
rBuffer.GetBufferCopy( pBuffer );
pBuffer.reset( new sal_uInt16[ nTabCount ] );
rBuffer.GetBufferCopy( pBuffer.get() );
}
XclExpChTrTabId::~XclExpChTrTabId()
......@@ -622,16 +622,15 @@ void XclExpChTrTabId::Copy( const XclExpChTrTabIdBuffer& rBuffer )
{
Clear();
nTabCount = rBuffer.GetBufferCount();
pBuffer = new sal_uInt16[ nTabCount ];
rBuffer.GetBufferCopy( pBuffer );
pBuffer.reset( new sal_uInt16[ nTabCount ] );
rBuffer.GetBufferCopy( pBuffer.get() );
}
void XclExpChTrTabId::SaveCont( XclExpStream& rStrm )
{
rStrm.EnableEncryption();
if( pBuffer )
for( sal_uInt16* pElem = pBuffer; pElem < (pBuffer + nTabCount); pElem++ )
rStrm << *pElem;
rStrm.Write(pBuffer.get(), nTabCount);
else
for( sal_uInt16 nIndex = 1; nIndex <= nTabCount; nIndex++ )
rStrm << nIndex;
......
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