summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-12-25 00:06:07 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-12-30 14:17:16 +0100
commit020444ed98d7a31403787238cd753e112a6a56fb (patch)
treeb251d455ba189160bd9a246b1fcfaae0f5863d24 /editeng
parent4acb0979b10bf35cf929078e53ccccea249e1416 (diff)
editeng: move EditLineList methods definition into header
Class is simple enough and more or less just wraps the vector anyway. Change-Id: I65a2980e8dd3c70b87e617920db623782d43b1b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/inc/EditLineList.hxx53
-rw-r--r--editeng/inc/editdoc.hxx1
-rw-r--r--editeng/source/editeng/editdoc.cxx64
3 files changed, 41 insertions, 77 deletions
diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx
index 2b3874913cad..a3a547d7ce24 100644
--- a/editeng/inc/EditLineList.hxx
+++ b/editeng/inc/EditLineList.hxx
@@ -19,8 +19,12 @@
#pragma once
+#include "EditLine.hxx"
+
+#include <memory>
#include <vector>
#include <sal/types.h>
+#include <tools/debug.hxx>
class EditLineList
{
@@ -28,18 +32,43 @@ class EditLineList
LinesType maLines;
public:
- EditLineList();
- ~EditLineList();
-
- void Reset();
- void DeleteFromLine(sal_Int32 nDelFrom);
- sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
- sal_Int32 Count() const;
- const EditLine& operator[](sal_Int32 nPos) const;
- EditLine& operator[](sal_Int32 nPos);
-
- void Append(EditLine* p);
- void Insert(sal_Int32 nPos, EditLine* p);
+ EditLineList() = default;
+
+ void Reset() { maLines.clear(); }
+
+ void DeleteFromLine(sal_Int32 nDelFrom)
+ {
+ assert(nDelFrom <= (static_cast<sal_Int32>(maLines.size()) - 1));
+ LinesType::iterator it = maLines.begin();
+ std::advance(it, nDelFrom);
+ maLines.erase(it, maLines.end());
+ }
+
+ sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd)
+ {
+ sal_Int32 n = maLines.size();
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ const EditLine& rLine = *maLines[i];
+ if ((bInclEnd && (rLine.GetEnd() >= nChar)) || (rLine.GetEnd() > nChar))
+ {
+ return i;
+ }
+ }
+
+ DBG_ASSERT(!bInclEnd, "Line not found: FindLine");
+ return n - 1;
+ }
+
+ sal_Int32 Count() const { return maLines.size(); }
+ const EditLine& operator[](sal_Int32 nPos) const { return *maLines[nPos]; }
+ EditLine& operator[](sal_Int32 nPos) { return *maLines[nPos]; }
+
+ void Append(EditLine* p) { maLines.push_back(std::unique_ptr<EditLine>(p)); }
+ void Insert(sal_Int32 nPos, EditLine* p)
+ {
+ maLines.insert(maLines.begin() + nPos, std::unique_ptr<EditLine>(p));
+ }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 3db8a8a64a63..e400a3b42e4a 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -33,7 +33,6 @@
#include "TextPortion.hxx"
#include "ItemList.hxx"
#include "ContentNode.hxx"
-#include "EditLine.hxx"
#include "EditLineList.hxx"
#include <cstddef>
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index e37bc47a7fa3..153cc25dfc1f 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -890,70 +890,6 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map
}
}
-EditLineList::EditLineList()
-{
-}
-
-EditLineList::~EditLineList()
-{
- Reset();
-}
-
-void EditLineList::Reset()
-{
- maLines.clear();
-}
-
-void EditLineList::DeleteFromLine(sal_Int32 nDelFrom)
-{
- assert(nDelFrom <= (static_cast<sal_Int32>(maLines.size()) - 1));
- LinesType::iterator it = maLines.begin();
- std::advance(it, nDelFrom);
- maLines.erase(it, maLines.end());
-}
-
-sal_Int32 EditLineList::FindLine(sal_Int32 nChar, bool bInclEnd)
-{
- sal_Int32 n = maLines.size();
- for (sal_Int32 i = 0; i < n; ++i)
- {
- const EditLine& rLine = *maLines[i];
- if ( (bInclEnd && (rLine.GetEnd() >= nChar)) ||
- (rLine.GetEnd() > nChar) )
- {
- return i;
- }
- }
-
- DBG_ASSERT( !bInclEnd, "Line not found: FindLine" );
- return n - 1;
-}
-
-sal_Int32 EditLineList::Count() const
-{
- return maLines.size();
-}
-
-const EditLine& EditLineList::operator[](sal_Int32 nPos) const
-{
- return *maLines[nPos];
-}
-
-EditLine& EditLineList::operator[](sal_Int32 nPos)
-{
- return *maLines[nPos];
-}
-
-void EditLineList::Append(EditLine* p)
-{
- maLines.push_back(std::unique_ptr<EditLine>(p));
-}
-
-void EditLineList::Insert(sal_Int32 nPos, EditLine* p)
-{
- maLines.insert(maLines.begin()+nPos, std::unique_ptr<EditLine>(p));
-}
-
EditPaM::EditPaM() : pNode(nullptr), nIndex(0) {}
EditPaM::EditPaM(ContentNode* p, sal_Int32 n) : pNode(p), nIndex(n) {}