[Libreoffice-commits] core.git: sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jul 12 06:28:14 UTC 2018
sc/source/filter/excel/fontbuff.cxx | 10 +++++-----
sc/source/filter/inc/lotfntbf.hxx | 36 ++++++++----------------------------
2 files changed, 13 insertions(+), 33 deletions(-)
New commits:
commit f37f83e9e879926568bf1f508ad554a20076100d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jul 11 11:16:58 2018 +0200
loplugin:useuniqueptr in LotusFontBuffer
Change-Id: I1039d3f40409a0839c35d6270741aae8017ddf62
Reviewed-on: https://gerrit.libreoffice.org/57295
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/filter/excel/fontbuff.cxx b/sc/source/filter/excel/fontbuff.cxx
index 05416a6b8a3a..180bab493d90 100644
--- a/sc/source/filter/excel/fontbuff.cxx
+++ b/sc/source/filter/excel/fontbuff.cxx
@@ -30,6 +30,7 @@
#include <editeng/wghtitem.hxx>
#include <osl/diagnose.h>
#include <sfx2/printer.hxx>
+#include <o3tl/make_unique.hxx>
#include <attrib.hxx>
#include <document.hxx>
@@ -94,7 +95,7 @@ void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeig
{
OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" );
if( nIndex < nSize )
- pData[ nIndex ].Height( *( new SvxFontHeightItem( static_cast<sal_uLong>(nHeight) * 20, 100, ATTR_FONT_HEIGHT ) ) );
+ pData[ nIndex ].Height( o3tl::make_unique<SvxFontHeightItem>( static_cast<sal_uLong>(nHeight) * 20, 100, ATTR_FONT_HEIGHT ) );
}
void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
@@ -105,7 +106,7 @@ void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
ENTRY* pEntry = pData + nIndex;
pEntry->Type( nType );
- if( pEntry->pTmpName )
+ if( pEntry->xTmpName )
MakeFont( pEntry );
}
}
@@ -134,10 +135,9 @@ void LotusFontBuffer::MakeFont( ENTRY* pEntry )
break;
}
- pEntry->pFont = new SvxFontItem( eFamily, *pEntry->pTmpName, EMPTY_OUSTRING, ePitch, eCharSet, ATTR_FONT );
+ pEntry->pFont.reset( new SvxFontItem( eFamily, *pEntry->xTmpName, EMPTY_OUSTRING, ePitch, eCharSet, ATTR_FONT ) );
- delete pEntry->pTmpName;
- pEntry->pTmpName = nullptr;
+ pEntry->xTmpName.reset();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/lotfntbf.hxx b/sc/source/filter/inc/lotfntbf.hxx
index cb42d5ed7e65..f388d8e51375 100644
--- a/sc/source/filter/inc/lotfntbf.hxx
+++ b/sc/source/filter/inc/lotfntbf.hxx
@@ -24,6 +24,7 @@
#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/colritem.hxx>
+#include <boost/optional.hpp>
// Code in fontbuff.cxx (excel)
@@ -32,38 +33,17 @@ class LotusFontBuffer
private:
struct ENTRY
{
- OUString* pTmpName;
- SvxFontItem* pFont;
- SvxFontHeightItem* pHeight;
- sal_Int32 nType; // < 0 -> undefined
- ENTRY()
- {
- pTmpName = nullptr;
- pFont = nullptr;
- pHeight = nullptr;
- nType = -1;
- }
- ~ENTRY()
- {
- if( pTmpName )
- delete pTmpName;
- if( pFont )
- delete pFont;
- if( pHeight )
- delete pHeight;
- }
+ boost::optional<OUString> xTmpName;
+ std::unique_ptr<SvxFontItem> pFont;
+ std::unique_ptr<SvxFontHeightItem> pHeight;
+ sal_Int32 nType = -1; // < 0 -> undefined
void TmpName( const OUString &rNew )
{
- if( pTmpName )
- *pTmpName = rNew;
- else
- pTmpName = new OUString( rNew );
+ xTmpName = rNew;
}
- void Height( SvxFontHeightItem& rNew )
+ void Height( std::unique_ptr<SvxFontHeightItem> pNew )
{
- if( pHeight )
- delete pHeight;
- pHeight = &rNew;
+ pHeight = std::move(pNew);
}
void Type( const sal_uInt16 nNew ) { nType = nNew; }
};
More information about the Libreoffice-commits
mailing list