From 50c63e5c2f7962e8893e2d04b0e958209432f4c9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 29 Jun 2018 15:38:29 +0200 Subject: pass OutlinerParaObject around by std::unique_ptr SdrText::SetOutlinerParaObject was modified to not check for self-assign, and instead assert because the existing check was no longer possible. Fix bug in SdrUndoObjSetText::Undo(), where it was calling SdrText::SetOutlinerParaObject unnecessarily, because NbcSetOutlinerParaObjectForText already does that. Optimise Outliner::GetEmptyParaObject by creating a new constructor for OutlinerParaObject, so we don't need to copy the new object we get back from GetEmptyTextObject, unnecessarily. Change-Id: I57c475583d6c31658c154e24992b3d587bad9841 Reviewed-on: https://gerrit.libreoffice.org/56730 Tested-by: Jenkins Reviewed-by: Noel Grandin --- editeng/source/outliner/outliner.cxx | 11 ++++----- editeng/source/outliner/outlobj.cxx | 5 ++++ editeng/source/outliner/overflowingtxt.cxx | 18 +++++++------- editeng/source/uno/unoforou.cxx | 3 +-- filter/source/msfilter/msdffimp.cxx | 8 +++---- filter/source/msfilter/svdfppt.cxx | 6 ++--- include/editeng/outliner.hxx | 4 ++-- include/editeng/outlobj.hxx | 1 + include/editeng/overflowingtxt.hxx | 16 ++++++------- include/svx/svdoashp.hxx | 2 +- include/svx/svdobj.hxx | 4 ++-- include/svx/svdomeas.hxx | 2 +- include/svx/svdotable.hxx | 2 +- include/svx/svdotext.hxx | 6 ++--- include/svx/svdtext.hxx | 2 +- oox/source/export/drawingml.cxx | 2 +- oox/source/export/vmlexport.cxx | 2 +- reportdesign/source/core/sdr/ReportDrawPage.cxx | 1 + sc/source/core/data/postit.cxx | 7 +++--- sc/source/filter/excel/xiescher.cxx | 5 ++-- sc/source/ui/unoobj/editsrc.cxx | 4 ++-- sd/inc/textapi.hxx | 2 +- sd/source/core/drawdoc4.cxx | 6 ++--- sd/source/core/sdpage.cxx | 8 +++---- sd/source/core/text/textapi.cxx | 8 +++---- sd/source/filter/xml/sdtransform.cxx | 1 + sd/source/filter/xml/sdxmlwrp.cxx | 1 + sd/source/ui/annotations/annotationwindow.cxx | 4 ++-- sd/source/ui/dlg/headerfooterdlg.cxx | 1 + sd/source/ui/docshell/docshel4.cxx | 5 ++-- sd/source/ui/func/fuexpand.cxx | 11 ++++----- sd/source/ui/func/fuinsert.cxx | 1 + sd/source/ui/func/fuinsfil.cxx | 5 ++-- sd/source/ui/func/fumorph.cxx | 1 + .../ui/slidesorter/controller/SlsSlotManager.cxx | 3 +-- sd/source/ui/view/DocumentRenderer.cxx | 9 ++----- sd/source/ui/view/drviews2.cxx | 4 ++-- sd/source/ui/view/drviews7.cxx | 3 +-- sd/source/ui/view/drviews8.cxx | 1 + sd/source/ui/view/drviews9.cxx | 1 + sd/source/ui/view/drviewse.cxx | 5 ++-- sd/source/ui/view/outlnvsh.cxx | 17 ++++++------- sd/source/ui/view/outlview.cxx | 3 +-- sd/source/ui/view/sdview.cxx | 1 + sd/source/ui/view/sdview4.cxx | 1 + sd/source/ui/view/viewshe2.cxx | 1 + svx/source/accessibility/AccessibleShape.cxx | 2 +- .../customshapes/EnhancedCustomShapeEngine.cxx | 3 ++- svx/source/inc/cell.hxx | 4 ++-- svx/source/sdr/primitive2d/sdrattributecreator.cxx | 3 +-- svx/source/sdr/properties/textproperties.cxx | 16 ++++++------- svx/source/svdraw/svdedtv2.cxx | 6 +++-- svx/source/svdraw/svdedxv.cxx | 4 ++-- svx/source/svdraw/svdoashp.cxx | 6 ++--- svx/source/svdraw/svdobj.cxx | 6 ++--- svx/source/svdraw/svdomeas.cxx | 4 ++-- svx/source/svdraw/svdoole2.cxx | 3 ++- svx/source/svdraw/svdotext.cxx | 28 +++++++++++----------- svx/source/svdraw/svdotxat.cxx | 4 ++-- svx/source/svdraw/svdotxed.cxx | 12 +++------- svx/source/svdraw/svdtext.cxx | 26 ++++++++++---------- svx/source/svdraw/svdundo.cxx | 22 ++++++++--------- svx/source/svdraw/textchainflow.cxx | 22 +++++++---------- svx/source/table/accessiblecell.cxx | 2 +- svx/source/table/cell.cxx | 25 ++++++++++--------- svx/source/table/svdotable.cxx | 10 ++++---- svx/source/table/tablertfexporter.cxx | 2 +- svx/source/table/tableundo.cxx | 3 ++- svx/source/unodraw/unoshtxt.cxx | 4 ++-- sw/source/core/fields/docufld.cxx | 1 + sw/source/core/fields/textapi.cxx | 3 ++- sw/source/core/inc/textapi.hxx | 4 ++-- sw/source/core/layout/fly.cxx | 1 + sw/source/core/unocore/unofield.cxx | 3 ++- sw/source/filter/ww8/rtfsdrexport.cxx | 2 +- sw/source/filter/ww8/wrtw8esh.cxx | 2 +- sw/source/filter/ww8/ww8graf.cxx | 7 +++--- sw/source/filter/ww8/ww8par.cxx | 1 + sw/source/uibase/docvw/AnnotationWin.cxx | 4 ++-- 79 files changed, 228 insertions(+), 231 deletions(-) diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 344ece6b82ff..d595486c2fdb 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -369,7 +369,7 @@ void Outliner::SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled) pEditEngine->SetHoriAlignIgnoreTrailingWhitespace( bEnabled ); } -OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const +std::unique_ptr Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const { if ( static_cast(nStartPara) + nCount > static_cast(pParaList->GetParagraphCount()) ) @@ -393,7 +393,7 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara); } - OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc); + std::unique_ptr pPObj(new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc)); pPObj->SetOutlinerMode(GetMode()); return pPObj; @@ -401,9 +401,8 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 void Outliner::SetToEmptyText() { - OutlinerParaObject *pEmptyTxt = GetEmptyParaObject(); + std::unique_ptr pEmptyTxt = GetEmptyParaObject(); SetText(*pEmptyTxt); - delete pEmptyTxt; } void Outliner::SetText( const OUString& rText, Paragraph* pPara ) @@ -2115,10 +2114,10 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const } } -OutlinerParaObject *Outliner::GetEmptyParaObject() const +std::unique_ptr Outliner::GetEmptyParaObject() const { std::unique_ptr pEmptyText = pEditEngine->GetEmptyTextObject(); - OutlinerParaObject* pPObj = new OutlinerParaObject( *pEmptyText ); + std::unique_ptr pPObj( new OutlinerParaObject( std::move(pEmptyText) )); pPObj->SetOutlinerMode(GetMode()); return pPObj; } diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx index 04688bb06728..8002419cc37d 100644 --- a/editeng/source/outliner/outlobj.cxx +++ b/editeng/source/outliner/outlobj.cxx @@ -77,6 +77,11 @@ OutlinerParaObject::OutlinerParaObject( const EditTextObject& rTextObj ) : { } +OutlinerParaObject::OutlinerParaObject( std::unique_ptr pTextObj ) : + mpImpl(OutlinerParaObjData(std::move(pTextObj), ParagraphDataVector(), true)) +{ +} + OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& r ) : mpImpl(r.mpImpl) { diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx index 5577104b7f7e..e5bc3097e82b 100644 --- a/editeng/source/outliner/overflowingtxt.cxx +++ b/editeng/source/outliner/overflowingtxt.cxx @@ -31,7 +31,7 @@ #include -OutlinerParaObject *TextChainingUtils::JuxtaposeParaObject( +std::unique_ptr TextChainingUtils::JuxtaposeParaObject( css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent, Outliner *pOutl, OutlinerParaObject const *pNextPObj) @@ -66,7 +66,7 @@ OutlinerParaObject *TextChainingUtils::JuxtaposeParaObject( return pOutl->CreateParaObject(); } -OutlinerParaObject *TextChainingUtils::DeeplyMergeParaObject( +std::unique_ptr TextChainingUtils::DeeplyMergeParaObject( css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent, Outliner *pOutl, OutlinerParaObject const *pNextPObj) @@ -125,7 +125,7 @@ bool NonOverflowingText::IsLastParaInterrupted() const } -OutlinerParaObject *NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const +std::unique_ptr NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const { pOutliner->QuickDelete(maContentSel); SAL_INFO("editeng.chaining", "Deleting selection from (Para: " << maContentSel.nStartPara @@ -144,12 +144,12 @@ ESelection NonOverflowingText::GetOverflowPointSel() const // The equivalent of ToParaObject for OverflowingText. Here we are prepending the overflowing text to the old dest box's text // XXX: In a sense a better name for OverflowingText and NonOverflowingText are respectively DestLinkText and SourceLinkText -OutlinerParaObject *OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj) +std::unique_ptr OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj) { return TextChainingUtils::JuxtaposeParaObject(mxOverflowingContent, pOutl, pNextPObj); } -OutlinerParaObject *OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj) +std::unique_ptr OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj) { return TextChainingUtils::DeeplyMergeParaObject(mxOverflowingContent, pOutl, pNextPObj); } @@ -174,7 +174,7 @@ ESelection OFlowChainedText::GetOverflowPointSel() const return mpNonOverflowingTxt->GetOverflowPointSel(); } -OutlinerParaObject *OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged) +std::unique_ptr OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged) { // Just return the roughly merged paras for now if (mpOverflowingTxt == nullptr) @@ -190,7 +190,7 @@ OutlinerParaObject *OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, } -OutlinerParaObject *OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner) +std::unique_ptr OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner) { if (mpNonOverflowingTxt == nullptr) return nullptr; @@ -212,9 +212,9 @@ UFlowChainedText::UFlowChainedText(Outliner const *pOutl, bool bIsDeepMerge) mbIsDeepMerge = bIsDeepMerge; } -OutlinerParaObject *UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText) +std::unique_ptr UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText) { - OutlinerParaObject *pNewText = nullptr; + std::unique_ptr pNewText; if (mbIsDeepMerge) { SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - UF] Deep merging paras" ); diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx index fa8e08ed16d7..c53d610b97c1 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -544,9 +544,8 @@ void SvxOutlinerForwarder::CopyText(const SvxTextForwarder& rSource) const SvxOutlinerForwarder* pSourceForwarder = dynamic_cast< const SvxOutlinerForwarder* >( &rSource ); if( !pSourceForwarder ) return; - OutlinerParaObject* pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject(); + std::unique_ptr pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject(); rOutliner.SetText( *pNewOutlinerParaObject ); - delete pNewOutlinerParaObject; } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 7d7e5e385390..29741fa2fc3b 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -3660,10 +3660,10 @@ void SvxMSDffManager::ReadObjText( const OUString& rText, SdrObject* pObj ) rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); nParaIndex++; } - OutlinerParaObject* pNewText = rOutliner.CreateParaObject(); + std::unique_ptr pNewText = rOutliner.CreateParaObject(); rOutliner.Clear(); rOutliner.SetUpdateMode( bOldUpdateMode ); - pText->SetOutlinerParaObject( pNewText ); + pText->SetOutlinerParaObject( std::move(pNewText) ); } } @@ -4496,9 +4496,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r } if ( bCreateNewParaObject ) { - OutlinerParaObject* pNewText = rOutliner.CreateParaObject(); + std::unique_ptr pNewText = rOutliner.CreateParaObject(); rOutliner.Init( OutlinerMode::TextObject ); - static_cast(pRet)->NbcSetOutlinerParaObject( pNewText ); + static_cast(pRet)->NbcSetOutlinerParaObject( std::move(pNewText) ); } } rOutliner.Clear(); diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 0f36b690634b..09590554ddd3 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -2350,10 +2350,10 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); } } - OutlinerParaObject* pNewText = rOutliner.CreateParaObject(); + std::unique_ptr pNewText = rOutliner.CreateParaObject(); rOutliner.Clear(); rOutliner.SetUpdateMode( bOldUpdateMode ); - pText->SetOutlinerParaObject( pNewText ); + pText->SetOutlinerParaObject( std::move(pNewText) ); } return pText; } @@ -7634,7 +7634,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, const sal_uInt32 { SdrText* pSdrText = pTable->getText( nTableIndex ); if ( pSdrText ) - pSdrText->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject) ); + pSdrText->SetOutlinerParaObject(o3tl::make_unique(*pParaObject) ); } } } diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 03743cd362ee..c0d4a9a82437 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -705,7 +705,7 @@ public: void SetToEmptyText(); - OutlinerParaObject* CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const; + std::unique_ptr CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const; const SfxItemSet& GetEmptyItemSet() const; @@ -759,7 +759,7 @@ public: void ClearOverflowingParaNum(); bool IsPageOverflow(); - OutlinerParaObject *GetEmptyParaObject() const; + std::unique_ptr GetEmptyParaObject() const; void DepthChangedHdl(Paragraph*, ParaFlag nPrevFlags); diff --git a/include/editeng/outlobj.hxx b/include/editeng/outlobj.hxx index 0186ce72af16..b7ddc4c59403 100644 --- a/include/editeng/outlobj.hxx +++ b/include/editeng/outlobj.hxx @@ -66,6 +66,7 @@ public: // constructors/destructor OutlinerParaObject( const EditTextObject&, const ParagraphDataVector&, bool bIsEditDoc); OutlinerParaObject( const EditTextObject&); + OutlinerParaObject( std::unique_ptr ); OutlinerParaObject( const OutlinerParaObject&); ~OutlinerParaObject(); diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx index 19bf287995d5..66d4527648c8 100644 --- a/include/editeng/overflowingtxt.hxx +++ b/include/editeng/overflowingtxt.hxx @@ -51,11 +51,11 @@ class TextChainingUtils public: static css::uno::Reference< css::datatransfer::XTransferable> CreateTransferableFromText(Outliner const *); - static OutlinerParaObject *JuxtaposeParaObject( + static std::unique_ptr JuxtaposeParaObject( css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent, Outliner *, OutlinerParaObject const *); - static OutlinerParaObject *DeeplyMergeParaObject( + static std::unique_ptr DeeplyMergeParaObject( css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent, Outliner *, OutlinerParaObject const *); @@ -70,8 +70,8 @@ public: class OverflowingText { public: - OutlinerParaObject *JuxtaposeParaObject(Outliner *, OutlinerParaObject const *); - OutlinerParaObject *DeeplyMergeParaObject(Outliner *, OutlinerParaObject const *); + std::unique_ptr JuxtaposeParaObject(Outliner *, OutlinerParaObject const *); + std::unique_ptr DeeplyMergeParaObject(Outliner *, OutlinerParaObject const *); private: friend class Outliner; @@ -83,7 +83,7 @@ private: class NonOverflowingText { public: - OutlinerParaObject *RemoveOverflowingText(Outliner *) const; + std::unique_ptr RemoveOverflowingText(Outliner *) const; ESelection GetOverflowPointSel() const; bool IsLastParaInterrupted() const; @@ -108,8 +108,8 @@ public: OFlowChainedText(Outliner const *, bool ); ~OFlowChainedText(); - OutlinerParaObject *InsertOverflowingText(Outliner *, OutlinerParaObject const *); - OutlinerParaObject *RemoveOverflowingText(Outliner *); + std::unique_ptr InsertOverflowingText(Outliner *, OutlinerParaObject const *); + std::unique_ptr RemoveOverflowingText(Outliner *); ESelection GetOverflowPointSel() const; @@ -127,7 +127,7 @@ class EDITENG_DLLPUBLIC UFlowChainedText { public: UFlowChainedText(Outliner const *, bool); - OutlinerParaObject *CreateMergedUnderflowParaObject(Outliner *, OutlinerParaObject const *); + std::unique_ptr CreateMergedUnderflowParaObject(Outliner *, OutlinerParaObject const *); private: css::uno::Reference< css::datatransfer::XTransferable > mxUnderflowingTxt; diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index e82e5018d137..8247b9b5fcce 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -220,7 +220,7 @@ public: virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; virtual basegfx::B2DPolyPolygon TakeContour() const override; - virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) override; + virtual void NbcSetOutlinerParaObject(std::unique_ptr pTextObject) override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 21529b482147..d97edb022e4c 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -680,8 +680,8 @@ public: // keep text in outliner's format // SetOutlinerParaObject: transfer ownership of *pTextObject! - void SetOutlinerParaObject(OutlinerParaObject* pTextObject); - virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject); + void SetOutlinerParaObject(std::unique_ptr pTextObject); + virtual void NbcSetOutlinerParaObject(std::unique_ptr pTextObject); virtual OutlinerParaObject* GetOutlinerParaObject() const; virtual void NbcReformatText(); virtual void ReformatText(); diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index 72abb9abefcd..0e30251dcab5 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -136,7 +136,7 @@ public: virtual void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const override; virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const override; virtual EEAnchorMode GetOutlinerViewAnchorMode() const override; - virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) override; + virtual void NbcSetOutlinerParaObject(std::unique_ptr pTextObject) override; virtual OutlinerParaObject* GetOutlinerParaObject() const override; virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 1119c8c9fc59..ad42885a124f 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -237,7 +237,7 @@ public: void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const; virtual EEAnchorMode GetOutlinerViewAnchorMode() const override; - virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) override; + virtual void NbcSetOutlinerParaObject(std::unique_ptr pTextObject) override; virtual OutlinerParaObject* GetOutlinerParaObject() const override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 7be26b52d40f..3b0e307246ba 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -488,10 +488,10 @@ public: virtual void EndTextEdit(SdrOutliner& rOutl); virtual EEAnchorMode GetOutlinerViewAnchorMode() const; - virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) override; - void NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText ); + virtual void NbcSetOutlinerParaObject(std::unique_ptr pTextObject) override; + void NbcSetOutlinerParaObjectForText( std::unique_ptr pTextObject, SdrText* pText ); virtual OutlinerParaObject* GetOutlinerParaObject() const override; - OutlinerParaObject* GetEditOutlinerParaObject() const; + std::unique_ptr GetEditOutlinerParaObject() const; virtual void NbcReformatText() override; virtual void ReformatText() override; diff --git a/include/svx/svdtext.hxx b/include/svx/svdtext.hxx index 11b91f028fb8..18f8d0bc7e00 100644 --- a/include/svx/svdtext.hxx +++ b/include/svx/svdtext.hxx @@ -49,7 +49,7 @@ public: void ForceOutlinerParaObject( OutlinerMode nOutlMode ); - virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject ); + virtual void SetOutlinerParaObject( std::unique_ptr pTextObject ); OutlinerParaObject* GetOutlinerParaObject() const; void CheckPortionInfo( SdrOutliner& rOutliner ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index dfb59f2db363..c9c390970440 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2481,7 +2481,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin */ if (pTxtObj->IsTextEditActive()) { - pParaObj = pTxtObj->GetEditOutlinerParaObject(); + pParaObj = pTxtObj->GetEditOutlinerParaObject().release(); bOwnParaObj = true; } else diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 2ec6992381a6..a655c77f9318 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1346,7 +1346,7 @@ sal_Int32 VMLExport::StartShape() */ if (pTxtObj->IsTextEditActive()) { - pParaObj = pTxtObj->GetEditOutlinerParaObject(); + pParaObj = pTxtObj->GetEditOutlinerParaObject().release(); bOwnParaObj = true; } else diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx index cf73d9c04c4b..d5226c1935d3 100644 --- a/reportdesign/source/core/sdr/ReportDrawPage.cxx +++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 4629bbdc052b..56020cfe3afa 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -713,7 +714,7 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const OSL_ENSURE( rInitData.mxOutlinerObj.get() || !rInitData.maSimpleText.isEmpty(), "ScPostIt::CreateCaptionFromInitData - need either outliner para object or simple text" ); if( rInitData.mxOutlinerObj.get() ) - maNoteData.m_pCaption->SetOutlinerParaObject( rInitData.mxOutlinerObj.release() ); + maNoteData.m_pCaption->SetOutlinerParaObject( std::move(rInitData.mxOutlinerObj) ); else maNoteData.m_pCaption->SetText( rInitData.maSimpleText ); @@ -772,7 +773,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const std::shared_ptr< SdrC { // copy edit text object (object must be inserted into page already) if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() ) - maNoteData.m_pCaption->SetOutlinerParaObject( new OutlinerParaObject( *pOPO ) ); + maNoteData.m_pCaption->SetOutlinerParaObject( o3tl::make_unique( *pOPO ) ); // copy formatting items (after text has been copied to apply font formatting) maNoteData.m_pCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() ); // move textbox position relative to new cell, copy textbox size @@ -850,7 +851,7 @@ std::shared_ptr< SdrCaptionObj > ScNoteUtil::CreateTempCaption( if( pNoteCaption && rUserText.isEmpty() ) { if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() ) - pCaption->SetOutlinerParaObject( new OutlinerParaObject( *pOPO ) ); + pCaption->SetOutlinerParaObject( o3tl::make_unique( *pOPO ) ); // set formatting (must be done after setting text) and resize the box to fit the text pCaption->SetMergedItemSetAndBroadcast( pNoteCaption->GetMergedItemSet() ); tools::Rectangle aCaptRect( pCaption->GetLogicRect().TopLeft(), pNoteCaption->GetLogicRect().GetSize() ); diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 72343c7797eb..00433e17c7bb 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -1469,10 +1469,9 @@ void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& // rich text std::unique_ptr< EditTextObject > xEditObj( XclImpStringHelper::CreateTextObject( GetRoot(), *maTextData.mxString ) ); - OutlinerParaObject* pOutlineObj = new OutlinerParaObject( *xEditObj ); + std::unique_ptr pOutlineObj(new OutlinerParaObject( *xEditObj )); pOutlineObj->SetOutlinerMode( OutlinerMode::TextObject ); - // text object takes ownership of the outliner object - pTextObj->NbcSetOutlinerParaObject( pOutlineObj ); + pTextObj->NbcSetOutlinerParaObject( std::move(pOutlineObj) ); } else { diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx index 1b604a517949..86c44fc08b38 100644 --- a/sc/source/ui/unoobj/editsrc.cxx +++ b/sc/source/ui/unoobj/editsrc.cxx @@ -179,10 +179,10 @@ void ScAnnotationEditSource::UpdateData() if( SdrObject* pObj = GetCaptionObj() ) { std::unique_ptr pEditObj = pEditEngine->CreateTextObject(); - OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj ); + std::unique_ptr pOPO( new OutlinerParaObject( *pEditObj ) ); pEditObj.reset(); pOPO->SetOutlinerMode( OutlinerMode::TextObject ); - pObj->NbcSetOutlinerParaObject( pOPO ); + pObj->NbcSetOutlinerParaObject( std::move(pOPO) ); pObj->ActionChanged(); } diff --git a/sd/inc/textapi.hxx b/sd/inc/textapi.hxx index d81ecf4b4ce2..00a60d13791d 100644 --- a/sd/inc/textapi.hxx +++ b/sd/inc/textapi.hxx @@ -40,7 +40,7 @@ public: /// @throws css::uno::RuntimeException void dispose(); - OutlinerParaObject* CreateText(); + std::unique_ptr CreateText(); void SetText( OutlinerParaObject const & rText ); OUString GetText(); diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index b938697eba50..171d2b345d63 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -904,7 +904,7 @@ void SdDrawDocument::SpellObject(SdrTextObj* pObj) if (mbHasOnlineSpellErrors) { - OutlinerParaObject* pOPO = pOutl->CreateParaObject(); + std::unique_ptr pOPO = pOutl->CreateParaObject(); if (pOPO) { if (!( *pOPO == *pObj->GetOutlinerParaObject() ) || @@ -914,11 +914,9 @@ void SdDrawDocument::SpellObject(SdrTextObj* pObj) // taking text from the outliner // use non-broadcasting version to avoid O(n^2) - pObj->NbcSetOutlinerParaObject( pOPO ); - pOPO = nullptr; + pObj->NbcSetOutlinerParaObject( std::move(pOPO) ); } } - delete pOPO; } } diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 539932c8e9dc..1746ea72cbd8 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -2097,8 +2097,9 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P SdOutliner* pOutl = rModel.GetInternalOutliner(); pOutl->Clear(); pOutl->SetText( *pOutlParaObj ); - pOutlParaObj = pOutl->CreateParaObject(); - pNewObj->SetOutlinerParaObject( pOutlParaObj ); + std::unique_ptr pNew = pOutl->CreateParaObject(); + pOutlParaObj = pNew.get(); + pNewObj->SetOutlinerParaObject( std::move(pNew) ); pOutl->Clear(); pNewObj->SetEmptyPresObj(false); @@ -2155,8 +2156,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P SdOutliner* pOutl = rModel.GetInternalOutliner(); pOutl->Clear(); pOutl->SetText( *pOutlParaObj ); - pOutlParaObj = pOutl->CreateParaObject(); - pNewObj->SetOutlinerParaObject( pOutlParaObj ); + pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); pOutl->Clear(); pNewObj->SetEmptyPresObj(false); diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx index 4965b84a471b..ec968c510f6e 100644 --- a/sd/source/core/text/textapi.cxx +++ b/sd/source/core/text/textapi.cxx @@ -64,7 +64,7 @@ UndoTextAPIChanged::UndoTextAPIChanged(SdrModel& rModel, TextApiObject* pTextObj void UndoTextAPIChanged::Undo() { if( !mpNewText ) - mpNewText.reset( mxTextObj->CreateText() ); + mpNewText = mxTextObj->CreateText(); mxTextObj->SetText( *mpOldText ); } @@ -99,7 +99,7 @@ public: void Dispose(); void SetText( OutlinerParaObject const & rText ); - OutlinerParaObject* CreateText(); + std::unique_ptr CreateText(); OUString GetText(); SdDrawDocument* GetDoc() { return m_xImpl->mpDoc; } }; @@ -150,7 +150,7 @@ void TextApiObject::dispose() } -OutlinerParaObject* TextApiObject::CreateText() +std::unique_ptr TextApiObject::CreateText() { return mpSource->CreateText(); } @@ -247,7 +247,7 @@ void TextAPIEditSource::SetText( OutlinerParaObject const & rText ) } } -OutlinerParaObject* TextAPIEditSource::CreateText() +std::unique_ptr TextAPIEditSource::CreateText() { if (m_xImpl->mpDoc && m_xImpl->mpOutliner) return m_xImpl->mpOutliner->CreateParaObject(); diff --git a/sd/source/filter/xml/sdtransform.cxx b/sd/source/filter/xml/sdtransform.cxx index f496e353be0e..ca1bfb12bbb8 100644 --- a/sd/source/filter/xml/sdtransform.cxx +++ b/sd/source/filter/xml/sdtransform.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index ddeb44fc778c..cd7d5e86abd7 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx index 186728414c66..aefa5b680a64 100644 --- a/sd/source/ui/annotations/annotationwindow.cxx +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -606,14 +606,14 @@ void AnnotationWindow::Deactivate() if( pTextApi ) { - OutlinerParaObject* pOPO = Engine()->CreateParaObject(); + std::unique_ptr pOPO = Engine()->CreateParaObject(); if( pOPO ) { if( mpDoc->IsUndoEnabled() ) mpDoc->BegUndo( SdResId( STR_ANNOTATION_UNDO_EDIT ) ); pTextApi->SetText( *pOPO ); - delete pOPO; + pOPO.reset(); // set current time to changed annotation xAnnotation->setDateTime( getCurrentDateTime() ); diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx index 0963fb1023c0..f876f3d54221 100644 --- a/sd/source/ui/dlg/headerfooterdlg.cxx +++ b/sd/source/ui/dlg/headerfooterdlg.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index 975b9af9dd56..54efa8178a26 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -590,8 +591,8 @@ bool DrawDocShell::SaveAs( SfxMedium& rMedium ) SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner(); if( pObj && pOutl && pOutl->IsModified() ) { - OutlinerParaObject* pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() ); - pObj->SetOutlinerParaObject( pNewText ); + std::unique_ptr pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() ); + pObj->SetOutlinerParaObject( std::move(pNewText) ); pOutl->ClearModifyFlag(); } } diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx index c0b54ec139b4..8406faf30000 100644 --- a/sd/source/ui/func/fuexpand.cxx +++ b/sd/source/ui/func/fuexpand.cxx @@ -185,7 +185,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) if (!pTextObj) continue; - OutlinerParaObject* pOutlinerParaObject = pOutl->CreateParaObject( nParaPos, 1); + std::unique_ptr pOutlinerParaObject = pOutl->CreateParaObject( nParaPos, 1); pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject); if( pOutlinerParaObject->GetDepth(0) != -1 ) @@ -194,14 +194,14 @@ void FuExpandPage::DoExecute( SfxRequest& ) pTempOutl->SetText( *pOutlinerParaObject ); - delete pOutlinerParaObject; + pOutlinerParaObject.reset(); pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 ); pOutlinerParaObject = pTempOutl->CreateParaObject(); } - pTextObj->SetOutlinerParaObject(pOutlinerParaObject); + pTextObj->SetOutlinerParaObject(std::move(pOutlinerParaObject)); pTextObj->SetEmptyPresObj(false); @@ -215,7 +215,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) if (pOutlineObj) { // create structuring text objects - OutlinerParaObject* pOPO = pOutl->CreateParaObject(++nParaPos, nChildCount); + std::unique_ptr pOPO = pOutl->CreateParaObject(++nParaPos, nChildCount); std::unique_ptr pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); pTempOutl->SetText( *pOPO ); @@ -229,11 +229,10 @@ void FuExpandPage::DoExecute( SfxRequest& ) pTempOutl->GetDepth( nPara ) - 1); } - delete pOPO; pOPO = pTempOutl->CreateParaObject(); pTempOutl.reset(); - pOutlineObj->SetOutlinerParaObject( pOPO ); + pOutlineObj->SetOutlinerParaObject( std::move(pOPO) ); pOutlineObj->SetEmptyPresObj(false); // remove hard attributes (Flag to sal_True) diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index 8743db87416e..2ba29aa2e041 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index f57a8556137a..a71502a61b45 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -493,19 +493,18 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) } } - OutlinerParaObject* pOPO = pOutliner->CreateParaObject(); + std::unique_ptr pOPO = pOutliner->CreateParaObject(); if (pOutlinerView) { pOutlinerView->InsertText(*pOPO); - delete pOPO; } else { SdrRectObj* pTO = new SdrRectObj( mpView->getSdrModelFromSdrView(), OBJ_TEXT); - pTO->SetOutlinerParaObject(pOPO); + pTO->SetOutlinerParaObject(std::move(pOPO)); const bool bUndo = mpView->IsUndoEnabled(); if( bUndo ) diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx index 92e7ed2d488d..45fd78f522a3 100644 --- a/sd/source/ui/func/fumorph.cxx +++ b/sd/source/ui/func/fumorph.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 8d5b591de045..d380d2e55bef 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -553,10 +553,9 @@ void SlotManager::GetMenuState (SfxItemSet& rSet) SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); if( pTextObj ) { - OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject(); + std::unique_ptr pParaObj = pTextObj->GetEditOutlinerParaObject(); if( pParaObj ) { - delete pParaObj; bDisable = false; } } diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index 184b22be9151..6c69c5e266fa 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1066,7 +1066,7 @@ namespace { { public: OutlinerPrinterPage ( - OutlinerParaObject* pParaObject, + std::unique_ptr pParaObject, const MapMode& rMapMode, const OUString& rsPageString, const Point& rPageStringOffset, @@ -1075,15 +1075,10 @@ namespace { const sal_uInt16 nPaperTray) : PrinterPage(PageKind::Handout, rMapMode, false, rsPageString, rPageStringOffset, nDrawMode, eOrientation, nPaperTray), - mpParaObject(pParaObject) + mpParaObject(std::move(pParaObject)) { } - virtual ~OutlinerPrinterPage() override - { - mpParaObject.reset(); - } - virtual void Print ( Printer& rPrinter, SdDrawDocument& rDocument, diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index c7bd428a3a10..af5b57298246 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2338,7 +2338,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) OutlinerMode nOutlMode = pOutl->GetMode(); pOutl->SetStyleSheet( 0, nullptr ); pOutl->QuickInsertField( *pFieldItem, ESelection() ); - OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject(); + std::unique_ptr pOutlParaObject = pOutl->CreateParaObject(); SdrRectObj* pRectObj = new SdrRectObj( *GetDoc(), @@ -2360,7 +2360,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) ::tools::Rectangle aLogicRect(aPos, aSize); pRectObj->SetLogicRect(aLogicRect); - pRectObj->SetOutlinerParaObject( pOutlParaObject ); + pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) ); mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView()); pOutl->Init( nOutlMode ); } diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 33fdf1edf914..a6634821ad7c 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -379,10 +379,9 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); if( pTextObj ) { - OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject(); + std::unique_ptr pParaObj = pTextObj->GetEditOutlinerParaObject(); if( pParaObj ) { - delete pParaObj; bDisable = false; } } diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx index ca2128ccd556..d21a3ad1eaa1 100644 --- a/sd/source/ui/view/drviews8.cxx +++ b/sd/source/ui/view/drviews8.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx index b253e25098ec..c6db972461c7 100644 --- a/sd/source/ui/view/drviews9.cxx +++ b/sd/source/ui/view/drviews9.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 0792f0cc281a..eaf4612ef6b9 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1456,7 +1457,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText, aURLField.SetTargetFrame(rTarget); SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD); pOutl->QuickInsertField( aURLItem, ESelection() ); - OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject(); + std::unique_ptr pOutlParaObject = pOutl->CreateParaObject(); SdrRectObj* pRectObj = new SdrRectObj( GetView()->getSdrModelFromSdrView(), @@ -1476,7 +1477,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText, ::tools::Rectangle aLogicRect(aPos, aSize); pRectObj->SetLogicRect(aLogicRect); - pRectObj->SetOutlinerParaObject( pOutlParaObject ); + pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) ); mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView()); pOutl->Init( nOutlMode ); } diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 2434813299e6..e8de41e29cb1 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -971,10 +971,9 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); if( pTextObj ) { - OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject(); + std::unique_ptr pParaObj = pTextObj->GetEditOutlinerParaObject(); if( pParaObj ) { - delete pParaObj; bDisable = false; } } @@ -1593,7 +1592,9 @@ void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara } // if we have a title object and a text, set the text - OutlinerParaObject* pOPO = pTO ? rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1) : nullptr; + std::unique_ptr pOPO; + if (pTO) + pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1); if (pOPO) { pOPO->SetOutlinerMode( OutlinerMode::TitleObject ); @@ -1601,7 +1602,6 @@ void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) ) { // do nothing, same text already set - delete pOPO; } else { @@ -1609,7 +1609,7 @@ void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara if( !bNewObject && pOlView->isRecordingUndo() ) pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); - pTO->SetOutlinerParaObject( pOPO ); + pTO->SetOutlinerParaObject( std::move(pOPO) ); pTO->SetEmptyPresObj( false ); pTO->ActionChanged(); } @@ -1654,7 +1654,7 @@ void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara ) return; ::Outliner& rOutliner = pOlView->GetOutliner(); - OutlinerParaObject* pOPO = nullptr; + std::unique_ptr pOPO; SdrTextObj* pTO = nullptr; bool bNewObject = false; @@ -1703,20 +1703,17 @@ void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara ) if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) ) { // do nothing, same text already set - delete pOPO; } else { if( !bNewObject && pOlView->isRecordingUndo() ) pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); - pTO->SetOutlinerParaObject( pOPO ); + pTO->SetOutlinerParaObject( std::move(pOPO) ); pTO->SetEmptyPresObj( false ); pTO->ActionChanged(); } } - else - delete pOPO; } else if( pTO ) { diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 1d04b5ecc3c1..534a484ce810 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -1339,11 +1339,10 @@ SvtScriptType OutlineView::GetScriptType() const { SvtScriptType nScriptType = ::sd::View::GetScriptType(); - OutlinerParaObject* pTempOPObj = mrOutliner.CreateParaObject(); + std::unique_ptr pTempOPObj = mrOutliner.CreateParaObject(); if(pTempOPObj) { nScriptType = pTempOPObj->GetTextObject().GetScriptType(); - delete pTempOPObj; } return nScriptType; diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index d03cc9dfede4..ca98672ef38c 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index fa9a48ea1a2c..61671f11d991 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 2b45314c419a..885422b508c5 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx index 19d9c2fed299..728871ed827a 100644 --- a/svx/source/accessibility/AccessibleShape.cxx +++ b/svx/source/accessibility/AccessibleShape.cxx @@ -161,7 +161,7 @@ void AccessibleShape::Init() OutlinerParaObject* pOutlinerParaObject = nullptr; if( pTextObj ) - pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active + pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject().release(); // Get the OutlinerParaObject if text edit is active bool bOwnParaObj = pOutlinerParaObject != nullptr; diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 2a62c0ac1daf..39d1f83cde8c 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -53,6 +53,7 @@ #include #include #include +#include using namespace css; using namespace css::uno; @@ -194,7 +195,7 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject()); if( pParaObj ) - pTextObj->NbcSetOutlinerParaObject( new OutlinerParaObject(*pParaObj) ); + pTextObj->NbcSetOutlinerParaObject( o3tl::make_unique(*pParaObj) ); // copy all attributes SfxItemSet aTargetItemSet(rSdrObjCustomShape.GetMergedItemSet()); diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx index 2f9a9dfec8c7..82428de96fe5 100644 --- a/svx/source/inc/cell.hxx +++ b/svx/source/inc/cell.hxx @@ -71,7 +71,7 @@ public: SVX_DLLPRIVATE const ::tools::Rectangle& getCellRect() const { return maCellRect; } SVX_DLLPRIVATE ::tools::Rectangle& getCellRect() { return maCellRect; } - OutlinerParaObject* GetEditOutlinerParaObject() const; + std::unique_ptr GetEditOutlinerParaObject() const; SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr ); SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const override; SVX_DLLPRIVATE void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const; @@ -168,7 +168,7 @@ public: // XEventListener SVX_DLLPRIVATE virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - SVX_DLLPRIVATE virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject ) override; + SVX_DLLPRIVATE virtual void SetOutlinerParaObject( std::unique_ptr pTextObject ) override; SVX_DLLPRIVATE void AddUndo(); diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 452971758bbc..4ee872eb681e 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -545,12 +545,11 @@ namespace drawinglayer if(bInEditMode) { - OutlinerParaObject* pTempObj = rTextObj.GetEditOutlinerParaObject(); + std::unique_ptr pTempObj = rTextObj.GetEditOutlinerParaObject(); if(pTempObj) { aOutlinerParaObject = *pTempObj; - delete pTempObj; } else { diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 503872cb4ba6..1ca04d65a628 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -128,10 +128,10 @@ namespace sdr mpItemSet->Put(aNewSet); } - OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = pOutliner->CreateParaObject(0, nParaCount); pOutliner->Clear(); - rObj.NbcSetOutlinerParaObjectForText(pTemp,pText); + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText); } } } @@ -187,10 +187,10 @@ namespace sdr ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL); rOutliner.RemoveAttribs(aSelection, true, 0); - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); rOutliner.Clear(); - rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); + rObj.NbcSetOutlinerParaObjectForText( std::move(pTemp), pText ); } } } @@ -338,9 +338,9 @@ namespace sdr delete pTempSet; } - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); rOutliner.Clear(); - rObj.NbcSetOutlinerParaObjectForText(pTemp, pText); + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); } } } @@ -518,8 +518,8 @@ namespace sdr if(bBurnIn) { - OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount); - rObj.NbcSetOutlinerParaObjectForText(pTemp,pText); + std::unique_ptr pTemp = pOutliner->CreateParaObject(0, nParaCount); + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText); } } diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index 18c4ebf0ca03..85ca2a280b08 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -41,8 +41,10 @@ #include #include #include +#include #include #include + using ::std::vector; using namespace com::sun::star; @@ -1573,7 +1575,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, if(pLast && pSrcPath->GetOutlinerParaObject()) { - pLast->SetOutlinerParaObject(new OutlinerParaObject(*pSrcPath->GetOutlinerParaObject())); + pLast->SetOutlinerParaObject(o3tl::make_unique(*pSrcPath->GetOutlinerParaObject())); } } else if(pCustomShape) @@ -1613,7 +1615,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject(); if(pParaObj) { - pTextObj->NbcSetOutlinerParaObject(new OutlinerParaObject(*pParaObj)); + pTextObj->NbcSetOutlinerParaObject(o3tl::make_unique(*pParaObj)); } // copy all attributes diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index ff40fc85c5a9..2003ecf667b6 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -2624,10 +2624,10 @@ void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet const & rFormatSet, rOutliner.SetParaAttribs(nPara, aSet); } - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); rOutliner.Clear(); - rTextObj.NbcSetOutlinerParaObjectForText(pTemp,pText); + rTextObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText); } } } diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 23308b4eaf40..3ff61483d2b3 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2634,7 +2634,7 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& // put text into the Outliner - if necessary the use the text from the EditOutliner OutlinerParaObject* pPara= GetOutlinerParaObject(); if (pEdtOutl && !bNoEditText) - pPara=pEdtOutl->CreateParaObject(); + pPara=pEdtOutl->CreateParaObject().release(); if (pPara) { @@ -2728,9 +2728,9 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect=tools::Rectangle(aTextPos,aTextSiz); } -void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) +void SdrObjCustomShape::NbcSetOutlinerParaObject(std::unique_ptr pTextObject) { - SdrTextObj::NbcSetOutlinerParaObject( pTextObject ); + SdrTextObj::NbcSetOutlinerParaObject( std::move(pTextObject) ); SetBoundRectDirty(); SetRectsDirty(true); InvalidateRenderGeometry(); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index f936e8c4bf3b..663c4b07083a 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1735,10 +1735,10 @@ void SdrObject::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterEndElement(pWriter); } -void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject) +void SdrObject::SetOutlinerParaObject(std::unique_ptr pTextObject) { tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - NbcSetOutlinerParaObject(pTextObject); + NbcSetOutlinerParaObject(std::move(pTextObject)); SetChanged(); BroadcastObjectChange(); if (GetCurrentBoundRect()!=aBoundRect0) { @@ -1746,7 +1746,7 @@ void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject) } } -void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/) +void SdrObject::NbcSetOutlinerParaObject(std::unique_ptr /*pTextObject*/) { } diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 53aa58ba4f06..b0738696d733 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -1285,9 +1285,9 @@ OutlinerParaObject* SdrMeasureObj::GetOutlinerParaObject() const return SdrTextObj::GetOutlinerParaObject(); } -void SdrMeasureObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) +void SdrMeasureObj::NbcSetOutlinerParaObject(std::unique_ptr pTextObject) { - SdrTextObj::NbcSetOutlinerParaObject(pTextObject); + SdrTextObj::NbcSetOutlinerParaObject(std::move(pTextObject)); if(SdrTextObj::GetOutlinerParaObject()) SetTextDirty(); // recalculate text } diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 40ea2dbb7f3b..feb7caf6700c 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -85,6 +85,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -1195,7 +1196,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const if(pOPO) { - pClone->NbcSetOutlinerParaObject(new OutlinerParaObject(*pOPO)); + pClone->NbcSetOutlinerParaObject(o3tl::make_unique(*pOPO)); } } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 41bd67eb19d5..1e6780866101 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -206,10 +206,10 @@ void SdrTextObj::NbcSetText(const OUString& rStr) rOutliner.SetStyleSheet( 0, GetStyleSheet()); rOutliner.SetUpdateMode(true); rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 )); - OutlinerParaObject* pNewText=rOutliner.CreateParaObject(); + std::unique_ptr pNewText=rOutliner.CreateParaObject(); Size aSiz(rOutliner.CalcTextSize()); rOutliner.Clear(); - NbcSetOutlinerParaObject(pNewText); + NbcSetOutlinerParaObject(std::move(pNewText)); aTextSize=aSiz; bTextSizeDirty=false; } @@ -228,11 +228,11 @@ void SdrTextObj::NbcSetText(SvStream& rInput, const OUString& rBaseURL, EETextFo SdrOutliner& rOutliner=ImpGetDrawOutliner(); rOutliner.SetStyleSheet( 0, GetStyleSheet()); rOutliner.Read(rInput,rBaseURL,eFormat); - OutlinerParaObject* pNewText=rOutliner.CreateParaObject(); + std::unique_ptr pNewText=rOutliner.CreateParaObject(); rOutliner.SetUpdateMode(true); Size aSiz(rOutliner.CalcTextSize()); rOutliner.Clear(); - NbcSetOutlinerParaObject(pNewText); + NbcSetOutlinerParaObject(std::move(pNewText)); aTextSize=aSiz; bTextSizeDirty=false; } @@ -711,7 +711,7 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe // put text into the outliner, if available from the edit outliner SdrText* pText = getActiveText(); OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : nullptr; - OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject() : pOutlinerParaObject; + OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject().release() : pOutlinerParaObject; if (pPara) { @@ -802,9 +802,9 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe rTextRect=aAnkRect; } -OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const +std::unique_ptr SdrTextObj::GetEditOutlinerParaObject() const { - OutlinerParaObject* pPara=nullptr; + std::unique_ptr pPara; if( HasTextImpl( pEdtOutl ) ) { sal_Int32 nParaCount = pEdtOutl->GetParagraphCount(); @@ -1041,7 +1041,7 @@ SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj) // objects). In the current form it makes only sense to // create locally and use locally on a known existing SdrText const Outliner* pEO=rObj.pEdtOutl; - OutlinerParaObject* pNewOutlinerParaObject = nullptr; + std::unique_ptr pNewOutlinerParaObject; if (pEO!=nullptr) { @@ -1049,10 +1049,10 @@ SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj) } else { - pNewOutlinerParaObject = new OutlinerParaObject(*rObj.getActiveText()->GetOutlinerParaObject()); + pNewOutlinerParaObject.reset( new OutlinerParaObject(*rObj.getActiveText()->GetOutlinerParaObject()) ); } - pText->SetOutlinerParaObject( pNewOutlinerParaObject ); + pText->SetOutlinerParaObject( std::move(pNewOutlinerParaObject) ); } ImpSetTextStyleSheetListeners(); @@ -1394,15 +1394,15 @@ OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const return nullptr; } -void SdrTextObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) +void SdrTextObj::NbcSetOutlinerParaObject(std::unique_ptr pTextObject) { - NbcSetOutlinerParaObjectForText( pTextObject, getActiveText() ); + NbcSetOutlinerParaObjectForText( std::move(pTextObject), getActiveText() ); } -void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText ) +void SdrTextObj::NbcSetOutlinerParaObjectForText( std::unique_ptr pTextObject, SdrText* pText ) { if( pText ) - pText->SetOutlinerParaObject( pTextObject ); + pText->SetOutlinerParaObject( std::move(pTextObject) ); if (pText && pText->GetOutlinerParaObject()) { diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx index a28a5a698a3c..7a3490e3722d 100644 --- a/svx/source/svdraw/svdotxat.cxx +++ b/svx/source/svdraw/svdotxat.cxx @@ -420,9 +420,9 @@ void SdrTextObj::RemoveOutlinerCharacterAttribs( const std::vector& if(!pEdtOutl || (pText != getActiveText()) ) { const sal_Int32 nParaCount = pOutliner->GetParagraphCount(); - OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = pOutliner->CreateParaObject(0, nParaCount); pOutliner->Clear(); - NbcSetOutlinerParaObjectForText(pTemp, pText); + NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); } } } diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index bb3e60d9291b..172ebff4e6a0 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -270,8 +270,7 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) // to make the gray field background vanish again rOutl.UpdateFields(); - bool bNewTextTransferred = false; - OutlinerParaObject* pNewText = rOutl.CreateParaObject( 0, rOutl.GetParagraphCount() ); + std::unique_ptr pNewText = rOutl.CreateParaObject( 0, rOutl.GetParagraphCount() ); // need to end edit mode early since SetOutlinerParaObject already // uses GetCurrentBoundRect() which needs to take the text into account @@ -283,16 +282,11 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) GetTextChain()->SetSwitchingToNextBox(this, false); if( getActiveText() ) { - getActiveText()->SetOutlinerParaObject( pNewText); - bNewTextTransferred = true; + getActiveText()->SetOutlinerParaObject( std::move(pNewText) ); } } else { // If we are not doing in-chaining switching just set the ParaObject - SetOutlinerParaObject(pNewText); - bNewTextTransferred = true; + SetOutlinerParaObject(std::move(pNewText)); } - - if (!bNewTextTransferred) - delete pNewText; } /* Chaining-related code */ diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx index 549578832885..dfbcc0daab7a 100644 --- a/svx/source/svdraw/svdtext.cxx +++ b/svx/source/svdraw/svdtext.cxx @@ -56,7 +56,7 @@ void SdrText::CheckPortionInfo( SdrOutliner& rOutliner ) if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject()) { // #i102062# MemoryLeak closed - mpOutlinerParaObject.reset( rOutliner.CreateParaObject() ); + mpOutlinerParaObject = rOutliner.CreateParaObject(); } } } @@ -72,21 +72,20 @@ const SfxItemSet& SdrText::GetItemSet() const return const_cast< SdrText* >(this)->GetObjectItemSet(); } -void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject ) +void SdrText::SetOutlinerParaObject( std::unique_ptr pTextObject ) { - if( mpOutlinerParaObject.get() != pTextObject ) - { - // Update HitTestOutliner - const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj()); + assert ( !mpOutlinerParaObject || (mpOutlinerParaObject.get() != pTextObject.get()) ); - if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get()) - { - mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr); - } + // Update HitTestOutliner + const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj()); - mpOutlinerParaObject.reset(pTextObject); - mbPortionInfoChecked = false; + if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get()) + { + mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr); } + + mpOutlinerParaObject = std::move(pTextObject); + mbPortionInfoChecked = false; } OutlinerParaObject* SdrText::GetOutlinerParaObject() const @@ -125,8 +124,7 @@ void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode ) Outliner& aDrawOutliner(mrObject.getSdrModelFromSdrObject().GetDrawOutliner()); pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() ); pOutliner->SetStyleSheet( 0, GetStyleSheet()); - OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject(); - SetOutlinerParaObject( pOutlinerParaObject ); + SetOutlinerParaObject( pOutliner->CreateParaObject() ); } } } diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 9741dd1ab5c3..cb5e6d3e2bbe 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -46,6 +46,7 @@ #include // #i124389# #include #include +#include // iterates over all views and unmarks this SdrObject if it is marked @@ -404,7 +405,7 @@ void SdrUndoAttrObj::Undo() if(pTextUndo) { - pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo)); + pObj->SetOutlinerParaObject(o3tl::make_unique(*pTextUndo)); } } @@ -482,7 +483,7 @@ void SdrUndoAttrObj::Redo() // #i8508# if(pTextRedo) { - pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo)); + pObj->SetOutlinerParaObject(o3tl::make_unique(*pTextRedo)); } } @@ -1071,9 +1072,8 @@ void SdrUndoObjSetText::Undo() if (pText) { // copy text for Undo, because the original now belongs to SetOutlinerParaObject() - OutlinerParaObject* pText1 = pOldText ? new OutlinerParaObject(*pOldText) : nullptr; - pText->SetOutlinerParaObject(pText1); - pTarget->NbcSetOutlinerParaObjectForText(pText1, pText); + std::unique_ptr pText1( pOldText ? new OutlinerParaObject(*pOldText) : nullptr ); + pTarget->NbcSetOutlinerParaObjectForText(std::move(pText1), pText); } pTarget->SetEmptyPresObj(bEmptyPresObj); @@ -1106,8 +1106,8 @@ void SdrUndoObjSetText::Redo() if (pText) { // copy text for Undo, because the original now belongs to SetOutlinerParaObject() - OutlinerParaObject* pText1 = pNewText ? new OutlinerParaObject(*pNewText) : nullptr; - pTarget->NbcSetOutlinerParaObjectForText( pText1, pText ); + std::unique_ptr pText1( pNewText ? new OutlinerParaObject(*pNewText) : nullptr ); + pTarget->NbcSetOutlinerParaObjectForText( std::move(pText1), pText ); } pTarget->ActionChanged(); @@ -1165,10 +1165,10 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView) if( bUndo ) rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0)); - OutlinerParaObject* pText1=pNewText.get(); - if (pText1!=nullptr) - pText1 = new OutlinerParaObject(*pText1); - pTextObj->SetOutlinerParaObject(pText1); + std::unique_ptr pText1; + if (pNewText) + pText1.reset(new OutlinerParaObject(*pNewText)); + pTextObj->SetOutlinerParaObject(std::move(pText1)); } } diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx index 5cce8877e098..b3d473923633 100644 --- a/svx/source/svdraw/textchainflow.cxx +++ b/svx/source/svdraw/textchainflow.cxx @@ -154,9 +154,8 @@ void TextChainFlow::ExecuteUnderflow(SdrOutliner *pOutl) { //GetTextChain()->SetNilChainingEvent(mpTargetLink, true); // making whole text - bool bNewTextTransferred = false; // merges underflowing text with the one in the next box - OutlinerParaObject *pNewText = mpUnderflChText->CreateMergedUnderflowParaObject(pOutl, mpNextLink->GetOutlinerParaObject()); + std::unique_ptr pNewText = mpUnderflChText->CreateMergedUnderflowParaObject(pOutl, mpNextLink->GetOutlinerParaObject()); // Set the other box empty; it will be replaced by the rest of the text if overflow occurs if (!mpTargetLink->GetPreventChainable()) @@ -165,20 +164,18 @@ void TextChainFlow::ExecuteUnderflow(SdrOutliner *pOutl) // We store the size since NbcSetOutlinerParaObject can change it //Size aOldSize = pOutl->GetMaxAutoPaperSize(); + auto pNewTextTemp = pNewText.get(); // because we need to access it after a std::move // This should not be done in editing mode!! //XXX if (!mpTargetLink->IsInEditMode()) { - mpTargetLink->NbcSetOutlinerParaObject(pNewText); - bNewTextTransferred = true; + mpTargetLink->NbcSetOutlinerParaObject(std::move(pNewText)); } // Restore size and set new text //pOutl->SetMaxAutoPaperSize(aOldSize); // XXX (it seems to be working anyway without this) - pOutl->SetText(*pNewText); + pOutl->SetText(*pNewTextTemp); //GetTextChain()->SetNilChainingEvent(mpTargetLink, false); - if (!bNewTextTransferred) - delete pNewText; // Check for new overflow CheckForFlowEvents(pOutl); @@ -201,7 +198,7 @@ void TextChainFlow::ExecuteOverflow(SdrOutliner *pNonOverflOutl, SdrOutliner *pO void TextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl) { - OutlinerParaObject *pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl); + std::unique_ptr pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl); SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] SOURCE box set to " << pNewText->GetTextObject().GetParagraphCount() << " paras"); @@ -209,7 +206,7 @@ void TextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl) // adds it to current outliner anyway (useful in static decomposition) pNonOverflOutl->SetText(*pNewText); - mpTargetLink->NbcSetOutlinerParaObject(pNewText); + mpTargetLink->NbcSetOutlinerParaObject(std::move(pNewText)); // For some reason the paper size is lost after last instruction, so we set it. pNonOverflOutl->SetPaperSize(Size(pNonOverflOutl->GetPaperSize().Width(), pNonOverflOutl->GetTextHeight())); @@ -224,14 +221,14 @@ void TextChainFlow::impMoveChainedTextToNextLink(SdrOutliner *pOverflOutl) return; } - OutlinerParaObject *pNewText = + std::unique_ptr pNewText = mpOverflChText->InsertOverflowingText(pOverflOutl, mpNextLink->GetOutlinerParaObject()); SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] DEST box set to " << pNewText->GetTextObject().GetParagraphCount() << " paras"); if (pNewText) - mpNextLink->NbcSetOutlinerParaObject(pNewText); + mpNextLink->NbcSetOutlinerParaObject(std::move(pNewText)); // Set Deep Merge status SAL_INFO("svx.chaining", "[DEEPMERGE] Setting deepMerge to " @@ -273,8 +270,7 @@ void EditingTextChainFlow::CheckForFlowEvents(SdrOutliner *pFlowOutl) void EditingTextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl) { - OutlinerParaObject *pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl); - delete pNewText; + std::unique_ptr pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl); //impSetTextForEditingOutliner(pNewText); //XXX: Don't call it since we do everything with NonOverflowingText::ToParaObject // XXX: You may need this for Underflow // XXX: I'm not sure whether we need this (after all operations such as Paste don't change this - as far as I understand) diff --git a/svx/source/table/accessiblecell.cxx b/svx/source/table/accessiblecell.cxx index 75eba41d2d43..d2aa8fd866d4 100644 --- a/svx/source/table/accessiblecell.cxx +++ b/svx/source/table/accessiblecell.cxx @@ -71,7 +71,7 @@ void AccessibleCell::Init() const vcl::Window* pWindow = maShapeTreeInfo.GetWindow (); if( (pView != nullptr) && (pWindow != nullptr) && mxCell.is()) { - OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active + OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject().release(); // Get the OutlinerParaObject if text edit is active bool bOwnParaObject = pOutlinerParaObject != nullptr; diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index ecd8666a4222..2e2f5fad140f 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -226,7 +226,7 @@ namespace sdr if( mxCell.is() ) { - OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject(); + OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject().release(); const bool bOwnParaObj = pParaObj != nullptr; @@ -279,9 +279,9 @@ namespace sdr mpItemSet->Put(aNewSet); } - OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = pOutliner->CreateParaObject(0, nParaCount); pOutliner->Clear(); - mxCell->SetOutlinerParaObject(pTemp); + mxCell->SetOutlinerParaObject(std::move(pTemp)); } if( bOwnParaObj ) @@ -306,7 +306,7 @@ namespace sdr rObj.SetVerticalWriting(bVertical); // Set a cell vertical property - OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject(); + OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject().release(); const bool bOwnParaObj = pParaObj != nullptr; @@ -327,7 +327,7 @@ namespace sdr const SvxTextRotateItem* pRotateItem = static_cast(pNewItem); // Set a cell vertical property - OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject(); + OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject().release(); const bool bOwnParaObj = pParaObj != nullptr; @@ -509,7 +509,7 @@ void Cell::replaceContentAndFormating( const CellRef& xSourceCell ) if( xSourceCell.is() && mpProperties ) { mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); - SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) ); + SetOutlinerParaObject( o3tl::make_unique(*xSourceCell->GetOutlinerParaObject()) ); SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); @@ -579,11 +579,10 @@ bool Cell::IsTextEditActive() SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); if(rTableObj.getActiveCell().get() == this ) { - OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject(); + std::unique_ptr pParaObj = rTableObj.GetEditOutlinerParaObject(); if( pParaObj != nullptr ) { isActive = true; - delete pParaObj; } } return isActive; @@ -611,7 +610,7 @@ bool Cell::hasText() const } -OutlinerParaObject* Cell::GetEditOutlinerParaObject() const +std::unique_ptr Cell::GetEditOutlinerParaObject() const { SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); if( rTableObj.getActiveCell().get() == this ) @@ -774,9 +773,9 @@ SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const } -void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject ) +void Cell::SetOutlinerParaObject( std::unique_ptr pTextObject ) { - SdrText::SetOutlinerParaObject( pTextObject ); + SdrText::SetOutlinerParaObject( std::move(pTextObject) ); maSelection.nStartPara = EE_PARA_MAX_COUNT; if( pTextObject == nullptr ) @@ -1572,10 +1571,10 @@ void SAL_CALL Cell::setAllPropertiesToDefault() ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL); rOutliner.RemoveAttribs(aSelection, true, 0); - OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, nParaCount); + std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); rOutliner.Clear(); - SetOutlinerParaObject(pTemp); + SetOutlinerParaObject(std::move(pTemp)); } } } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index f376c52b521e..6a7dcd3f3427 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1501,7 +1501,7 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too // set text at outliner, maybe from edit outliner OutlinerParaObject* pPara= xCell->GetOutlinerParaObject(); if (pEdtOutl && !bNoEditText && mpImpl->mxActiveCell == xCell ) - pPara=pEdtOutl->CreateParaObject(); + pPara=pEdtOutl->CreateParaObject().release(); if (pPara) { @@ -1863,7 +1863,7 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl) if(rOutl.IsModified()) { - OutlinerParaObject* pNewText = nullptr; + std::unique_ptr pNewText; Paragraph* p1stPara = rOutl.GetParagraph( 0 ); sal_Int32 nParaCnt = rOutl.GetParagraphCount(); @@ -1875,7 +1875,7 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl) // create new text object pNewText = rOutl.CreateParaObject( 0, nParaCnt ); } - SetOutlinerParaObject(pNewText); + SetOutlinerParaObject(std::move(pNewText)); } pEdtOutl = nullptr; @@ -1898,7 +1898,7 @@ OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() const } -void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject) +void SdrTableObj::NbcSetOutlinerParaObject( std::unique_ptr pTextObject) { CellRef xCell( getActiveCell() ); if( xCell.is() ) @@ -1911,7 +1911,7 @@ void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject) getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr); } - xCell->SetOutlinerParaObject( pTextObject ); + xCell->SetOutlinerParaObject( std::move(pTextObject) ); SetTextSizeDirty(); NbcAdjustTextFrameWidthAndHeight(); } diff --git a/svx/source/table/tablertfexporter.cxx b/svx/source/table/tablertfexporter.cxx index 37d793de6df3..1cfaa372da6a 100644 --- a/svx/source/table/tablertfexporter.cxx +++ b/svx/source/table/tablertfexporter.cxx @@ -174,7 +174,7 @@ void SdrTableRtfExporter::WriteCell( sal_Int32 nCol, sal_Int32 nRow ) OUString aContent; - OutlinerParaObject* pParaObj = xCell->GetEditOutlinerParaObject(); + OutlinerParaObject* pParaObj = xCell->GetEditOutlinerParaObject().release(); bool bOwnParaObj = pParaObj != nullptr; if( pParaObj == nullptr ) diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 913d8d1f716d..1f444ae0f660 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -20,6 +20,7 @@ #include #include +#include #include #include "tableundo.hxx" @@ -107,7 +108,7 @@ void CellUndo::setDataToCell( const Data& rData ) mxCell->mpProperties.reset(); if( rData.mpOutlinerParaObject ) - mxCell->SetOutlinerParaObject( new OutlinerParaObject(*rData.mpOutlinerParaObject) ); + mxCell->SetOutlinerParaObject( o3tl::make_unique(*rData.mpOutlinerParaObject) ); else mxCell->RemoveOutlinerParaObject(); diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index af313e15731e..466f564602e1 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -547,7 +547,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder() OutlinerParaObject* pOutlinerParaObject = nullptr; SdrTextObj* pTextObj = dynamic_cast( mpObject ); if( pTextObj && pTextObj->getActiveText() == mpText ) - pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active + pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject().release(); // Get the OutlinerParaObject if text edit is active bool bOwnParaObj(false); if( pOutlinerParaObject ) @@ -563,7 +563,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder() if( mpText && bOwnParaObj && mpObject->IsEmptyPresObj() && pTextObj->IsReallyEdited() ) { mpObject->SetEmptyPresObj( false ); - static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( pOutlinerParaObject, mpText ); + static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( std::unique_ptr(pOutlinerParaObject), mpText ); // #i103982# Here, due to mpObject->NbcSetOutlinerParaObjectForText, we LOSE ownership of the // OPO, so do NOT delete it when leaving this method (!) diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 051c5f06b457..0ff19e5a82e0 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include diff --git a/sw/source/core/fields/textapi.cxx b/sw/source/core/fields/textapi.cxx index 89c248eb06cb..605b3d06e885 100644 --- a/sw/source/core/fields/textapi.cxx +++ b/sw/source/core/fields/textapi.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -168,7 +169,7 @@ void SwTextAPIEditSource::SetString( const OUString& rText ) } } -OutlinerParaObject* SwTextAPIEditSource::CreateText() +std::unique_ptr SwTextAPIEditSource::CreateText() { if ( pImpl->mpPool && pImpl->mpOutliner ) return pImpl->mpOutliner->CreateParaObject(); diff --git a/sw/source/core/inc/textapi.hxx b/sw/source/core/inc/textapi.hxx index 02a138fc764f..4c03c8dc62f3 100644 --- a/sw/source/core/inc/textapi.hxx +++ b/sw/source/core/inc/textapi.hxx @@ -47,7 +47,7 @@ public: void Dispose(); void SetText( OutlinerParaObject const & rText ); void SetString( const OUString& rText ); - OutlinerParaObject* CreateText(); + std::unique_ptr CreateText(); OUString GetText(); }; @@ -58,7 +58,7 @@ public: SwTextAPIObject( SwTextAPIEditSource* p); virtual ~SwTextAPIObject() throw() override; void DisposeEditSource() { pSource->Dispose(); } - OutlinerParaObject* CreateText() { return pSource->CreateText(); } + std::unique_ptr CreateText() { return pSource->CreateText(); } void SetString( const OUString& rText ) { pSource->SetString( rText ); } void SetText( OutlinerParaObject const & rText ) { pSource->SetText( rText ); } OUString GetText() { return pSource->GetText(); } diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 74a2f6201e4b..af697e9b9030 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 97bfb73358b9..a758f6523295 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -97,6 +97,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -1354,7 +1355,7 @@ void SAL_CALL SwXTextField::attach( aDateTime ); if ( m_pImpl->m_xTextObject.is() ) { - pPostItField->SetTextObject( std::unique_ptr(m_pImpl->m_xTextObject->CreateText()) ); + pPostItField->SetTextObject( m_pImpl->m_xTextObject->CreateText() ); pPostItField->SetPar2(m_pImpl->m_xTextObject->GetText()); } xField.reset(pPostItField); diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index 209e3a9d993c..b0e96e21b5e3 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -611,7 +611,7 @@ sal_Int32 RtfSdrExport::StartShape() */ if (pTextObj->IsTextEditActive()) { - pOwnedParaObj.reset(pTextObj->GetEditOutlinerParaObject()); + pOwnedParaObj = pTextObj->GetEditOutlinerParaObject(); pParaObj = pOwnedParaObj.get(); } else diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 34d3a650ecc6..f36c89117179 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1319,7 +1319,7 @@ void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp) */ if (rTextObj.IsTextEditActive()) { - pParaObj = rTextObj.GetEditOutlinerParaObject(); + pParaObj = rTextObj.GetEditOutlinerParaObject().release(); bOwnParaObj = true; } else diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index cca597c50413..a06c4bc9f182 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -984,9 +984,8 @@ std::unique_ptr SwWW8ImplReader::ImportAsOutliner(OUString & } std::unique_ptr pTemporaryText = m_pDrawEditEngine->CreateTextObject(); - pRet.reset( new OutlinerParaObject(*pTemporaryText) ); + pRet.reset( new OutlinerParaObject( std::move(pTemporaryText) ) ); pRet->SetOutlinerMode( OutlinerMode::TextObject ); - pTemporaryText.reset(); m_pDrawEditEngine->SetText( OUString() ); m_pDrawEditEngine->SetParaAttribs(0, m_pDrawEditEngine->GetEmptyItemSet()); @@ -1193,11 +1192,11 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj, bool bVertical = pTextObj->IsVerticalWriting(); std::unique_ptr pTemporaryText = m_pDrawEditEngine->CreateTextObject(); - OutlinerParaObject* pOp = new OutlinerParaObject(*pTemporaryText); + std::unique_ptr pOp( new OutlinerParaObject(*pTemporaryText) ); pOp->SetOutlinerMode( OutlinerMode::TextObject ); pOp->SetVertical( bVertical ); pTemporaryText.reset(); - pTextObj->NbcSetOutlinerParaObject( pOp ); + pTextObj->NbcSetOutlinerParaObject( std::move(pOp) ); pTextObj->SetVerticalWriting(bVertical); // For the next TextBox also remove the old paragraph attributes diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index f5c723f2d30e..c2a7c02f7f5b 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 4b641a57dfa9..7fef02cdf522 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -241,7 +241,7 @@ void SwAnnotationWin::UpdateData() pOldField.reset(mpField->Copy()); } mpField->SetPar2(mpOutliner->GetEditEngine().GetText()); - mpField->SetTextObject(std::unique_ptr(mpOutliner->CreateParaObject())); + mpField->SetTextObject(mpOutliner->CreateParaObject()); if (rUndoRedo.DoesUndo()) { SwTextField *const pTextField = mpFormatField->GetTextField(); @@ -404,7 +404,7 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject const * pText) pOldField.reset(mpField->Copy()); } mpField->SetPar2(mpOutliner->GetEditEngine().GetText()); - mpField->SetTextObject(std::unique_ptr(mpOutliner->CreateParaObject())); + mpField->SetTextObject(mpOutliner->CreateParaObject()); if (rUndoRedo.DoesUndo()) { SwTextField *const pTextField = mpFormatField->GetTextField(); -- cgit