summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-14 15:58:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-15 08:25:03 +0200
commit3f20471490c61b19fe4222f8c40df255051f6e3d (patch)
tree5caca827ab21537cc02eeaf193bdc41698a4499f /sw
parent8ae592a7360d5f6a44d5ad2c34d818f638ff94b2 (diff)
use std::unique_ptr in FlatFndBox
and extend o3tl::make_unique to cope with arrays Change-Id: I84caa46ab5060f9777bfe275f229499cb0b407be Reviewed-on: https://gerrit.libreoffice.org/38794 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docsort.cxx12
-rw-r--r--sw/source/core/inc/docsort.hxx2
2 files changed, 5 insertions, 9 deletions
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index d71f9a079426..f2c02f409342 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -747,7 +747,6 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar,
FlatFndBox::FlatFndBox(SwDoc* pDocPtr, const FndBox_& rBox) :
pDoc(pDocPtr),
rBoxRef(rBox),
- pArr(nullptr),
nRow(0),
nCol(0)
{ // If the array is symmetric
@@ -760,9 +759,8 @@ FlatFndBox::FlatFndBox(SwDoc* pDocPtr, const FndBox_& rBox) :
// Create linear array
size_t nCount = static_cast<size_t>(nRows) * nCols;
- pArr = new const FndBox_*[nCount];
- FndBox_** ppTmp = const_cast<FndBox_**>(pArr);
- memset(ppTmp, 0, sizeof(const FndBox_*) * nCount);
+ pArr = o3tl::make_unique<FndBox_ const *[]>(nCount);
+ memset(pArr.get(), 0, sizeof(const FndBox_*) * nCount);
FillFlat( rBoxRef );
}
@@ -770,8 +768,6 @@ FlatFndBox::FlatFndBox(SwDoc* pDocPtr, const FndBox_& rBox) :
FlatFndBox::~FlatFndBox()
{
- FndBox_** ppTmp = const_cast<FndBox_**>(pArr);
- delete [] ppTmp;
}
/// All Lines of a Box need to have same number of Boxes
@@ -890,7 +886,7 @@ void FlatFndBox::FillFlat(const FndBox_& rBox, bool bLastBox)
{
// save it
sal_uInt16 nOff = nRow * nCols + nCol;
- *(pArr + nOff) = pBox;
+ pArr[nOff] = pBox;
// Save the Formula/Format/Value values
const SwFrameFormat* pFormat = pBox->GetBox()->GetFrameFormat();
@@ -931,7 +927,7 @@ void FlatFndBox::FillFlat(const FndBox_& rBox, bool bLastBox)
const FndBox_* FlatFndBox::GetBox(sal_uInt16 n_Col, sal_uInt16 n_Row) const
{
sal_uInt16 nOff = n_Row * nCols + n_Col;
- const FndBox_* pTmp = *(pArr + nOff);
+ const FndBox_* pTmp = pArr[nOff];
OSL_ENSURE(n_Col < nCols && n_Row < nRows && pTmp, "invalid array access");
return pTmp;
diff --git a/sw/source/core/inc/docsort.hxx b/sw/source/core/inc/docsort.hxx
index f8c1990ef9a3..b66ecd3f5159 100644
--- a/sw/source/core/inc/docsort.hxx
+++ b/sw/source/core/inc/docsort.hxx
@@ -140,7 +140,7 @@ private:
SwDoc* pDoc;
const FndBox_& rBoxRef;
- const FndBox_** pArr;
+ std::unique_ptr<FndBox_ const *[]> pArr;
std::vector<std::unique_ptr<SfxItemSet>> ppItemSets;
sal_uInt16 nRows;