[Libreoffice-commits] core.git: starmath/inc starmath/source

2020-09-07 Thread Luke Dixon (via logerrit)
 starmath/inc/caret.hxx |   13 ++---
 starmath/inc/cursor.hxx|3 +--
 starmath/source/cursor.cxx |   17 ++---
 starmath/source/view.cxx   |   16 
 4 files changed, 17 insertions(+), 32 deletions(-)

New commits:
commit 5267b6c04eed2662726bb90899eb40414779fcb3
Author: Luke Dixon 
AuthorDate: Tue Sep 8 01:37:23 2020 +0100
Commit: Noel Grandin 
CommitDate: Tue Sep 8 08:17:59 2020 +0200

starmath: stop change to caret pos graph when moving after brace

Currently, the code that moves the cursor after the brace changes the
current caret pos instead of moving to the next pos. Because of this, we
end up with one missing graph pos and a duplicate graph pos. This can be
seen by moving to the end of a brace body, pressing the key for the
closing brace and then pressing left and right to move in and out of the
brace.

This fix uses the existing code that sets the cursor position to the
next element in the graph instead of changing the cursor pos directly.
It also marks the caret pos as const to suggest not changing the caret
pos inside a graph entry.

Change-Id: I5492e54f1bddbfc90036f29698982fd8696f5e88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102214
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
index 327ee1d6ed16..c0e5c4f5fca0 100644
--- a/starmath/inc/caret.hxx
+++ b/starmath/inc/caret.hxx
@@ -103,15 +103,14 @@ private:
 
 /** An entry in SmCaretPosGraph */
 struct SmCaretPosGraphEntry{
-SmCaretPosGraphEntry(SmCaretPos pos,
- SmCaretPosGraphEntry* left,
- SmCaretPosGraphEntry* right) {
-CaretPos = pos;
-Left = left;
-Right = right;
+SmCaretPosGraphEntry(SmCaretPos pos, SmCaretPosGraphEntry* left, 
SmCaretPosGraphEntry* right)
+: CaretPos{pos}
+, Left{left}
+, Right{right}
+{
 }
 /** Caret position */
-SmCaretPos CaretPos;
+const SmCaretPos CaretPos;
 /** Entry to the left visually */
 SmCaretPosGraphEntry* Left;
 /** Entry to the right visually */
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 236485d5e04c..47218e490865 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -184,8 +184,7 @@ public:
 /** Draw the caret */
 void Draw(OutputDevice& pDev, Point Offset, bool isCaretVisible);
 
-bool IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** 
ppBraceNode) const;
-void MoveAfterBracket(SmBraceNode* pBraceNode);
+bool IsAtTailOfBracket(SmBracketType eBracketType) const;
 
 private:
 friend class SmDocShell;
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 5e69b5876a45..c476bd41228e 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1327,7 +1327,8 @@ void SmCursor::RequestRepaint(){
 }
 }
 
-bool SmCursor::IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** 
ppBraceNode) const {
+bool SmCursor::IsAtTailOfBracket(SmBracketType eBracketType) const
+{
 const SmCaretPos pos = GetPosition();
 if (!pos.IsValid()) {
 return false;
@@ -1391,23 +1392,9 @@ bool SmCursor::IsAtTailOfBracket(SmBracketType 
eBracketType, SmBraceNode** ppBra
 return false;
 }
 
-if (ppBraceNode) {
-*ppBraceNode = pBraceNode;
-}
-
 return true;
 }
 
-void SmCursor::MoveAfterBracket(SmBraceNode* pBraceNode)
-{
-mpPosition->CaretPos.pSelectedNode = pBraceNode;
-mpPosition->CaretPos.nIndex = 1;
-mpAnchor->CaretPos.pSelectedNode = pBraceNode;
-mpAnchor->CaretPos.nIndex = 1;
-RequestRepaint();
-}
-
-
 /// SmNodeListParser
 
 SmNode* SmNodeListParser::Parse(SmNodeList* list){
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 19274324ada7..dd967232723b 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -490,7 +490,6 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
 default:
 {
 sal_Unicode code = rKEvt.GetCharCode();
-SmBraceNode* pBraceNode = nullptr;
 
 if(code == ' ') {
 rCursor.InsertElement(BlankElement);
@@ -506,13 +505,14 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
 rCursor.InsertElement(FactorialElement);
 }else if(code == '%') {
 rCursor.InsertElement(PercentElement);
-}else if(code == ')' && 
rCursor.IsAtTailOfBracket(SmBracketType::Round, &pBraceNode)) {
-rCursor.MoveAfterBracket(pBraceNode);
-}else if(code == ']' && 
rCursor.IsAtTailOfBracket(SmBracketType::Square, &pBraceNode)) {
-rCursor.MoveAfterBracket(pBraceNode);
-}else if(code == '}' && 
rCursor.IsAtTailOfBracket(SmBracketType::Curly, &pBraceNode)) {
-rCursor.MoveAfter

[Libreoffice-commits] core.git: starmath/source

2020-09-02 Thread Luke Dixon (via logerrit)
 starmath/source/cursor.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c13671108fa7cee0cc1801e4c08800de1daab850
Author: Luke Dixon 
AuthorDate: Sun Aug 30 13:35:20 2020 +0100
Commit: Noel Grandin 
CommitDate: Wed Sep 2 20:55:25 2020 +0200

Fix crash when entering newline in starmath experimental editor

Currently things crash when adding a newline using the experimental
editor in Math Formula editor. It looks like this is happening because
the newly inserted line was getting destroyed when the unique_ptr goes
out of scope.

This change releases the unique_ptr so it doesn't get destroyed. As it
is now part of the tree it should be destroyed elsewhere.

Change-Id: Icfe2c0289c12302d39883dc04cef0351467aa845
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101737
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 2aae7adb555e..5e69b5876a45 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -765,7 +765,7 @@ bool SmCursor::InsertRow() {
 pTable->SetSubNode(i, pTable->GetSubNode(i-1));
 
 //Insert new line
-pTable->SetSubNode(nTableIndex + 1, pNewLine.get());
+pTable->SetSubNode(nTableIndex + 1, pNewLine.release());
 
 //Check if we need to change token type:
 if(pTable->GetNumSubNodes() > 2 && pTable->GetToken().eType == TBINOM) 
{
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits