[Libreoffice-commits] core.git: editeng/source include/editeng
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 3 12:29:41 UTC 2021
editeng/source/rtf/svxrtf.cxx | 25 ++++++++++++++++++-------
include/editeng/svxrtf.hxx | 3 +++
2 files changed, 21 insertions(+), 7 deletions(-)
New commits:
commit b30839cecd25b9f6f56fcf4b3d3e90ab23a3d0b7
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Jun 3 10:02:59 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jun 3 14:28:50 2021 +0200
use std::make_unique instead of new
Change-Id: I267b82dd573fc8bd30e1c5d47e9b1f2e98c2b412
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116645
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 43c6a8e6f8e5..9d5f3abe84ec 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -609,23 +609,34 @@ const vcl::Font& SvxRTFParser::GetFont( sal_uInt16 nId )
return *pDfltFont;
}
+std::unique_ptr<SvxRTFItemStackType> SvxRTFItemStackType::createSvxRTFItemStackType(
+ SfxItemPool& rPool, const sal_uInt16* pWhichRange, const EditPosition& rEditPosition)
+{
+ struct MakeUniqueEnabler : public SvxRTFItemStackType
+ {
+ MakeUniqueEnabler(SfxItemPool& rPool, const sal_uInt16* pWhichRange, const EditPosition& rEditPosition)
+ : SvxRTFItemStackType(rPool, pWhichRange, rEditPosition)
+ {
+ }
+ };
+ return std::make_unique<MakeUniqueEnabler>(rPool, pWhichRange, rEditPosition);
+}
+
SvxRTFItemStackType* SvxRTFParser::GetAttrSet_()
{
SvxRTFItemStackType* pCurrent = aAttrStack.empty() ? nullptr : aAttrStack.back().get();
- std::unique_ptr<SvxRTFItemStackType> pNew;
+ std::unique_ptr<SvxRTFItemStackType> xNew;
if( pCurrent )
- pNew.reset(new SvxRTFItemStackType( *pCurrent, *mxInsertPosition, false/*bCopyAttr*/ ));
+ xNew = std::make_unique<SvxRTFItemStackType>(*pCurrent, *mxInsertPosition, false/*bCopyAttr*/);
else
- pNew.reset(new SvxRTFItemStackType( *pAttrPool, aWhichMap.data(),
- *mxInsertPosition ));
- pNew->SetRTFDefaults( GetRTFDefaults() );
+ xNew = SvxRTFItemStackType::createSvxRTFItemStackType(*pAttrPool, aWhichMap.data(), *mxInsertPosition);
+ xNew->SetRTFDefaults( GetRTFDefaults() );
- aAttrStack.push_back( std::move(pNew) );
+ aAttrStack.push_back( std::move(xNew) );
bNewGroup = false;
return aAttrStack.back().get();
}
-
void SvxRTFParser::ClearStyleAttr_( SvxRTFItemStackType& rStkType )
{
// check attributes to the attributes of the stylesheet or to
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index d19c542885bf..d322b1823e2b 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -304,6 +304,9 @@ class SvxRTFItemStackType
SvxRTFItemStackType( SfxItemPool&, const sal_uInt16* pWhichRange,
const EditPosition& );
+ static std::unique_ptr<SvxRTFItemStackType> createSvxRTFItemStackType(
+ SfxItemPool&, const sal_uInt16* pWhichRange, const EditPosition&);
+
void Add(std::unique_ptr<SvxRTFItemStackType>);
void Compress( const SvxRTFParser& );
void DropChildList();
More information about the Libreoffice-commits
mailing list