starmath/inc/view.hxx | 1 starmath/source/cursor.cxx | 23 +++++++++++----------- starmath/source/view.cxx | 47 ++++++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 30 deletions(-)
New commits: commit 68c1f757962a8f2789821ff636bc397d1edd0051 Author: Ivan Timofeev <timofeev....@gmail.com> Date: Sun Dec 4 15:11:23 2011 +0400 visual formula editor: implement selection by mouse diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index d716e72..5781e26 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -103,6 +103,7 @@ public: // Window virtual void MouseButtonDown(const MouseEvent &rMEvt); + virtual void MouseMove(const MouseEvent &rMEvt); virtual void GetFocus(); virtual void LoseFocus(); diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index c9a0ffd..4dbc8a8 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -182,9 +182,7 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt) return; if (IsInlineEditEnabled()) { - // if it was clicked inside the formula then get the appropriate node - if (pTree->OrientedDist(aPos) <= 0) - pViewShell->GetDoc()->GetCursor().MoveTo(this, aPos, !rMEvt.IsShift()); + pViewShell->GetDoc()->GetCursor().MoveTo(this, aPos, !rMEvt.IsShift()); return; } const SmNode *pNode = 0; @@ -214,6 +212,22 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt) } } +void SmGraphicWindow::MouseMove(const MouseEvent &rMEvt) +{ + ScrollableWindow::MouseMove(rMEvt); + + if (rMEvt.IsLeft() && IsInlineEditEnabled()) + { + Point aPos(PixelToLogic(rMEvt.GetPosPixel()) - GetFormulaDrawPos()); + pViewShell->GetDoc()->GetCursor().MoveTo(this, aPos, false); + + CaretBlinkStop(); + SetIsCursorVisible(true); + CaretBlinkStart(); + RepaintViewShellDoc(); + } +} + bool SmGraphicWindow::IsInlineEditEnabled() const { return pViewShell->IsInlineEditEnabled(); commit 558b5ea32a99654dcb63526f107726f7aec4747f Author: Ivan Timofeev <timofeev....@gmail.com> Date: Sun Dec 4 15:05:46 2011 +0400 visual formula editor: copy/cut/paste for any keyboard layout diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 66626a0..c9a0ffd 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -421,8 +421,17 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt) ScrollableWindow::KeyInput(rKEvt); return; } - sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); + SmCursor& rCursor = pViewShell->GetDoc()->GetCursor(); + KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction(); + if (eFunc == KEYFUNC_COPY) + rCursor.Copy(); + else if (eFunc == KEYFUNC_CUT) + rCursor.Cut(); + else if (eFunc == KEYFUNC_PASTE) + rCursor.Paste(); + else { + sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); switch(nCode) { case KEY_LEFT: @@ -491,15 +500,6 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt) case KEY_EQUAL: rCursor.InsertElement(EqualElement); break; - case KEY_COPY: - rCursor.Copy(); - break; - case KEY_CUT: - rCursor.Cut(); - break; - case KEY_PASTE: - rCursor.Paste(); - break; default: { sal_Unicode code = rKEvt.GetCharCode(); @@ -507,12 +507,6 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt) if(code == ' ') { rCursor.InsertElement(BlankElement); - }else if(code == 'c' && rKEvt.GetKeyCode().IsMod1()) { - rCursor.Copy(); - }else if(code == 'x' && rKEvt.GetKeyCode().IsMod1()) { - rCursor.Cut(); - }else if(code == 'v' && rKEvt.GetKeyCode().IsMod1()) { - rCursor.Paste(); }else if(code == '^') { rCursor.InsertSubSup(RSUP); }else if(code == '(') { @@ -539,6 +533,7 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt) } } } + } CaretBlinkStop(); CaretBlinkStart(); SetIsCursorVisible(true); commit 5a227745095d3a700ca01e062264aa5afd080c8a Author: Ivan Timofeev <timofeev....@gmail.com> Date: Fri Dec 2 22:07:34 2011 +0400 visual formula editor: place cursor on numerator when creating empty fraction diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index b7f518f..c2d7f4f 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -977,7 +977,8 @@ void SmCursor::InsertFraction() { PatchLineList(pLineList, it); //Finish editing - FinishEdit(pLineList, pLineParent, nParentIndex, SmCaretPos(pDenom, 1)); + SmNode *pSelectedNode = bEmptyFraction ? pNum : pDenom; + FinishEdit(pLineList, pLineParent, nParentIndex, SmCaretPos(pSelectedNode, 1)); } void SmCursor::InsertText(XubString aString){ commit 8fb78b12219fb0b9c949f8c5bda558f0bd20cc9d Author: Ivan Timofeev <timofeev....@gmail.com> Date: Fri Dec 2 22:03:36 2011 +0400 visual formula editor: optimize some buildings a bit diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index 2f50532..b7f518f 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -700,15 +700,14 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) { it = FindPositionInLineList(pLineList, position->CaretPos); //If there's no selected nodes, create a place node + SmNode *pBodyNode; SmCaretPos PosAfterInsert; if(pSelectedNodesList->size() == 0) { - SmNode* pPlace = new SmPlaceNode(); - PosAfterInsert = SmCaretPos(pPlace, 1); - pSelectedNodesList->push_front(pPlace); - } + pBodyNode = new SmPlaceNode(); + PosAfterInsert = SmCaretPos(pBodyNode, 1); + } else + pBodyNode = SmNodeListParser().Parse(pSelectedNodesList); - //Parse body nodes - SmNode *pBodyNode = SmNodeListParser().Parse(pSelectedNodesList); delete pSelectedNodesList; //Create SmBraceNode @@ -959,10 +958,11 @@ void SmCursor::InsertFraction() { it = FindPositionInLineList(pLineList, position->CaretPos); //Create pNum, and pDenom - if(pSelectedNodesList->size() == 0) - pSelectedNodesList->push_front(new SmPlaceNode()); - SmNode *pNum = SmNodeListParser().Parse(pSelectedNodesList), - *pDenom = new SmPlaceNode(); + bool bEmptyFraction = pSelectedNodesList->empty(); + SmNode *pNum = bEmptyFraction + ? new SmPlaceNode() + : SmNodeListParser().Parse(pSelectedNodesList); + SmNode *pDenom = new SmPlaceNode(); delete pSelectedNodesList; pSelectedNodesList = NULL; _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits