summaryrefslogtreecommitdiff
path: root/starmath/source/cursor.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-16 12:22:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-18 09:38:28 +0200
commit9fd7808f79fe48af9d9a4d47561abb9b8c66cbc3 (patch)
treea16d9aad588e70a34bdfe69fe4e709d3bc99226b /starmath/source/cursor.cxx
parent2caee0fac86165730b676727390dc74852f9663d (diff)
loplugin:useuniqueptr pass SmNodeList around by std::unique_ptr(2)
Change-Id: I53b7f39ddc150367bc5f9c4a7ee7049d59e9f485 Reviewed-on: https://gerrit.libreoffice.org/59231 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/cursor.cxx')
-rw-r--r--starmath/source/cursor.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 4afe12d2e445..cc0037f2ef85 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -291,9 +291,8 @@ void SmCursor::Delete(){
FinishEdit(std::move(pLineList), pLineParent, nLineOffset, PosAfterDelete);
}
-void SmCursor::InsertNodes(SmNodeList* pNewNodes){
+void SmCursor::InsertNodes(std::unique_ptr<SmNodeList> pNewNodes){
if(pNewNodes->empty()){
- delete pNewNodes;
return;
}
@@ -331,8 +330,7 @@ void SmCursor::InsertNodes(SmNodeList* pNewNodes){
PatchLineList(pLineList.get(), patchIt);
SmCaretPos PosAfterInsert = PatchLineList(pLineList.get(), it);
//Release list, we've taken the nodes
- delete pNewNodes;
- pNewNodes = nullptr;
+ pNewNodes.reset();
//Finish editing
FinishEdit(std::move(pLineList), pLineParent, nParentIndex, PosAfterInsert);
@@ -881,9 +879,9 @@ void SmCursor::InsertText(const OUString& aString)
pText->AdjustFontDesc();
pText->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pText);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -983,9 +981,9 @@ void SmCursor::InsertElement(SmFormulaElement element){
pNewNode->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
//Insert new node
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pNewNode);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -1010,9 +1008,9 @@ void SmCursor::InsertSpecial(const OUString& _aString)
pSpecial->Prepare(mpDocShell->GetFormat(), *mpDocShell, 0);
//Insert the node
- SmNodeList* pList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pList(new SmNodeList);
pList->push_front(pSpecial);
- InsertNodes(pList);
+ InsertNodes(std::move(pList));
EndEdit();
}
@@ -1035,7 +1033,7 @@ void SmCursor::InsertCommandText(const OUString& aCommandText) {
Delete();
//Insert it
- InsertNodes(pLineList.release());
+ InsertNodes(std::move(pLineList));
EndEdit();
}
@@ -1087,9 +1085,9 @@ void SmCursor::Paste() {
EndEdit();
}
-SmNodeList* SmCursor::CloneList(SmClipboard &rClipboard){
+std::unique_ptr<SmNodeList> SmCursor::CloneList(SmClipboard &rClipboard){
SmCloningVisitor aCloneFactory;
- SmNodeList* pClones = new SmNodeList;
+ std::unique_ptr<SmNodeList> pClones(new SmNodeList);
for(auto &xNode : rClipboard){
SmNode *pClone = aCloneFactory.Clone(xNode.get());