[Libreoffice-commits] .: 4 commits - starmath/inc starmath/qa starmath/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 1 05:41:36 PDT 2012


 starmath/inc/cursor.hxx                         |    2 
 starmath/inc/parse.hxx                          |    2 
 starmath/inc/visitors.hxx                       |   19 +---
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |   10 +-
 starmath/source/accessibility.cxx               |   92 +++++++++++-------------
 starmath/source/accessibility.hxx               |    6 -
 starmath/source/cursor.cxx                      |    6 -
 starmath/source/parse.cxx                       |    2 
 starmath/source/visitors.cxx                    |    6 +
 9 files changed, 70 insertions(+), 75 deletions(-)

New commits:
commit b4a263329fe95c83b09fc9c626c021b7cd50cabc
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Mon Oct 1 16:35:38 2012 +0400

    String -> OUString
    
    Change-Id: I28c2d87ddd1ea83e29dd11ef8aa20d8d583f4dd9

diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 9207bda..39c5d3a 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -134,9 +134,9 @@ SmDocShell * SmGraphicAccessible::GetDoc_Impl()
     return pView ? pView->GetDoc() : 0;
 }
 
-String SmGraphicAccessible::GetAccessibleText_Impl()
+OUString SmGraphicAccessible::GetAccessibleText_Impl()
 {
-    String aTxt;
+    OUString aTxt;
     SmDocShell *pDoc = GetDoc_Impl();
     if (pDoc)
         aTxt = pDoc->GetAccessibleText();
@@ -451,9 +451,8 @@ sal_Bool SAL_CALL SmGraphicAccessible::setCaretPosition( sal_Int32 nIndex )
     throw (IndexOutOfBoundsException, RuntimeException)
 {
     SolarMutexGuard aGuard;
-    xub_StrLen nIdx = (xub_StrLen) nIndex;
-    String aTxt( GetAccessibleText_Impl() );
-    if (!(nIdx < aTxt.Len()))
+    OUString aTxt( GetAccessibleText_Impl() );
+    if (!(nIndex < aTxt.getLength()))
         throw IndexOutOfBoundsException();
     return sal_False;
 }
@@ -462,12 +461,10 @@ sal_Unicode SAL_CALL SmGraphicAccessible::getCharacter( sal_Int32 nIndex )
     throw (IndexOutOfBoundsException, RuntimeException)
 {
     SolarMutexGuard aGuard;
-
-    xub_StrLen nIdx = (xub_StrLen) nIndex;
-    String aTxt( GetAccessibleText_Impl() );
-    if (!(nIdx < aTxt.Len()))
+    OUString aTxt( GetAccessibleText_Impl() );
+    if (!(nIndex < aTxt.getLength()))
         throw IndexOutOfBoundsException();
-    return aTxt.GetChar( nIdx );
+    return aTxt[nIndex];
 }
 
 Sequence< beans::PropertyValue > SAL_CALL SmGraphicAccessible::getCharacterAttributes(
@@ -476,7 +473,7 @@ Sequence< beans::PropertyValue > SAL_CALL SmGraphicAccessible::getCharacterAttri
     throw (IndexOutOfBoundsException, RuntimeException)
 {
     SolarMutexGuard aGuard;
-    sal_Int32 nLen = GetAccessibleText_Impl().Len();
+    sal_Int32 nLen = GetAccessibleText_Impl().getLength();
     if (!(0 <= nIndex  &&  nIndex < nLen))
         throw IndexOutOfBoundsException();
     return Sequence< beans::PropertyValue >();
@@ -498,12 +495,12 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
         SmDocShell  *pDoc  = pView ? pView->GetDoc() : 0;
         if (!pDoc)
             throw RuntimeException();
-        String aTxt( GetAccessibleText_Impl() );
-        if (!(0 <= nIndex  &&  nIndex <= aTxt.Len()))   // aTxt.Len() is valid
+        OUString aTxt( GetAccessibleText_Impl() );
+        if (!(0 <= nIndex  &&  nIndex <= aTxt.getLength()))   // aTxt.getLength() is valid
             throw IndexOutOfBoundsException();
 
-        // find a reasonable rectangle for position aTxt.Len().
-        bool bWasBehindText = (nIndex == aTxt.Len());
+        // find a reasonable rectangle for position aTxt.getLength().
+        bool bWasBehindText = (nIndex == aTxt.getLength());
         if (bWasBehindText && nIndex)
             --nIndex;
 
@@ -560,7 +557,7 @@ sal_Int32 SAL_CALL SmGraphicAccessible::getCharacterCount()
     throw (RuntimeException)
 {
     SolarMutexGuard aGuard;
-    return GetAccessibleText_Impl().Len();
+    return GetAccessibleText_Impl().getLength();
 }
 
 sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoint )
@@ -656,7 +653,7 @@ sal_Bool SAL_CALL SmGraphicAccessible::setSelection(
     throw (IndexOutOfBoundsException, RuntimeException)
 {
     SolarMutexGuard aGuard;
-    sal_Int32 nLen = GetAccessibleText_Impl().Len();
+    sal_Int32 nLen = GetAccessibleText_Impl().getLength();
     if (!(0 <= nStartIndex  &&  nStartIndex < nLen) ||
         !(0 <= nEndIndex    &&  nEndIndex   < nLen))
         throw IndexOutOfBoundsException();
@@ -680,32 +677,31 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
     //!! may be switched.
 
     SolarMutexGuard aGuard;
-    String aTxt( GetAccessibleText_Impl() );
-    xub_StrLen nStart = (xub_StrLen) Min(nStartIndex, nEndIndex);
-    xub_StrLen nEnd   = (xub_StrLen) Max(nStartIndex, nEndIndex);
-    if (!(nStart <= aTxt.Len()) ||
-        !(nEnd   <= aTxt.Len()))
+    OUString aTxt( GetAccessibleText_Impl() );
+    sal_Int32 nStart = Min(nStartIndex, nEndIndex);
+    sal_Int32 nEnd   = Max(nStartIndex, nEndIndex);
+    if (!(nStart <= aTxt.getLength()) ||
+        !(nEnd   <= aTxt.getLength()))
         throw IndexOutOfBoundsException();
-    return aTxt.Copy( nStart, nEnd - nStart );
+    return aTxt.copy( nStart, nEnd - nStart );
 }
 
 ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    String aTxt( GetAccessibleText_Impl() );
-    xub_StrLen nIdx = (xub_StrLen) nIndex;
+    OUString aTxt( GetAccessibleText_Impl() );
     //!! nIndex is allowed to be the string length
-    if (!(nIdx <= aTxt.Len()))
+    if (!(nIndex <= aTxt.getLength()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
     aResult.SegmentStart = -1;
     aResult.SegmentEnd = -1;
-    if ( (AccessibleTextType::CHARACTER == aTextType)  &&  (nIdx < aTxt.Len()) )
+    if ( (AccessibleTextType::CHARACTER == aTextType)  &&  (nIndex < aTxt.getLength()) )
     {
-        aResult.SegmentText = aTxt.Copy(nIdx, 1);
-        aResult.SegmentStart = nIdx;
-        aResult.SegmentEnd = nIdx+1;
+        aResult.SegmentText = aTxt.copy(nIndex, 1);
+        aResult.SegmentStart = nIndex;
+        aResult.SegmentEnd = nIndex+1;
     }
     return aResult;
 }
@@ -713,21 +709,20 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
 ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    String aTxt( GetAccessibleText_Impl() );
-    xub_StrLen nIdx = (xub_StrLen) nIndex;
+    OUString aTxt( GetAccessibleText_Impl() );
     //!! nIndex is allowed to be the string length
-    if (!(nIdx <= aTxt.Len()))
+    if (!(nIndex <= aTxt.getLength()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
     aResult.SegmentStart = -1;
     aResult.SegmentEnd = -1;
 
-    if ( (AccessibleTextType::CHARACTER == aTextType)  && nIdx )
+    if ( (AccessibleTextType::CHARACTER == aTextType)  && nIndex )
     {
-        aResult.SegmentText = aTxt.Copy(nIdx-1, 1);
-        aResult.SegmentStart = nIdx-1;
-        aResult.SegmentEnd = nIdx;
+        aResult.SegmentText = aTxt.copy(nIndex-1, 1);
+        aResult.SegmentStart = nIndex-1;
+        aResult.SegmentEnd = nIndex;
     }
     return aResult;
 }
@@ -735,22 +730,21 @@ OUString SAL_CALL SmGraphicAccessible::getTextRange(
 ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    String aTxt( GetAccessibleText_Impl() );
-    xub_StrLen nIdx = (xub_StrLen) nIndex;
+    OUString aTxt( GetAccessibleText_Impl() );
     //!! nIndex is allowed to be the string length
-    if (!(nIdx <= aTxt.Len()))
+    if (!(nIndex <= aTxt.getLength()))
         throw IndexOutOfBoundsException();
 
     ::com::sun::star::accessibility::TextSegment aResult;
     aResult.SegmentStart = -1;
     aResult.SegmentEnd = -1;
 
-    nIdx++; // text *behind*
-    if ( (AccessibleTextType::CHARACTER == aTextType)  &&  (nIdx < aTxt.Len()) )
+    nIndex++; // text *behind*
+    if ( (AccessibleTextType::CHARACTER == aTextType)  &&  (nIndex < aTxt.getLength()) )
     {
-        aResult.SegmentText = aTxt.Copy(nIdx, 1);
-        aResult.SegmentStart = nIdx;
-        aResult.SegmentEnd = nIdx+1;
+        aResult.SegmentText = aTxt.copy(nIndex, 1);
+        aResult.SegmentStart = nIndex;
+        aResult.SegmentEnd = nIndex+1;
     }
     return aResult;
 }
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index 07db582..6a05823 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -84,7 +84,7 @@ class SmGraphicAccessible :
 
 protected:
     SmDocShell *    GetDoc_Impl();
-    String          GetAccessibleText_Impl();
+    OUString        GetAccessibleText_Impl();
 
 public:
     SmGraphicAccessible( SmGraphicWindow *pGraphicWin );
commit c397e90062e64c6698467913de6faab1d2701d7f
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Mon Oct 1 16:11:38 2012 +0400

    String -> OUString
    
    Change-Id: I29c644ed2c69f0c378f8c43b69c6c8c70d8cbf5e

diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index b271773..9207bda 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -105,7 +105,7 @@ static awt::Point lcl_GetLocationOnScreen( Window *pWin )
 //////////////////////////////////////////////////////////////////////
 
 SmGraphicAccessible::SmGraphicAccessible( SmGraphicWindow *pGraphicWin ) :
-    aAccName            ( String(SmResId(RID_DOCUMENTSTR)) ),
+    aAccName            (SM_RESSTR(RID_DOCUMENTSTR)),
     nClientId           (0),
     pWin                (pGraphicWin)
 {
@@ -115,7 +115,7 @@ SmGraphicAccessible::SmGraphicAccessible( SmGraphicWindow *pGraphicWin ) :
 
 SmGraphicAccessible::SmGraphicAccessible( const SmGraphicAccessible &rSmAcc ) :
     SmGraphicAccessibleBaseClass(),
-    aAccName            ( String(SmResId(RID_DOCUMENTSTR)) ),
+    aAccName            (SM_RESSTR(RID_DOCUMENTSTR)),
     nClientId           (0)
 {
     pWin = rSmAcc.pWin;
@@ -1631,7 +1631,7 @@ sal_Bool SmEditViewForwarder::Paste()
 //------------------------------------------------------------------------
 
 SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) :
-    aAccName            ( String(SmResId(STR_CMDBOXWINDOW)) ),
+    aAccName            (SM_RESSTR(STR_CMDBOXWINDOW)),
     pTextHelper         (0),
     pWin                (pEditWin)
 {
@@ -1641,7 +1641,7 @@ SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) :
 
 SmEditAccessible::SmEditAccessible( const SmEditAccessible &rSmAcc ) :
     SmEditAccessibleBaseClass(),
-    aAccName            ( String(SmResId(STR_CMDBOXWINDOW)) )
+    aAccName            (SM_RESSTR(STR_CMDBOXWINDOW))
 {
     pWin = rSmAcc.pWin;
     OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index b9918dd..07db582 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -72,7 +72,7 @@ class SmGraphicAccessible :
     public SmGraphicAccessibleBaseClass
 {
     osl::Mutex                          aListenerMutex;
-    String                              aAccName;
+    OUString                            aAccName;
     /// client id in the AccessibleEventNotifier queue
     sal_uInt32                          nClientId;
 
@@ -326,7 +326,7 @@ class SmEditAccessible :
     public SmEditAccessibleBaseClass
 {
     osl::Mutex                              aListenerMutex;
-    String                                  aAccName;
+    OUString                                aAccName;
     ::accessibility::AccessibleTextHelper    *pTextHelper;
     SmEditWindow                           *pWin;
 
commit b03eab3560bb5c8379ae711b41796dec459c20e0
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Thu Sep 27 21:07:25 2012 +0400

    String -> OUString
    
    Change-Id: Icdb39e5b5ba38d48f5cc3a4ae371fb77cb981242

diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx
index 9f79212..f20379d 100644
--- a/starmath/inc/visitors.hxx
+++ b/starmath/inc/visitors.hxx
@@ -453,11 +453,9 @@ private:
 class SmNodeToTextVisitor : public SmVisitor
 {
 public:
-    SmNodeToTextVisitor( SmNode* pNode, String &rText )
-        : rCmdText( rText ) {
-        pNode->Accept( this );
-    }
+    SmNodeToTextVisitor( SmNode* pNode, OUString &rText );
     virtual ~SmNodeToTextVisitor() {}
+
     void Visit( SmTableNode* pNode );
     void Visit( SmBraceNode* pNode );
     void Visit( SmBracebodyNode* pNode );
@@ -493,19 +491,16 @@ private:
             pNode->Accept( this );
         Separate( );
     }
-    inline void Append( const sal_Char* pCharStr ) {
-        rCmdText.AppendAscii( pCharStr );
-    }
-    inline void Append( const String &rText ) {
-        rCmdText.Append( rText );
+    void Append( const OUString &rText ) {
+        aCmdText.append( rText );
     }
     /** Append a blank for separation, if needed */
     inline void Separate( ){
-        if( !rCmdText.Len() || rCmdText.GetChar( rCmdText.Len( ) - 1 ) != ' ' )
-            rCmdText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " " ) );
+        if( !aCmdText.getLength() || aCmdText[ aCmdText.getLength() - 1 ] != ' ' )
+            aCmdText.append(' ');
     }
     /** Output text generated from the pNodes */
-    String &rCmdText;
+    OUStringBuffer aCmdText;
 };
 
 #endif /* SMVISITORS_H */
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 5e24fb0..b7e363c 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -494,11 +494,11 @@ void Test::SimpleSpecialChars()
  */
 void Test::parseandparseagain(const char *formula, const char *test_name)
 {
-    String input, output1, output2;
+    OUString output1, output2;
     SmNode *pNode1, *pNode2;
 
     // parse 1
-    input.AppendAscii(formula);
+    OUString input = OUString::createFromAscii(formula);
     pNode1 = SmParser().ParseExpression(input);
     pNode1->Prepare(xDocShRef->GetFormat(), *xDocShRef);
     SmNodeToTextVisitor(pNode1, output1);
@@ -519,17 +519,17 @@ void Test::parseandparseagain(const char *formula, const char *test_name)
 
 void Test::ParseAndCheck(const char *formula, const char * expected, const char *test_name)
 {
-    String sInput, sOutput, sExpected;
+    OUString sOutput;
     SmNode *pNode;
 
     // parse
-    sInput.AppendAscii(formula);
+    OUString sInput = OUString::createFromAscii(formula);
     pNode = SmParser().ParseExpression(sInput);
     pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef);
     SmNodeToTextVisitor(pNode, sOutput);
 
     // compare
-    sExpected.AppendAscii(expected);
+    OUString sExpected = OUString::createFromAscii(expected);
     CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name,
         sExpected,
         sOutput);
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 489c339..de674f4 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1462,7 +1462,7 @@ void SmCursor::EndEdit(){
     RequestRepaint();
 
     //Update the edit engine and text of the document
-    String formula;
+    OUString formula;
     SmNodeToTextVisitor(pTree, formula);
     //pTree->CreateTextFromNode(formula);
     pDocShell->aText = formula;
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 9c27970..f1b835a 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2117,6 +2117,12 @@ void SmSelectionDrawingVisitor::Visit( SmTextNode* pNode )
 
 /////////////////////////////// SmNodeToTextVisitor ///////////////////////////////
 
+SmNodeToTextVisitor::SmNodeToTextVisitor( SmNode* pNode, OUString &rText )
+{
+    pNode->Accept( this );
+    rText = aCmdText.makeStringAndClear();
+}
+
 void SmNodeToTextVisitor::Visit( SmTableNode* pNode )
 {
     if( pNode->GetToken( ).eType == TBINOM ) {
commit 773667483e3991b078eca03568681e2f3e8f4ec9
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Tue Sep 25 21:17:31 2012 +0400

    String -> OUString
    
    Change-Id: I94eafe01604b30d53d9021458a0a9c57dfc1144a

diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 3c274cb..b7a0d9c 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -155,7 +155,7 @@ public:
      * This will work for stuff like "A intersection B". But stuff spaning multiple lines
      * or dependent on the context which position is placed in will not work!
      */
-    void InsertCommandText(String aCommandText);
+    void InsertCommandText(OUString aCommandText);
 
     /** Insert a special node created from aString
      *
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index e4f1c6a..e3a8d23 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -263,7 +263,7 @@ public:
     /** Parse rBuffer to formula tree */
     SmNode      *Parse(const String &rBuffer);
     /** Parse rBuffer to formula subtree that constitutes an expression */
-    SmNode      *ParseExpression(const String &rBuffer);
+    SmNode      *ParseExpression(const OUString &rBuffer);
 
     const String & GetText() const { return m_aBufferString; };
 
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 9edb83e..489c339 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1156,12 +1156,12 @@ void SmCursor::InsertCommand(sal_uInt16 nCommand) {
                 InsertLimit(CSUP, true);
             break;
         default:
-            InsertCommandText(SmResId(nCommand));
+            InsertCommandText(SM_RESSTR(nCommand));
             break;
     }
 }
 
-void SmCursor::InsertCommandText(XubString aCommandText) {
+void SmCursor::InsertCommandText(OUString aCommandText) {
     //Parse the the sub expression
     SmNode* pSubExpr = SmParser().ParseExpression(aCommandText);
 
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 827ff16..51a60c2 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2452,7 +2452,7 @@ SmNode *SmParser::Parse(const String &rBuffer)
     return result;
 }
 
-SmNode *SmParser::ParseExpression(const String &rBuffer)
+SmNode *SmParser::ParseExpression(const OUString &rBuffer)
 {
     m_aBufferString = convertLineEnd(rBuffer, LINEEND_LF);
     m_nBufferIndex  = 0;


More information about the Libreoffice-commits mailing list