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

loplugin:useuniqueptr in XFParaStyle

Change-Id: I883c54698022d07dbcb72e66b1108178cf27a5ae
Reviewed-on: https://gerrit.libreoffice.org/50751Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 202aba9a
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include <xfilter/xfdropcap.hxx> #include <xfilter/xfdropcap.hxx>
#include <xfilter/xfstylecont.hxx> #include <xfilter/xfstylecont.hxx>
#include <xfilter/xflineheight.hxx> #include <xfilter/xflineheight.hxx>
#include <memory>
#define XFPARA_FLAG_FONT 0X00000001 #define XFPARA_FLAG_FONT 0X00000001
#define XFPARA_FLAG_DROPCAP 0X00000002 #define XFPARA_FLAG_DROPCAP 0X00000002
...@@ -231,8 +232,8 @@ protected: ...@@ -231,8 +232,8 @@ protected:
XFStyleContainer m_aTabs; XFStyleContainer m_aTabs;
rtl::Reference<XFFont> m_pFont; rtl::Reference<XFFont> m_pFont;
XFShadow m_aShadow; XFShadow m_aShadow;
XFBorders *m_pBorders; std::unique_ptr<XFBorders> m_pBorders;
XFBGImage *m_pBGImage; std::unique_ptr<XFBGImage> m_pBGImage;
XFDropcap m_aDropcap; XFDropcap m_aDropcap;
XFLineHeight m_aLineHeight; XFLineHeight m_aLineHeight;
XFBreaks m_aBreaks; XFBreaks m_aBreaks;
......
...@@ -104,14 +104,10 @@ XFParaStyle::XFParaStyle(const XFParaStyle& other) ...@@ -104,14 +104,10 @@ XFParaStyle::XFParaStyle(const XFParaStyle& other)
, m_bNumberRight(other.m_bNumberRight) , m_bNumberRight(other.m_bNumberRight)
{ {
if( other.m_pBorders ) if( other.m_pBorders )
m_pBorders = new XFBorders(*other.m_pBorders); m_pBorders.reset( new XFBorders(*other.m_pBorders) );
else
m_pBorders = nullptr;
if( other.m_pBGImage ) if( other.m_pBGImage )
m_pBGImage = new XFBGImage(*other.m_pBGImage); m_pBGImage.reset( new XFBGImage(*other.m_pBGImage) );
else
m_pBGImage = nullptr;
for (size_t i = 0; i < other.m_aTabs.GetCount(); ++i) for (size_t i = 0; i < other.m_aTabs.GetCount(); ++i)
{ {
...@@ -134,7 +130,7 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other) ...@@ -134,7 +130,7 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
if (this != &other) if (this != &other)
{ {
// first , clean member // first , clean member
delete m_pBGImage; m_pBGImage.reset();
m_aTabs.Reset(); m_aTabs.Reset();
m_strParentStyleName = other.m_strParentStyleName; m_strParentStyleName = other.m_strParentStyleName;
...@@ -151,14 +147,14 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other) ...@@ -151,14 +147,14 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
m_pFont = other.m_pFont; m_pFont = other.m_pFont;
if( other.m_pBorders ) if( other.m_pBorders )
m_pBorders = new XFBorders(*other.m_pBorders); m_pBorders.reset( new XFBorders(*other.m_pBorders) );
else else
m_pBorders = nullptr; m_pBorders.reset();
m_aBackColor = other.m_aBackColor; m_aBackColor = other.m_aBackColor;
if( other.m_pBGImage ) if( other.m_pBGImage )
m_pBGImage = new XFBGImage(*other.m_pBGImage); m_pBGImage.reset( new XFBGImage(*other.m_pBGImage) );
else else
m_pBGImage = nullptr; m_pBGImage.reset();
m_aShadow = other.m_aShadow; m_aShadow = other.m_aShadow;
m_aMargin = other.m_aMargin; m_aMargin = other.m_aMargin;
...@@ -186,8 +182,6 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other) ...@@ -186,8 +182,6 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
XFParaStyle::~XFParaStyle() XFParaStyle::~XFParaStyle()
{ {
delete m_pBorders;
delete m_pBGImage;
} }
enumXFStyle XFParaStyle::GetStyleFamily() enumXFStyle XFParaStyle::GetStyleFamily()
...@@ -232,14 +226,12 @@ void XFParaStyle::SetBackColor(XFColor const & color) ...@@ -232,14 +226,12 @@ void XFParaStyle::SetBackColor(XFColor const & color)
void XFParaStyle::SetBackImage(XFBGImage *image) void XFParaStyle::SetBackImage(XFBGImage *image)
{ {
delete m_pBGImage; m_pBGImage.reset( image );
m_pBGImage = image;
} }
void XFParaStyle::SetBorders(XFBorders *pBorders) void XFParaStyle::SetBorders(XFBorders *pBorders)
{ {
delete m_pBorders; m_pBorders.reset( pBorders );
m_pBorders = pBorders;
} }
void XFParaStyle::SetDropCap(sal_Int16 nLength, void XFParaStyle::SetDropCap(sal_Int16 nLength,
......
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