summaryrefslogtreecommitdiff
path: root/editeng
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 /editeng
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 'editeng')
-rw-r--r--editeng/source/outliner/outliner.cxx11
-rw-r--r--editeng/source/outliner/outlobj.cxx5
-rw-r--r--editeng/source/outliner/overflowingtxt.cxx18
-rw-r--r--editeng/source/uno/unoforou.cxx3
4 files changed, 20 insertions, 17 deletions
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 344ece6b82ff..d595486c2fdb 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -369,7 +369,7 @@ void Outliner::SetHoriAlignIgnoreTrailingWhitespace(bool bEnabled)
pEditEngine->SetHoriAlignIgnoreTrailingWhitespace( bEnabled );
}
-OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const
+std::unique_ptr<OutlinerParaObject> Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 nCount ) const
{
if ( static_cast<sal_uLong>(nStartPara) + nCount >
static_cast<sal_uLong>(pParaList->GetParagraphCount()) )
@@ -393,7 +393,7 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32
aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara);
}
- OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc);
+ std::unique_ptr<OutlinerParaObject> pPObj(new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc));
pPObj->SetOutlinerMode(GetMode());
return pPObj;
@@ -401,9 +401,8 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32
void Outliner::SetToEmptyText()
{
- OutlinerParaObject *pEmptyTxt = GetEmptyParaObject();
+ std::unique_ptr<OutlinerParaObject> pEmptyTxt = GetEmptyParaObject();
SetText(*pEmptyTxt);
- delete pEmptyTxt;
}
void Outliner::SetText( const OUString& rText, Paragraph* pPara )
@@ -2115,10 +2114,10 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const
}
}
-OutlinerParaObject *Outliner::GetEmptyParaObject() const
+std::unique_ptr<OutlinerParaObject> Outliner::GetEmptyParaObject() const
{
std::unique_ptr<EditTextObject> pEmptyText = pEditEngine->GetEmptyTextObject();
- OutlinerParaObject* pPObj = new OutlinerParaObject( *pEmptyText );
+ std::unique_ptr<OutlinerParaObject> pPObj( new OutlinerParaObject( std::move(pEmptyText) ));
pPObj->SetOutlinerMode(GetMode());
return pPObj;
}
diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx
index 04688bb06728..8002419cc37d 100644
--- a/editeng/source/outliner/outlobj.cxx
+++ b/editeng/source/outliner/outlobj.cxx
@@ -77,6 +77,11 @@ OutlinerParaObject::OutlinerParaObject( const EditTextObject& rTextObj ) :
{
}
+OutlinerParaObject::OutlinerParaObject( std::unique_ptr<EditTextObject> pTextObj ) :
+ mpImpl(OutlinerParaObjData(std::move(pTextObj), ParagraphDataVector(), true))
+{
+}
+
OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& r ) :
mpImpl(r.mpImpl)
{
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 5577104b7f7e..e5bc3097e82b 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
-OutlinerParaObject *TextChainingUtils::JuxtaposeParaObject(
+std::unique_ptr<OutlinerParaObject> TextChainingUtils::JuxtaposeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *pOutl,
OutlinerParaObject const *pNextPObj)
@@ -66,7 +66,7 @@ OutlinerParaObject *TextChainingUtils::JuxtaposeParaObject(
return pOutl->CreateParaObject();
}
-OutlinerParaObject *TextChainingUtils::DeeplyMergeParaObject(
+std::unique_ptr<OutlinerParaObject> TextChainingUtils::DeeplyMergeParaObject(
css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent,
Outliner *pOutl,
OutlinerParaObject const *pNextPObj)
@@ -125,7 +125,7 @@ bool NonOverflowingText::IsLastParaInterrupted() const
}
-OutlinerParaObject *NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const
+std::unique_ptr<OutlinerParaObject> NonOverflowingText::RemoveOverflowingText(Outliner *pOutliner) const
{
pOutliner->QuickDelete(maContentSel);
SAL_INFO("editeng.chaining", "Deleting selection from (Para: " << maContentSel.nStartPara
@@ -144,12 +144,12 @@ ESelection NonOverflowingText::GetOverflowPointSel() const
// The equivalent of ToParaObject for OverflowingText. Here we are prepending the overflowing text to the old dest box's text
// XXX: In a sense a better name for OverflowingText and NonOverflowingText are respectively DestLinkText and SourceLinkText
-OutlinerParaObject *OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
+std::unique_ptr<OutlinerParaObject> OverflowingText::JuxtaposeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
{
return TextChainingUtils::JuxtaposeParaObject(mxOverflowingContent, pOutl, pNextPObj);
}
-OutlinerParaObject *OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
+std::unique_ptr<OutlinerParaObject> OverflowingText::DeeplyMergeParaObject(Outliner *pOutl, OutlinerParaObject const *pNextPObj)
{
return TextChainingUtils::DeeplyMergeParaObject(mxOverflowingContent, pOutl, pNextPObj);
}
@@ -174,7 +174,7 @@ ESelection OFlowChainedText::GetOverflowPointSel() const
return mpNonOverflowingTxt->GetOverflowPointSel();
}
-OutlinerParaObject *OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged)
+std::unique_ptr<OutlinerParaObject> OFlowChainedText::InsertOverflowingText(Outliner *pOutliner, OutlinerParaObject const *pTextToBeMerged)
{
// Just return the roughly merged paras for now
if (mpOverflowingTxt == nullptr)
@@ -190,7 +190,7 @@ OutlinerParaObject *OFlowChainedText::InsertOverflowingText(Outliner *pOutliner,
}
-OutlinerParaObject *OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner)
+std::unique_ptr<OutlinerParaObject> OFlowChainedText::RemoveOverflowingText(Outliner *pOutliner)
{
if (mpNonOverflowingTxt == nullptr)
return nullptr;
@@ -212,9 +212,9 @@ UFlowChainedText::UFlowChainedText(Outliner const *pOutl, bool bIsDeepMerge)
mbIsDeepMerge = bIsDeepMerge;
}
-OutlinerParaObject *UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText)
+std::unique_ptr<OutlinerParaObject> UFlowChainedText::CreateMergedUnderflowParaObject(Outliner *pOutl, OutlinerParaObject const *pNextLinkWholeText)
{
- OutlinerParaObject *pNewText = nullptr;
+ std::unique_ptr<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 fa8e08ed16d7..c53d610b97c1 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -544,9 +544,8 @@ void SvxOutlinerForwarder::CopyText(const SvxTextForwarder& rSource)
const SvxOutlinerForwarder* pSourceForwarder = dynamic_cast< const SvxOutlinerForwarder* >( &rSource );
if( !pSourceForwarder )
return;
- OutlinerParaObject* pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject();
+ std::unique_ptr<OutlinerParaObject> pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject();
rOutliner.SetText( *pNewOutlinerParaObject );
- delete pNewOutlinerParaObject;
}