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

loplugin:useuniqueptr in SwGlossaryList

Change-Id: I208d46c27e5fefb20fbc9e049a0b3b36f7be4cbb
Reviewed-on: https://gerrit.libreoffice.org/58013
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 78e94024
......@@ -45,7 +45,7 @@ struct AutoTextGroup
class SwGlossaryList : public AutoTimer
{
std::vector<AutoTextGroup*> aGroupArr;
std::vector<std::unique_ptr<AutoTextGroup>> aGroupArr;
OUString sPath;
bool bFilled;
......
......@@ -111,7 +111,7 @@ bool SwGlossaryList::GetShortName(const OUString& rLongName,
size_t nCount = aGroupArr.size();
for(size_t i = 0; i < nCount; i++ )
{
AutoTextGroup* pGroup = aGroupArr[i];
AutoTextGroup* pGroup = aGroupArr[i].get();
if(!rGroupName.isEmpty() && rGroupName != pGroup->sName)
continue;
......@@ -176,7 +176,7 @@ OUString SwGlossaryList::GetGroupName(size_t nPos)
OSL_ENSURE(aGroupArr.size() > nPos, "group not available");
if(nPos < aGroupArr.size())
{
AutoTextGroup* pGroup = aGroupArr[nPos];
AutoTextGroup* pGroup = aGroupArr[nPos].get();
OUString sRet = pGroup->sName;
return sRet;
}
......@@ -188,7 +188,7 @@ OUString SwGlossaryList::GetGroupTitle(size_t nPos)
OSL_ENSURE(aGroupArr.size() > nPos, "group not available");
if(nPos < aGroupArr.size())
{
AutoTextGroup* pGroup = aGroupArr[nPos];
AutoTextGroup* pGroup = aGroupArr[nPos].get();
return pGroup->sTitle;
}
return OUString();
......@@ -199,7 +199,7 @@ sal_uInt16 SwGlossaryList::GetBlockCount(size_t nGroup)
OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
if(nGroup < aGroupArr.size())
{
AutoTextGroup* pGroup = aGroupArr[nGroup];
AutoTextGroup* pGroup = aGroupArr[nGroup].get();
return pGroup->nCount;
}
return 0;
......@@ -210,7 +210,7 @@ OUString SwGlossaryList::GetBlockLongName(size_t nGroup, sal_uInt16 nBlock)
OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
if(nGroup < aGroupArr.size())
{
AutoTextGroup* pGroup = aGroupArr[nGroup];
AutoTextGroup* pGroup = aGroupArr[nGroup].get();
return pGroup->sLongNames.getToken(nBlock, STRING_DELIM);
}
return OUString();
......@@ -221,7 +221,7 @@ OUString SwGlossaryList::GetBlockShortName(size_t nGroup, sal_uInt16 nBlock)
OSL_ENSURE(aGroupArr.size() > nGroup, "group not available");
if(nGroup < aGroupArr.size())
{
AutoTextGroup* pGroup = aGroupArr[nGroup];
AutoTextGroup* pGroup = aGroupArr[nGroup].get();
return pGroup->sShortNames.getToken(nBlock, STRING_DELIM);
}
return OUString();
......@@ -253,17 +253,17 @@ void SwGlossaryList::Update()
sGrpName.getToken(1, GLOS_DELIM).toInt32());
if( nPath < rPathArr.size() )
{
AutoTextGroup* pGroup = new AutoTextGroup;
std::unique_ptr<AutoTextGroup> pGroup(new AutoTextGroup);
pGroup->sName = sGrpName;
FillGroup(pGroup, pGlossaries);
FillGroup(pGroup.get(), pGlossaries);
OUString sName = rPathArr[nPath] + "/" +
pGroup->sName.getToken(0, GLOS_DELIM) + sExt;
FStatHelper::GetModifiedDateTimeOfFile( sName,
&pGroup->aDateModified,
&pGroup->aDateModified );
aGroupArr.insert( aGroupArr.begin(), pGroup );
aGroupArr.insert( aGroupArr.begin(), std::move(pGroup) );
}
}
bFilled = true;
......@@ -295,7 +295,7 @@ void SwGlossaryList::Update()
FillGroup( pFound, pGlossaries );
pFound->aDateModified = *pDT;
aGroupArr.push_back(pFound);
aGroupArr.push_back(std::unique_ptr<AutoTextGroup>(pFound));
}
else if( pFound->aDateModified < *pDT )
{
......@@ -311,7 +311,7 @@ void SwGlossaryList::Update()
{
--i;
// maybe remove deleted groups
AutoTextGroup* pGroup = aGroupArr[i];
AutoTextGroup* pGroup = aGroupArr[i].get();
const size_t nGroupPath = static_cast<size_t>(
pGroup->sName.getToken( 1, GLOS_DELIM).toInt32());
// Only the groups will be checked which are registered
......@@ -343,10 +343,10 @@ void SwGlossaryList::Invoke()
AutoTextGroup* SwGlossaryList::FindGroup(const OUString& rGroupName)
{
for(AutoTextGroup* pRet : aGroupArr)
for(auto & pRet : aGroupArr)
{
if(pRet->sName == rGroupName)
return pRet;
return pRet.get();
}
return nullptr;
}
......@@ -384,7 +384,7 @@ void SwGlossaryList::HasLongName(const OUString& rBegin, std::vector<OUString> *
for(size_t i = 0; i < nCount; ++i)
{
AutoTextGroup* pGroup = aGroupArr[i];
AutoTextGroup* pGroup = aGroupArr[i].get();
for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
{
OUString sBlock = pGroup->sLongNames.getToken(j, STRING_DELIM);
......@@ -402,10 +402,6 @@ void SwGlossaryList::HasLongName(const OUString& rBegin, std::vector<OUString> *
void SwGlossaryList::ClearGroups()
{
const size_t nCount = aGroupArr.size();
for( size_t i = 0; i < nCount; ++i )
delete aGroupArr[ i ];
aGroupArr.clear();
bFilled = false;
}
......
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