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

use unique_ptr in LotusRangeList

Change-Id: Ie99b3a4d6a311b2f5140a00fddbbd53801b8cfb3
Reviewed-on: https://gerrit.libreoffice.org/67045
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 4ac86e33
......@@ -89,7 +89,7 @@ class LotusRangeList
private:
LR_ID nIdCnt;
ScComplexRefData aComplRef;
std::vector<LotusRange*> maRanges;
std::vector<std::unique_ptr<LotusRange>> maRanges;
public:
LotusRangeList();
......@@ -97,7 +97,7 @@ public:
inline sal_uInt16 GetIndex( SCCOL nCol, SCROW nRow );
inline sal_uInt16 GetIndex( SCCOL nColS, SCROW nRowS, SCCOL nColE, SCROW nRowE );
sal_uInt16 GetIndex( const LotusRange& );
void Append( LotusRange* pLR );
void Append( std::unique_ptr<LotusRange> pLR );
};
inline LR_ID LotusRangeList::GetIndex( SCCOL nCol, SCROW nRow )
......
......@@ -201,13 +201,13 @@ void OP_NamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
if (ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd))
{
LotusRange* pRange;
std::unique_ptr<LotusRange> pRange;
if( nColSt == nColEnd && nRowSt == nRowEnd )
pRange = new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt) );
pRange.reset(new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt) ));
else
pRange = new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt),
static_cast<SCCOL> (nColEnd), static_cast<SCROW> (nRowEnd) );
pRange.reset(new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt),
static_cast<SCCOL> (nColEnd), static_cast<SCROW> (nRowEnd) ));
sal_Char cBuf[sizeof(cBuffer)+1];
if( rtl::isAsciiDigit( static_cast<unsigned char>(*cBuffer) ) )
......@@ -222,7 +222,7 @@ void OP_NamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
aTmp = ScfTools::ConvertToScDefinedName( aTmp );
rContext.pLotusRoot->maRangeNames.Append( pRange );
rContext.pLotusRoot->maRangeNames.Append( std::move(pRange) );
}
}
......@@ -240,13 +240,13 @@ void OP_SymphNamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
if (ValidColRow( static_cast<SCCOL>(nColSt), nRowSt) && ValidColRow( static_cast<SCCOL>(nColEnd), nRowEnd))
{
LotusRange* pRange;
std::unique_ptr<LotusRange> pRange;
if( nType )
pRange = new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt) );
pRange.reset(new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt) ));
else
pRange = new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt),
static_cast<SCCOL> (nColEnd), static_cast<SCROW> (nRowEnd) );
pRange.reset(new LotusRange( static_cast<SCCOL> (nColSt), static_cast<SCROW> (nRowSt),
static_cast<SCCOL> (nColEnd), static_cast<SCROW> (nRowEnd) ));
sal_Char cBuf[sizeof(cBuffer)+1];
if( rtl::isAsciiDigit( static_cast<unsigned char>(*cBuffer) ) )
......@@ -260,7 +260,7 @@ void OP_SymphNamedRange(LotusContext& rContext, SvStream& r, sal_uInt16 /*n*/)
OUString aTmp( cBuf, strlen(cBuf), rContext.pLotusRoot->eCharsetQ );
aTmp = ScfTools::ConvertToScDefinedName( aTmp );
rContext.pLotusRoot->maRangeNames.Append( pRange );
rContext.pLotusRoot->maRangeNames.Append( std::move(pRange) );
}
}
......
......@@ -386,43 +386,42 @@ LotusRangeList::LotusRangeList()
LotusRangeList::~LotusRangeList ()
{
for (const auto& rpRange : maRanges)
delete rpRange;
}
LR_ID LotusRangeList::GetIndex( const LotusRange &rRef )
{
std::vector<LotusRange*>::iterator pIter = std::find_if(maRanges.begin(), maRanges.end(),
[&rRef](const LotusRange* pRange) { return rRef == *pRange; });
auto pIter = std::find_if(maRanges.begin(), maRanges.end(),
[&rRef](const std::unique_ptr<LotusRange>& pRange) { return rRef == *pRange; });
if (pIter != maRanges.end())
return (*pIter)->nId;
return ID_FAIL;
}
void LotusRangeList::Append( LotusRange* pLR )
void LotusRangeList::Append( std::unique_ptr<LotusRange> pLR )
{
SAL_WARN_IF( !pLR, "sc.filter", "*LotusRangeList::Append(): no pointer!" );
maRanges.push_back(pLR);
assert( pLR );
auto pLRTmp = pLR.get();
maRanges.push_back(std::move(pLR));
ScTokenArray aTokArray;
ScSingleRefData* pSingRef = &aComplRef.Ref1;
pSingRef->SetAbsCol(pLR->nColStart);
pSingRef->SetAbsRow(pLR->nRowStart);
pSingRef->SetAbsCol(pLRTmp->nColStart);
pSingRef->SetAbsRow(pLRTmp->nRowStart);
if( pLR->IsSingle() )
if( pLRTmp->IsSingle() )
aTokArray.AddSingleReference( *pSingRef );
else
{
pSingRef = &aComplRef.Ref2;
pSingRef->SetAbsCol(pLR->nColEnd);
pSingRef->SetAbsRow(pLR->nRowEnd);
pSingRef->SetAbsCol(pLRTmp->nColEnd);
pSingRef->SetAbsRow(pLRTmp->nRowEnd);
aTokArray.AddDoubleReference( aComplRef );
}
pLR->SetId( nIdCnt );
pLRTmp->SetId( nIdCnt );
nIdCnt++;
}
......
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