summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-12-30 11:25:34 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-01-01 09:21:14 +0100
commit417d1d56b39453b5ae8396a8286d8291061f049b (patch)
tree9d1078ebaafbf39f4d56d08d3d7f6b6785698242 /editeng
parent252c0316c3be09079e08afc9fa512ca5a60ea957 (diff)
editeng: make it clear EditDoc is responsible for ContentNodes
Change-Id: I38b9b1a5ba48d73438865f5a040f2483f6814c40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161479 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/editdoc.hxx7
-rw-r--r--editeng/source/editeng/editdoc.cxx18
-rw-r--r--editeng/source/editeng/impedit2.cxx6
-rw-r--r--editeng/source/editeng/impedit3.cxx2
4 files changed, 18 insertions, 15 deletions
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 7fc29556957c..e9016989e840 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -100,7 +100,10 @@ public:
};
-
+/** Edit document
+ *
+ * Holder, responsible for the content nodes and the manipulation of those.
+ */
class EditDoc
{
private:
@@ -204,7 +207,7 @@ public:
sal_Int32 Count() const;
const ContentNode* operator[](sal_Int32 nPos) const;
ContentNode* operator[](sal_Int32 nPos);
- void Insert(sal_Int32 nPos, ContentNode* p);
+ void Insert(sal_Int32 nPos, std::unique_ptr<ContentNode> p);
/// deletes
void Remove(sal_Int32 nPos);
/// does not delete
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 0afcc9cdd81c..c44c0b5a123c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -943,14 +943,14 @@ ContentNode* EditDoc::operator[](sal_Int32 nPos)
return GetObject(nPos);
}
-void EditDoc::Insert(sal_Int32 nPos, ContentNode* p)
+void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr<ContentNode> pNode)
{
if (nPos < 0 || nPos == SAL_MAX_INT32)
{
SAL_WARN( "editeng", "EditDoc::Insert - overflow pos " << nPos);
return;
}
- maContents.insert(maContents.begin()+nPos, std::unique_ptr<ContentNode>(p));
+ maContents.insert(maContents.begin()+nPos, std::move(pNode));
}
void EditDoc::Remove(sal_Int32 nPos)
@@ -1057,8 +1057,8 @@ EditPaM EditDoc::Clear()
{
maContents.clear();
- ContentNode* pNode = new ContentNode( GetItemPool() );
- Insert(0, pNode);
+ ContentNode* pNode = new ContentNode(GetItemPool());
+ Insert(0, std::unique_ptr<ContentNode>(pNode));
CreateDefFont(false);
@@ -1100,8 +1100,8 @@ EditPaM EditDoc::RemoveText()
maContents.clear();
- ContentNode* pNode = new ContentNode( GetItemPool() );
- Insert(0, pNode);
+ ContentNode* pNode = new ContentNode(GetItemPool());
+ Insert(0, std::unique_ptr<ContentNode>(pNode));
pNode->SetStyleSheet(pPrevStyle, false);
pNode->GetContentAttribs().GetItems().Set( aPrevSet );
@@ -1109,7 +1109,7 @@ EditPaM EditDoc::RemoveText()
SetModified(true);
- return EditPaM( pNode, 0 );
+ return EditPaM(pNode, 0);
}
EditPaM EditDoc::InsertText( EditPaM aPaM, std::u16string_view rStr )
@@ -1143,7 +1143,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs )
aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true) );
// ContentNode constructor copies also the paragraph attributes
- ContentNode* pNode = new ContentNode( aStr, std::move(aContentAttribs) );
+ ContentNode* pNode = new ContentNode(aStr, std::move(aContentAttribs));
// Copy the Default Font
pNode->GetCharAttribs().GetDefFont() = aPaM.GetNode()->GetCharAttribs().GetDefFont();
@@ -1161,7 +1161,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs )
// Character attributes may need to be copied or trimmed:
pNode->CopyAndCutAttribs( aPaM.GetNode(), GetItemPool(), bKeepEndingAttribs );
- Insert(nPos+1, pNode);
+ Insert(nPos+1, std::unique_ptr<ContentNode>(pNode));
SetModified(true);
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index d3a62cb2b9de..b7a1aca97e2f 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2218,8 +2218,8 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n
aSelection.Max().SetNode( pTmpPortion->GetNode() );
aSelection.Max().SetIndex( pTmpPortion->GetNode()->Len() );
- ContentNode* pN = pTmpPortion->GetNode();
- maEditDoc.Insert(nRealNewPos+i, pN);
+ ContentNode* pNode = pTmpPortion->GetNode();
+ maEditDoc.Insert(nRealNewPos+i, std::unique_ptr<ContentNode>(pNode));
GetParaPortions().Insert(nRealNewPos+i, std::move(pTmpPortion));
++i;
@@ -2998,7 +2998,7 @@ EditPaM ImpEditEngine::ImpFastInsertParagraph( sal_Int32 nPara )
if ( GetStatus().DoOnlineSpelling() )
pNode->CreateWrongList();
- maEditDoc.Insert(nPara, pNode);
+ maEditDoc.Insert(nPara, std::unique_ptr<ContentNode>(pNode));
GetParaPortions().Insert(nPara, std::make_unique<ParaPortion>( pNode ));
if ( IsCallParaInsertedOrDeleted() )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 73a051e457fe..67598d46db20 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4124,7 +4124,7 @@ void ImpEditEngine::InsertContent( ContentNode* pNode, sal_Int32 nPos )
DBG_ASSERT( pNode, "NULL-Pointer in InsertContent! " );
DBG_ASSERT( IsInUndo(), "InsertContent only for Undo()!" );
GetParaPortions().Insert(nPos, std::make_unique<ParaPortion>( pNode ));
- maEditDoc.Insert(nPos, pNode);
+ maEditDoc.Insert(nPos, std::unique_ptr<ContentNode>(pNode));
if ( IsCallParaInsertedOrDeleted() )
GetEditEnginePtr()->ParagraphInserted( nPos );
}