summaryrefslogtreecommitdiff
path: root/lotuswordpro/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 08:36:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 11:39:58 +0100
commit05f12ce00f03be685df9a392001c2ae5f3258edf (patch)
tree6db99b8cef07948163c9688139da726b8086b571 /lotuswordpro/source
parent01f7be3806b45343131902580ce821a1a3ac3d19 (diff)
use unique_ptr in lotuswordpro
Change-Id: I49ae12639d1a5adab25407115cf65ebcfe3936c9 Reviewed-on: https://gerrit.libreoffice.org/65920 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro/source')
-rw-r--r--lotuswordpro/source/filter/lwpcelllayout.cxx6
-rw-r--r--lotuswordpro/source/filter/lwpframelayout.cxx4
-rw-r--r--lotuswordpro/source/filter/lwplayout.cxx4
-rw-r--r--lotuswordpro/source/filter/lwplayout.hxx2
-rw-r--r--lotuswordpro/source/filter/lwppagelayout.cxx12
-rw-r--r--lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx30
-rw-r--r--lotuswordpro/source/filter/tocread.cxx18
-rw-r--r--lotuswordpro/source/filter/xfilter/xfframestyle.cxx4
-rw-r--r--lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx4
-rw-r--r--lotuswordpro/source/filter/xfilter/xfpagemaster.cxx6
10 files changed, 38 insertions, 52 deletions
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 2d25248c6af7..373656132adb 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -438,7 +438,7 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow, GetLeftColID(nCol), pTableLayout);
if (pLeftNeighbour)
{
- XFBorders * pNeighbourBorders = pLeftNeighbour->GetXFBorders();
+ std::unique_ptr<XFBorders> pNeighbourBorders = pLeftNeighbour->GetXFBorders();
if (pNeighbourBorders)
{
XFBorder& rRightBorder = pNeighbourBorders->GetRight();
@@ -449,7 +449,6 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
// we should not ignored it
bNoLeftBorder = true;
}
- delete pNeighbourBorders;
}
}
@@ -457,7 +456,7 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
LwpCellLayout * pBelowNeighbour = GetCellByRowCol(GetBelowRowID(nRow), nCol, pTableLayout);
if (pBelowNeighbour) //&& (eType == enumRightNotLastCellBorder || eType == enumLeftNotLastCellBorder) )
{
- XFBorders * pBelowBorders = pBelowNeighbour->GetXFBorders();
+ std::unique_ptr<XFBorders> pBelowBorders = pBelowNeighbour->GetXFBorders();
if (pBelowBorders)
{
XFBorder& rTopBorder = pBelowBorders->GetTop();
@@ -468,7 +467,6 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
// we should not ignored it
bNoBottomBorder = true;
}
- delete pBelowBorders;
}
}
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 5aa92128f6d8..3e6d9580f4e6 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -346,10 +346,10 @@ void LwpFrame::ApplyPadding(XFFrameStyle *pFrameStyle)
*/
void LwpFrame::ApplyBorders(XFFrameStyle *pFrameStyle)
{
- XFBorders* pBordres = m_pLayout->GetXFBorders();
+ std::unique_ptr<XFBorders> pBordres = m_pLayout->GetXFBorders();
if(pBordres)
{
- pFrameStyle->SetBorders(pBordres);
+ pFrameStyle->SetBorders(std::move(pBordres));
}
}
/**
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index ce17fab7970f..bcc9482dc0ea 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -843,7 +843,7 @@ LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
/**
* @descr: create xfborder.
*/
-XFBorders* LwpMiddleLayout::GetXFBorders()
+std::unique_ptr<XFBorders> LwpMiddleLayout::GetXFBorders()
{
LwpBorderStuff* pBorderStuff = GetBorderStuff();
if(pBorderStuff&&pBorderStuff->GetSide() != 0)
@@ -861,7 +861,7 @@ XFBorders* LwpMiddleLayout::GetXFBorders()
LwpParaStyle::ApplySubBorder(pBorderStuff, nC, xXFBorders.get());
}
}
- return xXFBorders.release();
+ return xXFBorders;
}
return nullptr;
}
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index 1e07f4b1ae14..5cb97064cbf3 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -352,7 +352,7 @@ public:
LwpBackgroundStuff* GetBackgroundStuff();
LwpLayoutGeometry* GetGeometry();
enumXFTextDir GetTextDirection();
- XFBorders* GetXFBorders();
+ std::unique_ptr<XFBorders> GetXFBorders();
LwpColor* GetBackColor();
virtual bool IsAutoGrow() override;
virtual bool IsAutoGrowUp() override;
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 2ce6bc94afe7..16173371c0d8 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -189,10 +189,10 @@ void LwpPageLayout::ParseColumns(XFPageMaster * pm1)
*/
void LwpPageLayout::ParseBorders(XFPageMaster *pm1)
{
- XFBorders* pBordres = GetXFBorders();
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
if(pBordres)
{
- pm1->SetBorders(pBordres);
+ pm1->SetBorders(std::move(pBordres));
}
}
@@ -813,10 +813,10 @@ void LwpHeaderLayout::ParseMargins(XFHeaderStyle* ph1)
void LwpHeaderLayout::ParseBorder(XFHeaderStyle* pHeaderStyle)
{
- XFBorders* pBordres = GetXFBorders();
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
if(pBordres)
{
- pHeaderStyle->SetBorders(pBordres);
+ pHeaderStyle->SetBorders(std::move(pBordres));
}
}
@@ -975,10 +975,10 @@ void LwpFooterLayout::ParseMargins(XFFooterStyle* pFooterStyle)
void LwpFooterLayout::ParseBorder(XFFooterStyle* pFooterStyle)
{
- XFBorders* pBordres = GetXFBorders();
+ std::unique_ptr<XFBorders> pBordres = GetXFBorders();
if(pBordres)
{
- pFooterStyle->SetBorders(pBordres);
+ pFooterStyle->SetBorders(std::move(pBordres));
}
}
diff --git a/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx
index e77c45138649..036f0ea7209d 100644
--- a/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx
+++ b/lotuswordpro/source/filter/lwpsdwgrouploaderv0102.cxx
@@ -319,7 +319,7 @@ XFFrame* LwpSdwGroupLoaderV0102::CreateDrawObject()
unsigned char recType(0);
m_pStream->ReadUChar(recType);
- LwpDrawObj* pDrawObj = nullptr;
+ std::unique_ptr<LwpDrawObj> pDrawObj;
XFFrame* pRetObjct = nullptr;
switch(recType)
@@ -327,52 +327,52 @@ XFFrame* LwpSdwGroupLoaderV0102::CreateDrawObject()
case OT_PERPLINE://fall-through
case OT_LINE:
{
- pDrawObj = new LwpDrawLine(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawLine(m_pStream, &m_aTransformData));
break;
}
case OT_POLYLINE:
{
- pDrawObj = new LwpDrawPolyLine(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawPolyLine(m_pStream, &m_aTransformData));
break;
}
case OT_POLYGON:
{
- pDrawObj = new LwpDrawPolygon(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawPolygon(m_pStream, &m_aTransformData));
pDrawObj->SetObjectType(OT_POLYGON);
break;
}
case OT_SQUARE://fall-through
case OT_RECT:
{
- pDrawObj = new LwpDrawRectangle(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawRectangle(m_pStream, &m_aTransformData));
break;
}
case OT_RNDSQUARE://fall-through
case OT_RNDRECT:
{
- pDrawObj = new LwpDrawRectangle(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawRectangle(m_pStream, &m_aTransformData));
pDrawObj->SetObjectType(OT_RNDRECT);
break;
}
case OT_CIRCLE://fall-through
case OT_OVAL:
{
- pDrawObj = new LwpDrawEllipse(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawEllipse(m_pStream, &m_aTransformData));
break;
}
case OT_ARC:
{
- pDrawObj = new LwpDrawArc(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawArc(m_pStream, &m_aTransformData));
break;
}
case OT_TEXT:
{
- pDrawObj = new LwpDrawTextBox(m_pStream);
+ pDrawObj.reset(new LwpDrawTextBox(m_pStream));
break;
}
case OT_TEXTART:
{
- pDrawObj = new LwpDrawTextArt(m_pStream, &m_aTransformData);
+ pDrawObj.reset(new LwpDrawTextArt(m_pStream, &m_aTransformData));
pDrawObj->SetObjectType(OT_TEXTART);
break;
}
@@ -380,7 +380,7 @@ XFFrame* LwpSdwGroupLoaderV0102::CreateDrawObject()
{
m_pStream->SeekRel(2);
// read out the object header
- pDrawObj = new LwpDrawGroup(m_pStream);
+ pDrawObj.reset(new LwpDrawGroup(m_pStream));
pRetObjct = CreateDrawGroupObject();
@@ -396,7 +396,7 @@ XFFrame* LwpSdwGroupLoaderV0102::CreateDrawObject()
break;
}
case OT_BITMAP:
- pDrawObj = new LwpDrawBitmap(m_pStream);
+ pDrawObj.reset(new LwpDrawBitmap(m_pStream));
pDrawObj->SetObjectType(OT_BITMAP);
break;
}
@@ -407,12 +407,6 @@ XFFrame* LwpSdwGroupLoaderV0102::CreateDrawObject()
pRetObjct = pDrawObj->CreateXFDrawObject();
}
- if (pDrawObj)
- {
- delete pDrawObj;
- pDrawObj = nullptr;
- }
-
return pRetObjct;
}
diff --git a/lotuswordpro/source/filter/tocread.cxx b/lotuswordpro/source/filter/tocread.cxx
index baf84184319b..8cc0d7cdb9ab 100644
--- a/lotuswordpro/source/filter/tocread.cxx
+++ b/lotuswordpro/source/filter/tocread.cxx
@@ -271,23 +271,21 @@ CBenTOCReader::ReadTOC()
#define STACK_BUFFER_SIZE 256
char sStackBuffer[STACK_BUFFER_SIZE];
- char * sAllocBuffer;
+ std::unique_ptr<char[]> sAllocBuffer;
char * sBuffer;
if (Length > STACK_BUFFER_SIZE)
{
- sBuffer = new char[Length];
- sAllocBuffer = sBuffer;
+ sAllocBuffer.reset(new char[Length]);
+ sBuffer = sAllocBuffer.get();
}
else
{
sBuffer = sStackBuffer;
- sAllocBuffer = nullptr;
}
if ((Err = cpContainer->ReadKnownSize(sBuffer, Length)) !=
BenErr_OK)
{
- delete[] sAllocBuffer;
return Err;
}
@@ -297,7 +295,6 @@ CBenTOCReader::ReadTOC()
if (FindNamedObject(&cpContainer->GetNamedObjects(),
sName, &pPrevNamedObjectListElmt) != nullptr)
{
- delete[] sAllocBuffer;
return BenErr_DuplicateName;
}
@@ -305,11 +302,10 @@ CBenTOCReader::ReadTOC()
if (PropertyID == BEN_PROPID_GLOBAL_PROPERTY_NAME)
pObject = new CBenPropertyName(cpContainer, ObjectID,
- pPrevObject, sName, pPrevNamedObjectListElmt);
- else pObject = new CBenTypeName(cpContainer, ObjectID,
- pPrevObject, sName, pPrevNamedObjectListElmt);
-
- delete[] sAllocBuffer;
+ pPrevObject, sName, pPrevNamedObjectListElmt);
+ else
+ pObject = new CBenTypeName(cpContainer, ObjectID,
+ pPrevObject, sName, pPrevNamedObjectListElmt);
}
else if (PropertyID == BEN_PROPID_OBJ_REFERENCES)
{
diff --git a/lotuswordpro/source/filter/xfilter/xfframestyle.cxx b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx
index 51e715f6a134..472e11072c8a 100644
--- a/lotuswordpro/source/filter/xfilter/xfframestyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfframestyle.cxx
@@ -80,9 +80,9 @@ XFFrameStyle::~XFFrameStyle()
{
}
-void XFFrameStyle::SetBorders(XFBorders *pBorders)
+void XFFrameStyle::SetBorders(std::unique_ptr<XFBorders> pBorders)
{
- m_pBorders.reset(pBorders);
+ m_pBorders = std::move(pBorders);
}
void XFFrameStyle::SetColumns(XFColumns *pColumns)
diff --git a/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx
index f8c17cd2d316..eb061b6d55af 100644
--- a/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfheaderstyle.cxx
@@ -103,9 +103,9 @@ void XFHeaderStyle::SetShadow(XFShadow *pShadow)
m_pShadow.reset( pShadow );
}
-void XFHeaderStyle::SetBorders(XFBorders *pBorders)
+void XFHeaderStyle::SetBorders(std::unique_ptr<XFBorders> pBorders)
{
- m_pBorders.reset(pBorders);
+ m_pBorders = std::move(pBorders);
}
void XFHeaderStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
diff --git a/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx b/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx
index 62f2c38538da..ca5d1adbb84f 100644
--- a/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfpagemaster.cxx
@@ -106,11 +106,9 @@ void XFPageMaster::SetMargins(double left, double right,double top, double bo
m_aMargin.SetBottom(bottom);
}
-void XFPageMaster::SetBorders(XFBorders *pBorders)
+void XFPageMaster::SetBorders(std::unique_ptr<XFBorders> pBorders)
{
- if( pBorders == m_pBorders.get() )
- return;
- m_pBorders.reset( pBorders );
+ m_pBorders = std::move( pBorders );
}
void XFPageMaster::SetShadow(XFShadow *pShadow)