use std::make_unique instead of new

Change-Id: Idb9dc1897b5617a6e12110638857e153e2ba56dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116525
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2021-06-01 13:46:27 +02:00
parent 2f78b2c4e8
commit e7afd64074
2 changed files with 12 additions and 14 deletions
+8 -9
View File
@@ -218,16 +218,15 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
pCurrent->nStyleNo )
{
// Open a new Group
std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType(
*pCurrent, *mxInsertPosition, true ));
pNew->SetRTFDefaults( GetRTFDefaults() );
auto xNew(std::make_unique<SvxRTFItemStackType>(*pCurrent, *mxInsertPosition, true));
xNew->SetRTFDefaults( GetRTFDefaults() );
// "Set" all valid attributes up until this point
AttrGroupEnd();
pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); // can be changed after AttrGroupEnd!
pNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
xNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
aAttrStack.push_back( std::move(pNew) );
aAttrStack.push_back( std::move(xNew) );
pCurrent = aAttrStack.back().get();
}
else
@@ -1704,14 +1703,14 @@ void SvxRTFParser::RTFPardPlain( bool const bPard, SfxItemSet** ppSet )
if (pCurrent->aAttrSet.Count() || pCurrent->m_pChildList || pCurrent->nStyleNo)
{
// open a new group
std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType( *pCurrent, *mxInsertPosition, true ));
pNew->SetRTFDefaults( GetRTFDefaults() );
auto xNew(std::make_unique<SvxRTFItemStackType>(*pCurrent, *mxInsertPosition, true));
xNew->SetRTFDefaults( GetRTFDefaults() );
// Set all until here valid attributes
AttrGroupEnd();
pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); // can be changed after AttrGroupEnd!
pNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
aAttrStack.push_back( std::move(pNew) );
xNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
aAttrStack.push_back( std::move(xNew) );
pCurrent = aAttrStack.back().get();
}
else
+4 -5
View File
@@ -811,15 +811,14 @@ void SvxRTFParser::AttrGroupEnd() // process the current, delete from Stack
bCrsrBack = false;
// Open a new Group.
std::unique_ptr<SvxRTFItemStackType> pNew(new SvxRTFItemStackType(
*pCurrent, *mxInsertPosition, true ));
pNew->SetRTFDefaults( GetRTFDefaults() );
auto xNew(std::make_unique<SvxRTFItemStackType>(*pCurrent, *mxInsertPosition, true));
xNew->SetRTFDefaults( GetRTFDefaults() );
// Set all until here valid Attributes
AttrGroupEnd();
pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get(); // can be changed after AttrGroupEnd!
pNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
aAttrStack.push_back( std::move(pNew) );
xNew->aAttrSet.SetParent( pCurrent ? &pCurrent->aAttrSet : nullptr );
aAttrStack.push_back( std::move(xNew) );
}
}
else