diff options
-rw-r--r-- | starmath/inc/visitors.hxx | 19 | ||||
-rw-r--r-- | starmath/qa/cppunit/test_nodetotextvisitors.cxx | 10 | ||||
-rw-r--r-- | starmath/source/cursor.cxx | 2 | ||||
-rw-r--r-- | starmath/source/visitors.cxx | 6 |
4 files changed, 19 insertions, 18 deletions
diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx index 9f792124d1c4..f20379d4df20 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 5e24fb04781c..b7e363ca4818 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 489c339f4d49..de674f491b77 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 9c279702d057..f1b835a462ee 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 ) { |