editeng/source/editeng/editeng.cxx  |   34 ++--------------------------------
 editeng/source/editeng/impedit.hxx  |    2 ++
 editeng/source/editeng/impedit2.cxx |   20 ++++++++++++++++++++
 editeng/source/editeng/impedit4.cxx |   20 ++++++++++++++++++++
 4 files changed, 44 insertions(+), 32 deletions(-)

New commits:
commit 4f74afd4cdfce405933e155e8fb9937e42fe30c0
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jun 16 16:40:35 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jun 17 09:45:07 2024 +0200

    move RemoveParagragh code from EditEngine to ImpEditEngine
    
    so we have the implementation in one class, instead of bouncing
    back and forth between two.
    
    Change-Id: Ifc82d3dd2624868f812533b9df9a34af51a06888
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168953
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index c9c9941f89a0..bfd1803cc59a 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -982,22 +982,7 @@ std::unique_ptr<EditTextObject> 
EditEngine::CreateTextObject( sal_Int32 nPara, s
 
 void EditEngine::RemoveParagraph( sal_Int32 nPara )
 {
-    DBG_ASSERT(getImpl().GetEditDoc().Count() > 1, "The first paragraph should 
not be deleted!");
-    if (getImpl().GetEditDoc().Count() <= 1)
-        return;
-
-    ContentNode* pNode = getImpl().GetEditDoc().GetObject(nPara);
-    const ParaPortion* pPortion = 
getImpl().GetParaPortions().SafeGetObject(nPara);
-    DBG_ASSERT( pPortion && pNode, "Paragraph not found: RemoveParagraph" );
-    if ( pNode && pPortion )
-    {
-        // No Undo encapsulation needed.
-        getImpl().ImpRemoveParagraph(nPara);
-        getImpl().InvalidateFromParagraph(nPara);
-        getImpl().UpdateSelections();
-        if (getImpl().IsUpdateLayout())
-            getImpl().FormatAndLayout();
-    }
+    getImpl().RemoveParagraph(nPara);
 }
 
 sal_Int32 EditEngine::GetTextLen( sal_Int32 nPara ) const
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 61c8f94ac0a2..324ced7e7138 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -1374,6 +1374,7 @@ public:
 
     bool PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, 
vcl::Window const * pFrameWin );
     static bool IsSimpleCharInput( const KeyEvent& rKeyEvent );
+    void RemoveParagraph( sal_Int32 nPara );
 
 #ifdef DBG_UTIL
     void DumpData(bool bInfoBox);
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index ad974d5aff9c..ca919c10676c 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2522,6 +2522,26 @@ EditPaM ImpEditEngine::ImpDeleteSelection(const 
EditSelection& rCurSel)
     return aStartPaM;
 }
 
+void ImpEditEngine::RemoveParagraph( sal_Int32 nPara )
+{
+    DBG_ASSERT(maEditDoc.Count() > 1, "The first paragraph should not be 
deleted!");
+    if (maEditDoc.Count() <= 1)
+        return;
+
+    ContentNode* pNode = maEditDoc.GetObject(nPara);
+    const ParaPortion* pPortion = maParaPortionList.SafeGetObject(nPara);
+    DBG_ASSERT( pPortion && pNode, "Paragraph not found: RemoveParagraph" );
+    if ( pNode && pPortion )
+    {
+        // No Undo encapsulation needed.
+        ImpRemoveParagraph(nPara);
+        InvalidateFromParagraph(nPara);
+        UpdateSelections();
+        if (IsUpdateLayout())
+            FormatAndLayout();
+    }
+}
+
 void ImpEditEngine::ImpRemoveParagraph( sal_Int32 nPara )
 {
     assert(maEditDoc.GetObject(nPara));
commit 4ac56fa47e5f525a403d7ef7fa1d0a0243fb6604
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jun 16 14:33:58 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jun 17 09:44:57 2024 +0200

    move CreateTextObject code from EditEngine to ImpEditEngine
    
    so we have the implementation in one class, instead of bouncing
    back and forth between two.
    
    Change-Id: Iec53dad76756241b0f0ec31e76def89e336ee6ad
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168952
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index c91497172b82..c9c9941f89a0 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -977,22 +977,7 @@ void EditEngine::SetEndPasteOrDropHdl( const 
Link<PasteOrDropInfos&,void>& rLink
 
 std::unique_ptr<EditTextObject> EditEngine::CreateTextObject( sal_Int32 nPara, 
sal_Int32 nParas )
 {
-    DBG_ASSERT(0 <= nPara && nPara < getImpl().GetEditDoc().Count(), 
"CreateTextObject: Startpara out of Range");
-    DBG_ASSERT(nParas <= getImpl().GetEditDoc().Count() - nPara, 
"CreateTextObject: Endpara out of Range");
-
-    ContentNode* pStartNode = getImpl().GetEditDoc().GetObject(nPara);
-    ContentNode* pEndNode = getImpl().GetEditDoc().GetObject(nPara + nParas - 
1);
-    DBG_ASSERT( pStartNode, "Start-Paragraph does not exist: CreateTextObject" 
);
-    DBG_ASSERT( pEndNode, "End-Paragraph does not exist: CreateTextObject" );
-
-    if ( pStartNode && pEndNode )
-    {
-        EditSelection aTmpSel;
-        aTmpSel.Min() = EditPaM( pStartNode, 0 );
-        aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() );
-        return getImpl().CreateTextObject(aTmpSel);
-    }
-    return nullptr;
+    return getImpl().CreateTextObject(nPara, nParas);
 }
 
 void EditEngine::RemoveParagraph( sal_Int32 nPara )
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 066de62dc742..61c8f94ac0a2 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -1037,6 +1037,7 @@ public:
     void            Write( SvStream& rOutput, EETextFormat eFormat );
     void            Write(SvStream& rOutput, EETextFormat eFormat, const 
EditSelection& rSel);
 
+    std::unique_ptr<EditTextObject> CreateTextObject(sal_Int32 nPara, 
sal_Int32 nParas);
     std::unique_ptr<EditTextObject> CreateTextObject();
     std::unique_ptr<EditTextObject> CreateTextObject(const EditSelection& 
rSel);
     void            SetText( const EditTextObject& rTextObject );
diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index b0a46db93e71..c0e499e6f1bf 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1028,6 +1028,26 @@ std::unique_ptr<EditTextObject> 
ImpEditEngine::GetEmptyTextObject()
     return CreateTextObject( aEmptySel );
 }
 
+std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( sal_Int32 
nPara, sal_Int32 nParas )
+{
+    DBG_ASSERT(0 <= nPara && nPara < maEditDoc.Count(), "CreateTextObject: 
Startpara out of Range");
+    DBG_ASSERT(nParas <= maEditDoc.Count() - nPara, "CreateTextObject: Endpara 
out of Range");
+
+    ContentNode* pStartNode = maEditDoc.GetObject(nPara);
+    ContentNode* pEndNode = maEditDoc.GetObject(nPara + nParas - 1);
+    DBG_ASSERT( pStartNode, "Start-Paragraph does not exist: CreateTextObject" 
);
+    DBG_ASSERT( pEndNode, "End-Paragraph does not exist: CreateTextObject" );
+
+    if ( pStartNode && pEndNode )
+    {
+        EditSelection aTmpSel;
+        aTmpSel.Min() = EditPaM( pStartNode, 0 );
+        aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() );
+        return CreateTextObject(aTmpSel);
+    }
+    return nullptr;
+}
+
 std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject()
 {
     EditSelection aCompleteSelection;

Reply via email to