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

Takeshi Abe tabe at fixedpoint.jp
Fri Jul 22 00:47:52 UTC 2016


 starmath/source/cursor.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit f045d14791a84f478c40fbd6b0590f527b36cbff
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Jul 21 17:57:28 2016 +0900

    starmath: Return early if the cursor locates after a text node
    
    No longer create unnecessary copy of nodes.
    
    Change-Id: Icf8cdd3ce0f9ebbf7159e9e7eaea7abe52c05060
    Reviewed-on: https://gerrit.libreoffice.org/27366
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index bef900a..b1ef0b0 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -354,16 +354,17 @@ SmNodeList::iterator SmCursor::FindPositionInLineList(SmNodeList* pLineList,
                 if(rCaretPos.Index > 0)
                 {
                     SmTextNode* pText = static_cast<SmTextNode*>(rCaretPos.pSelectedNode);
+                    if (rCaretPos.Index == pText->GetText().getLength())
+                        return ++it;
                     OUString str1 = pText->GetText().copy(0, rCaretPos.Index);
                     OUString str2 = pText->GetText().copy(rCaretPos.Index);
                     pText->ChangeText(str1);
                     ++it;
                     //Insert str2 as new text node
-                    if(!str2.isEmpty()){
-                        SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc());
-                        pNewText->ChangeText(str2);
-                        it = pLineList->insert(it, pNewText);
-                    }
+                    assert(!str2.isEmpty());
+                    SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc());
+                    pNewText->ChangeText(str2);
+                    it = pLineList->insert(it, pNewText);
                 }
             }else
                 ++it;


More information about the Libreoffice-commits mailing list