summaryrefslogtreecommitdiff
path: root/include/editeng
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-06-23 21:31:50 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-06-24 02:14:51 +0200
commitc32128b35d177808df47ca98a91c2ef75e922c4a (patch)
treebc91e6abd3d87b000f1bd917868aee5e1ac2d644 /include/editeng
parent2f9c7d0e1ed37ea223be3f31dd9e070e37f2a0d2 (diff)
editeng: add convenience creators to ESelection All, NotFound
ESelection::All() select all text ESelection::NotFound() sets seletion to not found state ESelection::NoSelection() sets selection to no / invalid selection Introduce max paragraph and position constants in ESelection, use for EE_PARA_APPEND, EE_PARA_ALL, EE_PARA_MAX_COUNT, EE_TEXTPOS_ALL, EE_TEXTPOS_MAX_COUNT. Also simplify some ESelection constructs. Change-Id: Ib110c5a730a1deabe4f988baa5a600249b3a31e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169356 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'include/editeng')
-rw-r--r--include/editeng/ESelection.hxx14
-rw-r--r--include/editeng/editdata.hxx10
2 files changed, 19 insertions, 5 deletions
diff --git a/include/editeng/ESelection.hxx b/include/editeng/ESelection.hxx
index 7f5aa8e81cf6..1b6c98516435 100644
--- a/include/editeng/ESelection.hxx
+++ b/include/editeng/ESelection.hxx
@@ -21,6 +21,20 @@
struct ESelection
{
+ static constexpr sal_Int32 MAX_PARAGRAPH_POSITION = SAL_MAX_INT32;
+ static constexpr sal_Int32 MAX_TEXT_POSITION = SAL_MAX_INT32;
+
+ // Select all text
+ static ESelection All() { return ESelection(0, 0, MAX_PARAGRAPH_POSITION, MAX_TEXT_POSITION); }
+
+ // Set to "not found" state
+ static ESelection NotFound() { return ESelection(MAX_PARAGRAPH_POSITION, MAX_TEXT_POSITION); }
+ // Set to no selection
+ static ESelection NoSelection()
+ {
+ return ESelection(MAX_PARAGRAPH_POSITION, MAX_TEXT_POSITION);
+ }
+
sal_Int32 nStartPara = 0;
sal_Int32 nStartPos = 0;
sal_Int32 nEndPara = 0;
diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx
index 799b29bf5acb..25745f7f4cde 100644
--- a/include/editeng/editdata.hxx
+++ b/include/editeng/editdata.hxx
@@ -47,12 +47,12 @@ enum class EEAnchorMode {
enum class EERemoveParaAttribsMode { RemoveAll, RemoveCharItems, RemoveNone };
-#define EE_PARA_APPEND SAL_MAX_INT32
-#define EE_PARA_ALL SAL_MAX_INT32
-#define EE_PARA_MAX_COUNT SAL_MAX_INT32
+#define EE_PARA_APPEND ESelection::MAX_PARAGRAPH_POSITION
+#define EE_PARA_ALL ESelection::MAX_PARAGRAPH_POSITION
+#define EE_PARA_MAX_COUNT ESelection::MAX_PARAGRAPH_POSITION
-#define EE_TEXTPOS_ALL SAL_MAX_INT32
-#define EE_TEXTPOS_MAX_COUNT SAL_MAX_INT32
+#define EE_TEXTPOS_ALL ESelection::MAX_TEXT_POSITION
+#define EE_TEXTPOS_MAX_COUNT ESelection::MAX_TEXT_POSITION
EDITENG_DLLPUBLIC extern const size_t EE_APPEND;