Kaydet (Commit) 9fd7808f authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 2caee0fa
......@@ -261,7 +261,7 @@ private:
void BuildGraph();
/** Insert new nodes in the tree after position */
void InsertNodes(SmNodeList* pNewNodes);
void InsertNodes(std::unique_ptr<SmNodeList> pNewNodes);
/** tries to set position to a specific SmCaretPos
*
......@@ -273,7 +273,7 @@ private:
void AnnotateSelection();
/** Clone list of nodes in a clipboard (creates a deep clone) */
static SmNodeList* CloneList(SmClipboard &rClipboard);
static std::unique_ptr<SmNodeList> CloneList(SmClipboard &rClipboard);
/** Find an iterator pointing to the node in pLineList following rCaretPos
*
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment