summaryrefslogtreecommitdiff
path: root/starmath/inc/caret.hxx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-12-27 19:14:37 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2016-12-27 18:29:19 +0000
commit95d47fbf4110a81af9776edc6da387d9189abfa4 (patch)
treefd38d10a6d4c39e89224d4292320b9b442cdbdef /starmath/inc/caret.hxx
parente899b893434deec1e5f2196654277de8f70d5ef2 (diff)
starmath: SmCaretPos's index must be non-negative
Change-Id: I69a2fc0c9ccaa76a0d93127ac6a1544fe9924605 Reviewed-on: https://gerrit.libreoffice.org/32444 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath/inc/caret.hxx')
-rw-r--r--starmath/inc/caret.hxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
index 113ab8fc843e..a1d12cd4c7c2 100644
--- a/starmath/inc/caret.hxx
+++ b/starmath/inc/caret.hxx
@@ -15,6 +15,7 @@
#include "node.hxx"
+#include <cassert>
#include <memory>
#include <vector>
@@ -24,10 +25,13 @@ struct SmCaretPos{
: pSelectedNode(selectedNode)
, nIndex(iIndex)
{
+ assert(nIndex >= 0);
}
+
/** Selected node */
SmNode* pSelectedNode;
- /** Index within the selected node
+
+ /** Index (invariant: non-negative) within the selected node
*
* 0: Position in front of a node
* 1: Position after a node or after first char in SmTextNode
@@ -38,6 +42,7 @@ struct SmCaretPos{
//TODO: Special cases for SmBlankNode is needed
//TODO: Consider forgetting about the todo above... As it's really unpleasant.
int nIndex;
+
/** True, if this is a valid caret position */
bool IsValid() const { return pSelectedNode != nullptr; }
bool operator==(const SmCaretPos &pos) const {