use more string_view in starmath

Change-Id: I3569d8dd41bf1c2db6a1fd379ca5596342922e45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140786
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-09-30 09:06:25 +02:00
parent 379dc86922
commit 9ec9ace3f0
4 changed files with 11 additions and 11 deletions

View file

@ -55,7 +55,7 @@ class SmParser5 final : public AbstractSmParser
void NextTokenColor(SmTokenType dvipload);
void NextTokenFontSize();
sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
void Replace(sal_Int32 nPos, sal_Int32 nLen, const OUString& rText);
void Replace(sal_Int32 nPos, sal_Int32 nLen, std::u16string_view aText);
inline bool TokenInGroup(TG nGroup);

View file

@ -2162,14 +2162,14 @@ void SmMathSymbolNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
/**************************************************************************/
static bool lcl_IsFromGreekSymbolSet( const OUString &rTokenText )
static bool lcl_IsFromGreekSymbolSet( std::u16string_view aTokenText )
{
bool bRes = false;
// valid symbol name needs to have a '%' at pos 0 and at least an additional char
if (rTokenText.getLength() > 2 && rTokenText[0] == u'%')
if (aTokenText.size() > 2 && aTokenText[0] == u'%')
{
OUString aName( rTokenText.copy(1) );
OUString aName( aTokenText.substr(1) );
SmSym *pSymbol = SM_MOD()->GetSymbolManager().GetSymbolByName( aName );
if (pSymbol && SmLocalizedSymbolData::GetExportSymbolSetName(pSymbol->GetSymbolSetName()) == "Greek")
bRes = true;

View file

@ -374,12 +374,12 @@ static bool lcl_IsNotWholeNumber16(const OUString& rText)
}
//Text replace onto m_aBufferString
void SmParser5::Replace(sal_Int32 nPos, sal_Int32 nLen, const OUString& rText)
void SmParser5::Replace(sal_Int32 nPos, sal_Int32 nLen, std::u16string_view aText)
{
assert(nPos + nLen <= m_aBufferString.getLength()); //checks if length allows text replace
m_aBufferString = m_aBufferString.replaceAt(nPos, nLen, rText); //replace and reindex
sal_Int32 nChg = rText.getLength() - nLen;
m_aBufferString = m_aBufferString.replaceAt(nPos, nLen, aText); //replace and reindex
sal_Int32 nChg = aText.size() - nLen;
m_nBufferIndex = m_nBufferIndex + nChg;
m_nTokenIndex = m_nTokenIndex + nChg;
}

View file

@ -108,7 +108,7 @@ bool SmGetGlyphBoundRect(const vcl::RenderContext &rDev,
return bSuccess;
}
bool SmIsMathAlpha(const OUString &rText)
bool SmIsMathAlpha(std::u16string_view aText)
// true iff symbol (from StarMath Font) should be treated as letter
{
// Set of symbols, which should be treated as letters in StarMath Font
@ -125,11 +125,11 @@ bool SmIsMathAlpha(const OUString &rText)
u'\x2130', u'\x2131'
});
if (rText.isEmpty())
if (aText.empty())
return false;
OSL_ENSURE(rText.getLength() == 1, "Sm : string must be exactly one character long");
sal_Unicode cChar = rText[0];
OSL_ENSURE(aText.size() == 1, "Sm : string must be exactly one character long");
sal_Unicode cChar = aText[0];
// is it a greek symbol?
if (u'\xE0AC' <= cChar && cChar <= u'\xE0D4')