diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-06-16 14:33:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-06-17 09:44:57 +0200 |
commit | 4ac56fa47e5f525a403d7ef7fa1d0a0243fb6604 (patch) | |
tree | 692707f5212027b554777ce6d506fb834fae3f16 /editeng/source | |
parent | 5ab48fd9b1a65579b2a63077cd3d2192b57af2a5 (diff) |
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.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 17 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 20 |
3 files changed, 22 insertions, 16 deletions
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; |