summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-29 15:38:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-02 08:47:58 +0200
commit50c63e5c2f7962e8893e2d04b0e958209432f4c9 (patch)
tree308893225e96328c5ff5fd071a97c2110e61577b /sc
parentd98f1e4e0373782ad71b945dcc92c1c3d6dcf6c8 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/postit.cxx7
-rw-r--r--sc/source/filter/excel/xiescher.cxx5
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx4
3 files changed, 8 insertions, 8 deletions
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 <userdat.hxx>
#include <detfunc.hxx>
#include <editutil.hxx>
+#include <o3tl/make_unique.hxx>
#include <utility>
@@ -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<OutlinerParaObject>( *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<OutlinerParaObject>( *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<OutlinerParaObject> 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<EditTextObject> pEditObj = pEditEngine->CreateTextObject();
- OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
+ std::unique_ptr<OutlinerParaObject> pOPO( new OutlinerParaObject( *pEditObj ) );
pEditObj.reset();
pOPO->SetOutlinerMode( OutlinerMode::TextObject );
- pObj->NbcSetOutlinerParaObject( pOPO );
+ pObj->NbcSetOutlinerParaObject( std::move(pOPO) );
pObj->ActionChanged();
}