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

loplugin:useuniqueptr in ScEditFieldObj

consequently fixing potential leak in InitDoc

Change-Id: I50885f32d2465b41ede5dcf6653d7d8d30a3aeba
Reviewed-on: https://gerrit.libreoffice.org/59557
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 16357f1c
......@@ -204,7 +204,7 @@ public:
ScEditFieldObj(
const css::uno::Reference<css::text::XTextRange>& rContent,
ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel);
std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel);
virtual ~ScEditFieldObj() override;
sal_Int32 GetFieldType() const { return meType;}
......@@ -213,7 +213,7 @@ public:
SvxFieldItem CreateFieldItem();
void InitDoc(
const css::uno::Reference<css::text::XTextRange>& rContent,
ScEditSource* pEditSrc, const ESelection& rSel);
std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel);
// XTextField
virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
......
......@@ -6250,7 +6250,7 @@ void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRang
aSelection.nEndPos = aSelection.nStartPos + 1;
uno::Reference<text::XTextRange> xParent(this);
pCellField->InitDoc(
xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
xParent, o3tl::make_unique<ScCellEditSource>(pDocSh, aCellPos), aSelection);
// for bAbsorb=FALSE, the new selection must be behind the inserted content
// (the xml filter relies on this)
......
......@@ -336,7 +336,7 @@ uno::Reference<text::XTextField> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int3
sal_Int32 eType = pData->GetClassId();
uno::Reference<text::XTextField> xRet(
new ScEditFieldObj(mxContent, new ScCellEditSource(pDocShell, aCellPos), eType, aSelection));
new ScEditFieldObj(mxContent, o3tl::make_unique<ScCellEditSource>(pDocShell, aCellPos), eType, aSelection));
return xRet;
}
......@@ -493,7 +493,7 @@ uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_In
sal_Int32 eRealType = pData->GetClassId();
uno::Reference<text::XTextField> xRet(
new ScEditFieldObj(xTextRange, new ScHeaderFooterEditSource(mrData), eRealType, aSelection));
new ScEditFieldObj(xTextRange, o3tl::make_unique<ScHeaderFooterEditSource>(mrData), eRealType, aSelection));
return xRet;
}
......@@ -1061,10 +1061,10 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any
ScEditFieldObj::ScEditFieldObj(
const uno::Reference<text::XTextRange>& rContent,
ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel) :
std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel) :
OComponentHelper(getMutex()),
pPropSet(nullptr),
mpEditSource(pEditSrc),
mpEditSource(std::move(pEditSrc)),
aSelection(rSel),
meType(eType), mpData(nullptr), mpContent(rContent), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
{
......@@ -1093,7 +1093,7 @@ ScEditFieldObj::ScEditFieldObj(
}
void ScEditFieldObj::InitDoc(
const uno::Reference<text::XTextRange>& rContent, ScEditSource* pEditSrc, const ESelection& rSel)
const uno::Reference<text::XTextRange>& rContent, std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel)
{
if (!mpEditSource)
{
......@@ -1101,7 +1101,7 @@ void ScEditFieldObj::InitDoc(
mpData.reset();
aSelection = rSel;
mpEditSource.reset( pEditSrc );
mpEditSource = std::move( pEditSrc );
}
}
......
......@@ -28,6 +28,7 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/text/textfield/Type.hpp>
#include <editsrc.hxx>
#include <servuno.hxx>
#include <unonames.hxx>
#include <appluno.hxx>
......
......@@ -447,7 +447,7 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
break;
}
pHeaderField->InitDoc(xTextRange, new ScHeaderFooterEditSource(aTextData), aSelection);
pHeaderField->InitDoc(xTextRange, o3tl::make_unique<ScHeaderFooterEditSource>(aTextData), aSelection);
// for bAbsorb=FALSE, the new selection must be behind the inserted content
// (the xml filter relies on this)
......
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