Kaydet (Commit) 6f135b0a authored tarafından Thomas Arnhold's avatar Thomas Arnhold Kaydeden (comit) Andrzej J.R. Hunt

String to OUString

And removed nearly all xub_StrLen in starmath.

Some sal_uInt16 which were xub_StrLen before
9a0d753b are also converted to sal_Int32
where applicable.

Change-Id: I31d7794f4c7aa840545edff41a102b76bb39e042
Reviewed-on: https://gerrit.libreoffice.org/5817Reviewed-by: 's avatarAndrzej J.R. Hunt <andrzej@ahunt.org>
Tested-by: 's avatarAndrzej J.R. Hunt <andrzej@ahunt.org>
üst 4c491c12
...@@ -159,7 +159,7 @@ public: ...@@ -159,7 +159,7 @@ public:
virtual void GetAccessibleText( OUStringBuffer &rText ) const; virtual void GetAccessibleText( OUStringBuffer &rText ) const;
sal_Int32 GetAccessibleIndex() const { return nAccIndex; } sal_Int32 GetAccessibleIndex() const { return nAccIndex; }
const SmNode * FindNodeWithAccessibleIndex(xub_StrLen nAccIndex) const; const SmNode * FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const;
sal_uInt16 GetRow() const { return (sal_uInt16)aNodeToken.nRow; } sal_uInt16 GetRow() const { return (sal_uInt16)aNodeToken.nRow; }
sal_uInt16 GetColumn() const { return (sal_uInt16)aNodeToken.nCol; } sal_uInt16 GetColumn() const { return (sal_uInt16)aNodeToken.nCol; }
......
...@@ -118,8 +118,8 @@ struct SmToken ...@@ -118,8 +118,8 @@ struct SmToken
sal_uInt16 nLevel; sal_uInt16 nLevel;
// token position // token position
sal_uInt16 nRow; sal_Int32 nRow;
xub_StrLen nCol; sal_Int32 nCol;
SmToken(); SmToken();
SmToken(SmTokenType eTokenType, SmToken(SmTokenType eTokenType,
...@@ -150,7 +150,7 @@ struct SmErrorDesc ...@@ -150,7 +150,7 @@ struct SmErrorDesc
{ {
SmParseError Type; SmParseError Type;
SmNode *pNode; SmNode *pNode;
String Text; OUString Text;
}; };
...@@ -180,15 +180,15 @@ struct SmTokenTableEntry ...@@ -180,15 +180,15 @@ struct SmTokenTableEntry
class SmParser class SmParser
{ {
String m_aBufferString; OUString m_aBufferString;
SmToken m_aCurToken; SmToken m_aCurToken;
SmNodeStack m_aNodeStack; SmNodeStack m_aNodeStack;
SmErrDescList m_aErrDescList; SmErrDescList m_aErrDescList;
int m_nCurError; int m_nCurError;
LanguageType m_nLang; LanguageType m_nLang;
xub_StrLen m_nBufferIndex, sal_Int32 m_nBufferIndex,
m_nTokenIndex; m_nTokenIndex;
sal_uInt16 m_Row, sal_Int32 m_Row,
m_nColOff; m_nColOff;
SmConvert m_eConversion; SmConvert m_eConversion;
bool bImportSymNames, bool bImportSymNames,
...@@ -206,12 +206,12 @@ class SmParser ...@@ -206,12 +206,12 @@ class SmParser
protected: protected:
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
bool IsDelimiter( const String &rTxt, xub_StrLen nPos ); bool IsDelimiter( const OUString &rTxt, sal_Int32 nPos );
#endif #endif
void NextToken(); void NextToken();
xub_StrLen GetTokenIndex() const { return m_nTokenIndex; } sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
void Insert(const String &rText, sal_uInt16 nPos); void Insert(const OUString &rText, sal_Int32 nPos);
void Replace( sal_uInt16 nPos, sal_uInt16 nLen, const String &rText ); void Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
inline bool TokenInGroup( sal_uLong nGroup ); inline bool TokenInGroup( sal_uLong nGroup );
...@@ -253,17 +253,17 @@ protected: ...@@ -253,17 +253,17 @@ protected:
void Error(SmParseError Error); void Error(SmParseError Error);
void ClearUsedSymbols() { m_aUsedSymbols.clear(); } void ClearUsedSymbols() { m_aUsedSymbols.clear(); }
void AddToUsedSymbols( const String &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); } void AddToUsedSymbols( const OUString &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); }
public: public:
SmParser(); SmParser();
/** Parse rBuffer to formula tree */ /** Parse rBuffer to formula tree */
SmNode *Parse(const String &rBuffer); SmNode *Parse(const OUString &rBuffer);
/** Parse rBuffer to formula subtree that constitutes an expression */ /** Parse rBuffer to formula subtree that constitutes an expression */
SmNode *ParseExpression(const OUString &rBuffer); SmNode *ParseExpression(const OUString &rBuffer);
const String & GetText() const { return m_aBufferString; }; const OUString & GetText() const { return m_aBufferString; };
SmConvert GetConversion() const { return m_eConversion; } SmConvert GetConversion() const { return m_eConversion; }
void SetConversion(SmConvert eConv) { m_eConversion = eConv; } void SetConversion(SmConvert eConv) { m_eConversion = eConv; }
...@@ -277,8 +277,8 @@ public: ...@@ -277,8 +277,8 @@ public:
const SmErrorDesc* NextError(); const SmErrorDesc* NextError();
const SmErrorDesc* PrevError(); const SmErrorDesc* PrevError();
const SmErrorDesc* GetError(size_t i = size_t(-1) ); const SmErrorDesc* GetError(size_t i = size_t(-1) );
static const SmTokenTableEntry* GetTokenTableEntry( const String &rName ); static const SmTokenTableEntry* GetTokenTableEntry( const OUString &rName );
bool IsUsedSymbol( const String &rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } bool IsUsedSymbol( const OUString &rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); }
std::set< OUString > GetUsedSymbols() const { return m_aUsedSymbols; } std::set< OUString > GetUsedSymbols() const { return m_aUsedSymbols; }
}; };
......
...@@ -142,7 +142,7 @@ void Test::editMarker() ...@@ -142,7 +142,7 @@ void Test::editMarker()
void Test::editFailure() void Test::editFailure()
{ {
m_xDocShRef->SetText(String("color a b over {a/}")); m_xDocShRef->SetText("color a b over {a/}");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError(); const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
......
...@@ -504,7 +504,7 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde ...@@ -504,7 +504,7 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
--nIndex; --nIndex;
const SmNode *pTree = pDoc->GetFormulaTree(); const SmNode *pTree = pDoc->GetFormulaTree();
const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( (xub_StrLen) nIndex ); const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( nIndex );
//! pNode may be 0 if the index belongs to a char that was inserted //! pNode may be 0 if the index belongs to a char that was inserted
//! only for the accessible text! //! only for the accessible text!
if (pNode) if (pNode)
...@@ -1450,7 +1450,7 @@ void SmTextForwarder::AppendParagraph() ...@@ -1450,7 +1450,7 @@ void SmTextForwarder::AppendParagraph()
sal_uInt16 SmTextForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) sal_uInt16 SmTextForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet )
{ {
xub_StrLen nRes = 0; sal_uInt16 nRes = 0;
EditEngine *pEditEngine = rEditAcc.GetEditEngine(); EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine && nPara < pEditEngine->GetParagraphCount()) if (pEditEngine && nPara < pEditEngine->GetParagraphCount())
{ {
......
...@@ -823,7 +823,7 @@ void SmEditWindow::MarkError(const Point &rPos) ...@@ -823,7 +823,7 @@ void SmEditWindow::MarkError(const Point &rPos)
OSL_ENSURE( pEditView, "EditView missing" ); OSL_ENSURE( pEditView, "EditView missing" );
if (pEditView) if (pEditView)
{ {
const xub_StrLen nCol = sal::static_int_cast< xub_StrLen >(rPos.X()); const sal_uInt16 nCol = sal::static_int_cast< sal_uInt16 >(rPos.X());
const sal_uInt16 nRow = sal::static_int_cast< sal_uInt16 >(rPos.Y() - 1); const sal_uInt16 nRow = sal::static_int_cast< sal_uInt16 >(rPos.Y() - 1);
pEditView->SetSelection(ESelection(nRow, nCol - 1, nRow, nCol)); pEditView->SetSelection(ESelection(nRow, nCol - 1, nRow, nCol));
......
...@@ -519,7 +519,7 @@ void SmNode::GetAccessibleText( OUStringBuffer &/*rText*/ ) const ...@@ -519,7 +519,7 @@ void SmNode::GetAccessibleText( OUStringBuffer &/*rText*/ ) const
OSL_FAIL( "SmNode: GetAccessibleText not overloaded" ); OSL_FAIL( "SmNode: GetAccessibleText not overloaded" );
} }
const SmNode * SmNode::FindNodeWithAccessibleIndex(xub_StrLen nAccIdx) const const SmNode * SmNode::FindNodeWithAccessibleIndex(sal_Int32 nAccIdx) const
{ {
const SmNode *pResult = 0; const SmNode *pResult = 0;
......
...@@ -302,14 +302,14 @@ static const SmTokenTableEntry aTokenTable[] = ...@@ -302,14 +302,14 @@ static const SmTokenTableEntry aTokenTable[] =
{ "", TEND, '\0', 0, 0} { "", TEND, '\0', 0, 0}
}; };
const SmTokenTableEntry * SmParser::GetTokenTableEntry( const String &rName ) const SmTokenTableEntry * SmParser::GetTokenTableEntry( const OUString &rName )
{ {
const SmTokenTableEntry * pRes = 0; const SmTokenTableEntry * pRes = 0;
if (rName.Len()) if (!rName.isEmpty())
{ {
for (size_t i = 0; i < SAL_N_ELEMENTS(aTokenTable); ++i) for (size_t i = 0; i < SAL_N_ELEMENTS(aTokenTable); ++i)
{ {
if (rName.EqualsIgnoreCaseAscii( aTokenTable[i].pIdent )) if (rName.equalsIgnoreAsciiCase( OUString::createFromAscii(aTokenTable[i].pIdent) ))
{ {
pRes = &aTokenTable[i]; pRes = &aTokenTable[i];
break; break;
...@@ -325,12 +325,12 @@ const SmTokenTableEntry * SmParser::GetTokenTableEntry( const String &rName ) ...@@ -325,12 +325,12 @@ const SmTokenTableEntry * SmParser::GetTokenTableEntry( const String &rName )
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
bool SmParser::IsDelimiter( const String &rTxt, xub_StrLen nPos ) bool SmParser::IsDelimiter( const OUString &rTxt, sal_Int32 nPos )
// returns 'true' iff cChar is '\0' or a delimeter // returns 'true' iff cChar is '\0' or a delimeter
{ {
OSL_ENSURE( nPos <= rTxt.Len(), "index out of range" ); OSL_ENSURE( nPos <= rTxt.getLength(), "index out of range" );
sal_Unicode cChar = rTxt.GetChar( nPos ); sal_Unicode cChar = rTxt[nPos];
if(!cChar) if(!cChar)
return true; return true;
...@@ -351,22 +351,22 @@ bool SmParser::IsDelimiter( const String &rTxt, xub_StrLen nPos ) ...@@ -351,22 +351,22 @@ bool SmParser::IsDelimiter( const String &rTxt, xub_StrLen nPos )
#endif #endif
void SmParser::Insert(const String &rText, sal_uInt16 nPos) void SmParser::Insert(const OUString &rText, sal_Int32 nPos)
{ {
m_aBufferString.Insert(rText, nPos); m_aBufferString = m_aBufferString.replaceAt(nPos, 0, rText);
xub_StrLen nLen = rText.Len(); sal_Int32 nLen = rText.getLength();
m_nBufferIndex = m_nBufferIndex + nLen; m_nBufferIndex = m_nBufferIndex + nLen;
m_nTokenIndex = m_nTokenIndex + nLen; m_nTokenIndex = m_nTokenIndex + nLen;
} }
void SmParser::Replace( sal_uInt16 nPos, sal_uInt16 nLen, const String &rText ) void SmParser::Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText )
{ {
OSL_ENSURE( nPos + nLen <= m_aBufferString.Len(), "argument mismatch" ); OSL_ENSURE( nPos + nLen <= m_aBufferString.getLength(), "argument mismatch" );
m_aBufferString.Replace( nPos, nLen, rText ); m_aBufferString = m_aBufferString.replaceAt( nPos, nLen, rText );
sal_Int16 nChg = rText.Len() - nLen; sal_Int32 nChg = rText.getLength() - nLen;
m_nBufferIndex = m_nBufferIndex + nChg; m_nBufferIndex = m_nBufferIndex + nChg;
m_nTokenIndex = m_nTokenIndex + nChg; m_nTokenIndex = m_nTokenIndex + nChg;
} }
...@@ -393,11 +393,11 @@ const sal_Int32 coNumContFlags = ...@@ -393,11 +393,11 @@ const sal_Int32 coNumContFlags =
void SmParser::NextToken() void SmParser::NextToken()
{ {
static const String aEmptyStr; static const OUString aEmptyStr;
xub_StrLen nBufLen = m_aBufferString.Len(); sal_Int32 nBufLen = m_aBufferString.getLength();
ParseResult aRes; ParseResult aRes;
xub_StrLen nRealStart; sal_Int32 nRealStart;
bool bCont; bool bCont;
CharClass aCC(SM_MOD()->GetSysLocale().GetLanguageTag()); CharClass aCC(SM_MOD()->GetSysLocale().GetLanguageTag());
do do
...@@ -426,13 +426,13 @@ void SmParser::NextToken() ...@@ -426,13 +426,13 @@ void SmParser::NextToken()
coContFlags, aEmptyStr); coContFlags, aEmptyStr);
} }
nRealStart = m_nBufferIndex + sal::static_int_cast< xub_StrLen >(aRes.LeadingWhiteSpace); nRealStart = m_nBufferIndex + aRes.LeadingWhiteSpace;
m_nBufferIndex = nRealStart; m_nBufferIndex = nRealStart;
bCont = false; bCont = false;
if ( aRes.TokenType == 0 && if ( aRes.TokenType == 0 &&
nRealStart < nBufLen && nRealStart < nBufLen &&
'\n' == m_aBufferString.GetChar( nRealStart ) ) '\n' == m_aBufferString[ nRealStart ] )
{ {
// keep data needed for tokens row and col entry up to date // keep data needed for tokens row and col entry up to date
++m_Row; ++m_Row;
...@@ -441,12 +441,12 @@ void SmParser::NextToken() ...@@ -441,12 +441,12 @@ void SmParser::NextToken()
} }
else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR) else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
{ {
if (m_aBufferString.EqualsAscii("%%", nRealStart, 2)) if (m_aBufferString.copy(nRealStart, 2) == "%%")
{ {
//SkipComment //SkipComment
m_nBufferIndex = nRealStart + 2; m_nBufferIndex = nRealStart + 2;
while (m_nBufferIndex < nBufLen && while (m_nBufferIndex < nBufLen &&
'\n' != m_aBufferString.GetChar( m_nBufferIndex )) '\n' != m_aBufferString[ m_nBufferIndex ])
++m_nBufferIndex; ++m_nBufferIndex;
bCont = true; bCont = true;
} }
...@@ -477,10 +477,10 @@ void SmParser::NextToken() ...@@ -477,10 +477,10 @@ void SmParser::NextToken()
m_aCurToken.cMathChar = '\0'; m_aCurToken.cMathChar = '\0';
m_aCurToken.nGroup = 0; m_aCurToken.nGroup = 0;
m_aCurToken.nLevel = 5; m_aCurToken.nLevel = 5;
m_aCurToken.aText = m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ); m_aCurToken.aText = m_aBufferString.copy( nRealStart, n );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
if (!IsDelimiter( m_aBufferString, static_cast< xub_StrLen >(aRes.EndPos) )) if (!IsDelimiter( m_aBufferString, aRes.EndPos ))
{ {
OSL_FAIL( "identifier really finished? (compatibility!)" ); OSL_FAIL( "identifier really finished? (compatibility!)" );
} }
...@@ -500,7 +500,7 @@ void SmParser::NextToken() ...@@ -500,7 +500,7 @@ void SmParser::NextToken()
{ {
sal_Int32 n = aRes.EndPos - nRealStart; sal_Int32 n = aRes.EndPos - nRealStart;
OSL_ENSURE( n >= 0, "length < 0" ); OSL_ENSURE( n >= 0, "length < 0" );
String aName( m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ) ); OUString aName( m_aBufferString.copy( nRealStart, n ) );
const SmTokenTableEntry *pEntry = GetTokenTableEntry( aName ); const SmTokenTableEntry *pEntry = GetTokenTableEntry( aName );
if (pEntry) if (pEntry)
...@@ -520,14 +520,14 @@ void SmParser::NextToken() ...@@ -520,14 +520,14 @@ void SmParser::NextToken()
m_aCurToken.aText = aName; m_aCurToken.aText = aName;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
if (!IsDelimiter( m_aBufferString, static_cast< xub_StrLen >(aRes.EndPos) )) if (!IsDelimiter( m_aBufferString, aRes.EndPos ))
{ {
OSL_FAIL( "identifier really finished? (compatibility!)" ); OSL_FAIL( "identifier really finished? (compatibility!)" );
} }
#endif #endif
} }
} }
else if (aRes.TokenType == 0 && '_' == m_aBufferString.GetChar( nRealStart )) else if (aRes.TokenType == 0 && '_' == m_aBufferString[ nRealStart ])
{ {
m_aCurToken.eType = TRSUB; m_aCurToken.eType = TRSUB;
m_aCurToken.cMathChar = '\0'; m_aCurToken.cMathChar = '\0';
...@@ -542,13 +542,12 @@ void SmParser::NextToken() ...@@ -542,13 +542,12 @@ void SmParser::NextToken()
sal_Int32 &rnEndPos = aRes.EndPos; sal_Int32 &rnEndPos = aRes.EndPos;
if (rnEndPos - nRealStart <= 2) if (rnEndPos - nRealStart <= 2)
{ {
sal_Unicode ch = m_aBufferString.GetChar(nRealStart); sal_Unicode ch = m_aBufferString[ nRealStart ];
switch (ch) switch (ch)
{ {
case '<': case '<':
{ {
if (m_aBufferString. if (m_aBufferString.copy(nRealStart, 2) == "<<")
EqualsAscii("<<", nRealStart, 2))
{ {
m_aCurToken.eType = TLL; m_aCurToken.eType = TLL;
m_aCurToken.cMathChar = MS_LL; m_aCurToken.cMathChar = MS_LL;
...@@ -558,8 +557,7 @@ void SmParser::NextToken() ...@@ -558,8 +557,7 @@ void SmParser::NextToken()
rnEndPos = nRealStart + 2; rnEndPos = nRealStart + 2;
} }
else if (m_aBufferString. else if (m_aBufferString.copy(nRealStart, 2) == "<=")
EqualsAscii("<=", nRealStart, 2))
{ {
m_aCurToken.eType = TLE; m_aCurToken.eType = TLE;
m_aCurToken.cMathChar = MS_LE; m_aCurToken.cMathChar = MS_LE;
...@@ -569,8 +567,7 @@ void SmParser::NextToken() ...@@ -569,8 +567,7 @@ void SmParser::NextToken()
rnEndPos = nRealStart + 2; rnEndPos = nRealStart + 2;
} }
else if (m_aBufferString. else if (m_aBufferString.copy(nRealStart, 2) == "<>")
EqualsAscii("<>", nRealStart, 2))
{ {
m_aCurToken.eType = TNEQ; m_aCurToken.eType = TNEQ;
m_aCurToken.cMathChar = MS_NEQ; m_aCurToken.cMathChar = MS_NEQ;
...@@ -580,8 +577,7 @@ void SmParser::NextToken() ...@@ -580,8 +577,7 @@ void SmParser::NextToken()
rnEndPos = nRealStart + 2; rnEndPos = nRealStart + 2;
} }
else if (m_aBufferString. else if (m_aBufferString.copy(nRealStart, 3) == "<?>")
EqualsAscii("<?>", nRealStart, 3))
{ {
m_aCurToken.eType = TPLACE; m_aCurToken.eType = TPLACE;
m_aCurToken.cMathChar = MS_PLACE; m_aCurToken.cMathChar = MS_PLACE;
...@@ -603,8 +599,7 @@ void SmParser::NextToken() ...@@ -603,8 +599,7 @@ void SmParser::NextToken()
break; break;
case '>': case '>':
{ {
if (m_aBufferString. if (m_aBufferString.copy(nRealStart, 2) == ">=")
EqualsAscii(">=", nRealStart, 2))
{ {
m_aCurToken.eType = TGE; m_aCurToken.eType = TGE;
m_aCurToken.cMathChar = MS_GE; m_aCurToken.cMathChar = MS_GE;
...@@ -614,8 +609,7 @@ void SmParser::NextToken() ...@@ -614,8 +609,7 @@ void SmParser::NextToken()
rnEndPos = nRealStart + 2; rnEndPos = nRealStart + 2;
} }
else if (m_aBufferString. else if (m_aBufferString.copy(nRealStart, 2) == ">>")
EqualsAscii(">>", nRealStart, 2))
{ {
m_aCurToken.eType = TGG; m_aCurToken.eType = TGG;
m_aCurToken.cMathChar = MS_GG; m_aCurToken.cMathChar = MS_GG;
...@@ -645,7 +639,7 @@ void SmParser::NextToken() ...@@ -645,7 +639,7 @@ void SmParser::NextToken()
sal_Int32 &rnEndPos = aRes.EndPos; sal_Int32 &rnEndPos = aRes.EndPos;
if (rnEndPos - nRealStart == 1) if (rnEndPos - nRealStart == 1)
{ {
sal_Unicode ch = m_aBufferString.GetChar(nRealStart); sal_Unicode ch = m_aBufferString[ nRealStart ];
switch (ch) switch (ch)
{ {
case '%': case '%':
...@@ -653,7 +647,7 @@ void SmParser::NextToken() ...@@ -653,7 +647,7 @@ void SmParser::NextToken()
//! modifies aRes.EndPos //! modifies aRes.EndPos
OSL_ENSURE( rnEndPos >= nBufLen || OSL_ENSURE( rnEndPos >= nBufLen ||
'%' != m_aBufferString.GetChar( sal::static_int_cast< xub_StrLen >(rnEndPos) ), '%' != m_aBufferString[ rnEndPos ],
"unexpected comment start" ); "unexpected comment start" );
// get identifier of user-defined character // get identifier of user-defined character
...@@ -664,8 +658,7 @@ void SmParser::NextToken() ...@@ -664,8 +658,7 @@ void SmParser::NextToken()
coContFlags, coContFlags,
aEmptyStr ); aEmptyStr );
xub_StrLen nTmpStart = sal::static_int_cast< xub_StrLen >(rnEndPos + sal_Int32 nTmpStart = rnEndPos + aTmpRes.LeadingWhiteSpace;
aTmpRes.LeadingWhiteSpace);
// default setting for the case that no identifier // default setting for the case that no identifier
// i.e. a valid symbol-name is following the '%' // i.e. a valid symbol-name is following the '%'
...@@ -674,16 +667,16 @@ void SmParser::NextToken() ...@@ -674,16 +667,16 @@ void SmParser::NextToken()
m_aCurToken.cMathChar = '\0'; m_aCurToken.cMathChar = '\0';
m_aCurToken.nGroup = 0; m_aCurToken.nGroup = 0;
m_aCurToken.nLevel = 5; m_aCurToken.nLevel = 5;
m_aCurToken.aText = String(); m_aCurToken.aText = OUString();
m_aCurToken.nRow = sal::static_int_cast< xub_StrLen >(m_Row); m_aCurToken.nRow = m_Row;
m_aCurToken.nCol = nTmpStart - m_nColOff; m_aCurToken.nCol = nTmpStart - m_nColOff;
if (aTmpRes.TokenType & KParseType::IDENTNAME) if (aTmpRes.TokenType & KParseType::IDENTNAME)
{ {
xub_StrLen n = sal::static_int_cast< xub_StrLen >(aTmpRes.EndPos - nTmpStart); sal_Int32 n = aTmpRes.EndPos - nTmpStart;
m_aCurToken.eType = TSPECIAL; m_aCurToken.eType = TSPECIAL;
m_aCurToken.aText = m_aBufferString.Copy( sal::static_int_cast< xub_StrLen >(nTmpStart-1), n+1 ); m_aCurToken.aText = m_aBufferString.copy( nTmpStart-1, n+1 );
OSL_ENSURE( aTmpRes.EndPos > rnEndPos, OSL_ENSURE( aTmpRes.EndPos > rnEndPos,
"empty identifier" ); "empty identifier" );
...@@ -781,8 +774,7 @@ void SmParser::NextToken() ...@@ -781,8 +774,7 @@ void SmParser::NextToken()
break; break;
case '#': case '#':
{ {
if (m_aBufferString. if (m_aBufferString.copy(nRealStart, 2) == "##")
EqualsAscii("##", nRealStart, 2))
{ {
m_aCurToken.eType = TDPOUND; m_aCurToken.eType = TDPOUND;
m_aCurToken.cMathChar = '\0'; m_aCurToken.cMathChar = '\0';
...@@ -840,8 +832,7 @@ void SmParser::NextToken() ...@@ -840,8 +832,7 @@ void SmParser::NextToken()
break; break;
case '+': case '+':
{ {
if (m_aBufferString. if (m_aBufferString.copy(nRealStart, 2) == "+-")
EqualsAscii("+-", nRealStart, 2))
{ {
m_aCurToken.eType = TPLUSMINUS; m_aCurToken.eType = TPLUSMINUS;
m_aCurToken.cMathChar = MS_PLUSMINUS; m_aCurToken.cMathChar = MS_PLUSMINUS;
...@@ -863,8 +854,7 @@ void SmParser::NextToken() ...@@ -863,8 +854,7 @@ void SmParser::NextToken()
break; break;
case '-': case '-':
{ {
if (m_aBufferString. if (m_aBufferString.copy(nRealStart, 2) == "-+")
EqualsAscii("-+", nRealStart, 2))
{ {
m_aCurToken.eType = TMINUSPLUS; m_aCurToken.eType = TMINUSPLUS;
m_aCurToken.cMathChar = MS_MINUSPLUS; m_aCurToken.cMathChar = MS_MINUSPLUS;
...@@ -894,16 +884,15 @@ void SmParser::NextToken() ...@@ -894,16 +884,15 @@ void SmParser::NextToken()
m_aCurToken.nGroup = 0; m_aCurToken.nGroup = 0;
m_aCurToken.nLevel = 5; m_aCurToken.nLevel = 5;
xub_StrLen nTxtStart = m_nBufferIndex; sal_Int32 nTxtStart = m_nBufferIndex;
sal_Unicode cChar; sal_Unicode cChar;
do do
{ {
cChar = m_aBufferString.GetChar( ++m_nBufferIndex ); cChar = m_aBufferString[ ++m_nBufferIndex ];
} }
while ( cChar == '.' || rtl::isAsciiDigit( cChar ) ); while ( cChar == '.' || rtl::isAsciiDigit( cChar ) );
m_aCurToken.aText = m_aBufferString.Copy( sal::static_int_cast< xub_StrLen >(nTxtStart), m_aCurToken.aText = m_aBufferString.copy( nTxtStart, m_nBufferIndex - nTxtStart );
sal::static_int_cast< xub_StrLen >(m_nBufferIndex - nTxtStart) );
aRes.EndPos = m_nBufferIndex; aRes.EndPos = m_nBufferIndex;
} }
break; break;
...@@ -939,13 +928,13 @@ void SmParser::NextToken() ...@@ -939,13 +928,13 @@ void SmParser::NextToken()
m_aCurToken.cMathChar = '\0'; m_aCurToken.cMathChar = '\0';
m_aCurToken.nGroup = 0; m_aCurToken.nGroup = 0;
m_aCurToken.nLevel = 5; m_aCurToken.nLevel = 5;
m_aCurToken.aText = m_aBufferString.Copy( nRealStart, 1 ); m_aCurToken.aText = m_aBufferString.copy( nRealStart, 1 );
aRes.EndPos = nRealStart + 1; aRes.EndPos = nRealStart + 1;
} }
if (TEND != m_aCurToken.eType) if (TEND != m_aCurToken.eType)
m_nBufferIndex = sal::static_int_cast< xub_StrLen >(aRes.EndPos); m_nBufferIndex = aRes.EndPos;
} }
...@@ -995,7 +984,7 @@ void SmParser::Align() ...@@ -995,7 +984,7 @@ void SmParser::Align()
if (CONVERT_40_TO_50 == GetConversion()) if (CONVERT_40_TO_50 == GetConversion())
// encapsulate expression to be aligned in group braces // encapsulate expression to be aligned in group braces
// (here group-open brace) // (here group-open brace)
{ Insert(OUString('{'), GetTokenIndex()); { Insert("{", GetTokenIndex());
bNeedGroupClose = true; bNeedGroupClose = true;
// get first valid align statement in sequence // get first valid align statement in sequence
...@@ -1006,7 +995,7 @@ void SmParser::Align() ...@@ -1006,7 +995,7 @@ void SmParser::Align()
if (TokenInGroup(TGDISCARDED) || pSNode) if (TokenInGroup(TGDISCARDED) || pSNode)
{ {
m_nBufferIndex = GetTokenIndex(); m_nBufferIndex = GetTokenIndex();
m_aBufferString.Erase(m_nBufferIndex, m_aCurToken.aText.getLength()); m_aBufferString = m_aBufferString.replaceAt(m_nBufferIndex, m_aCurToken.aText.getLength(), "");
} }
else else
pSNode = new SmAlignNode(m_aCurToken); pSNode = new SmAlignNode(m_aCurToken);
...@@ -1033,7 +1022,7 @@ void SmParser::Align() ...@@ -1033,7 +1022,7 @@ void SmParser::Align()
Expression(); Expression();
if (bNeedGroupClose) if (bNeedGroupClose)
Insert(OUString('}'), GetTokenIndex()); Insert("}", GetTokenIndex());
if (pSNode) if (pSNode)
{ {
...@@ -1438,9 +1427,9 @@ void SmParser::Term(bool bGroupNumberIdent) ...@@ -1438,9 +1427,9 @@ void SmParser::Term(bool bGroupNumberIdent)
// work to distinguish from "x_2 n". // work to distinguish from "x_2 n".
// See https://issues.apache.org/ooo/show_bug.cgi?id=11752 and // See https://issues.apache.org/ooo/show_bug.cgi?id=11752 and
// https://www.libreoffice.org/bugzilla/show_bug.cgi?id=55853 // https://www.libreoffice.org/bugzilla/show_bug.cgi?id=55853
xub_StrLen nBufLen = m_aBufferString.Len(); sal_Int32 nBufLen = m_aBufferString.getLength();
CharClass aCC(SM_MOD()->GetSysLocale().GetLanguageTag()); CharClass aCC(SM_MOD()->GetSysLocale().GetLanguageTag());
sal_uInt16 nTokens = 1; sal_Int32 nTokens = 1;
// We need to be careful to call NextToken() only after having // We need to be careful to call NextToken() only after having
// tested for a whitespace separator (otherwise it will be // tested for a whitespace separator (otherwise it will be
...@@ -1599,7 +1588,7 @@ void SmParser::Term(bool bGroupNumberIdent) ...@@ -1599,7 +1588,7 @@ void SmParser::Term(bool bGroupNumberIdent)
else // encapsulate old 4.0 style parsing in braces else // encapsulate old 4.0 style parsing in braces
{ {
// insert opening brace // insert opening brace
Insert(OUString('{'), GetTokenIndex()); Insert("{", GetTokenIndex());
// //
// parse in 4.0 style // parse in 4.0 style
...@@ -1616,7 +1605,7 @@ void SmParser::Term(bool bGroupNumberIdent) ...@@ -1616,7 +1605,7 @@ void SmParser::Term(bool bGroupNumberIdent)
} }
// insert closing brace // insert closing brace
Insert(OUString('}'), GetTokenIndex()); Insert("}", GetTokenIndex());
SmStructureNode *pSNode = new SmExpressionNode(pFunc->GetToken()); SmStructureNode *pSNode = new SmExpressionNode(pFunc->GetToken());
pSNode->SetSubNodes(pFunc, lcl_popOrZero(m_aNodeStack)); pSNode->SetSubNodes(pFunc, lcl_popOrZero(m_aNodeStack));
...@@ -2474,7 +2463,7 @@ SmParser::SmParser() ...@@ -2474,7 +2463,7 @@ SmParser::SmParser()
m_nLang = Application::GetSettings().GetUILanguageTag().getLanguageType(); m_nLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
} }
SmNode *SmParser::Parse(const String &rBuffer) SmNode *SmParser::Parse(const OUString &rBuffer)
{ {
ClearUsedSymbols(); ClearUsedSymbols();
......
...@@ -86,8 +86,8 @@ const OUString SmLocalizedSymbolData::GetUiSymbolName( const OUString &rExportNa ...@@ -86,8 +86,8 @@ const OUString SmLocalizedSymbolData::GetUiSymbolName( const OUString &rExportNa
const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray(); const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray(); const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count()); sal_uInt32 nCount = rExportNames.Count();
for (sal_uInt16 i = 0; i < nCount && aRes.isEmpty(); ++i) for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
{ {
if (rExportNames.GetString(i).equals(rExportName)) if (rExportNames.GetString(i).equals(rExportName))
{ {
...@@ -107,8 +107,8 @@ const OUString SmLocalizedSymbolData::GetExportSymbolName( const OUString &rUiNa ...@@ -107,8 +107,8 @@ const OUString SmLocalizedSymbolData::GetExportSymbolName( const OUString &rUiNa
const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray(); const ResStringArray &rUiNames = rData.GetUiSymbolNamesArray();
const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray(); const ResStringArray &rExportNames = rData.GetExportSymbolNamesArray();
sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count()); sal_uInt32 nCount = rUiNames.Count();
for (sal_uInt16 i = 0; i < nCount && aRes.isEmpty(); ++i) for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
{ {
if (rUiNames.GetString(i).equals(rUiName)) if (rUiNames.GetString(i).equals(rUiName))
{ {
...@@ -128,8 +128,8 @@ const OUString SmLocalizedSymbolData::GetUiSymbolSetName( const OUString &rExpor ...@@ -128,8 +128,8 @@ const OUString SmLocalizedSymbolData::GetUiSymbolSetName( const OUString &rExpor
const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray(); const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray(); const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rExportNames.Count()); sal_uInt32 nCount = rExportNames.Count();
for (sal_uInt16 i = 0; i < nCount && aRes.isEmpty(); ++i) for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
{ {
if (rExportNames.GetString(i).equals(rExportName)) if (rExportNames.GetString(i).equals(rExportName))
{ {
...@@ -149,8 +149,8 @@ const OUString SmLocalizedSymbolData::GetExportSymbolSetName( const OUString &rU ...@@ -149,8 +149,8 @@ const OUString SmLocalizedSymbolData::GetExportSymbolSetName( const OUString &rU
const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData(); const SmLocalizedSymbolData &rData = SM_MOD()->GetLocSymbolData();
const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray(); const ResStringArray &rUiNames = rData.GetUiSymbolSetNamesArray();
const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray(); const ResStringArray &rExportNames = rData.GetExportSymbolSetNamesArray();
sal_uInt16 nCount = sal::static_int_cast< xub_StrLen >(rUiNames.Count()); sal_uInt32 nCount = rUiNames.Count();
for (sal_uInt16 i = 0; i < nCount && aRes.isEmpty(); ++i) for (sal_uInt32 i = 0; i < nCount && aRes.isEmpty(); ++i)
{ {
if (rUiNames.GetString(i).equals(rUiName)) if (rUiNames.GetString(i).equals(rUiName))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment