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

Michael Duelli m.duelli at web.de
Thu Aug 8 02:12:07 PDT 2013


 starmath/source/edit.cxx |   35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

New commits:
commit 356b2f0edfd5a01ed05976c1bdb74948ff84b5fd
Author: Michael Duelli <m.duelli at web.de>
Date:   Thu Aug 1 01:01:57 2013 +0200

    Extension to fix all cases of fdo#32059: Commands merge with variables
    
    Change 467d5e0a2e074ff2afb4d1b1a37cff2094b0895b fixed insertions of
    space in front of commands for Elements dialog only.
    
    This change also fixes insertion via Elements dock.
    
    Change-Id: I37f8510bc4a6dc0145026ca04fbb0443e1e31cd0
    Reviewed-on: https://gerrit.libreoffice.org/5225
    Reviewed-by: Marcos Souza <marcos.souza.org at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index ec9680f..2a7cb93 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -755,16 +755,16 @@ void SmEditWindow::InsertCommand(sal_uInt16 nCommand)
 
         nEndIndex += aSelection.nEndPos;
 
-        // remove right space of current symbol if there already one
+        // remove right space of current symbol if there already is one
         if (nEndIndex < aCurrentFormula.getLength() &&
             aCurrentFormula[nEndIndex] == ' ')
             aText = aText.trim();
 
-        // put an space before put a new command when necessary(if we're not in the begin of a line)
+        // put a space before a new command if not in the beginning of a line
         if (aSelection.nStartPos > 0 && aCurrentFormula[nStartIndex - 1] != ' ')
-            aText = " " + aText;
-
-        pEditView->InsertText(aText);
+            pEditView->InsertText(" " + aText);
+        else
+            pEditView->InsertText(aText);
 
         // Remember start of the selection and move the cursor there afterwards.
         aSelection.nEndPara = aSelection.nStartPara;
@@ -975,7 +975,30 @@ void SmEditWindow::InsertText(const OUString& rText)
     OSL_ENSURE( pEditView, "EditView missing" );
     if (pEditView)
     {
-        pEditView->InsertText(rText);
+        // Note: Insertion of a space in front of commands is done here and
+        // in SmEditWindow::InsertCommand.
+        ESelection aSelection = pEditView->GetSelection();
+        OUString aCurrentFormula = pEditView->GetEditEngine()->GetText();
+        sal_Int32 nStartIndex = 0;
+        sal_Int32 nEndIndex = 0;
+
+        // get the start position (when we get a multi line formula)
+        for (sal_Int32 nParaPos = 0; nParaPos < aSelection.nStartPara; nParaPos++)
+             nStartIndex = aCurrentFormula.indexOf("\n", nStartIndex) + 1;
+
+        nStartIndex += aSelection.nStartPos;
+
+        // get the end position (when we get a multi line formula)
+        for (sal_Int32 nParaPos = 0; nParaPos < aSelection.nEndPara; nParaPos++)
+             nEndIndex = aCurrentFormula.indexOf("\n", nEndIndex) + 1;
+
+        nEndIndex += aSelection.nEndPos;
+
+        // put a space before a new command if not in the beginning of a line
+        if (aSelection.nStartPos > 0 && aCurrentFormula[nStartIndex - 1] != ' ')
+            pEditView->InsertText(" " + rText);
+        else
+            pEditView->InsertText(rText);
         aModifyTimer.Start();
         StartCursorMove();
     }


More information about the Libreoffice-commits mailing list