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