summaryrefslogtreecommitdiff
path: root/starmath/inc
diff options
context:
space:
mode:
authorJonas Finnemann Jensen <jopsen@gmail.com>2010-11-24 09:36:21 +0100
committerJonas Finnemann Jensen <jopsen@gmail.com>2011-01-30 20:20:21 +0100
commit592777e2b22e4f1121b755d49ecdfdfb2e322d45 (patch)
treea73a24d279ef457959b3edfa46090d214be3f393 /starmath/inc
parentaede297486282b3f49804a72f7230e4536bb0469 (diff)
Enable line deletion in starmath
* Implemented SmCursor::DeletePrev, for deletion of lines * Fixed nasty bug in SmCursor::InsertRow * Code cleanup in cursor.cxx
Diffstat (limited to 'starmath/inc')
-rw-r--r--starmath/inc/cursor.hxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 49f1e0c18a8c..b5fbd13e28cb 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -132,6 +132,12 @@ public:
/** Delete the current selection or do nothing */
void Delete();
+ /** Delete selection, previous element or merge lines
+ *
+ * This method implements the behaviour of backspace.
+ */
+ void DeletePrev(OutputDevice* pDev);
+
/** Insert text at the current position */
void InsertText(XubString aString);
@@ -270,6 +276,28 @@ private:
*/
static SmNodeList* LineToList(SmStructureNode* pLine, SmNodeList* pList = new SmNodeList());
+ /** Auxiliary function for calling LineToList on a node
+ *
+ * This method sets pNode = NULL and remove it from it's parent.
+ * (Assuming it has a parent, and is a child of it).
+ */
+ static SmNodeList* NodeToList(SmNode*& rpNode, SmNodeList* pList = new SmNodeList()){
+ //Remove from parent and NULL rpNode
+ SmNode* pNode = rpNode;
+ if(rpNode && rpNode->GetParent()){ //Don't remove this, correctness relies on it
+ int index = rpNode->GetParent()->IndexOfSubNode(rpNode);
+ if(index != -1)
+ rpNode->GetParent()->SetSubNode(index, NULL);
+ }
+ rpNode = NULL;
+ //Create line from node
+ if(pNode && IsLineCompositionNode(pNode))
+ return LineToList((SmStructureNode*)pNode, pList);
+ if(pNode)
+ pList->push_front(pNode);
+ return pList;
+ }
+
/** Clone a visual line to a list
*
* Doesn't clone SmErrorNode's these are ignored, as they are context dependent metadata.