diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-22 23:40:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-23 10:10:09 +0000 |
commit | b7ea36101497c275cb08b0e37facbde656197d9b (patch) | |
tree | a05e25d4f01c94c69712d17a1ab4cdbc925ef355 | |
parent | _SVSTDARR_ULONGS not used here (diff) | |
download | core-b7ea36101497c275cb08b0e37facbde656197d9b.tar.gz core-b7ea36101497c275cb08b0e37facbde656197d9b.zip |
add stripStart, can replace EraseTrailingChars
28 files changed, 188 insertions, 108 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx index e6b2d721099d..c1f56497da4c 100644 --- a/comphelper/inc/comphelper/string.hxx +++ b/comphelper/inc/comphelper/string.hxx @@ -223,7 +223,7 @@ COMPHELPER_DLLPUBLIC rtl::OUString remove(const rtl::OUString &rIn, /** Strips occurrences of a character from the start of the source string @param rIn The input OString - @param c The character to be stripped from the beginning + @param c The character to be stripped from the start @return The resulting OString */ @@ -233,13 +233,32 @@ COMPHELPER_DLLPUBLIC rtl::OString stripStart(const rtl::OString &rIn, /** Strips occurrences of a character from the start of the source string @param rIn The input OUString - @param c The character to be stripped from the beginning + @param c The character to be stripped from the start @return The resulting OUString */ COMPHELPER_DLLPUBLIC rtl::OUString stripStart(const rtl::OUString &rIn, sal_Unicode c); +/** Strips occurrences of a character from the end of the source string + + @param rIn The input OString + @param c The character to be stripped from the end + + @return The resulting OString + */ +COMPHELPER_DLLPUBLIC rtl::OString stripEnd(const rtl::OString &rIn, + sal_Char c); + +/** Strips occurrences of a character from the end of the source string + + @param rIn The input OUString + @param c The character to be stripped from the end + + @return The resulting OUString + */ +COMPHELPER_DLLPUBLIC rtl::OUString stripEnd(const rtl::OUString &rIn, + sal_Unicode c); /** Returns a token in the OString diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index 790519d07839..1e89408930bf 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -50,6 +50,7 @@ public: void testReplace(); void testRemove(); void testStripStart(); + void testStripEnd(); void testToken(); void testDecimalStringToNumber(); void testIsdigitAsciiString(); @@ -64,6 +65,7 @@ public: CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testRemove); CPPUNIT_TEST(testStripStart); + CPPUNIT_TEST(testStripEnd); CPPUNIT_TEST(testToken); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); @@ -452,6 +454,26 @@ void TestString::testStripStart() CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ba"))); } +void TestString::testStripEnd() +{ + ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc")); + ::rtl::OString aOut; + + aOut = ::comphelper::string::stripEnd(aIn, 'b'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc"))); + + aOut = ::comphelper::string::stripEnd(aIn, 'c'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab"))); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa")); + aOut = ::comphelper::string::stripEnd(aIn, 'a'); + CPPUNIT_ASSERT(aOut.isEmpty()); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba")); + aOut = ::comphelper::string::stripEnd(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab"))); +} + void TestString::testToken() { ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12")); diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index 09fb2684e7ce..02d1cd4d104c 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -200,6 +200,37 @@ rtl::OUString stripStart(const rtl::OUString &rIn, sal_Unicode c) return tmpl_stripStart<rtl::OUString, sal_Unicode>(rIn, c); } +namespace +{ + template <typename T, typename C> T tmpl_stripEnd(const T &rIn, + const C cRemove) + { + if (rIn.isEmpty()) + return rIn; + + sal_Int32 i = rIn.getLength(); + + while (i > 0) + { + if (rIn[i-1] != cRemove) + break; + --i; + } + + return rIn.copy(0, i); + } +} + +rtl::OString stripEnd(const rtl::OString &rIn, sal_Char c) +{ + return tmpl_stripEnd<rtl::OString, sal_Char>(rIn, c); +} + +rtl::OUString stripEnd(const rtl::OUString &rIn, sal_Unicode c) +{ + return tmpl_stripEnd<rtl::OUString, sal_Unicode>(rIn, c); +} + sal_uInt32 decimalStringToNumber( ::rtl::OUString const & str ) { diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index 6c91c3e3852b..0dd607380983 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -65,10 +65,9 @@ static long nStaticTabs[]= // static function ------------------------------------------------------- -static String getNormDicEntry_Impl( const String &rText ) +static String getNormDicEntry_Impl(const rtl::OUString &rText) { - String aTmp( rText ); - aTmp.EraseTrailingChars( '.' ); + rtl::OUString aTmp(comphelper::string::stripEnd(rText, '.')); return comphelper::string::remove(aTmp, '='); } diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx index e337bc6fe146..0105e346b88a 100644 --- a/extensions/source/propctrlr/browserline.cxx +++ b/extensions/source/propctrlr/browserline.cxx @@ -30,19 +30,17 @@ #include "precompiled_extensions.hxx" #include "browserline.hxx" -/** === begin UNO includes === **/ #include <com/sun/star/inspection/PropertyLineElement.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> -/** === end UNO includes === **/ -#include <vcl/svapp.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> #include <toolkit/helper/vclunohelper.hxx> - -#include <comphelper/processfactory.hxx> -#include <comphelper/componentcontext.hxx> +#include <vcl/svapp.hxx> //............................................................................ namespace pcr @@ -306,16 +304,16 @@ namespace pcr //------------------------------------------------------------------ XubString OBrowserLine::GetTitle() const { - String sDisplayName = m_aFtTitle.GetText(); + rtl::OUString sDisplayName = m_aFtTitle.GetText(); - // for Issue 69452 - if (Application::GetSettings().GetLayoutRTL()) - { - sal_Unicode cRTL_mark = 0x200F; - sDisplayName.EraseTrailingChars(cRTL_mark); - } + // for Issue 69452 + if (Application::GetSettings().GetLayoutRTL()) + { + sal_Unicode cRTL_mark = 0x200F; + sDisplayName = comphelper::string::stripEnd(sDisplayName, cRTL_mark); + } - sDisplayName.EraseTrailingChars( '.' ); + sDisplayName = comphelper::string::stripEnd(sDisplayName, '.'); return sDisplayName; } diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 2234125a420f..d00242f5db11 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -366,8 +366,8 @@ sal_Bool ResData::SetId( const ByteString &rId, sal_uInt16 nLevel ) { YYWarning( "LocalId > 255 chars, truncating..." ); sId.Erase( 255 ); - sId.EraseTrailingChars( ' ' ); - sId.EraseTrailingChars( '\t' ); + sId = comphelper::string::stripEnd(sId, ' '); + sId = comphelper::string::stripEnd(sId, '\t'); } return sal_True; @@ -643,7 +643,7 @@ int Export::Execute( int nToken, const char * pToken ) sToken = comphelper::string::remove(sToken, '\r'); sToken = comphelper::string::remove(sToken, '{'); while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; - sToken.EraseTrailingChars( ' ' ); + sToken = comphelper::string::stripEnd(sToken, ' '); ByteString sT = getToken(sToken, 0, ' '); pResData->sResTyp = sT.ToLowerAscii(); ByteString sId( sToken.Copy( pResData->sResTyp.Len() + 1 )); @@ -1280,7 +1280,7 @@ ByteString Export::GetPairedListID( const ByteString& sText ){ ByteString sIdent = getToken(sText, 1, ';'); sIdent.ToUpperAscii(); while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; - sIdent.EraseTrailingChars( ' ' ); + sIdent = comphelper::string::stripEnd(sIdent, ' '); sIdent = comphelper::string::stripStart(sIdent, ' '); return sIdent; } @@ -1288,10 +1288,10 @@ ByteString Export::GetPairedListString( const ByteString& sText ){ // < "STRING" ; IDENTIFIER ; > ; ByteString sString = getToken(sText, 0, ';'); while( sString.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; - sString.EraseTrailingChars( ' ' ); + sString = comphelper::string::stripEnd(sString, ' '); ByteString s1 = sString.Copy( sString.Search( '\"' )+1 ); sString = s1.Copy( 0 , s1.SearchBackward( '\"' ) ); - sString.EraseTrailingChars( ' ' ); + sString = comphelper::string::stripEnd(sString, ' '); sString = comphelper::string::stripStart(sString, ' '); return sString; } @@ -1311,7 +1311,7 @@ sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, else { sGID += "."; sGID += pResData->sId; - sGID.EraseTrailingChars( '.' ); + sGID = comphelper::string::stripEnd(sGID, '.'); } ByteString sTimeStamp( Export::GetTimeStamp()); @@ -1548,7 +1548,7 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {}; sToken = comphelper::string::stripStart(sToken, ' '); - sToken.EraseTrailingChars( ' ' ); + sToken = comphelper::string::stripEnd(sToken, ' '); if ( sToken.Len()) { sReturn += "\\\" "; sReturn += sToken; diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx index 036edafb0601..e25870236a15 100644 --- a/l10ntools/source/gsicheck.cxx +++ b/l10ntools/source/gsicheck.cxx @@ -393,7 +393,7 @@ void GSIBlock::PrintList( ParserMessageList *pList, ByteString aPrefix, aContext = pLine->GetText().Copy( 0, 300 ); else aContext = pLine->Copy( pMsg->GetTagBegin()-150, 300 ); - aContext.EraseTrailingChars(' '); + aContext = comphelper::string::stripEnd(aContext, ' '); aContext = comphelper::string::stripStart(aContext, ' '); } diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index efa5c0cef529..5a9f82e5fe0a 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -506,8 +506,8 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile ByteString HelpParser::GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY ){ ByteString testpath = rPathX; static const ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US ); - testpath.EraseTrailingChars( '/' ); - testpath.EraseTrailingChars( '\\' ); + testpath = comphelper::string::stripEnd(testpath, '/'); + testpath = comphelper::string::stripEnd(testpath, '\\'); testpath += sDelimiter; testpath += sCur; testpath += sDelimiter; diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 57216afc6f74..83affd6baed4 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -174,13 +174,13 @@ void LngParser::WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_in bool LngParser::isNextGroup( ByteString &sGroup_out , ByteString &sLine_in ) { sLine_in = comphelper::string::stripStart(sLine_in, ' '); - sLine_in.EraseTrailingChars( ' ' ); + sLine_in = comphelper::string::stripEnd(sLine_in, ' '); if (( sLine_in.GetChar( 0 ) == '[' ) && ( sLine_in.GetChar( sLine_in.Len() - 1 ) == ']' )) { sGroup_out = getToken(getToken(sLine_in, 1, '['), 0, ']'); sGroup_out = comphelper::string::stripStart(sGroup_out, ' '); - sGroup_out.EraseTrailingChars( ' ' ); + sGroup_out = comphelper::string::stripEnd(sGroup_out, ' '); return true; } return false; @@ -226,13 +226,13 @@ sal_Bool LngParser::Merge( { ByteString sLine( *(*pLines)[ nPos ] ); sLine = comphelper::string::stripStart(sLine, ' '); - sLine.EraseTrailingChars( ' ' ); + sLine = comphelper::string::stripEnd(sLine, ' '); if (( sLine.GetChar( 0 ) == '[' ) && ( sLine.GetChar( sLine.Len() - 1 ) == ']' )) { sGroup = getToken(getToken(sLine, 1, '['), 0, ']'); sGroup = comphelper::string::stripStart(sGroup, ' '); - sGroup.EraseTrailingChars( ' ' ); + sGroup = comphelper::string::stripEnd(sGroup, ' '); bGroup = sal_True; } nPos ++; @@ -255,13 +255,13 @@ sal_Bool LngParser::Merge( { ByteString sLine( *(*pLines)[ nPos ] ); sLine = comphelper::string::stripStart(sLine, ' '); - sLine.EraseTrailingChars( ' ' ); + sLine = comphelper::string::stripEnd(sLine, ' '); if (( sLine.GetChar( 0 ) == '[' ) && ( sLine.GetChar( sLine.Len() - 1 ) == ']' )) { sGroup = getToken(getToken(sLine, 1, '['), 0, ']'); sGroup = comphelper::string::stripStart(sGroup, ' '); - sGroup.EraseTrailingChars( ' ' ); + sGroup = comphelper::string::stripEnd(sGroup, ' '); bGroup = sal_True; nPos ++; sLanguagesDone = ""; @@ -270,7 +270,7 @@ sal_Bool LngParser::Merge( { ByteString sLang = getToken(sLine, 0, '='); sLang = comphelper::string::stripStart(sLang, ' '); - sLang.EraseTrailingChars( ' ' ); + sLang = comphelper::string::stripEnd(sLang, ' '); ByteString sSearch( ";" ); sSearch += sLang; diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 0d49e84e1545..e390fdd6b36b 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -442,7 +442,7 @@ void XRMResParser::ConvertStringToDBFormat( ByteString &rString ) sResult = rString; rString = comphelper::string::stripStart(rString, _LF); rString = comphelper::string::stripStart(rString, '\t'); - rString.EraseTrailingChars( '\t' ); + rString = comphelper::string::stripEnd(rString, '\t'); } while ( sResult != rString ); rString.SearchAndReplaceAll( "\t", "\\t" ); diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 168800478f46..6c2b23656881 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -43,6 +43,7 @@ #include "tool.h" #include <math.h> +#include <comphelper/string.hxx> extern WKTYP eTyp; @@ -77,7 +78,7 @@ void LotusToSc::DoFunc( DefTokenId eOc, sal_uInt8 nAnz, const sal_Char* pExtStri if( n != STRING_NOTFOUND ) t.Erase( 0, n + s.Len() ); - t.EraseTrailingChars( '(' ); + t = comphelper::string::stripEnd(t, '('); eOc = lcl_KnownAddIn( t ); diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 595d23318493..e532d98185bf 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -48,8 +48,9 @@ #include <boost/unordered_map.hpp> #include <rtl/ustrbuf.hxx> -#include <comphelper/processfactory.hxx> #include <comphelper/configurationhelper.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -1040,7 +1041,7 @@ SearchTabPage_Impl::~SearchTabPage_Impl() aUserData += ';'; } - aUserData.EraseTrailingChars(';'); + aUserData = comphelper::string::stripEnd(aUserData, ';'); Any aUserItem = makeAny( ::rtl::OUString( aUserData ) ); aViewOpt.SetUserItem( USERITEM_NAME, aUserItem ); } diff --git a/sfx2/source/bastyp/frmhtmlw.cxx b/sfx2/source/bastyp/frmhtmlw.cxx index 2451d107408c..504baa79fc02 100644 --- a/sfx2/source/bastyp/frmhtmlw.cxx +++ b/sfx2/source/bastyp/frmhtmlw.cxx @@ -49,8 +49,8 @@ #include <sfx2/sfx.hrc> #include "bastyp.hrc" -#include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/script/XTypeConverter.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> @@ -238,16 +238,17 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const String& rBaseURL, xUserDefinedProps->getPropertySetInfo(); DBG_ASSERT(xPropInfo.is(), "UserDefinedProperties Info is null"); uno::Sequence<beans::Property> props = xPropInfo->getProperties(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) { - try { + for (sal_Int32 i = 0; i < props.getLength(); ++i) + { + try + { ::rtl::OUString name = props[i].Name; - ::rtl::OUString str; uno::Any aStr = xConverter->convertToSimpleType( xUserDefinedProps->getPropertyValue(name), uno::TypeClass_STRING); + ::rtl::OUString str; aStr >>= str; - String valstr(str); - valstr.EraseTrailingChars(); + String valstr(comphelper::string::stripEnd(str, ' ')); OutMeta( rStrm, pIndent, name, valstr, sal_False, eDestEnc, pNonConvertableChars ); } diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index ab4094ab03e2..72ba885992d8 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -31,6 +31,7 @@ #include "document.hxx" #include "view.hxx" #include "accessibility.hxx" +#include <comphelper/string.hxx> void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor){ SmCaretPosGraphEntry* NewPos = NULL; @@ -1112,7 +1113,7 @@ void SmCursor::InsertSpecial(XubString aString) { Delete(); aString.EraseLeadingAndTrailingChars(); - aString.EraseLeadingChars('%'); + aString = comphelper::string::stripStart(aString, '%'); //Create instance of special node SmToken token; diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index e9eced85b334..426163d7d9f0 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -2188,8 +2188,8 @@ bool SmSymDefineDialog::SelectSymbolSet(ComboBox &rComboBox, // 'Normalisieren' des SymbolNamens (ohne leading und trailing Leerzeichen) XubString aNormName (rSymbolSetName); - aNormName.EraseLeadingChars(' '); - aNormName.EraseTrailingChars(' '); + aNormName = comphelper::string::stripStart(aNormName, ' '); + aNormName = comphelper::string::stripEnd(aNormName, ' '); // und evtl Abweichungen in der Eingabe beseitigen rComboBox.SetText(aNormName); diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 6ab4cbf79e82..b3bb953be6e2 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -49,6 +49,10 @@ one go*/ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/uno/Any.h> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/servicehelper.hxx> +#include <comphelper/string.hxx> #include <rtl/math.hxx> #include <sfx2/frame.hxx> #include <sfx2/docfile.hxx> @@ -58,7 +62,6 @@ one go*/ #include <unotools/saveopt.hxx> #include <svl/stritem.hxx> #include <svl/itemprop.hxx> -#include <comphelper/processfactory.hxx> #include <unotools/streamwrap.hxx> #include <sax/tools/converter.hxx> #include <xmloff/xmlnmspe.hxx> @@ -68,8 +71,6 @@ one go*/ #include <xmloff/xmluconv.hxx> #include <xmloff/xmlmetai.hxx> #include <osl/mutex.hxx> -#include <comphelper/genericpropertyset.hxx> -#include <comphelper/servicehelper.hxx> #include <memory> @@ -572,7 +573,7 @@ void SmXMLImport::endDocument(void) //Make up some editable text aText = pDocShell->GetText(); pTree->CreateTextFromNode(aText); - aText.EraseTrailingChars(); + aText = comphelper::string::stripEnd(aText, ' '); if ((aText.GetChar(0) == '{') && (aText.GetChar(aText.Len()-1) == '}')) { diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index 29ed2837980a..156537ae8112 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -38,6 +38,7 @@ #include "mathtype.hxx" #include "visitors.hxx" +#include <comphelper/string.hxx> #include <tools/gen.hxx> #include <tools/fract.hxx> #include <rtl/math.hxx> @@ -449,7 +450,7 @@ void SmNode::CreateTextFromNode(String &rText) pNode->CreateTextFromNode(rText); if (nSize > 1) { - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); APPEND(rText,"} "); } } @@ -824,7 +825,7 @@ void SmExpressionNode::CreateTextFromNode(String &rText) if (nSize > 1) { - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); APPEND(rText,"} "); } } @@ -1654,13 +1655,13 @@ void SmSubSupNode::CreateTextFromNode(String &rText) } if (NULL != (pNode = GetSubNode(RSUB+1))) { - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); rText.Append('_'); pNode->CreateTextFromNode(rText); } if (NULL != (pNode = GetSubNode(RSUP+1))) { - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); rText.Append('^'); pNode->CreateTextFromNode(rText); } @@ -1677,7 +1678,7 @@ void SmBraceNode::CreateTextFromNode(String &rText) String aStr; GetSubNode(0)->CreateTextFromNode(aStr); aStr.EraseLeadingAndTrailingChars(); - aStr.EraseLeadingChars('\\'); + aStr = comphelper::string::stripStart(aStr, '\\'); if (aStr.Len()) { if (aStr.EqualsAscii("divides")) @@ -1700,7 +1701,7 @@ void SmBraceNode::CreateTextFromNode(String &rText) String aStr; GetSubNode(2)->CreateTextFromNode(aStr); aStr.EraseLeadingAndTrailingChars(); - aStr.EraseLeadingChars('\\'); + aStr = comphelper::string::stripStart(aStr, '\\'); if (aStr.Len()) { if (aStr.EqualsAscii("divides")) @@ -2521,7 +2522,7 @@ void SmMatrixNode::CreateTextFromNode(String &rText) if (i != nNumRows-1) APPEND(rText,"## "); } - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); APPEND(rText,"} "); } @@ -2817,7 +2818,7 @@ void SmAttributNode::CreateTextFromNode(String &rText) if (NULL != (pNode = GetSubNode(1))) pNode->CreateTextFromNode(rText); - rText.EraseTrailingChars(); + rText = comphelper::string::stripEnd(rText, ' '); if (nLast == 0xE082) APPEND(rText," overbrace {}"); diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 4d3ea9c6bd76..b72c0855b0a5 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1079,8 +1079,8 @@ Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const String& rLine) aSize.Width() = ((aSize.Width() / TabPos) + 1) * TabPos; aText = rLine.GetToken(i, '\t'); - aText.EraseLeadingChars('\t'); - aText.EraseTrailingChars('\t'); + aText = comphelper::string::stripStart(aText, '\t'); + aText = comphelper::string::stripEnd(aText, '\t'); aSize.Width() += rDevice.GetTextWidth(aText); } } @@ -1103,8 +1103,8 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const String& rText, long M { aLine = rText.GetToken(i, '\n'); aLine = comphelper::string::remove(aLine, '\r'); - aLine.EraseLeadingChars('\n'); - aLine.EraseTrailingChars('\n'); + aLine = comphelper::string::stripStart(aLine, '\n'); + aLine = comphelper::string::stripEnd(aLine, '\n'); aSize = GetTextLineSize(rDevice, aLine); @@ -1134,9 +1134,9 @@ Size SmViewShell::GetTextSize(OutputDevice& rDevice, const String& rText, long M TextSize.Height() += aSize.Height(); TextSize.Width() = Max(TextSize.Width(), Min(aSize.Width(), MaxWidth)); - aLine.EraseLeadingChars(' '); - aLine.EraseLeadingChars('\t'); - aLine.EraseLeadingChars(' '); + aLine = comphelper::string::stripStart(aLine, ' '); + aLine = comphelper::string::stripStart(aLine, '\t'); + aLine = comphelper::string::stripStart(aLine, ' '); } while (aLine.Len() > 0); } @@ -1169,8 +1169,8 @@ void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, co aPoint.X() = ((aPoint.X() / TabPos) + 1) * TabPos; aText = rLine.GetToken(i, '\t'); - aText.EraseLeadingChars('\t'); - aText.EraseTrailingChars('\t'); + aText = comphelper::string::stripStart(aText, '\t'); + aText = comphelper::string::stripEnd(aText, '\t'); rDevice.DrawText(aPoint, aText); aPoint.X() += rDevice.GetTextWidth(aText); } @@ -1194,8 +1194,8 @@ void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const { aLine = rText.GetToken(i, '\n'); aLine = comphelper::string::remove(aLine, '\r'); - aLine.EraseLeadingChars('\n'); - aLine.EraseTrailingChars('\n'); + aLine = comphelper::string::stripEnd(aLine, '\n'); + aLine = comphelper::string::stripEnd(aLine, '\n'); aSize = GetTextLineSize(rDevice, aLine); if (aSize.Width() > MaxWidth) { @@ -1222,9 +1222,9 @@ void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const DrawTextLine(rDevice, aPoint, aText); aPoint.Y() += aSize.Height(); - aLine.EraseLeadingChars(' '); - aLine.EraseLeadingChars('\t'); - aLine.EraseLeadingChars(' '); + aLine = comphelper::string::stripStart(aLine, ' '); + aLine = comphelper::string::stripStart(aLine, '\t'); + aLine = comphelper::string::stripStart(aLine, ' '); } while (GetTextLineSize(rDevice, aLine).Width() > MaxWidth); diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 6e7370ba06ae..c579e14601b8 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -63,6 +63,7 @@ #include <tools/urlobj.hxx> #include <tools/datetime.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <unotools/localfilehelper.hxx> #include <ucbhelper/content.hxx> #include <ucbhelper/commandenvironment.hxx> @@ -1686,7 +1687,7 @@ String SvtFileView::GetConfigString() const sRet += ';'; } - sRet.EraseTrailingChars( ';' ); + sRet = comphelper::string::stripEnd(sRet, ';'); return sRet; } diff --git a/svtools/source/control/fmtfield.cxx b/svtools/source/control/fmtfield.cxx index 188ef360f829..6e602e2bee42 100644 --- a/svtools/source/control/fmtfield.cxx +++ b/svtools/source/control/fmtfield.cxx @@ -32,6 +32,7 @@ #include <stdio.h> #include <tools/debug.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <unotools/localedatawrapper.hxx> #include <vcl/svapp.hxx> #include <svl/zformat.hxx> @@ -1348,8 +1349,8 @@ void DoubleCurrencyField::UpdateCurrencyFormat() if (getPrependCurrSym()) { XubString sSymbol = getCurrencySymbol(); - sSymbol.EraseLeadingChars(' '); - sSymbol.EraseTrailingChars(' '); + sSymbol = comphelper::string::stripStart(sSymbol, ' '); + sSymbol = comphelper::string::stripEnd(sSymbol, ' '); XubString sTemp = String::CreateFromAscii("[$"); sTemp += sSymbol; @@ -1370,8 +1371,8 @@ void DoubleCurrencyField::UpdateCurrencyFormat() else { XubString sTemp = getCurrencySymbol(); - sTemp.EraseLeadingChars(' '); - sTemp.EraseTrailingChars(' '); + sTemp = comphelper::string::stripStart(sTemp, ' '); + sTemp = comphelper::string::stripEnd(sTemp, ' '); sNewFormat += String::CreateFromAscii(" [$"); sNewFormat += sTemp; diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 097a8ada8658..6b99f8f54f69 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/ucb/XContentAccess.hpp> #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <vcl/toolbox.hxx> #include <osl/thread.hxx> #include <osl/mutex.hxx> @@ -1162,7 +1163,7 @@ String SvtURLBox::GetURL() #ifdef WNT // erase trailing spaces on Windows since thay are invalid on this OS and // most of the time they are inserted by accident via copy / paste - aText.EraseTrailingChars(); + aText = comphelper::string::stripEnd(aText, ' '); if ( !aText.Len() ) return aText; // #i9739# @@ -1327,7 +1328,7 @@ sal_Bool SvtURLBox_Impl::TildeParsing( else { // "blabla/" path should be converted to "blabla" - aParseTilde.EraseTrailingChars( '/' ); + aParseTilde = comphelper::string::stripEnd(aParseTilde, '/'); } } else diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx index 1d3b7ab9f1ab..5f73c5cb00cd 100644 --- a/svtools/source/misc/imap2.cxx +++ b/svtools/source/misc/imap2.cxx @@ -382,12 +382,12 @@ long ImageMap::ImpReadCERNRadius( const char** ppStr ) String ImageMap::ImpReadCERNURL( const char** ppStr, const String& rBaseURL ) { - String aStr( String::CreateFromAscii( *ppStr ) ); + rtl::OUString aStr(rtl::OUString::createFromAscii(*ppStr)); - aStr.EraseLeadingChars( ' ' ); - aStr.EraseLeadingChars( '\t' ); - aStr.EraseTrailingChars( ' ' ); - aStr.EraseTrailingChars( '\t' ); + aStr = comphelper::string::stripStart(aStr, ' '); + aStr = comphelper::string::stripStart(aStr, '\t'); + aStr = comphelper::string::stripEnd(aStr, ' '); + aStr = comphelper::string::stripEnd(aStr, '\t'); return INetURLObject::GetAbsURL( rBaseURL, aStr ); } diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx index 96cb4f154012..292d36f6a14f 100644 --- a/svtools/source/svhtml/htmlsupp.cxx +++ b/svtools/source/svhtml/htmlsupp.cxx @@ -31,11 +31,11 @@ #include <ctype.h> #include <stdio.h> -#include <tools/urlobj.hxx> - +#include <comphelper/string.hxx> #include <svtools/parhtml.hxx> #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> +#include <tools/urlobj.hxx> // Table for converting option values into strings static HTMLOptionEnum const aScriptLangOptEnums[] = @@ -135,7 +135,7 @@ void HTMLParser::RemoveSGMLComment( String &rString, sal_Bool bFull ) if( bFull ) { // "//" or "'", maybe preceding CR/LF - rString.EraseTrailingChars(); + rString = comphelper::string::stripEnd(rString, ' '); xub_StrLen nDel = 0, nLen = rString.Len(); if( nLen >= 2 && rString.Copy(nLen-2).CompareToAscii("//") == COMPARE_EQUAL ) diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index 7f234e8fd577..857395fa3f92 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -2523,8 +2523,8 @@ void SwHTMLParser::EndSelect() for( i = 0; i < nEntryCnt; i++ ) { - String sText( *pFormImpl->GetStringList()[i] ); - sText.EraseTrailingChars(); + rtl::OUString sText( *pFormImpl->GetStringList()[i] ); + sText = comphelper::string::stripEnd(sText, ' '); pStrings[i] = sText; sText = *pFormImpl->GetValueList()[i]; diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx index 7bb6210714a8..44563d0c3ca3 100644 --- a/sw/source/filter/rtf/rtffld.cxx +++ b/sw/source/filter/rtf/rtffld.cxx @@ -34,6 +34,7 @@ #include <sal/macros.h> #include <com/sun/star/i18n/ScriptType.hdl> +#include <comphelper/string.hxx> #include <vcl/graph.hxx> #include <svl/urihelper.hxx> #include <svtools/rtftoken.h> @@ -159,7 +160,7 @@ static RTF_FLD_TYPES _WhichFld( String& rName, String& rNext ) nFndPos += nTokenStt + static_cast< xub_StrLen >(nLen); while( rNext.GetChar( nFndPos ) == ' ' ) ++nFndPos; rNext.Erase( 0, nFndPos ); - rNext.EraseTrailingChars(); + rNext = comphelper::string::stripEnd(rNext, ' '); return aFldNmArr[n].eFldType; } } @@ -242,7 +243,7 @@ sal_Unicode RtfFieldSwitch::GetSwitch( String& rParam ) rParam = sParam.GetToken( 0, c ); sParam.Erase( 0, rParam.Len() + nOffset ).EraseLeadingChars(); if( '\\' == c ) - rParam.EraseTrailingChars(); + rParam = comphelper::string::stripEnd(rParam, ' '); nCurPos = 0; return cKey; diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 38236e6ccee8..b381ad08fba6 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -105,6 +105,7 @@ #include <svx/svdoutl.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <editeng/outlobj.hxx> #include <editeng/paperinf.hxx> @@ -1583,7 +1584,7 @@ sal_uInt16 SwRTFParser::ReadRevTbl() break; case RTF_TEXTTOKEN: - aToken.EraseTrailingChars(';'); + aToken = comphelper::string::stripEnd(aToken, ';'); sal_uInt16 nSWId = pDoc->InsertRedlineAuthor(aToken); // Store matchpair diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 789e57d8f92c..24b20062fb33 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -2087,9 +2087,9 @@ void PrintFontManager::initFontsAlias() // remove eventual quotes aAlias = comphelper::string::stripStart(aAlias, '"'); - aAlias.EraseTrailingChars( '"' ); + aAlias = comphelper::string::stripEnd(aAlias, '"'); aMap = comphelper::string::stripStart(aMap, '"'); - aMap.EraseTrailingChars( '"' ); + aMap = comphelper::string::stripEnd(aMap, '"'); XLFDEntry aAliasEntry, aMapEntry; parseXLFD( aAlias, aAliasEntry ); diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index e3b797005fce..724d46a9b054 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -606,13 +606,13 @@ String PPDParser::getPPDPrinterName( const String& rFile ) { aCurLine.Erase( 0, 9 ); aCurLine = comphelper::string::stripStart(aCurLine, ' '); - aCurLine.EraseTrailingChars( ' ' ); + aCurLine = comphelper::string::stripEnd(aCurLine, ' '); aCurLine = comphelper::string::stripStart(aCurLine, '\t'); - aCurLine.EraseTrailingChars( '\t' ); - aCurLine.EraseTrailingChars( '\r' ); - aCurLine.EraseTrailingChars( '\n' ); + aCurLine = comphelper::string::stripEnd(aCurLine, '\t'); + aCurLine = comphelper::string::stripEnd(aCurLine, '\r'); + aCurLine = comphelper::string::stripEnd(aCurLine, '\n'); aCurLine = comphelper::string::stripStart(aCurLine, '"'); - aCurLine.EraseTrailingChars( '"' ); + aCurLine = comphelper::string::stripEnd(aCurLine, '"'); aStream.Close(); aStream.Open( getPPDFile( aCurLine ) ); continue; @@ -705,13 +705,13 @@ PPDParser::PPDParser( const String& rFile ) : { aCurLine.Erase( 0, 9 ); aCurLine = comphelper::string::stripStart(aCurLine, ' '); - aCurLine.EraseTrailingChars( ' ' ); + aCurLine = comphelper::string::stripEnd(aCurLine, ' '); aCurLine = comphelper::string::stripStart(aCurLine, '\t'); - aCurLine.EraseTrailingChars( '\t' ); - aCurLine.EraseTrailingChars( '\r' ); - aCurLine.EraseTrailingChars( '\n' ); + aCurLine = comphelper::string::stripEnd(aCurLine, '\t'); + aCurLine = comphelper::string::stripEnd(aCurLine, '\r'); + aCurLine = comphelper::string::stripEnd(aCurLine, '\n'); aCurLine = comphelper::string::stripStart(aCurLine, '"'); - aCurLine.EraseTrailingChars( '"' ); + aCurLine = comphelper::string::stripEnd(aCurLine, '"'); aStream.Close(); aStream.Open( getPPDFile( String( aCurLine, m_aFileEncoding ) ) ); continue; |