summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/outliner/outliner.cxx21
-rw-r--r--editeng/source/outliner/outlobj.cxx11
-rw-r--r--editeng/source/outliner/overflowingtxt.cxx22
-rw-r--r--editeng/source/uno/unoforou.cxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx4
-rw-r--r--filter/source/msfilter/svdfppt.cxx4
-rw-r--r--include/editeng/outliner.hxx4
-rw-r--r--include/editeng/outlobj.hxx3
-rw-r--r--include/editeng/overflowingtxt.hxx16
-rw-r--r--include/svx/svdoashp.hxx2
-rw-r--r--include/svx/svdobj.hxx4
-rw-r--r--include/svx/svdomeas.hxx2
-rw-r--r--include/svx/svdotable.hxx2
-rw-r--r--include/svx/svdotext.hxx6
-rw-r--r--include/svx/svdtext.hxx11
-rw-r--r--include/svx/svdundo.hxx5
-rw-r--r--oox/source/export/drawingml.cxx12
-rw-r--r--oox/source/export/vmlexport.cxx12
-rw-r--r--reportdesign/source/core/sdr/ReportDrawPage.cxx2
-rw-r--r--sc/source/core/data/postit.cxx17
-rw-r--r--sc/source/filter/excel/xiescher.cxx6
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx6
-rw-r--r--sd/inc/textapi.hxx2
-rw-r--r--sd/source/core/drawdoc4.cxx4
-rw-r--r--sd/source/core/sdpage.cxx5
-rw-r--r--sd/source/core/text/textapi.cxx12
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx2
-rw-r--r--sd/source/ui/annotations/annotationwindow.cxx4
-rw-r--r--sd/source/ui/docshell/docshel4.cxx2
-rw-r--r--sd/source/ui/func/fuexpand.cxx4
-rw-r--r--sd/source/ui/func/fuinsert.cxx2
-rw-r--r--sd/source/ui/func/fuinsfil.cxx2
-rw-r--r--sd/source/ui/func/fumorph.cxx4
-rw-r--r--sd/source/ui/unoidl/unoobj.cxx2
-rw-r--r--sd/source/ui/view/DocumentRenderer.cxx4
-rw-r--r--sd/source/ui/view/drviews2.cxx2
-rw-r--r--sd/source/ui/view/drviews8.cxx2
-rw-r--r--sd/source/ui/view/drviews9.cxx2
-rw-r--r--sd/source/ui/view/drviewse.cxx2
-rw-r--r--sd/source/ui/view/outlnvsh.cxx4
-rw-r--r--sd/source/ui/view/outlview.cxx2
-rw-r--r--sd/source/ui/view/sdview4.cxx2
-rw-r--r--sd/source/ui/view/viewshe2.cxx2
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx2
-rw-r--r--svx/source/inc/cell.hxx4
-rw-r--r--svx/source/sdr/attribute/sdrtextattribute.cxx2
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx2
-rw-r--r--svx/source/sdr/properties/textproperties.cxx8
-rw-r--r--svx/source/svdraw/svdedtv2.cxx4
-rw-r--r--svx/source/svdraw/svdedxv.cxx2
-rw-r--r--svx/source/svdraw/svdoashp.cxx10
-rw-r--r--svx/source/svdraw/svdobj.cxx6
-rw-r--r--svx/source/svdraw/svdomeas.cxx2
-rw-r--r--svx/source/svdraw/svdoole2.cxx2
-rw-r--r--svx/source/svdraw/svdotext.cxx25
-rw-r--r--svx/source/svdraw/svdotxat.cxx2
-rw-r--r--svx/source/svdraw/svdotxed.cxx2
-rw-r--r--svx/source/svdraw/svdtext.cxx39
-rw-r--r--svx/source/svdraw/svdundo.cxx21
-rw-r--r--svx/source/svdraw/textchainflow.cxx11
-rw-r--r--svx/source/table/cell.cxx52
-rw-r--r--svx/source/table/svdotable.cxx13
-rw-r--r--svx/source/table/tablecontroller.cxx2
-rw-r--r--svx/source/table/tablertfexporter.cxx10
-rw-r--r--svx/source/table/tablertfimporter.cxx2
-rw-r--r--svx/source/table/tableundo.cxx2
-rw-r--r--svx/source/unodraw/unoshtxt.cxx15
-rw-r--r--sw/inc/docufld.hxx7
-rw-r--r--sw/source/core/fields/docufld.cxx6
-rw-r--r--sw/source/core/fields/textapi.cxx4
-rw-r--r--sw/source/core/inc/textapi.hxx4
-rw-r--r--sw/source/core/layout/fly.cxx2
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx5
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx12
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx14
-rw-r--r--sw/source/filter/ww8/ww8par.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par.hxx2
77 files changed, 264 insertions, 275 deletions
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index b30de5d206a0..7370c5666313 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -358,7 +358,7 @@ sal_Int32 Outliner::GetBulletsNumberingStatus() const
: 2;
}
-std::unique_ptr<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const
+std::optional<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const
{
if ( static_cast<sal_uLong>(nStartPara) + nCount >
o3tl::make_unsigned(pParaList->GetParagraphCount()) )
@@ -370,7 +370,7 @@ std::unique_ptr<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStart
nCount = pEditEngine->GetParagraphCount() - nStartPara;
if (nCount <= 0)
- return nullptr;
+ return std::nullopt;
std::unique_ptr<EditTextObject> xText = pEditEngine->CreateTextObject( nStartPara, nCount );
const bool bIsEditDoc(OutlinerMode::TextObject == GetOutlinerMode());
@@ -382,16 +382,15 @@ std::unique_ptr<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStart
aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara);
}
- std::unique_ptr<OutlinerParaObject> pPObj(new OutlinerParaObject(std::move(xText), aParagraphDataVector, bIsEditDoc));
- pPObj->SetOutlinerMode(GetOutlinerMode());
+ OutlinerParaObject aPObj(std::move(xText), aParagraphDataVector, bIsEditDoc);
+ aPObj.SetOutlinerMode(GetOutlinerMode());
- return pPObj;
+ return aPObj;
}
void Outliner::SetToEmptyText()
{
- std::unique_ptr<OutlinerParaObject> pEmptyTxt = GetEmptyParaObject();
- SetText(*pEmptyTxt);
+ SetText(GetEmptyParaObject());
}
void Outliner::SetText( const OUString& rText, Paragraph* pPara )
@@ -2118,12 +2117,12 @@ std::optional<NonOverflowingText> Outliner::GetNonOverflowingText() const
}
}
-std::unique_ptr<OutlinerParaObject> Outliner::GetEmptyParaObject() const
+OutlinerParaObject Outliner::GetEmptyParaObject() const
{
std::unique_ptr<EditTextObject> pEmptyText = pEditEngine->GetEmptyTextObject();
- std::unique_ptr<OutlinerParaObject> pPObj( new OutlinerParaObject( std::move(pEmptyText) ));
- pPObj->SetOutlinerMode(GetOutlinerMode());
- return pPObj;
+ OutlinerParaObject aPObj( std::move(pEmptyText) );
+ aPObj.SetOutlinerMode(GetOutlinerMode());
+ return aPObj;
}
std::optional<OverflowingText> Outliner::GetOverflowingText() const
diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx
index e8cbd6dbd565..0c0050ebaded 100644
--- a/editeng/source/outliner/outlobj.cxx
+++ b/editeng/source/outliner/outlobj.cxx
@@ -77,6 +77,11 @@ OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& r ) :
{
}
+OutlinerParaObject::OutlinerParaObject( OutlinerParaObject&& r ) noexcept :
+ mpImpl(std::move(r.mpImpl))
+{
+}
+
OutlinerParaObject::~OutlinerParaObject()
{
}
@@ -87,6 +92,12 @@ OutlinerParaObject& OutlinerParaObject::operator=( const OutlinerParaObject& r )
return *this;
}
+OutlinerParaObject& OutlinerParaObject::operator=( OutlinerParaObject&& r ) noexcept
+{
+ mpImpl = std::move(r.mpImpl);
+ return *this;
+}
+
bool OutlinerParaObject::operator==( const OutlinerParaObject& r ) const
{
return r.mpImpl == mpImpl;
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 0c038dbfb311..ca7f363010d1 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -30,7 +30,7 @@
#include <editdoc.hxx>
-std::unique_ptr<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject(
+std::optional<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *pOutl,
OutlinerParaObject const *pNextPObj)
@@ -65,7 +65,7 @@ std::unique_ptr<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject(
return pOutl->CreateParaObject();
}
-std::unique_ptr<OutlinerParaObject> TextChainingUtils::DeeplyMergeParaObject(
+std::optional<OutlinerParaObject> TextChainingUtils::DeeplyMergeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *pOutl,
OutlinerParaObject const *pNextPObj)
@@ -122,7 +122,7 @@ bool NonOverflowingText::IsLastParaInterrupted() const
}
-std::unique_ptr<OutlinerParaObject> NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const
+std::optional<OutlinerParaObject> NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const
{
pOutliner->QuickDelete(maContentSel);
SAL_INFO("editeng.chaining", "Deleting selection from (Para: " << maContentSel.nStartPara
@@ -141,12 +141,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
-std::unique_ptr<OutlinerParaObject> OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
+std::optional<OutlinerParaObject> OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
{
return TextChainingUtils::JuxtaposeParaObject(mxOverflowingContent, pOutl, pNextPObj);
}
-std::unique_ptr<OutlinerParaObject> OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
+std::optional<OutlinerParaObject> OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
{
return TextChainingUtils::DeeplyMergeParaObject(mxOverflowingContent, pOutl, pNextPObj);
}
@@ -170,11 +170,11 @@ ESelection OFlowChainedText::GetOverflowPointSel() const
return mpNonOverflowingTxt->GetOverflowPointSel();
}
-std::unique_ptr<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged)
+std::optional<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged)
{
// Just return the roughly merged paras for now
if (!mpOverflowingTxt)
- return nullptr;
+ return std::nullopt;
if (mbIsDeepMerge) {
SAL_INFO("editeng.chaining", "[TEXTCHAINFLOW - OF] Deep merging paras" );
@@ -186,10 +186,10 @@ std::unique_ptr<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outl
}
-std::unique_ptr<OutlinerParaObject> OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner)
+std::optional<OutlinerParaObject> OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner)
{
if (!mpNonOverflowingTxt)
- return nullptr;
+ return std::nullopt;
return mpNonOverflowingTxt->RemoveOverflowingText(pOutliner);
}
@@ -207,9 +207,9 @@ UFlowChainedText::UFlowChainedText(Outliner const *pOutl, bool bIsDeepMerge)
mbIsDeepMerge = bIsDeepMerge;
}
-std::unique_ptr<OutlinerParaObject> UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText)
+std::optional<OutlinerParaObject> UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText)
{
- std::unique_ptr<OutlinerParaObject> pNewText;
+ std::optional<OutlinerParaObject> 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 144126d25e08..e348e254ea28 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -541,7 +541,7 @@ void SvxOutlinerForwarder::CopyText(const SvxTextForwarder& rSource)
const SvxOutlinerForwarder* pSourceForwarder = dynamic_cast< const SvxOutlinerForwarder* >( &rSource );
if( !pSourceForwarder )
return;
- std::unique_ptr<OutlinerParaObject> pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject();
rOutliner.SetText( *pNewOutlinerParaObject );
}
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 5df5baacbdf9..e24b342f6f3e 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3664,7 +3664,7 @@ void SvxMSDffManager::ReadObjText( const OUString& rText, SdrObject* pObj )
rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection );
nParaIndex++;
}
- std::unique_ptr<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
rOutliner.Clear();
rOutliner.SetUpdateMode( bOldUpdateMode );
pText->SetOutlinerParaObject( std::move(pNewText) );
@@ -4495,7 +4495,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
}
if ( bCreateNewParaObject )
{
- std::unique_ptr<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
rOutliner.Init( OutlinerMode::TextObject );
static_cast<SdrObjCustomShape*>(pRet)->NbcSetOutlinerParaObject( std::move(pNewText) );
}
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 0de16f0a6689..8deff59fbf4d 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -2367,7 +2367,7 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj*
rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection );
}
}
- std::unique_ptr<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewText = rOutliner.CreateParaObject();
rOutliner.Clear();
rOutliner.SetUpdateMode( bOldUpdateMode );
rOutliner.EnableUndo(bUndoEnabled);
@@ -7588,7 +7588,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, const sal_uInt32
{
SdrText* pSdrText = pTable->getText( nTableIndex );
if ( pSdrText )
- pSdrText->SetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pParaObject) );
+ pSdrText->SetOutlinerParaObject(*pParaObject);
}
}
}
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 23ff675707c1..c340bd15c8c0 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -684,7 +684,7 @@ public:
void SetToEmptyText();
- std::unique_ptr<OutlinerParaObject> CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
+ std::optional<OutlinerParaObject> CreateParaObject( sal_Int32 nStartPara = 0, sal_Int32 nParaCount = EE_PARA_ALL ) const;
const SfxItemSet& GetEmptyItemSet() const;
@@ -738,7 +738,7 @@ public:
void ClearOverflowingParaNum();
bool IsPageOverflow();
- std::unique_ptr<OutlinerParaObject> GetEmptyParaObject() const;
+ OutlinerParaObject GetEmptyParaObject() const;
void DepthChangedHdl(Paragraph*, ParaFlag nPrevFlags);
diff --git a/include/editeng/outlobj.hxx b/include/editeng/outlobj.hxx
index b2c00a1683ff..fac9bed9ffb9 100644
--- a/include/editeng/outlobj.hxx
+++ b/include/editeng/outlobj.hxx
@@ -71,13 +71,16 @@ public:
OutlinerParaObject(std::unique_ptr<EditTextObject>, const ParagraphDataVector&, bool bIsEditDoc);
OutlinerParaObject( std::unique_ptr<EditTextObject> );
OutlinerParaObject( const OutlinerParaObject&);
+ OutlinerParaObject(OutlinerParaObject&&) noexcept;
~OutlinerParaObject();
// assignment operator
OutlinerParaObject& operator=(const OutlinerParaObject& rCandidate);
+ OutlinerParaObject& operator=(OutlinerParaObject&&) noexcept;
// compare operator
bool operator==(const OutlinerParaObject& rCandidate) const;
+ bool operator!=(const OutlinerParaObject& rCandidate) const { return !operator==(rCandidate); }
// #i102062#
bool isWrongListEqual(const OutlinerParaObject& rCompare) const;
diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx
index 3ec7a34354a9..043b8ebd21f4 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -50,11 +50,11 @@ class TextChainingUtils
public:
static css::uno::Reference< css::datatransfer::XTransferable> CreateTransferableFromText(Outliner const *);
- static std::unique_ptr<OutlinerParaObject> JuxtaposeParaObject(
+ static std::optional<OutlinerParaObject> JuxtaposeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *,
OutlinerParaObject const *);
- static std::unique_ptr<OutlinerParaObject> DeeplyMergeParaObject(
+ static std::optional<OutlinerParaObject> DeeplyMergeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *,
OutlinerParaObject const *);
@@ -71,8 +71,8 @@ class OverflowingText
public:
OverflowingText(css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent);
- std::unique_ptr<OutlinerParaObject> JuxtaposeParaObject(Outliner *, OutlinerParaObject const *);
- std::unique_ptr<OutlinerParaObject> DeeplyMergeParaObject(Outliner *, OutlinerParaObject const *);
+ std::optional<OutlinerParaObject> JuxtaposeParaObject(Outliner *, OutlinerParaObject const *);
+ std::optional<OutlinerParaObject> DeeplyMergeParaObject(Outliner *, OutlinerParaObject const *);
private:
css::uno::Reference< css::datatransfer::XTransferable > mxOverflowingContent;
@@ -83,7 +83,7 @@ class NonOverflowingText
public:
NonOverflowingText(const ESelection &aSel, bool bLastParaInterrupted);
- std::unique_ptr<OutlinerParaObject> RemoveOverflowingText(Outliner *) const;
+ std::optional<OutlinerParaObject> RemoveOverflowingText(Outliner *) const;
ESelection GetOverflowPointSel() const;
bool IsLastParaInterrupted() const;
@@ -105,8 +105,8 @@ public:
OFlowChainedText(Outliner const *, bool );
~OFlowChainedText();
- std::unique_ptr<OutlinerParaObject> InsertOverflowingText(Outliner *, OutlinerParaObject const *);
- std::unique_ptr<OutlinerParaObject> RemoveOverflowingText(Outliner *);
+ std::optional<OutlinerParaObject> InsertOverflowingText(Outliner *, OutlinerParaObject const *);
+ std::optional<OutlinerParaObject> RemoveOverflowingText(Outliner *);
ESelection GetOverflowPointSel() const;
@@ -124,7 +124,7 @@ class EDITENG_DLLPUBLIC UFlowChainedText
{
public:
UFlowChainedText(Outliner const *, bool);
- std::unique_ptr<OutlinerParaObject> CreateMergedUnderflowParaObject(Outliner *, OutlinerParaObject const *);
+ std::optional<OutlinerParaObject> 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 48374bc035aa..bb0d3446292e 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(std::unique_ptr<OutlinerParaObject> pTextObject) override;
+ virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) override;
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index d10adcd36445..d3b8089d4d64 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -631,8 +631,8 @@ public:
// keep text in outliner's format
// SetOutlinerParaObject: transfer ownership of *pTextObject!
- void SetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject);
- virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject);
+ void SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject);
+ virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject);
virtual OutlinerParaObject* GetOutlinerParaObject() const;
virtual void NbcReformatText();
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index 83277c5e9831..15a6d0e0026e 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -131,7 +131,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(std::unique_ptr<OutlinerParaObject> pTextObject) override;
+ virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 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 710da9379628..18497bcc2494 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -239,7 +239,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(std::unique_ptr<OutlinerParaObject> pTextObject) override;
+ virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) override;
virtual OutlinerParaObject* GetOutlinerParaObject() const override;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 546c856ca912..d192552d16ad 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -488,11 +488,11 @@ public:
virtual void EndTextEdit(SdrOutliner& rOutl);
virtual EEAnchorMode GetOutlinerViewAnchorMode() const;
- virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject) override;
- void NbcSetOutlinerParaObjectForText( std::unique_ptr<OutlinerParaObject> pTextObject, SdrText* pText );
+ virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) override;
+ void NbcSetOutlinerParaObjectForText( std::optional<OutlinerParaObject> pTextObject, SdrText* pText );
virtual OutlinerParaObject* GetOutlinerParaObject() const override;
bool CanCreateEditOutlinerParaObject() const;
- std::unique_ptr<OutlinerParaObject> CreateEditOutlinerParaObject() const;
+ std::optional<OutlinerParaObject> CreateEditOutlinerParaObject() const;
virtual void NbcReformatText() override;
diff --git a/include/svx/svdtext.hxx b/include/svx/svdtext.hxx
index 4a11c12b841e..b3c5cbbf90ec 100644
--- a/include/svx/svdtext.hxx
+++ b/include/svx/svdtext.hxx
@@ -19,10 +19,12 @@
#pragma once
+#include <editeng/outlobj.hxx>
#include <svx/sdr/properties/defaultproperties.hxx>
#include <svx/svxdllapi.h>
#include <tools/weakbase.hxx>
#include <memory>
+#include <optional>
class OutlinerParaObject;
class SdrOutliner;
@@ -48,8 +50,9 @@ public:
void ForceOutlinerParaObject(OutlinerMode nOutlMode);
- virtual void SetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject);
- OutlinerParaObject* GetOutlinerParaObject() const;
+ virtual void SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject);
+ OutlinerParaObject* GetOutlinerParaObject();
+ const OutlinerParaObject* GetOutlinerParaObject() const;
void CheckPortionInfo(SdrOutliner& rOutliner);
void ReformatText();
@@ -63,7 +66,7 @@ public:
SdrTextObj& GetObject() const { return mrObject; }
/** returns the current OutlinerParaObject and removes it from this instance */
- std::unique_ptr<OutlinerParaObject> RemoveOutlinerParaObject();
+ std::optional<OutlinerParaObject> RemoveOutlinerParaObject();
void dumpAsXml(xmlTextWriterPtr pWriter) const;
@@ -72,7 +75,7 @@ protected:
virtual SfxStyleSheet* GetStyleSheet() const;
private:
- std::unique_ptr<OutlinerParaObject> mpOutlinerParaObject;
+ std::optional<OutlinerParaObject> mpOutlinerParaObject;
SdrTextObj& mrObject;
bool mbPortionInfoChecked;
};
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index cdfd8070f6ac..ccfa69476bba 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -25,6 +25,7 @@
#include <memory>
#include <vector>
+#include <editeng/outlobj.hxx>
#include <svl/undo.hxx>
#include <svl/style.hxx>
#include <tools/gen.hxx>
@@ -393,9 +394,9 @@ public:
class SVXCORE_DLLPUBLIC SdrUndoObjSetText : public SdrUndoObj
{
protected:
- std::unique_ptr<OutlinerParaObject>
+ std::optional<OutlinerParaObject>
pOldText;
- std::unique_ptr<OutlinerParaObject>
+ std::optional<OutlinerParaObject>
pNewText;
bool bNewTextAvailable;
bool bEmptyPresObj;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 91f4a779a984..54a7f2f6eab1 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3457,8 +3457,7 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
const SdrTextObj* pTxtObj = dynamic_cast<SdrTextObj*>( pSdrObject );
if (pTxtObj && mpTextExport)
{
- const OutlinerParaObject* pParaObj = nullptr;
- bool bOwnParaObj = false;
+ std::optional<OutlinerParaObject> pParaObj;
/*
#i13885#
@@ -3467,18 +3466,15 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
*/
if (pTxtObj->IsTextEditActive())
{
- pParaObj = pTxtObj->CreateEditOutlinerParaObject().release();
- bOwnParaObj = true;
+ pParaObj = pTxtObj->CreateEditOutlinerParaObject();
}
- else
- pParaObj = pTxtObj->GetOutlinerParaObject();
+ else if (pTxtObj->GetOutlinerParaObject())
+ pParaObj = *pTxtObj->GetOutlinerParaObject();
if (pParaObj)
{
// this is reached only in case some text is attached to the shape
mpTextExport->WriteOutliner(*pParaObj);
- if (bOwnParaObj)
- delete pParaObj;
}
return;
}
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 5b267184a291..d4243c6e07bf 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1420,8 +1420,7 @@ sal_Int32 VMLExport::StartShape()
const SdrTextObj* pTxtObj = dynamic_cast<const SdrTextObj*>( m_pSdrObject );
if (pTxtObj && m_pTextExport && msfilter::util::HasTextBoxContent(m_nShapeType) && !IsWaterMarkShape(m_pSdrObject->GetName()) && !lcl_isTextBox(m_pSdrObject))
{
- const OutlinerParaObject* pParaObj = nullptr;
- bool bOwnParaObj = false;
+ std::optional<OutlinerParaObject> pParaObj;
/*
#i13885#
@@ -1430,12 +1429,11 @@ sal_Int32 VMLExport::StartShape()
*/
if (pTxtObj->IsTextEditActive())
{
- pParaObj = pTxtObj->CreateEditOutlinerParaObject().release();
- bOwnParaObj = true;
+ pParaObj = pTxtObj->CreateEditOutlinerParaObject();
}
- else
+ else if (pTxtObj->GetOutlinerParaObject())
{
- pParaObj = pTxtObj->GetOutlinerParaObject();
+ pParaObj = *pTxtObj->GetOutlinerParaObject();
}
if( pParaObj )
@@ -1450,8 +1448,6 @@ sal_Int32 VMLExport::StartShape()
m_pSerializer->startElementNS(XML_v, XML_textbox, pTextboxAttrList);
m_pTextExport->WriteOutliner(*pParaObj);
m_pSerializer->endElementNS(XML_v, XML_textbox);
- if( bOwnParaObj )
- delete pParaObj;
}
}
diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx
index 0c1e15cebb13..1823c3c07527 100644
--- a/reportdesign/source/core/sdr/ReportDrawPage.cxx
+++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx
@@ -113,7 +113,7 @@ uno::Reference< drawing::XShape > OReportDrawPage::CreateShape( SdrObject *pObj
* The empty OLE object gets a new IPObj
**************************************************/
pObj->SetEmptyPresObj(false);
- rOle2Obj.SetOutlinerParaObject(nullptr);
+ rOle2Obj.SetOutlinerParaObject(std::nullopt);
rOle2Obj.SetObjRef(xObj);
rOle2Obj.SetPersistName(sName);
rOle2Obj.SetName(sName);
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index a4ec79b2c909..c1e13308d455 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -821,7 +821,7 @@ void ScCaptionPtr::clear()
struct ScCaptionInitData
{
std::unique_ptr< SfxItemSet > mxItemSet; /// Caption object formatting.
- std::unique_ptr< OutlinerParaObject > mxOutlinerObj; /// Text object with all text portion formatting.
+ std::optional< OutlinerParaObject > mxOutlinerObj; /// Text object with all text portion formatting.
OUString maSimpleText; /// Simple text without formatting.
Point maCaptionOffset; /// Caption position relative to cell corner.
Size maCaptionSize; /// Size of the caption object.
@@ -900,8 +900,8 @@ const OutlinerParaObject* ScPostIt::GetOutlinerObject() const
{
if( maNoteData.mxCaption )
return maNoteData.mxCaption->GetOutlinerParaObject();
- if( maNoteData.mxInitData )
- return maNoteData.mxInitData->mxOutlinerObj.get();
+ if( maNoteData.mxInitData && maNoteData.mxInitData->mxOutlinerObj )
+ return &*maNoteData.mxInitData->mxOutlinerObj;
return nullptr;
}
@@ -967,7 +967,7 @@ void ScPostIt::ForgetCaption( bool bPreserveData )
ScCaptionInitData* pInitData = new ScCaptionInitData;
const OutlinerParaObject* pOPO = GetOutlinerObject();
if (pOPO)
- pInitData->mxOutlinerObj.reset( new OutlinerParaObject(*pOPO));
+ pInitData->mxOutlinerObj = *pOPO;
pInitData->maSimpleText = GetText();
maNoteData.mxInitData.reset(pInitData);
@@ -1110,7 +1110,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
{
// copy edit text object (object must be inserted into page already)
if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
- maNoteData.mxCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
+ maNoteData.mxCaption->SetOutlinerParaObject( *pOPO );
// copy formatting items (after text has been copied to apply font formatting)
maNoteData.mxCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() );
// move textbox position relative to new cell, copy textbox size
@@ -1196,7 +1196,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
if( pNoteCaption && rUserText.isEmpty() )
{
if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() )
- pCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
+ pCaption->SetOutlinerParaObject( *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() );
@@ -1249,7 +1249,10 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
ScCaptionInitData& rInitData = *aNoteData.mxInitData;
rInitData.mxItemSet = std::move(pItemSet);
- rInitData.mxOutlinerObj.reset( pOutlinerObj );
+ if (pOutlinerObj)
+ rInitData.mxOutlinerObj = *pOutlinerObj;
+ else
+ rInitData.mxOutlinerObj.reset();
// convert absolute caption position to relative position
rInitData.mbDefaultPosSize = rCaptionRect.IsEmpty();
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index ea40954e89f3..5732b49bac30 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1506,9 +1506,9 @@ void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject&
// rich text
std::unique_ptr< EditTextObject > xEditObj(
XclImpStringHelper::CreateTextObject( GetRoot(), *maTextData.mxString ) );
- std::unique_ptr<OutlinerParaObject> pOutlineObj(new OutlinerParaObject(std::move(xEditObj)));
- pOutlineObj->SetOutlinerMode( OutlinerMode::TextObject );
- pTextObj->NbcSetOutlinerParaObject( std::move(pOutlineObj) );
+ OutlinerParaObject aOutlineObj(std::move(xEditObj));
+ aOutlineObj.SetOutlinerMode( OutlinerMode::TextObject );
+ pTextObj->NbcSetOutlinerParaObject( std::move(aOutlineObj) );
}
else
{
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index 231f080fa9da..f96f9c020125 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -169,9 +169,9 @@ void ScAnnotationEditSource::UpdateData()
if( SdrObject* pObj = GetCaptionObj() )
{
- std::unique_ptr<OutlinerParaObject> pOPO( new OutlinerParaObject(pEditEngine->CreateTextObject()) );
- pOPO->SetOutlinerMode( OutlinerMode::TextObject );
- pObj->NbcSetOutlinerParaObject( std::move(pOPO) );
+ OutlinerParaObject aOPO( pEditEngine->CreateTextObject() );
+ aOPO.SetOutlinerMode( OutlinerMode::TextObject );
+ pObj->NbcSetOutlinerParaObject( std::move(aOPO) );
pObj->ActionChanged();
}
diff --git a/sd/inc/textapi.hxx b/sd/inc/textapi.hxx
index 090cab889b4f..70110349053a 100644
--- a/sd/inc/textapi.hxx
+++ b/sd/inc/textapi.hxx
@@ -39,7 +39,7 @@ public:
/// @throws css::uno::RuntimeException
void dispose();
- std::unique_ptr<OutlinerParaObject> CreateText();
+ std::optional<OutlinerParaObject> CreateText();
void SetText( OutlinerParaObject const & rText );
OUString GetText() const;
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index e41e43daf06c..bda437336226 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -986,10 +986,10 @@ void SdDrawDocument::SpellObject(SdrTextObj* pObj)
if (mbHasOnlineSpellErrors)
{
- std::unique_ptr<OutlinerParaObject> pOPO = pOutl->CreateParaObject();
+ std::optional<OutlinerParaObject> pOPO = pOutl->CreateParaObject();
if (pOPO)
{
- if (!( *pOPO == *pObj->GetOutlinerParaObject() ) ||
+ if ( *pOPO != *pObj->GetOutlinerParaObject() ||
!pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO ))
{
sd::ModifyGuard aGuard( this );
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 55ee1a8a280d..c1bd4d178558 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -2084,9 +2084,8 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc
SdOutliner* pOutl = rModel.GetInternalOutliner();
pOutl->Clear();
pOutl->SetText( *pOutlParaObj );
- std::unique_ptr<OutlinerParaObject> pNew = pOutl->CreateParaObject();
- pOutlParaObj = pNew.get();
- pNewObj->SetOutlinerParaObject( std::move(pNew) );
+ pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() );
+ pOutlParaObj = pNewObj->GetOutlinerParaObject();
pOutl->Clear();
pNewObj->SetEmptyPresObj(false);
diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx
index ca20ac440db3..f9f0d9ba91a7 100644
--- a/sd/source/core/text/textapi.cxx
+++ b/sd/source/core/text/textapi.cxx
@@ -53,8 +53,8 @@ public:
virtual void Redo() override;
protected:
- std::unique_ptr<OutlinerParaObject> mpOldText;
- std::unique_ptr<OutlinerParaObject> mpNewText;
+ std::optional<OutlinerParaObject> mpOldText;
+ std::optional<OutlinerParaObject> mpNewText;
rtl::Reference< TextApiObject > mxTextObj;
};
@@ -109,7 +109,7 @@ public:
void Dispose();
void SetText( OutlinerParaObject const & rText );
- std::unique_ptr<OutlinerParaObject> CreateText();
+ std::optional<OutlinerParaObject> CreateText();
OUString GetText() const;
SdDrawDocument* GetDoc() { return m_xImpl->mpDoc; }
};
@@ -160,7 +160,7 @@ void TextApiObject::dispose()
}
-std::unique_ptr<OutlinerParaObject> TextApiObject::CreateText()
+std::optional<OutlinerParaObject> TextApiObject::CreateText()
{
return mpSource->CreateText();
}
@@ -257,12 +257,12 @@ void TextAPIEditSource::SetText( OutlinerParaObject const & rText )
}
}
-std::unique_ptr<OutlinerParaObject> TextAPIEditSource::CreateText()
+std::optional<OutlinerParaObject> TextAPIEditSource::CreateText()
{
if (m_xImpl->mpDoc && m_xImpl->mpOutliner)
return m_xImpl->mpOutliner->CreateParaObject();
else
- return nullptr;
+ return std::nullopt;
}
OUString TextAPIEditSource::GetText() const
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index ca1fe2d84f24..6d248b35e89e 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -597,7 +597,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
if (!sReplyText.isEmpty())
aOutliner.Insert(sReplyText);
- std::unique_ptr< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() );
+ std::optional< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() );
pTextApi->SetText(*pOPO);
OUString sReplyAuthor;
diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx
index 0022b84c9625..31d1891c2e0e 100644
--- a/sd/source/ui/annotations/annotationwindow.cxx
+++ b/sd/source/ui/annotations/annotationwindow.cxx
@@ -506,7 +506,7 @@ void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotatio
if( pTextApi )
{
- std::unique_ptr< OutlinerParaObject > pOPO( pTextApi->CreateText() );
+ std::optional< OutlinerParaObject > pOPO( pTextApi->CreateText() );
mpOutliner->SetText(*pOPO);
}
@@ -574,7 +574,7 @@ void AnnotationWindow::SaveToDocument()
if( pTextApi )
{
- std::unique_ptr<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject();
+ std::optional<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject();
if( pOPO )
{
if( mpDoc->IsUndoEnabled() )
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index 18c48afd441f..c154340f0a6a 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -561,7 +561,7 @@ bool DrawDocShell::SaveAs( SfxMedium& rMedium )
SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner();
if( pObj && pOutl && pOutl->IsModified() )
{
- std::unique_ptr<OutlinerParaObject> pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() );
+ std::optional<OutlinerParaObject> 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 833d628742e0..7b499db91786 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -183,7 +183,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
if (!pTextObj)
continue;
- std::unique_ptr<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1);
+ std::optional<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1);
pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject);
if( pOutlinerParaObject->GetDepth(0) != -1 )
@@ -213,7 +213,7 @@ void FuExpandPage::DoExecute( SfxRequest& )
if (pOutlineObj)
{
// create structuring text objects
- std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount);
+ std::optional<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount);
std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
pTempOutl->SetText( *pOPO );
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 07d1417e0161..f8f5625e7763 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -546,7 +546,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
// the empty OLE object gets a new IPObj
bInsertNewObject = false;
pObj->SetEmptyPresObj(false);
- static_cast<SdrOle2Obj*>(pObj)->SetOutlinerParaObject(nullptr);
+ static_cast<SdrOle2Obj*>(pObj)->SetOutlinerParaObject(std::nullopt);
static_cast<SdrOle2Obj*>(pObj)->SetObjRef(xObj);
static_cast<SdrOle2Obj*>(pObj)->SetPersistName(aName);
static_cast<SdrOle2Obj*>(pObj)->SetName(aName);
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index aec950b0c779..d776e07f1246 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -480,7 +480,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
}
}
- std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pOPO = aOutliner.CreateParaObject();
if (pOutlinerView)
{
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index cf51719d3857..9782c3f0c27e 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -86,8 +86,8 @@ void FuMorph::DoExecute( SfxRequest& )
SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()));
// delete text at clone, otherwise we do not get a correct PathObj
- pCloneObj1->SetOutlinerParaObject(nullptr);
- pCloneObj2->SetOutlinerParaObject(nullptr);
+ pCloneObj1->SetOutlinerParaObject(std::nullopt);
+ pCloneObj2->SetOutlinerParaObject(std::nullopt);
// create path objects
SdrObjectUniquePtr pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index 49bdbc6e94b6..78bc5cd6b9dd 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -897,7 +897,7 @@ void SdXShape::SetEmptyPresObj(bool bEmpty)
const bool bVertical = pOutlinerParaObject && pOutlinerParaObject->IsEffectivelyVertical();
// really delete SdrOutlinerObj at pObj
- pObj->NbcSetOutlinerParaObject(nullptr);
+ pObj->NbcSetOutlinerParaObject(std::nullopt);
if( bVertical )
if (auto pTextObj = dynamic_cast<SdrTextObj*>( pObj ) )
pTextObj->SetVerticalWriting( true );
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
index ed93441139a1..2aa37302eb03 100644
--- a/sd/source/ui/view/DocumentRenderer.cxx
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -1095,7 +1095,7 @@ namespace {
{
public:
OutlinerPrinterPage (
- std::unique_ptr<OutlinerParaObject> pParaObject,
+ std::optional<OutlinerParaObject> pParaObject,
const MapMode& rMapMode,
const OUString& rsPageString,
const Point& rPageStringOffset,
@@ -1148,7 +1148,7 @@ namespace {
}
private:
- std::unique_ptr<OutlinerParaObject> mpParaObject;
+ std::optional<OutlinerParaObject> mpParaObject;
};
}
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 7a1c81c89bf7..5a1a75e4670c 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2490,7 +2490,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
OutlinerMode nOutlMode = pOutl->GetOutlinerMode();
pOutl->SetStyleSheet( 0, nullptr );
pOutl->QuickInsertField( *pFieldItem, ESelection() );
- std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
+ std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
SdrRectObj* pRectObj = new SdrRectObj(
*GetDoc(),
diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx
index b6c043e91109..10703fbc4158 100644
--- a/sd/source/ui/view/drviews8.cxx
+++ b/sd/source/ui/view/drviews8.cxx
@@ -105,7 +105,7 @@ void DrawViewShell::ScannerEvent()
{
bInsertNewObject = false;
pGrafObj->SetEmptyPresObj(false);
- pGrafObj->SetOutlinerParaObject(nullptr);
+ pGrafObj->SetOutlinerParaObject(std::nullopt);
pGrafObj->SetGraphic( Graphic( aScanBmp ) );
}
}
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index 0909d8536fcd..4ba735f153cd 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -150,7 +150,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq)
SdrGrafObj* pNewGrafObj(pGrafObj->CloneSdrObject(pGrafObj->getSdrModelFromSdrObject()));
pNewGrafObj->SetEmptyPresObj(false);
- pNewGrafObj->SetOutlinerParaObject(nullptr);
+ pNewGrafObj->SetOutlinerParaObject(std::nullopt);
pNewGrafObj->SetGraphic(aGraphic);
OUString aStr = mpDrawView->GetDescriptionOfMarkedObjects() +
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 3acc0b882c3d..b1016470bc42 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1489,7 +1489,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText,
aURLField.SetTargetFrame(rTarget);
SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
pOutl->QuickInsertField( aURLItem, ESelection() );
- std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
+ std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
SdrRectObj* pRectObj = new SdrRectObj(
GetView()->getSdrModelFromSdrView(),
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 7a77c2a7275e..f4d1b15d7888 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1582,7 +1582,7 @@ void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara
}
// if we have a title object and a text, set the text
- std::unique_ptr<OutlinerParaObject> pOPO;
+ std::optional<OutlinerParaObject> pOPO;
if (pTO)
pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1);
if (pOPO)
@@ -1645,7 +1645,7 @@ void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara )
return;
::Outliner& rOutliner = pOlView->GetOutliner();
- std::unique_ptr<OutlinerParaObject> pOPO;
+ std::optional<OutlinerParaObject> pOPO;
SdrTextObj* pTO = nullptr;
OutlinerMode eOutlinerMode = OutlinerMode::TitleObject;
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index 6234d7bfe298..eae262aa26a7 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -1319,7 +1319,7 @@ SvtScriptType OutlineView::GetScriptType() const
{
SvtScriptType nScriptType = ::sd::View::GetScriptType();
- std::unique_ptr<OutlinerParaObject> pTempOPObj = mrOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pTempOPObj = mrOutliner.CreateParaObject();
if(pTempOPObj)
{
nScriptType = pTempOPObj->GetTextObject().GetScriptType();
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index bc6e48286889..00e27a641c01 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -127,7 +127,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
{
::tools::Rectangle aRect( pNewGrafObj->GetLogicRect() );
pNewGrafObj->AdjustToMaxRect( aRect );
- pNewGrafObj->SetOutlinerParaObject(nullptr);
+ pNewGrafObj->SetOutlinerParaObject(std::nullopt);
pNewGrafObj->SetEmptyPresObj(false);
}
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
index 0837c0ecbb8a..607768ec726c 100644
--- a/sd/source/ui/view/viewshe2.cxx
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -691,7 +691,7 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb)
{
// OLE object is no longer empty
pObj->SetEmptyPresObj(false);
- pObj->SetOutlinerParaObject(nullptr);
+ pObj->SetOutlinerParaObject(std::nullopt);
pObj->ClearGraphic();
// the empty OLE object gets a new IPObj
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 9999f54c1c33..b66a2c8c6507 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -184,7 +184,7 @@ std::unique_ptr<SdrObject, SdrObjectFreeOp> EnhancedCustomShapeEngine::ImplForce
OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject());
if( pParaObj )
- pTextObj->NbcSetOutlinerParaObject( std::make_unique<OutlinerParaObject>(*pParaObj) );
+ pTextObj->NbcSetOutlinerParaObject( *pParaObj );
// copy all attributes
SfxItemSet aTargetItemSet(rSdrObjCustomShape.GetMergedItemSet());
diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx
index 9522e006850b..36ce254d1aa7 100644
--- a/svx/source/inc/cell.hxx
+++ b/svx/source/inc/cell.hxx
@@ -69,7 +69,7 @@ public:
SVX_DLLPRIVATE ::tools::Rectangle& getCellRect() { return maCellRect; }
bool CanCreateEditOutlinerParaObject() const;
- std::unique_ptr<OutlinerParaObject> CreateEditOutlinerParaObject() const;
+ std::optional<OutlinerParaObject> CreateEditOutlinerParaObject() const;
SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const override;
SVX_DLLPRIVATE void TakeTextAnchorRect(tools::Rectangle& rAnchorRect) const;
@@ -166,7 +166,7 @@ public:
// XEventListener
SVX_DLLPRIVATE virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
- SVX_DLLPRIVATE virtual void SetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject ) override;
+ SVX_DLLPRIVATE virtual void SetOutlinerParaObject( std::optional<OutlinerParaObject> pTextObject ) override;
SVX_DLLPRIVATE void AddUndo();
diff --git a/svx/source/sdr/attribute/sdrtextattribute.cxx b/svx/source/sdr/attribute/sdrtextattribute.cxx
index aaf62ea9dd99..8ddeab497595 100644
--- a/svx/source/sdr/attribute/sdrtextattribute.cxx
+++ b/svx/source/sdr/attribute/sdrtextattribute.cxx
@@ -185,7 +185,7 @@ namespace drawinglayer::attribute
{
// compares OPO and it's contents, but traditionally not the RedLining
// which is not seen as model, but as temporary information
- if(!(getOutlinerParaObject() == rCandidate.getOutlinerParaObject()))
+ if(getOutlinerParaObject() != rCandidate.getOutlinerParaObject())
{
return false;
}
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 855bc0daf573..bfc76b41231d 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -570,7 +570,7 @@ namespace drawinglayer::primitive2d
if(bInEditMode)
{
- std::unique_ptr<OutlinerParaObject> pTempObj = rTextObj.CreateEditOutlinerParaObject();
+ std::optional<OutlinerParaObject> pTempObj = rTextObj.CreateEditOutlinerParaObject();
if(pTempObj)
{
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 062ef79d4420..2ada7eb32198 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -136,7 +136,7 @@ namespace sdr::properties
mxItemSet->Put(aNewSet);
}
- std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
pOutliner->Clear();
rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText);
@@ -195,7 +195,7 @@ namespace sdr::properties
ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL);
rOutliner.RemoveAttribs(aSelection, true, 0);
- std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
rOutliner.Clear();
rObj.NbcSetOutlinerParaObjectForText( std::move(pTemp), pText );
@@ -342,7 +342,7 @@ namespace sdr::properties
}
}
- std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
rOutliner.Clear();
rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText);
}
@@ -520,7 +520,7 @@ namespace sdr::properties
if(bBurnIn)
{
- std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> 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 d8ba459c4d2e..e284b5c965f2 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1638,7 +1638,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(pLast && pSrcPath->GetOutlinerParaObject())
{
- pLast->SetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pSrcPath->GetOutlinerParaObject()));
+ pLast->SetOutlinerParaObject(*pSrcPath->GetOutlinerParaObject());
}
}
else if(pCustomShape)
@@ -1678,7 +1678,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject();
if(pParaObj)
{
- pTextObj->NbcSetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pParaObj));
+ pTextObj->NbcSetOutlinerParaObject(*pParaObj);
}
// copy all attributes
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index e7a3f18076f1..8f469715bae9 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2731,7 +2731,7 @@ void SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const& rFormatSet, S
rOutliner.SetParaAttribs(nPara, aSet);
}
- std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
rOutliner.Clear();
rTextObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText);
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 96471b570841..534851d43df6 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2663,9 +2663,11 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle&
rOutliner.SetPaperSize( aNullSize );
// put text into the Outliner - if necessary the use the text from the EditOutliner
- OutlinerParaObject* pPara= GetOutlinerParaObject();
+ std::optional<OutlinerParaObject> pPara;
+ if (GetOutlinerParaObject())
+ pPara = *GetOutlinerParaObject();
if (mpEditingOutliner && !bNoEditText)
- pPara=mpEditingOutliner->CreateParaObject().release();
+ pPara=mpEditingOutliner->CreateParaObject();
if (pPara)
{
@@ -2686,8 +2688,6 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle&
{
rOutliner.SetTextObj( nullptr );
}
- if (mpEditingOutliner && !bNoEditText && pPara)
- delete pPara;
rOutliner.SetUpdateMode(true);
rOutliner.SetControlWord(nStat0);
@@ -2759,7 +2759,7 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle&
rTextRect=tools::Rectangle(aTextPos,aTextSiz);
}
-void SdrObjCustomShape::NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject)
+void SdrObjCustomShape::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject)
{
SdrTextObj::NbcSetOutlinerParaObject( std::move(pTextObject) );
SetBoundRectDirty();
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index b6c39ed1d762..f7d93162e12e 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1151,7 +1151,7 @@ basegfx::B2DPolyPolygon SdrObject::TakeContour() const
{
// no text and no text animation
pClone->SetMergedItem(SdrTextAniKindItem(SdrTextAniKind::NONE));
- pClone->SetOutlinerParaObject(nullptr);
+ pClone->SetOutlinerParaObject(std::nullopt);
}
const SdrEdgeObj* pEdgeObj = dynamic_cast< const SdrEdgeObj* >(this);
@@ -1802,7 +1802,7 @@ void SdrObject::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
-void SdrObject::SetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject)
+void SdrObject::SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject)
{
tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
NbcSetOutlinerParaObject(std::move(pTextObject));
@@ -1833,7 +1833,7 @@ void SdrObject::SetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextO
}
}
-void SdrObject::NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> /*pTextObject*/)
+void SdrObject::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> /*pTextObject*/)
{
}
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 1d8b59698ebb..a72040a4a792 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -1280,7 +1280,7 @@ OutlinerParaObject* SdrMeasureObj::GetOutlinerParaObject() const
return SdrTextObj::GetOutlinerParaObject();
}
-void SdrMeasureObj::NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject)
+void SdrMeasureObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject)
{
SdrTextObj::NbcSetOutlinerParaObject(std::move(pTextObject));
if(SdrTextObj::GetOutlinerParaObject())
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 308c2ebfe1e5..8d9997e0da70 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1229,7 +1229,7 @@ SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
if(pOPO)
{
- pClone->NbcSetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pOPO));
+ pClone->NbcSetOutlinerParaObject(*pOPO);
}
}
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 57020917c79e..bd492dfc50fa 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -118,7 +118,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource)
// objects). In the current form it makes only sense to
// create locally and use locally on a known existing SdrText
const Outliner* pEO = rSource.mpEditingOutliner;
- std::unique_ptr<OutlinerParaObject> pNewOutlinerParaObject;
+ std::optional<OutlinerParaObject> pNewOutlinerParaObject;
if (pEO!=nullptr)
{
@@ -126,7 +126,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource)
}
else if (nullptr != rSource.getActiveText()->GetOutlinerParaObject())
{
- pNewOutlinerParaObject.reset( new OutlinerParaObject(*rSource.getActiveText()->GetOutlinerParaObject()) );
+ pNewOutlinerParaObject = *rSource.getActiveText()->GetOutlinerParaObject();
}
pText->SetOutlinerParaObject( std::move(pNewOutlinerParaObject) );
@@ -242,7 +242,7 @@ void SdrTextObj::NbcSetText(const OUString& rStr)
SdrOutliner& rOutliner=ImpGetDrawOutliner();
rOutliner.SetStyleSheet( 0, GetStyleSheet());
rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 ));
- std::unique_ptr<OutlinerParaObject> pNewText=rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewText=rOutliner.CreateParaObject();
NbcSetOutlinerParaObject(std::move(pNewText));
mbTextSizeDirty=true;
}
@@ -261,7 +261,7 @@ void SdrTextObj::NbcSetText(SvStream& rInput, const OUString& rBaseURL, EETextFo
SdrOutliner& rOutliner=ImpGetDrawOutliner();
rOutliner.SetStyleSheet( 0, GetStyleSheet());
rOutliner.Read(rInput,rBaseURL,eFormat);
- std::unique_ptr<OutlinerParaObject> pNewText=rOutliner.CreateParaObject();
+ std::optional<OutlinerParaObject> pNewText=rOutliner.CreateParaObject();
rOutliner.SetUpdateMode(true);
Size aSize(rOutliner.CalcTextSize());
rOutliner.Clear();
@@ -769,7 +769,11 @@ 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 = (mpEditingOutliner && !bNoEditText) ? mpEditingOutliner->CreateParaObject().release() : pOutlinerParaObject;
+ std::optional<OutlinerParaObject> pPara;
+ if (mpEditingOutliner && !bNoEditText)
+ pPara = mpEditingOutliner->CreateParaObject();
+ else if (pOutlinerParaObject)
+ pPara = *pOutlinerParaObject;
if (pPara)
{
@@ -794,9 +798,6 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe
rOutliner.SetTextObj( nullptr );
}
- if (mpEditingOutliner && !bNoEditText && pPara)
- delete pPara;
-
rOutliner.SetUpdateMode(true);
rOutliner.SetControlWord(nStat0);
@@ -869,9 +870,9 @@ bool SdrTextObj::CanCreateEditOutlinerParaObject() const
return false;
}
-std::unique_ptr<OutlinerParaObject> SdrTextObj::CreateEditOutlinerParaObject() const
+std::optional<OutlinerParaObject> SdrTextObj::CreateEditOutlinerParaObject() const
{
- std::unique_ptr<OutlinerParaObject> pPara;
+ std::optional<OutlinerParaObject> pPara;
if( HasTextImpl( mpEditingOutliner ) )
{
sal_Int32 nParaCount = mpEditingOutliner->GetParagraphCount();
@@ -1338,12 +1339,12 @@ OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const
return nullptr;
}
-void SdrTextObj::NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject)
+void SdrTextObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject)
{
NbcSetOutlinerParaObjectForText( std::move(pTextObject), getActiveText() );
}
-void SdrTextObj::NbcSetOutlinerParaObjectForText( std::unique_ptr<OutlinerParaObject> pTextObject, SdrText* pText )
+void SdrTextObj::NbcSetOutlinerParaObjectForText( std::optional<OutlinerParaObject> pTextObject, SdrText* pText )
{
if( pText )
pText->SetOutlinerParaObject( std::move(pTextObject) );
diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx
index 1cd7bc57b105..adeb2412ced2 100644
--- a/svx/source/svdraw/svdotxat.cxx
+++ b/svx/source/svdraw/svdotxat.cxx
@@ -406,7 +406,7 @@ void SdrTextObj::RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>&
if(!mpEditingOutliner || (pText != getActiveText()) )
{
const sal_Int32 nParaCount = pOutliner->GetParagraphCount();
- std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
pOutliner->Clear();
NbcSetOutlinerParaObjectForText(std::move(pTemp), pText);
}
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
index 5840b1f950af..8642332a49a2 100644
--- a/svx/source/svdraw/svdotxed.cxx
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -269,7 +269,7 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl)
// to make the gray field background vanish again
rOutl.UpdateFields();
- std::unique_ptr<OutlinerParaObject> pNewText = rOutl.CreateParaObject( 0, rOutl.GetParagraphCount() );
+ std::optional<OutlinerParaObject> 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
diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx
index 9f4a5ce04f38..bd06940e25ac 100644
--- a/svx/source/svdraw/svdtext.cxx
+++ b/svx/source/svdraw/svdtext.cxx
@@ -52,7 +52,7 @@ void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
// TODO: optimization: we could create a BigTextObject
mbPortionInfoChecked=true;
- if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject())
+ if(mpOutlinerParaObject && rOutliner.ShouldCreateBigTextObject())
{
// #i102062# MemoryLeak closed
mpOutlinerParaObject = rOutliner.CreateParaObject();
@@ -70,39 +70,46 @@ const SfxItemSet& SdrText::GetItemSet() const
return const_cast< SdrText* >(this)->GetObjectItemSet();
}
-void SdrText::SetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject )
+void SdrText::SetOutlinerParaObject( std::optional<OutlinerParaObject> pTextObject )
{
- assert ( !mpOutlinerParaObject || (mpOutlinerParaObject.get() != pTextObject.get()) );
-
// Update HitTestOutliner
const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
- if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
- {
- mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
- }
+ if(pTestObj)
+ if ( (!pTestObj->GetOutlinerParaObject() && !mpOutlinerParaObject)
+ || (pTestObj->GetOutlinerParaObject() && mpOutlinerParaObject && *pTestObj->GetOutlinerParaObject() == *mpOutlinerParaObject) )
+ {
+ mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
+ }
mpOutlinerParaObject = std::move(pTextObject);
mbPortionInfoChecked = false;
}
-OutlinerParaObject* SdrText::GetOutlinerParaObject() const
+OutlinerParaObject* SdrText::GetOutlinerParaObject()
+{
+ return mpOutlinerParaObject ? &*mpOutlinerParaObject : nullptr;
+}
+
+const OutlinerParaObject* SdrText::GetOutlinerParaObject() const
{
- return mpOutlinerParaObject.get();
+ return mpOutlinerParaObject ? &*mpOutlinerParaObject : nullptr;
}
/** returns the current OutlinerParaObject and removes it from this instance */
-std::unique_ptr<OutlinerParaObject> SdrText::RemoveOutlinerParaObject()
+std::optional<OutlinerParaObject> SdrText::RemoveOutlinerParaObject()
{
// Update HitTestOutliner
const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
- if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
- {
- mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
- }
+ if(pTestObj)
+ if ( (!pTestObj->GetOutlinerParaObject() && !mpOutlinerParaObject)
+ || (pTestObj->GetOutlinerParaObject() && mpOutlinerParaObject && *pTestObj->GetOutlinerParaObject() == *mpOutlinerParaObject) )
+ {
+ mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
+ }
- std::unique_ptr<OutlinerParaObject> pOPO = std::move(mpOutlinerParaObject);
+ std::optional<OutlinerParaObject> pOPO = std::move(mpOutlinerParaObject);
mbPortionInfoChecked = false;
return pOPO;
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 2fac21a7fa22..2eea31d23237 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -391,7 +391,7 @@ void SdrUndoAttrObj::Undo()
if(pTextUndo)
{
- pObj->SetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pTextUndo));
+ pObj->SetOutlinerParaObject(*pTextUndo);
}
}
@@ -473,7 +473,7 @@ void SdrUndoAttrObj::Redo()
// #i8508#
if(pTextRedo)
{
- pObj->SetOutlinerParaObject(std::make_unique<OutlinerParaObject>(*pTextRedo));
+ pObj->SetOutlinerParaObject(*pTextRedo);
}
}
@@ -981,7 +981,7 @@ SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText)
{
SdrText* pText = static_cast< SdrTextObj*>( &rNewObj )->getText(mnText);
if( pText && pText->GetOutlinerParaObject() )
- pOldText.reset( new OutlinerParaObject(*pText->GetOutlinerParaObject()) );
+ pOldText = *pText->GetOutlinerParaObject();
bEmptyPresObj = rNewObj.IsEmptyPresObj();
}
@@ -996,7 +996,7 @@ bool SdrUndoObjSetText::IsDifferent() const
{
if (!pOldText || !pNewText)
return pOldText || pNewText;
- return !(*pOldText == *pNewText);
+ return *pOldText != *pNewText;
}
void SdrUndoObjSetText::AfterSetText()
@@ -1005,7 +1005,7 @@ void SdrUndoObjSetText::AfterSetText()
{
SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
if( pText && pText->GetOutlinerParaObject() )
- pNewText.reset( new OutlinerParaObject(*pText->GetOutlinerParaObject()) );
+ pNewText = *pText->GetOutlinerParaObject();
bNewTextAvailable=true;
}
}
@@ -1034,8 +1034,7 @@ void SdrUndoObjSetText::Undo()
if (pText)
{
// copy text for Undo, because the original now belongs to SetOutlinerParaObject()
- std::unique_ptr<OutlinerParaObject> pText1( pOldText ? new OutlinerParaObject(*pOldText) : nullptr );
- pTarget->NbcSetOutlinerParaObjectForText(std::move(pText1), pText);
+ pTarget->NbcSetOutlinerParaObjectForText(pOldText, pText);
}
pTarget->SetEmptyPresObj(bEmptyPresObj);
@@ -1068,8 +1067,7 @@ void SdrUndoObjSetText::Redo()
if (pText)
{
// copy text for Undo, because the original now belongs to SetOutlinerParaObject()
- std::unique_ptr<OutlinerParaObject> pText1( pNewText ? new OutlinerParaObject(*pNewText) : nullptr );
- pTarget->NbcSetOutlinerParaObjectForText( std::move(pText1), pText );
+ pTarget->NbcSetOutlinerParaObjectForText( pNewText, pText );
}
pTarget->ActionChanged();
@@ -1123,10 +1121,7 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView)
if( bUndo )
rView.AddUndo(std::make_unique<SdrUndoObjSetText>(*pTextObj,0));
- std::unique_ptr<OutlinerParaObject> pText1;
- if (pNewText)
- pText1.reset(new OutlinerParaObject(*pNewText));
- pTextObj->SetOutlinerParaObject(std::move(pText1));
+ pTextObj->SetOutlinerParaObject(pNewText);
}
}
diff --git a/svx/source/svdraw/textchainflow.cxx b/svx/source/svdraw/textchainflow.cxx
index f35d9c8a623b..2c4a7c84f2b2 100644
--- a/svx/source/svdraw/textchainflow.cxx
+++ b/svx/source/svdraw/textchainflow.cxx
@@ -156,7 +156,7 @@ void TextChainFlow::ExecuteUnderflow(SdrOutliner *pOutl)
//GetTextChain()->SetNilChainingEvent(mpTargetLink, true);
// making whole text
// merges underflowing text with the one in the next box
- std::unique_ptr<OutlinerParaObject> pNewText = mpUnderflChText->CreateMergedUnderflowParaObject(pOutl, mpNextLink->GetOutlinerParaObject());
+ std::optional<OutlinerParaObject> 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,16 +165,15 @@ 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(std::move(pNewText));
+ mpTargetLink->NbcSetOutlinerParaObject(pNewText);
}
// Restore size and set new text
//pOutl->SetMaxAutoPaperSize(aOldSize); // XXX (it seems to be working anyway without this)
- pOutl->SetText(*pNewTextTemp);
+ pOutl->SetText(*pNewText);
//GetTextChain()->SetNilChainingEvent(mpTargetLink, false);
@@ -199,7 +198,7 @@ void TextChainFlow::ExecuteOverflow(SdrOutliner *pNonOverflOutl, SdrOutliner *pO
void TextChainFlow::impLeaveOnlyNonOverflowingText(SdrOutliner *pNonOverflOutl)
{
- std::unique_ptr<OutlinerParaObject> pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl);
+ std::optional<OutlinerParaObject> pNewText = mpOverflChText->RemoveOverflowingText(pNonOverflOutl);
SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] SOURCE box set to "
<< pNewText->GetTextObject().GetParagraphCount() << " paras");
@@ -222,7 +221,7 @@ void TextChainFlow::impMoveChainedTextToNextLink(SdrOutliner *pOverflOutl)
return;
}
- std::unique_ptr<OutlinerParaObject> pNewText =
+ std::optional<OutlinerParaObject> pNewText =
mpOverflChText->InsertOverflowingText(pOverflOutl,
mpNextLink->GetOutlinerParaObject());
SAL_INFO("svx.chaining", "[TEXTCHAINFLOW - OF] DEST box set to "
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index ed16ada82763..52c6f7ebe3d2 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -228,12 +228,10 @@ namespace sdr::properties
if( mxCell.is() )
{
- OutlinerParaObject* pParaObj = mxCell->CreateEditOutlinerParaObject().release();
+ std::optional<OutlinerParaObject> pParaObj = mxCell->CreateEditOutlinerParaObject();
- const bool bOwnParaObj = pParaObj != nullptr;
-
- if( pParaObj == nullptr )
- pParaObj = mxCell->GetOutlinerParaObject();
+ if( !pParaObj && mxCell->GetOutlinerParaObject())
+ pParaObj = *mxCell->GetOutlinerParaObject();
if(pParaObj)
{
@@ -281,13 +279,11 @@ namespace sdr::properties
mxItemSet->Put(aNewSet);
}
- std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount);
pOutliner->Clear();
mxCell->SetOutlinerParaObject(std::move(pTemp));
}
- if( bOwnParaObj )
- delete pParaObj;
}
}
@@ -308,19 +304,14 @@ namespace sdr::properties
rObj.SetVerticalWriting(bVertical);
// Set a cell vertical property
- OutlinerParaObject* pParaObj = mxCell->CreateEditOutlinerParaObject().release();
-
- const bool bOwnParaObj = pParaObj != nullptr;
+ std::optional<OutlinerParaObject> pParaObj = mxCell->CreateEditOutlinerParaObject();
- if( pParaObj == nullptr )
- pParaObj = mxCell->GetOutlinerParaObject();
+ if( !pParaObj && mxCell->GetOutlinerParaObject() )
+ pParaObj = *mxCell->GetOutlinerParaObject();
if(pParaObj)
{
pParaObj->SetVertical(bVertical);
-
- if( bOwnParaObj )
- delete pParaObj;
}
}
@@ -329,12 +320,10 @@ namespace sdr::properties
const SvxTextRotateItem* pRotateItem = static_cast<const SvxTextRotateItem*>(pNewItem);
// Set a cell vertical property
- OutlinerParaObject* pParaObj = mxCell->CreateEditOutlinerParaObject().release();
+ std::optional<OutlinerParaObject> pParaObj = mxCell->CreateEditOutlinerParaObject();
- const bool bOwnParaObj = pParaObj != nullptr;
-
- if (pParaObj == nullptr)
- pParaObj = mxCell->GetOutlinerParaObject();
+ if (!pParaObj && mxCell->GetOutlinerParaObject())
+ pParaObj = *mxCell->GetOutlinerParaObject();
if (pParaObj)
{
@@ -344,9 +333,6 @@ namespace sdr::properties
pParaObj->SetRotation(TextRotation::BOTTOMTOTOP);
else
pParaObj->SetRotation(TextRotation::NONE);
-
- if (bOwnParaObj)
- delete pParaObj;
}
// Change autogrow direction
@@ -448,7 +434,7 @@ void Cell::dispose()
if( mpProperties )
{
mpProperties.reset();
- SetOutlinerParaObject( nullptr );
+ SetOutlinerParaObject( std::nullopt );
}
}
@@ -521,9 +507,9 @@ void Cell::replaceContentAndFormatting( const CellRef& xSourceCell )
// tdf#118354 OutlinerParaObject may be nullptr, do not dereference when
// not set (!)
- if(nullptr != xSourceCell->GetOutlinerParaObject())
+ if(xSourceCell->GetOutlinerParaObject())
{
- SetOutlinerParaObject( std::make_unique<OutlinerParaObject>(*xSourceCell->GetOutlinerParaObject()) );
+ SetOutlinerParaObject( *xSourceCell->GetOutlinerParaObject() );
}
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
@@ -605,7 +591,7 @@ bool Cell::IsTextEditActive() const
bool Cell::hasText() const
{
- OutlinerParaObject* pParaObj = GetOutlinerParaObject();
+ const OutlinerParaObject* pParaObj = GetOutlinerParaObject();
if( pParaObj )
{
const EditTextObject& rTextObj = pParaObj->GetTextObject();
@@ -631,12 +617,12 @@ bool Cell::CanCreateEditOutlinerParaObject() const
return false;
}
-std::unique_ptr<OutlinerParaObject> Cell::CreateEditOutlinerParaObject() const
+std::optional<OutlinerParaObject> Cell::CreateEditOutlinerParaObject() const
{
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
if( rTableObj.getActiveCell().get() == this )
return rTableObj.CreateEditOutlinerParaObject();
- return nullptr;
+ return std::nullopt;
}
@@ -807,9 +793,9 @@ SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
}
-void Cell::SetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject )
+void Cell::SetOutlinerParaObject( std::optional<OutlinerParaObject> pTextObject )
{
- bool bNullTextObject = pTextObject == nullptr;
+ bool bNullTextObject = !pTextObject;
SdrText::SetOutlinerParaObject( std::move(pTextObject) );
maSelection.nStartPara = EE_PARA_MAX_COUNT;
@@ -1597,7 +1583,7 @@ void SAL_CALL Cell::setAllPropertiesToDefault()
ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL);
rOutliner.RemoveAttribs(aSelection, true, 0);
- std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
+ std::optional<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount);
rOutliner.Clear();
SetOutlinerParaObject(std::move(pTemp));
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 4632b854fe78..bbb653501b8d 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1523,9 +1523,11 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too
// set text at outliner, maybe from edit outliner
- OutlinerParaObject* pPara= xCell->GetOutlinerParaObject();
+ std::optional<OutlinerParaObject> pPara;
+ if (xCell->GetOutlinerParaObject())
+ pPara = *xCell->GetOutlinerParaObject();
if (mpEditingOutliner && !bNoEditText && mpImpl->mxActiveCell == xCell )
- pPara=mpEditingOutliner->CreateParaObject().release();
+ pPara = mpEditingOutliner->CreateParaObject();
if (pPara)
{
@@ -1546,9 +1548,6 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too
rOutliner.SetTextObj( nullptr );
}
- if (mpEditingOutliner && !bNoEditText && pPara && mpImpl->mxActiveCell == xCell )
- delete pPara;
-
rOutliner.SetUpdateMode(true);
rOutliner.SetControlWord(nStat0);
@@ -1862,7 +1861,7 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
if(rOutl.IsModified())
{
- std::unique_ptr<OutlinerParaObject> pNewText;
+ std::optional<OutlinerParaObject> pNewText;
Paragraph* p1stPara = rOutl.GetParagraph( 0 );
sal_Int32 nParaCnt = rOutl.GetParagraphCount();
@@ -1897,7 +1896,7 @@ OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() const
}
-void SdrTableObj::NbcSetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject)
+void SdrTableObj::NbcSetOutlinerParaObject( std::optional<OutlinerParaObject> pTextObject)
{
CellRef xCell( getActiveCell() );
if( !xCell.is() )
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index e12d5fb1d68b..ec0d93d3e662 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -1449,7 +1449,7 @@ bool SvxTableController::DeleteMarked()
{
if (bUndo)
xCell->AddUndo();
- xCell->SetOutlinerParaObject(nullptr);
+ xCell->SetOutlinerParaObject(std::nullopt);
}
}
}
diff --git a/svx/source/table/tablertfexporter.cxx b/svx/source/table/tablertfexporter.cxx
index b131fa09bf3c..d29cdc958cc7 100644
--- a/svx/source/table/tablertfexporter.cxx
+++ b/svx/source/table/tablertfexporter.cxx
@@ -169,11 +169,10 @@ void SdrTableRtfExporter::WriteCell( sal_Int32 nCol, sal_Int32 nRow )
OUString aContent;
- OutlinerParaObject* pParaObj = xCell->CreateEditOutlinerParaObject().release();
- bool bOwnParaObj = pParaObj != nullptr;
+ std::optional<OutlinerParaObject> pParaObj = xCell->CreateEditOutlinerParaObject();
- if( pParaObj == nullptr )
- pParaObj = xCell->GetOutlinerParaObject();
+ if( !pParaObj && xCell->GetOutlinerParaObject() )
+ pParaObj = *xCell->GetOutlinerParaObject();
if(pParaObj)
{
@@ -184,9 +183,6 @@ void SdrTableRtfExporter::WriteCell( sal_Int32 nCol, sal_Int32 nRow )
aContent = rOutliner.GetEditEngine().GetText();
rOutliner.Clear();
-
- if( bOwnParaObj )
- delete pParaObj;
}
bool bResetAttr = false;
diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx
index 0fc765ba66ce..f00ca3a159b2 100644
--- a/svx/source/table/tablertfimporter.cxx
+++ b/svx/source/table/tablertfimporter.cxx
@@ -315,7 +315,7 @@ void SdrTableRTFParser::FillTable()
if( xCellInfo->maItemSet.GetItemState(SDRATTR_TABLE_BORDER,false,&pPoolItem)==SfxItemState::SET)
xCell->SetMergedItem( *pPoolItem );
- std::unique_ptr<OutlinerParaObject> pTextObject(mpOutliner->CreateParaObject( xCellInfo->mnStartPara, xCellInfo->mnParaCount ));
+ std::optional<OutlinerParaObject> pTextObject(mpOutliner->CreateParaObject( xCellInfo->mnStartPara, xCellInfo->mnParaCount ));
if( pTextObject )
{
SdrOutliner& rOutliner=mrTableObj.ImpGetDrawOutliner();
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index a037db9c9aa8..2840562a4acf 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -107,7 +107,7 @@ void CellUndo::setDataToCell( const Data& rData )
mxCell->mpProperties.reset();
if( rData.mpOutlinerParaObject )
- mxCell->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>(*rData.mpOutlinerParaObject) );
+ mxCell->SetOutlinerParaObject( *rData.mpOutlinerParaObject );
else
mxCell->RemoveOutlinerParaObject();
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 7afed3609a5d..50c341cab694 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -534,16 +534,16 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
{
mpTextForwarder->flushCache();
- OutlinerParaObject* pOutlinerParaObject = nullptr;
+ std::optional<OutlinerParaObject> pOutlinerParaObject;
SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject );
if( pTextObj && pTextObj->getActiveText() == mpText )
- pOutlinerParaObject = pTextObj->CreateEditOutlinerParaObject().release(); // Get the OutlinerParaObject if text edit is active
+ pOutlinerParaObject = pTextObj->CreateEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
bool bOwnParaObj(false);
if( pOutlinerParaObject )
bOwnParaObj = true; // text edit active
- else
- pOutlinerParaObject = mpText->GetOutlinerParaObject();
+ else if (mpText->GetOutlinerParaObject())
+ pOutlinerParaObject = *mpText->GetOutlinerParaObject();
if( pOutlinerParaObject && ( bOwnParaObj || !mpObject->IsEmptyPresObj() || mpObject->getSdrPageFromSdrObject()->IsMasterPage() ) )
{
@@ -556,7 +556,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
if( mpText && bOwnParaObj && mpObject->IsEmptyPresObj() && pTextObj->IsReallyEdited() )
{
mpObject->SetEmptyPresObj( false );
- static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( std::unique_ptr<OutlinerParaObject>(pOutlinerParaObject), mpText );
+ static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( pOutlinerParaObject, mpText );
// #i103982# Here, due to mpObject->NbcSetOutlinerParaObjectForText, we LOSE ownership of the
// OPO, so do NOT delete it when leaving this method (!)
@@ -600,9 +600,6 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
}
mbDataValid = true;
-
- if( bOwnParaObj )
- delete pOutlinerParaObject;
}
if( bCreated && mpOutliner && HasView() )
@@ -786,7 +783,7 @@ void SvxTextEditSourceImpl::UpdateData()
}
else
{
- pTextObj->NbcSetOutlinerParaObjectForText( nullptr,mpText );
+ pTextObj->NbcSetOutlinerParaObjectForText( std::nullopt, mpText );
}
}
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index f3a2cdc14b4c..1b76fe7bf83b 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -23,6 +23,7 @@
#include <string_view>
+#include <editeng/outlobj.hxx>
#include <tools/solar.h>
#include <tools/date.hxx>
#include <tools/datetime.hxx>
@@ -450,7 +451,7 @@ class SW_DLLPUBLIC SwPostItField final : public SwField
OUString m_sName; ///< Name of the comment.
DateTime m_aDateTime;
bool m_bResolved;
- std::unique_ptr<OutlinerParaObject> mpText;
+ std::optional<OutlinerParaObject> mpText;
rtl::Reference<SwTextAPIObject> m_xTextObject;
sal_uInt32 m_nPostItId;
@@ -491,8 +492,8 @@ public:
void SetName(const OUString& rStr);
const OUString& GetName() const { return m_sName;}
- const OutlinerParaObject* GetTextObject() const { return mpText.get();}
- void SetTextObject( std::unique_ptr<OutlinerParaObject> pText );
+ const OutlinerParaObject* GetTextObject() const { return mpText ? &*mpText : nullptr;}
+ void SetTextObject( std::optional<OutlinerParaObject> pText );
void SetResolved(bool bNewState);
void ToggleResolved();
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 7c703fcbffa1..41016a18b3ba 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1782,7 +1782,7 @@ std::unique_ptr<SwField> SwPostItField::Copy() const
std::unique_ptr<SwPostItField> pRet(new SwPostItField( static_cast<SwPostItFieldType*>(GetTyp()), m_sAuthor, m_sText, m_sInitials, m_sName,
m_aDateTime, m_bResolved, m_nPostItId));
if (mpText)
- pRet->SetTextObject( std::make_unique<OutlinerParaObject>(*mpText) );
+ pRet->SetTextObject( *mpText );
// Note: member <m_xTextObject> not copied.
@@ -1820,7 +1820,7 @@ void SwPostItField::SetName(const OUString& rName)
}
-void SwPostItField::SetTextObject( std::unique_ptr<OutlinerParaObject> pText )
+void SwPostItField::SetTextObject( std::optional<OutlinerParaObject> pText )
{
mpText = std::move(pText);
}
@@ -1938,7 +1938,7 @@ void SwPostItField::dumpAsXml(xmlTextWriterPtr pWriter) const
SwField::dumpAsXml(pWriter);
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("mpText"));
- (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", mpText.get());
+ (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", mpText ? &*mpText : nullptr);
if (mpText)
mpText->dumpAsXml(pWriter);
(void)xmlTextWriterEndElement(pWriter);
diff --git a/sw/source/core/fields/textapi.cxx b/sw/source/core/fields/textapi.cxx
index 25c9d46edefa..2efb97ef61ed 100644
--- a/sw/source/core/fields/textapi.cxx
+++ b/sw/source/core/fields/textapi.cxx
@@ -174,12 +174,12 @@ void SwTextAPIEditSource::SetString( const OUString& rText )
m_pImpl->mpOutliner->Insert( rText );
}
-std::unique_ptr<OutlinerParaObject> SwTextAPIEditSource::CreateText()
+std::optional<OutlinerParaObject> SwTextAPIEditSource::CreateText()
{
if ( m_pImpl->mpPool && m_pImpl->mpOutliner )
return m_pImpl->mpOutliner->CreateParaObject();
else
- return nullptr;
+ return std::nullopt;
}
OUString SwTextAPIEditSource::GetText() const
diff --git a/sw/source/core/inc/textapi.hxx b/sw/source/core/inc/textapi.hxx
index 261388446333..48586b5fa561 100644
--- a/sw/source/core/inc/textapi.hxx
+++ b/sw/source/core/inc/textapi.hxx
@@ -43,7 +43,7 @@ public:
void Dispose();
void SetText( OutlinerParaObject const & rText );
void SetString( const OUString& rText );
- std::unique_ptr<OutlinerParaObject> CreateText();
+ std::optional<OutlinerParaObject> CreateText();
OUString GetText() const;
};
@@ -54,7 +54,7 @@ public:
SwTextAPIObject( std::unique_ptr<SwTextAPIEditSource> p);
virtual ~SwTextAPIObject() noexcept override;
void DisposeEditSource() { m_pSource->Dispose(); }
- std::unique_ptr<OutlinerParaObject> CreateText() { return m_pSource->CreateText(); }
+ std::optional<OutlinerParaObject> CreateText() { return m_pSource->CreateText(); }
void SetString( const OUString& rText ) { m_pSource->SetString( rText ); }
void SetText( OutlinerParaObject const & rText ) { m_pSource->SetText( rText ); }
OUString GetText() const { return m_pSource->GetText(); }
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 15b50ed3ce7b..ed2786d5dd14 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1321,7 +1321,7 @@ void SwFlyFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorderA
Size aSize(getFrameArea().Width(), getFrameArea().Height());
pCustomShape->SuggestTextFrameSize(aSize);
// Do the calculations normally done after touching editeng text of the shape.
- pCustomShape->NbcSetOutlinerParaObjectForText(nullptr, nullptr);
+ pCustomShape->NbcSetOutlinerParaObjectForText(std::nullopt, nullptr);
}
}
}
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 320d8026ed33..671d1b85356f 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -597,7 +597,7 @@ sal_Int32 RtfSdrExport::StartShape()
if (pTextObj)
{
const OutlinerParaObject* pParaObj = nullptr;
- std::unique_ptr<const OutlinerParaObject> pOwnedParaObj;
+ std::optional<OutlinerParaObject> pOwnedParaObj;
/*
#i13885#
@@ -607,7 +607,8 @@ sal_Int32 RtfSdrExport::StartShape()
if (pTextObj->IsTextEditActive())
{
pOwnedParaObj = pTextObj->CreateEditOutlinerParaObject();
- pParaObj = pOwnedParaObj.get();
+ if (pOwnedParaObj)
+ pParaObj = &*pOwnedParaObj;
}
else
{
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 38e9eb2554ad..0e5d92009d54 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1316,8 +1316,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp)
{
- const OutlinerParaObject* pParaObj = nullptr;
- bool bOwnParaObj = false;
+ std::optional<OutlinerParaObject> pParaObj;
/*
#i13885#
@@ -1326,19 +1325,16 @@ void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp)
*/
if (rTextObj.IsTextEditActive())
{
- pParaObj = rTextObj.CreateEditOutlinerParaObject().release();
- bOwnParaObj = true;
+ pParaObj = rTextObj.CreateEditOutlinerParaObject();
}
- else
+ else if (rTextObj.GetOutlinerParaObject())
{
- pParaObj = rTextObj.GetOutlinerParaObject();
+ pParaObj = *rTextObj.GetOutlinerParaObject();
}
if( pParaObj )
{
WriteOutliner(*pParaObj, nTyp);
- if( bOwnParaObj )
- delete pParaObj;
}
}
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 53b83df43f07..a8a32cc2a574 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -960,9 +960,9 @@ static void removePositions(EditEngine &rDrawEditEngine, const std::vector<sal_I
}
}
-std::unique_ptr<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType)
+std::optional<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType)
{
- std::unique_ptr<OutlinerParaObject> pRet;
+ std::optional<OutlinerParaObject> pRet;
sal_Int32 nLen = GetRangeAsDrawingString(rString, nStartCp, nEndCp, eType);
if (nLen > 0)
@@ -992,7 +992,7 @@ std::unique_ptr<OutlinerParaObject> SwWW8ImplReader::ImportAsOutliner(OUString &
}
std::unique_ptr<EditTextObject> pTemporaryText = m_pDrawEditEngine->CreateTextObject();
- pRet.reset( new OutlinerParaObject( std::move(pTemporaryText) ) );
+ pRet.emplace( std::move(pTemporaryText) );
pRet->SetOutlinerMode( OutlinerMode::TextObject );
m_pDrawEditEngine->SetText( OUString() );
@@ -1196,10 +1196,10 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
}
bool bVertical = pTextObj->IsVerticalWriting();
- std::unique_ptr<OutlinerParaObject> pOp(new OutlinerParaObject(m_pDrawEditEngine->CreateTextObject()));
- pOp->SetOutlinerMode( OutlinerMode::TextObject );
- pOp->SetVertical( bVertical );
- pTextObj->NbcSetOutlinerParaObject( std::move(pOp) );
+ OutlinerParaObject aOp(m_pDrawEditEngine->CreateTextObject());
+ aOp.SetOutlinerMode( OutlinerMode::TextObject );
+ aOp.SetVertical( bVertical );
+ pTextObj->NbcSetOutlinerParaObject( std::move(aOp) );
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 e26df0532845..62631335a4ed 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2159,7 +2159,7 @@ tools::Long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
DateTime aDate = msfilter::util::DTTM2DateTime(nDateTime);
OUString sText;
- std::unique_ptr<OutlinerParaObject> pOutliner = ImportAsOutliner( sText, pRes->nCp2OrIdx,
+ std::optional<OutlinerParaObject> pOutliner = ImportAsOutliner( sText, pRes->nCp2OrIdx,
pRes->nCp2OrIdx + pRes->nMemLen, MAN_AND );
m_xFormatOfJustInsertedApo.reset();
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index f1a9c4fde3cb..dfd62872421d 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1599,7 +1599,7 @@ private:
bool GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, sal_uInt16 nTxBxS,
sal_uInt16 nSequence);
sal_Int32 GetRangeAsDrawingString(OUString& rString, tools::Long StartCp, tools::Long nEndCp, ManTypes eType);
- std::unique_ptr<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
+ std::optional<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
void InsertTxbxText(SdrTextObj* pTextObj, Size const * pObjSiz,
sal_uInt16 nTxBxS, sal_uInt16 nSequence, tools::Long nPosCp, SwFrameFormat const * pFlyFormat,
bool bMakeSdrGrafObj, bool& rbEraseTextObj,