summaryrefslogtreecommitdiffstats
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-11 10:22:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-15 08:38:03 +0200
commit7ec60cdc3a6ca76d96411288ad55435de39c4b0c (patch)
tree6ba9a4e5c4a3fe817342b361bd8b471c42d9d726 /editeng
parentloplugin:returnconstant in ScDetectiveFunc (diff)
downloadcore-7ec60cdc3a6ca76d96411288ad55435de39c4b0c.tar.gz
core-7ec60cdc3a6ca76d96411288ad55435de39c4b0c.zip
loplugin:useuniqueptr pass XEditAttribute around by std::unique_ptr
Change-Id: Idaf02002cecb1300a5fc3bcb0e298b11a1958bb1 Reviewed-on: https://gerrit.libreoffice.org/59008 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editobj.cxx13
-rw-r--r--editeng/source/editeng/editobj2.hxx4
-rw-r--r--editeng/source/editeng/impedit4.cxx6
3 files changed, 11 insertions, 12 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 9b7fa07924d6..57eea220c5a8 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -60,12 +60,12 @@ using std::endl;
using namespace com::sun::star;
-XEditAttribute* MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
+std::unique_ptr<XEditAttribute> MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
{
// Create thw new attribute in the pool
const SfxPoolItem& rNew = rPool.Put( rItem );
- XEditAttribute* pNew = new XEditAttribute( rNew, nStart, nEnd );
+ std::unique_ptr<XEditAttribute> pNew(new XEditAttribute( rNew, nStart, nEnd ));
return pNew;
}
@@ -130,9 +130,9 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
for (const auto & aAttrib : rCopyFrom.maCharAttribs)
{
const XEditAttribute& rAttr = *aAttrib.get();
- XEditAttribute* pMyAttr = MakeXEditAttribute(
+ std::unique_ptr<XEditAttribute> pMyAttr = MakeXEditAttribute(
rPoolToUse, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
- maCharAttribs.push_back(std::unique_ptr<XEditAttribute>(pMyAttr));
+ maCharAttribs.push_back(std::move(pMyAttr));
}
if ( rCopyFrom.GetWrongList() )
@@ -644,15 +644,14 @@ void EditTextObjectImpl::SetScriptType( SvtScriptType nType )
nScriptType = nType;
}
-XEditAttribute* EditTextObjectImpl::CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
+std::unique_ptr<XEditAttribute> EditTextObjectImpl::CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
{
return MakeXEditAttribute( *pPool, rItem, nStart, nEnd );
}
-void EditTextObjectImpl::DestroyAttrib( XEditAttribute* pAttr )
+void EditTextObjectImpl::DestroyAttrib( std::unique_ptr<XEditAttribute> pAttr )
{
pPool->Remove( *pAttr->GetItem() );
- delete pAttr;
}
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index b30fadb3fe63..7da37fc2f31d 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -219,8 +219,8 @@ public:
void SetScriptType( SvtScriptType nType );
ContentInfo* CreateAndInsertContent();
- XEditAttribute* CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd );
- void DestroyAttrib( XEditAttribute* pAttr );
+ std::unique_ptr<XEditAttribute> CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd );
+ void DestroyAttrib( std::unique_ptr<XEditAttribute> pAttr );
ContentInfosType& GetContents() { return aContents;}
const ContentInfosType& GetContents() const { return aContents;}
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index b9b55534b37e..5c2378917381 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1060,7 +1060,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
if ( bEmptyPara ||
( ( pAttr->GetEnd() > nStartPos ) && ( pAttr->GetStart() < nEndPos ) ) )
{
- XEditAttribute* pX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd());
+ std::unique_ptr<XEditAttribute> pX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd());
// Possibly Correct ...
if ( ( nNode == nStartNode ) && ( nStartPos != 0 ) )
{
@@ -1075,9 +1075,9 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
}
DBG_ASSERT( pX->GetEnd() <= (nEndPos-nStartPos), "CreateBinTextObject: Attribute too long!" );
if ( !pX->GetLen() && !bEmptyPara )
- pTxtObj->mpImpl->DestroyAttrib(pX);
+ pTxtObj->mpImpl->DestroyAttrib(std::move(pX));
else
- pC->GetCharAttribs().push_back(std::unique_ptr<XEditAttribute>(pX));
+ pC->GetCharAttribs().push_back(std::move(pX));
}
nAttr++;
pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );