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

Thomas Arnhold thomas at arnhold.org
Thu Sep 5 01:02:04 PDT 2013


 starmath/source/document.cxx |   29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

New commits:
commit 17ff0d2b866f0e501057695d1485bf7d8d882f2a
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Sep 4 22:24:21 2013 +0200

    String to OUString for SmDocShell::ReplaceBadChars
    
    And simplify a little bit.
    
    Change-Id: I3b3cf2ea29f59f173e74b59a8e999f19f86e9a0a
    Reviewed-on: https://gerrit.libreoffice.org/5818
    Tested-by: Andrzej J.R. Hunt <andrzej at ahunt.org>
    Reviewed-by: Andrzej J.R. Hunt <andrzej at ahunt.org>

diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 5d1fde8..5923fe4 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -873,31 +873,24 @@ sal_Bool SmDocShell::Save()
 sal_Bool SmDocShell::ReplaceBadChars()
 {
     sal_Bool bReplace = sal_False;
+
     if (pEditEngine)
     {
-        String aEngTxt( pEditEngine->GetText( LINEEND_LF ) );
-        const sal_Unicode *pEngTxt = aEngTxt.GetBuffer();
-        xub_StrLen nLen = aEngTxt.Len();
-        for (xub_StrLen i = 0;  i < nLen && !bReplace;  ++i)
-        {
-            const sal_Unicode c = *pEngTxt++;
-            if (c < ' ' && c != '\r' && c != '\n' && c != '\t')
-                bReplace = sal_True;
-        }
-        if (bReplace)
+        OUStringBuffer aBuf( pEditEngine->GetText( LINEEND_LF ) );
+
+        for (sal_Int32 i = 0;  i < aBuf.getLength();  ++i)
         {
-            sal_Unicode *pChgTxt = aEngTxt.GetBufferAccess();
-            for (xub_StrLen i = 0;  i < nLen;  ++i)
+            if (aBuf[i] < ' ' && aBuf[i] != '\r' && aBuf[i] != '\n' && aBuf[i] != '\t')
             {
-                sal_Unicode &rc = *pChgTxt++;
-                if (rc < ' ' && rc != '\r' && rc != '\n' && rc != '\t')
-                    rc = ' ';
+                aBuf[i] = ' ';
+                bReplace = sal_True;
             }
-            aEngTxt.ReleaseBufferAccess( nLen );
-
-            aText = aEngTxt;
         }
+
+        if (bReplace)
+            aText = aBuf.makeStringAndClear();
     }
+
     return bReplace;
 }
 


More information about the Libreoffice-commits mailing list