diff options
-rw-r--r-- | comphelper/inc/comphelper/string.hxx | 21 | ||||
-rw-r--r-- | comphelper/qa/string/test_string.cxx | 22 | ||||
-rw-r--r-- | comphelper/source/misc/string.cxx | 31 | ||||
-rw-r--r-- | l10ntools/source/export.cxx | 6 | ||||
-rw-r--r-- | l10ntools/source/gsicheck.cxx | 2 | ||||
-rw-r--r-- | l10ntools/source/helpmerge.cxx | 4 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 106 | ||||
-rw-r--r-- | l10ntools/source/localize.cxx | 2 | ||||
-rw-r--r-- | l10ntools/source/xrmmerge.cxx | 4 | ||||
-rw-r--r-- | rsc/source/rsc/rsc.cxx | 4 | ||||
-rw-r--r-- | sc/Library_scd.mk | 1 | ||||
-rw-r--r-- | sc/source/ui/unoobj/scdetect.cxx | 3 | ||||
-rw-r--r-- | sfx2/inc/sfx2/newstyle.hxx | 8 | ||||
-rw-r--r-- | svtools/bmpmaker/bmpcore.cxx | 4 | ||||
-rw-r--r-- | svtools/source/misc/imap2.cxx | 8 | ||||
-rw-r--r-- | tools/bootstrp/prj.cxx | 2 | ||||
-rw-r--r-- | tools/inc/tools/urlobj.hxx | 93 | ||||
-rw-r--r-- | tools/source/inet/inetstrm.cxx | 7 | ||||
-rw-r--r-- | vcl/generic/fontmanager/fontmanager.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 13 |
20 files changed, 217 insertions, 131 deletions
diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx index 00a1664016cf..e6b2d721099d 100644 --- a/comphelper/inc/comphelper/string.hxx +++ b/comphelper/inc/comphelper/string.hxx @@ -220,6 +220,27 @@ COMPHELPER_DLLPUBLIC rtl::OString remove(const rtl::OString &rIn, COMPHELPER_DLLPUBLIC rtl::OUString remove(const rtl::OUString &rIn, sal_Unicode c); +/** 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 + + @return The resulting OString + */ +COMPHELPER_DLLPUBLIC rtl::OString stripStart(const rtl::OString &rIn, + sal_Char c); + +/** 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 + + @return The resulting OUString + */ +COMPHELPER_DLLPUBLIC rtl::OUString stripStart(const rtl::OUString &rIn, + sal_Unicode c); + + /** Returns a token in the OString @param token the number of the token to return diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx index 2ce6f2cff1bb..790519d07839 100644 --- a/comphelper/qa/string/test_string.cxx +++ b/comphelper/qa/string/test_string.cxx @@ -49,6 +49,7 @@ public: void testNatural(); void testReplace(); void testRemove(); + void testStripStart(); void testToken(); void testDecimalStringToNumber(); void testIsdigitAsciiString(); @@ -62,6 +63,7 @@ public: CPPUNIT_TEST(testNatural); CPPUNIT_TEST(testReplace); CPPUNIT_TEST(testRemove); + CPPUNIT_TEST(testStripStart); CPPUNIT_TEST(testToken); CPPUNIT_TEST(testDecimalStringToNumber); CPPUNIT_TEST(testIsdigitAsciiString); @@ -430,6 +432,26 @@ void TestString::testRemove() CPPUNIT_ASSERT(aOut.isEmpty()); } +void TestString::testStripStart() +{ + ::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc")); + ::rtl::OString aOut; + + aOut = ::comphelper::string::stripStart(aIn, 'b'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc"))); + + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("bc"))); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa")); + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.isEmpty()); + + aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba")); + aOut = ::comphelper::string::stripStart(aIn, 'a'); + CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ba"))); +} + 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 8525e79bd4fc..09fb2684e7ce 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -169,6 +169,37 @@ rtl::OUString remove(const rtl::OUString &rIn, sal_Unicode c) return tmpl_remove<rtl::OUString, sal_Unicode, rtl::OUStringBuffer>(rIn, c); } +namespace +{ + template <typename T, typename C> T tmpl_stripStart(const T &rIn, + const C cRemove) + { + if (rIn.isEmpty()) + return rIn; + + sal_Int32 i = 0; + + while (i < rIn.getLength()) + { + if (rIn[i] != cRemove) + break; + ++i; + } + + return rIn.copy(i); + } +} + +rtl::OString stripStart(const rtl::OString &rIn, sal_Char c) +{ + return tmpl_stripStart<rtl::OString, sal_Char>(rIn, c); +} + +rtl::OUString stripStart(const rtl::OUString &rIn, sal_Unicode c) +{ + return tmpl_stripStart<rtl::OUString, sal_Unicode>(rIn, c); +} + sal_uInt32 decimalStringToNumber( ::rtl::OUString const & str ) { diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 7ad52f670b9b..2234125a420f 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -1281,7 +1281,7 @@ ByteString Export::GetPairedListID( const ByteString& sText ){ sIdent.ToUpperAscii(); while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; sIdent.EraseTrailingChars( ' ' ); - sIdent.EraseLeadingChars( ' ' ); + sIdent = comphelper::string::stripStart(sIdent, ' '); return sIdent; } ByteString Export::GetPairedListString( const ByteString& sText ){ @@ -1292,7 +1292,7 @@ ByteString Export::GetPairedListString( const ByteString& sText ){ ByteString s1 = sString.Copy( sString.Search( '\"' )+1 ); sString = s1.Copy( 0 , s1.SearchBackward( '\"' ) ); sString.EraseTrailingChars( ' ' ); - sString.EraseLeadingChars( ' ' ); + sString = comphelper::string::stripStart(sString, ' '); return sString; } ByteString Export::StripList( const ByteString& sText ){ @@ -1547,7 +1547,7 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) STRING_NOTFOUND ) {}; while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {}; - sToken.EraseLeadingChars( ' ' ); + sToken = comphelper::string::stripStart(sToken, ' '); sToken.EraseTrailingChars( ' ' ); if ( sToken.Len()) { sReturn += "\\\" "; diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx index 9f1485b6d1c1..036edafb0601 100644 --- a/l10ntools/source/gsicheck.cxx +++ b/l10ntools/source/gsicheck.cxx @@ -394,7 +394,7 @@ void GSIBlock::PrintList( ParserMessageList *pList, ByteString aPrefix, else aContext = pLine->Copy( pMsg->GetTagBegin()-150, 300 ); aContext.EraseTrailingChars(' '); - aContext.EraseLeadingChars(' '); + aContext = comphelper::string::stripStart(aContext, ' '); } PrintMessage( pMsg->Prefix(), pMsg->GetErrorText(), aPrefix, aContext, pLine->GetLineNumber(), pLine->GetUniqId() ); diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index 214105c25c79..efa5c0cef529 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -512,8 +512,8 @@ ByteString HelpParser::GetOutpath( const ByteString& rPathX , const ByteString& testpath += sCur; testpath += sDelimiter; ByteString sRelativePath( rPathY ); - sRelativePath.EraseLeadingChars( '/' ); - sRelativePath.EraseLeadingChars( '\\' ); + sRelativePath = comphelper::string::stripStart(sRelativePath, '/'); + sRelativePath = comphelper::string::stripStart(sRelativePath, '\\'); testpath += sRelativePath; testpath += sDelimiter; return testpath; diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 7592d4979160..57216afc6f74 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -142,54 +142,59 @@ sal_Bool LngParser::CreateSDF( return true; } - void LngParser::WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_inout , - const ByteString &rPrj , const ByteString &rRoot , - const ByteString &sActFileName , const ByteString &sID ) - { - - sal_Bool bExport = true; - if ( bExport ) { - ByteString sTimeStamp( Export::GetTimeStamp()); - ByteString sCur; - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ - sCur = aLanguages[ n ]; - ByteString sAct = rText_inout[ sCur ]; - if ( !sAct.Len() && sCur.Len() ) - sAct = rText_inout[ ByteString("en-US") ]; - - ByteString sOutput( rPrj ); sOutput += "\t"; - if ( rRoot.Len()) - sOutput += sActFileName; - sOutput += "\t0\t"; - sOutput += "LngText\t"; - sOutput += sID; sOutput += "\t\t\t\t0\t"; - sOutput += sCur; sOutput += "\t"; - sOutput += sAct; sOutput += "\t\t\t\t"; - sOutput += sTimeStamp; - aSDFStream.WriteLine( sOutput ); - } - } - } - bool LngParser::isNextGroup( ByteString &sGroup_out , ByteString &sLine_in ){ - sLine_in.EraseLeadingChars( ' ' ); +void LngParser::WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_inout , + const ByteString &rPrj , const ByteString &rRoot , + const ByteString &sActFileName , const ByteString &sID ) +{ + + sal_Bool bExport = true; + if ( bExport ) { + ByteString sTimeStamp( Export::GetTimeStamp()); + ByteString sCur; + for( unsigned int n = 0; n < aLanguages.size(); n++ ){ + sCur = aLanguages[ n ]; + ByteString sAct = rText_inout[ sCur ]; + if ( !sAct.Len() && sCur.Len() ) + sAct = rText_inout[ ByteString("en-US") ]; + + ByteString sOutput( rPrj ); sOutput += "\t"; + if ( rRoot.Len()) + sOutput += sActFileName; + sOutput += "\t0\t"; + sOutput += "LngText\t"; + sOutput += sID; sOutput += "\t\t\t\t0\t"; + sOutput += sCur; sOutput += "\t"; + sOutput += sAct; sOutput += "\t\t\t\t"; + sOutput += sTimeStamp; + aSDFStream.WriteLine( sOutput ); + } + } +} + +bool LngParser::isNextGroup( ByteString &sGroup_out , ByteString &sLine_in ) +{ + sLine_in = comphelper::string::stripStart(sLine_in, ' '); sLine_in.EraseTrailingChars( ' ' ); if (( sLine_in.GetChar( 0 ) == '[' ) && - ( sLine_in.GetChar( sLine_in.Len() - 1 ) == ']' )){ + ( sLine_in.GetChar( sLine_in.Len() - 1 ) == ']' )) + { sGroup_out = getToken(getToken(sLine_in, 1, '['), 0, ']'); - sGroup_out.EraseLeadingChars( ' ' ); + sGroup_out = comphelper::string::stripStart(sGroup_out, ' '); sGroup_out.EraseTrailingChars( ' ' ); return true; } return false; - } - void LngParser::ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout){ - ByteString sLang = getToken(sLine_in, 0, '='); - sLang.EraseLeadingChars( ' ' ); - sLang.EraseTrailingChars( ' ' ); - ByteString sText = getToken(getToken(sLine_in, 1, '\"'), 0, '\"'); - if( sLang.Len() ) - rText_inout[ sLang ] = sText; - } +} + +void LngParser::ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout) +{ + rtl::OString sLang = getToken(sLine_in, 0, '='); + sLang = comphelper::string::stripStart(sLang, ' '); + sLang = comphelper::string::stripStart(sLang, ' '); + rtl::OString sText = getToken(getToken(sLine_in, 1, '\"'), 0, '\"'); + if (!sLang.isEmpty()) + rText_inout[ sLang ] = sText; +} /*****************************************************************************/ sal_Bool LngParser::Merge( @@ -217,15 +222,16 @@ sal_Bool LngParser::Merge( ByteString sGroup; // seek to next group - while ( nPos < pLines->size() && !bGroup ) { + while ( nPos < pLines->size() && !bGroup ) + { ByteString sLine( *(*pLines)[ nPos ] ); - sLine.EraseLeadingChars( ' ' ); + sLine = comphelper::string::stripStart(sLine, ' '); sLine.EraseTrailingChars( ' ' ); if (( sLine.GetChar( 0 ) == '[' ) && ( sLine.GetChar( sLine.Len() - 1 ) == ']' )) { sGroup = getToken(getToken(sLine, 1, '['), 0, ']'); - sGroup.EraseLeadingChars( ' ' ); + sGroup = comphelper::string::stripStart(sGroup, ' '); sGroup.EraseTrailingChars( ' ' ); bGroup = sal_True; } @@ -245,23 +251,25 @@ sal_Bool LngParser::Merge( ByteString sLanguagesDone; - while ( nPos < pLines->size() && !bGroup ) { + while ( nPos < pLines->size() && !bGroup ) + { ByteString sLine( *(*pLines)[ nPos ] ); - sLine.EraseLeadingChars( ' ' ); + sLine = comphelper::string::stripStart(sLine, ' '); sLine.EraseTrailingChars( ' ' ); if (( sLine.GetChar( 0 ) == '[' ) && ( sLine.GetChar( sLine.Len() - 1 ) == ']' )) { sGroup = getToken(getToken(sLine, 1, '['), 0, ']'); - sGroup.EraseLeadingChars( ' ' ); + sGroup = comphelper::string::stripStart(sGroup, ' '); sGroup.EraseTrailingChars( ' ' ); bGroup = sal_True; nPos ++; sLanguagesDone = ""; } - else if ( sLine.GetTokenCount( '=' ) > 1 ) { + else if ( sLine.GetTokenCount( '=' ) > 1 ) + { ByteString sLang = getToken(sLine, 0, '='); - sLang.EraseLeadingChars( ' ' ); + sLang = comphelper::string::stripStart(sLang, ' '); sLang.EraseTrailingChars( ' ' ); ByteString sSearch( ";" ); diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 609e344a9ade..4bbdf2eadf5c 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -279,7 +279,7 @@ const ByteString SourceTreeLocalizer::GetProjectRootRel() DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US ); sCur.SearchAndReplaceAll( sDelimiter, "/" ); - sCur.EraseLeadingChars( '/' ); + sCur = comphelper::string::stripStart(sCur, '/'); sal_uLong nCount = sCur.GetTokenCount( '/' ); ByteString sProjectRootRel; diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index 166d35598cfe..0d49e84e1545 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -440,8 +440,8 @@ void XRMResParser::ConvertStringToDBFormat( ByteString &rString ) ByteString sResult; do { sResult = rString; - rString.EraseLeadingChars( _LF ); - rString.EraseLeadingChars( '\t' ); + rString = comphelper::string::stripStart(rString, _LF); + rString = comphelper::string::stripStart(rString, '\t'); rString.EraseTrailingChars( '\t' ); } while ( sResult != rString ); diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index b9969de123fa..1a1a5e3a5c61 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -1196,8 +1196,8 @@ void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile, if( !aIStm.ReadLine( aLine ) ) break; - aLine.EraseLeadingChars( ' ' ); - aLine.EraseLeadingChars( '\t' ); + aLine = comphelper::string::stripStart(aLine, ' '); + aLine = comphelper::string::stripStart(aLine, '\t'); aLine = comphelper::string::remove(aLine, ';'); if (comphelper::string::isdigitAsciiString(aLine)) diff --git a/sc/Library_scd.mk b/sc/Library_scd.mk index cc879c845a3a..cff297576fa0 100644 --- a/sc/Library_scd.mk +++ b/sc/Library_scd.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Library_add_api,scd,\ )) $(eval $(call gb_Library_add_linked_libs,scd,\ + comphelper \ cppu \ cppuhelper \ sal \ diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 59ba7f1fe304..1132a767157d 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/io/XInputStream.hpp> @@ -729,7 +730,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) } else if ( bIsXLS && bMaybeText ) { - aHeader.EraseLeadingChars(); + aHeader = comphelper::string::stripStart(aHeader, ' '); if( aHeader.CompareTo( "<?xml", 5 ) == COMPARE_EQUAL ) pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilter2003XML) ); else diff --git a/sfx2/inc/sfx2/newstyle.hxx b/sfx2/inc/sfx2/newstyle.hxx index 22f47eec8974..32f30d9a56c6 100644 --- a/sfx2/inc/sfx2/newstyle.hxx +++ b/sfx2/inc/sfx2/newstyle.hxx @@ -28,9 +28,9 @@ #ifndef _NEWSTYLE_HXX #define _NEWSTYLE_HXX -#include "sal/config.h" -#include "sfx2/dllapi.h" - +#include <comphelper/string.hxx> +#include <sal/config.h> +#include <sfx2/dllapi.h> #include <vcl/button.hxx> #include <vcl/msgbox.hxx> #include <vcl/combobox.hxx> @@ -57,7 +57,7 @@ public: SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& ); ~SfxNewStyleDlg(); - String GetName() const { return aColBox.GetText().EraseLeadingChars(); } + String GetName() const { return comphelper::string::stripStart(aColBox.GetText(), ' '); } }; #endif diff --git a/svtools/bmpmaker/bmpcore.cxx b/svtools/bmpmaker/bmpcore.cxx index d1e0964210d9..159d6e4701c1 100644 --- a/svtools/bmpmaker/bmpcore.cxx +++ b/svtools/bmpmaker/bmpcore.cxx @@ -130,8 +130,8 @@ void BmpCreator::ImplCreate( const ::std::vector< DirEntry >& rInDirs, if( !pSRS->ReadLine( aLine ) ) break; - aLine.EraseLeadingChars( ' ' ); - aLine.EraseLeadingChars( '\t' ); + aLine = comphelper::string::stripStart(aLine, ' '); + aLine = comphelper::string::stripStart(aLine, '\t'); aLine = comphelper::string::remove(aLine, ';'); if (comphelper::string::isdigitAsciiString(aLine)) diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx index 5b1d23d8cc53..1d3b7ab9f1ab 100644 --- a/svtools/source/misc/imap2.cxx +++ b/svtools/source/misc/imap2.cxx @@ -265,8 +265,8 @@ void ImageMap::ImpReadCERNLine( const rtl::OString& rLine, const String& rBaseUR { ByteString aStr( rLine ); - aStr.EraseLeadingChars( ' ' ); - aStr.EraseLeadingChars( '\t' ); + aStr = comphelper::string::stripStart(aStr, ' '); + aStr = comphelper::string::stripStart(aStr, '\t'); aStr = comphelper::string::remove(aStr, ';'); aStr.ToLowerAscii(); @@ -408,8 +408,8 @@ void ImageMap::ImpReadNCSALine( const rtl::OString& rLine, const String& rBaseUR { ByteString aStr( rLine ); - aStr.EraseLeadingChars( ' ' ); - aStr.EraseLeadingChars( '\t' ); + aStr = comphelper::string::stripStart(aStr, ' '); + aStr = comphelper::string::stripStart(aStr, '\t'); aStr = comphelper::string::remove(aStr, ';'); aStr.ToLowerAscii(); diff --git a/tools/bootstrp/prj.cxx b/tools/bootstrp/prj.cxx index d6432e9f3f79..a3caf2328080 100644 --- a/tools/bootstrp/prj.cxx +++ b/tools/bootstrp/prj.cxx @@ -72,7 +72,7 @@ rtl::OString SimpleConfig::getNext() #pragma warning (pop) #endif - aStringBuffer.EraseLeadingChars( '\t' ); + aStringBuffer = comphelper::string::stripStart(aStringBuffer, '\t'); return aString; } diff --git a/tools/inc/tools/urlobj.hxx b/tools/inc/tools/urlobj.hxx index 08211e944162..bc792fb5c796 100644 --- a/tools/inc/tools/urlobj.hxx +++ b/tools/inc/tools/urlobj.hxx @@ -157,8 +157,8 @@ public: /** The way input strings that represent (parts of) URIs are interpreted in set-methods. - @descr Most set-methods accept either a ByteString or a rtl::OUString - as input. Using a ByteString, octets in the range 0x80--0xFF are + @descr Most set-methods accept either a rtl::OString or a rtl::OUString + as input. Using a rtl::OString, octets in the range 0x80--0xFF are replaced by single escape sequences. Using a rtl::OUString , UTF-32 characters in the range 0x80--0x10FFFF are replaced by sequences of escape sequences, representing the UTF-8 coded characters. @@ -271,7 +271,7 @@ public: //======================================================================== // Strict Parsing: - inline INetURLObject(ByteString const & rTheAbsURIRef, + inline INetURLObject(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -279,7 +279,7 @@ public: EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); - inline bool SetURL(ByteString const & rTheAbsURIRef, + inline bool SetURL(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -404,7 +404,7 @@ public: { m_eSmartScheme = eTheSmartScheme; } inline bool - SetSmartURL(ByteString const & rTheAbsURIRef, + SetSmartURL(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, FSysStyle eStyle = FSYS_DETECT); @@ -416,7 +416,7 @@ public: FSysStyle eStyle = FSYS_DETECT); inline INetURLObject - smartRel2Abs(ByteString const & rTheRelURIRef, + smartRel2Abs(const rtl::OString& rTheRelURIRef, bool & rWasAbsolute, bool bIgnoreFragment = false, EncodeMechanism eMechanism = WAS_ENCODED, @@ -437,7 +437,7 @@ public: // Relative URLs: inline bool - GetNewAbsURL(ByteString const & rTheRelURIRef, + GetNewAbsURL(const rtl::OString& rTheRelURIRef, INetURLObject * pTheAbsURIRef, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, @@ -469,8 +469,8 @@ public: FSysStyle eStyle = FSYS_DETECT); static inline rtl::OUString - GetRelURL(ByteString const & rTheBaseURIRef, - ByteString const & rTheAbsURIRef, + GetRelURL(const rtl::OString& rTheBaseURIRef, + const rtl::OString& rTheAbsURIRef, EncodeMechanism eEncodeMechanism = WAS_ENCODED, DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, @@ -491,7 +491,7 @@ public: rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) const; - static inline bool translateToExternal(ByteString const & rTheIntURIRef, + static inline bool translateToExternal(const rtl::OString& rTheIntURIRef, rtl::OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, @@ -505,7 +505,7 @@ public: rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); - static inline bool translateToInternal(ByteString const & rTheExtURIRef, + static inline bool translateToInternal(const rtl::OString& rTheExtURIRef, rtl::OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, @@ -534,7 +534,7 @@ public: */ static rtl::OUString GetScheme(INetProtocol eTheScheme); - static inline INetProtocol CompareProtocolScheme(ByteString const & + static inline INetProtocol CompareProtocolScheme(const rtl::OString& rTheAbsURIRef) { return CompareProtocolScheme(extend(rTheAbsURIRef)); } @@ -559,7 +559,7 @@ public: = RTL_TEXTENCODING_UTF8) const { return decode(m_aAuth, getEscapePrefix(), eMechanism, eCharset); } - inline bool SetUser(ByteString const & rTheUser, + inline bool SetUser(const rtl::OString& rTheUser, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) { return setUser(extend(rTheUser), true, eMechanism, eCharset); } @@ -569,7 +569,7 @@ public: rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) { return setUser(rTheUser, false, eMechanism, eCharset); } - inline bool SetPass(ByteString const & rThePassword, + inline bool SetPass(const rtl::OString& rThePassword, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -577,8 +577,8 @@ public: EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); - inline bool SetUserAndPass(ByteString const & rTheUser, - ByteString const & rThePassword, + inline bool SetUserAndPass(const rtl::OString& rTheUser, + const rtl:OString& rThePassword, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -604,7 +604,7 @@ public: sal_uInt32 GetPort() const; - inline bool SetHost(ByteString const & rTheHost, + inline bool SetHost(const rtl::OString& rTheHost, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) { return setHost(extend(rTheHost), true, eMechanism, eCharset); } @@ -626,7 +626,7 @@ public: = RTL_TEXTENCODING_UTF8) const { return decode(m_aPath, getEscapePrefix(), eMechanism, eCharset); } - inline bool SetURLPath(ByteString const & rThePath, + inline bool SetURLPath(const rtl::OString& rThePath, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) { return setPath(extend(rThePath), true, eMechanism, eCharset); } @@ -933,7 +933,7 @@ public: = RTL_TEXTENCODING_UTF8) const { return decode(m_aQuery, getEscapePrefix(), eMechanism, eCharset); } - inline bool SetParam(ByteString const & rTheQuery, + inline bool SetParam(const rtl::OString& rTheQuery, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -951,7 +951,7 @@ public: = RTL_TEXTENCODING_UTF8) const { return decode(m_aFragment, getEscapePrefix(), eMechanism, eCharset); } - inline bool SetMark(ByteString const & rTheFragment, + inline bool SetMark(const rtl::OString& rTheFragment, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); @@ -1073,7 +1073,7 @@ public: @return The encoded representation of the text ('forbidden' characters replaced by escape sequences). */ - static inline rtl::OUString encode(ByteString const & rText, Part ePart, + static inline rtl::OUString encode(const rtl::OString& rText, Part ePart, sal_Char cEscapePrefix, EncodeMechanism eMechanism, rtl_TextEncoding eCharset @@ -1190,7 +1190,7 @@ public: rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) const; - inline bool Append(ByteString const & rTheSegment, + inline bool Append(const rtl::OString& rTheSegment, EncodeMechanism eMechanism = WAS_ENCODED, rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) { return appendSegment(extend(rTheSegment), true, eMechanism, eCharset); } @@ -1426,7 +1426,7 @@ private: // Coding: - static inline rtl::OUString extend(ByteString const & rOctets) + static inline rtl::OUString extend(const rtl::OString& rOctets) { return rtl::OUString(rOctets.GetBuffer(), rOctets.Len(), RTL_TEXTENCODING_ISO_8859_1); @@ -1495,7 +1495,7 @@ inline rtl::OUString INetURLObject::decode(SubString const & rSubString, rtl::OUString(); } -inline INetURLObject::INetURLObject(ByteString const & rTheAbsURIRef, +inline INetURLObject::INetURLObject(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism, rtl_TextEncoding eCharset): m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) @@ -1513,7 +1513,7 @@ inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef, FSysStyle(0)); } -inline bool INetURLObject::SetURL(ByteString const & rTheAbsURIRef, +inline bool INetURLObject::SetURL(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { @@ -1539,7 +1539,7 @@ inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef, setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, eStyle); } -inline bool INetURLObject::SetSmartURL(ByteString const & rTheAbsURIRef, +inline bool INetURLObject::SetSmartURL(const rtl::OString& rTheAbsURIRef, EncodeMechanism eMechanism, rtl_TextEncoding eCharset, FSysStyle eStyle) @@ -1558,7 +1558,7 @@ inline bool INetURLObject::SetSmartURL(rtl::OUString const & rTheAbsURIRef, } inline INetURLObject -INetURLObject::smartRel2Abs(ByteString const & rTheRelURIRef, +INetURLObject::smartRel2Abs(const rtl::OString& rTheRelURIRef, bool & rWasAbsolute, bool bIgnoreFragment, EncodeMechanism eMechanism, @@ -1589,7 +1589,7 @@ INetURLObject::smartRel2Abs(rtl::OUString const & rTheRelURIRef, return aTheAbsURIRef; } -inline bool INetURLObject::GetNewAbsURL(ByteString const & rTheRelURIRef, +inline bool INetURLObject::GetNewAbsURL(const rtl::OString& rTheRelURIRef, INetURLObject * pTheAbsURIRef, EncodeMechanism eMechanism, rtl_TextEncoding eCharset, @@ -1626,8 +1626,8 @@ inline bool INetURLObject::GetNewAbsURL(rtl::OUString const & rTheRelURIRef, } // static -inline rtl::OUString INetURLObject::GetRelURL(ByteString const & rTheBaseURIRef, - ByteString const & rTheAbsURIRef, +inline rtl::OUString INetURLObject::GetRelURL(const rtl::OString& rTheBaseURIRef, + const rtl::OString& rTheAbsURIRef, EncodeMechanism eEncodeMechanism, DecodeMechanism eDecodeMechanism, rtl_TextEncoding eCharset, @@ -1656,8 +1656,7 @@ inline rtl::OUString INetURLObject::GetRelURL(rtl::OUString const & rTheBaseURIR } // static -inline bool INetURLObject::translateToExternal(ByteString const & - rTheIntURIRef, +inline bool INetURLObject::translateToExternal(const rtl::OString& rTheIntURIRef, rtl::OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism, @@ -1683,7 +1682,7 @@ inline bool INetURLObject::translateToExternal(rtl::OUString const & } // static -inline bool INetURLObject::translateToInternal(ByteString const & +inline bool INetURLObject::translateToInternal(const rtl::OString& rTheExtURIRef, rtl::OUString & rTheIntURIRef, DecodeMechanism @@ -1709,11 +1708,11 @@ inline bool INetURLObject::translateToInternal(rtl::OUString const & eDecodeMechanism, eCharset); } -inline bool INetURLObject::SetPass(ByteString const & rThePassword, +inline bool INetURLObject::SetPass(const rtl::OString& rThePassword, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rThePassword.Len() == 0 ? + return rThePassword.isEmpty() ? clearPassword() : setPassword(extend(rThePassword), true, eMechanism, eCharset); } @@ -1722,18 +1721,18 @@ inline bool INetURLObject::SetPass(rtl::OUString const & rThePassword, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rThePassword.getLength() == 0 ? + return rThePassword.isEmpty() ? clearPassword() : setPassword(rThePassword, false, eMechanism, eCharset); } -inline bool INetURLObject::SetUserAndPass(ByteString const & rTheUser, - ByteString const & rThePassword, +inline bool INetURLObject::SetUserAndPass(const rtl::OString& rTheUser, + const rtl::OString& rThePassword, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { return setUser(extend(rTheUser), true, eMechanism, eCharset) - && (rThePassword.Len() == 0 ? + && (rThePassword.isEmpty() ? clearPassword() : setPassword(extend(rThePassword), true, eMechanism, eCharset)); @@ -1745,7 +1744,7 @@ inline bool INetURLObject::SetUserAndPass(rtl::OUString const & rTheUser, rtl_TextEncoding eCharset) { return setUser(rTheUser, false, eMechanism, eCharset) - && (rThePassword.getLength() == 0 ? + && (rThePassword.isEmpty() ? clearPassword() : setPassword(rThePassword, false, eMechanism, eCharset)); } @@ -1761,11 +1760,11 @@ inline bool INetURLObject::insertName(rtl::OUString const & rTheName, bIgnoreFinalSlash, eMechanism, eCharset); } -inline bool INetURLObject::SetParam(ByteString const & rTheQuery, +inline bool INetURLObject::SetParam(const rtl::OString& rTheQuery, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rTheQuery.Len() == 0 ? + return rTheQuery.isEmpty() ? clearQuery() : setQuery(extend(rTheQuery), true, eMechanism, eCharset); } @@ -1774,16 +1773,16 @@ inline bool INetURLObject::SetParam(rtl::OUString const & rTheQuery, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rTheQuery.getLength() == 0 ? + return rTheQuery.isEmpty() ? clearQuery() : setQuery(rTheQuery, false, eMechanism, eCharset); } -inline bool INetURLObject::SetMark(ByteString const & rTheFragment, +inline bool INetURLObject::SetMark(const rtl::OString& rTheFragment, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rTheFragment.Len() == 0 ? + return rTheFragment.isEmpty() ? clearFragment() : setFragment(extend(rTheFragment), true, eMechanism, eCharset); } @@ -1792,7 +1791,7 @@ inline bool INetURLObject::SetMark(rtl::OUString const & rTheFragment, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) { - return rTheFragment.getLength() == 0 ? + return rTheFragment.isEmpty() ? clearFragment() : setFragment(rTheFragment, false, eMechanism, eCharset); } @@ -1805,7 +1804,7 @@ inline INetURLObject::INetURLObject(rtl::OUString const & rFSysPath, } // static -inline rtl::OUString INetURLObject::encode(ByteString const & rText, Part ePart, +inline rtl::OUString INetURLObject::encode(const rtl::OString& rText, Part ePart, sal_Char cEscapePrefix, EncodeMechanism eMechanism, rtl_TextEncoding eCharset) diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index 6fc8df2d2ed8..a11f22d4712c 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_tools.hxx" +#include <comphelper/string.hxx> #include <sal/types.h> #include <rtl/memory.h> #include <rtl/strbuf.hxx> @@ -510,7 +511,7 @@ int INetMessageOStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) aField.Copy (0, nPos)); ByteString aValue ( aField.Copy (nPos + 1, aField.Len() - nPos + 1)); - aValue.EraseLeadingChars (' '); + aValue = comphelper::string::stripStart(aValue, ' '); pTargetMsg->SetHeaderField ( INetMessageHeader (aName, aValue)); @@ -1298,8 +1299,8 @@ INetMIMEMessageStream::GetMsgEncoding (const String& rContentType) if (rContentType.GetTokenCount ('=') > 1) { String aCharset (rContentType.GetToken (1, '=')); - aCharset.EraseLeadingChars (' '); - aCharset.EraseLeadingChars ('"'); + aCharset = comphelper::string::stripStart(aCharset, ' '); + aCharset = comphelper::string::stripStart(aCharset, '"'); if (aCharset.CompareIgnoreCaseToAscii ("us-ascii", 8) == 0) return INETMSG_ENCODING_7BIT; diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 3d95034160e8..789e57d8f92c 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -83,7 +83,8 @@ #include <valgrind/callgrind.h> #endif -#include "comphelper/processfactory.hxx" +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> #include "com/sun/star/beans/XMaterialHolder.hpp" #include "com/sun/star/beans/NamedValue.hpp" @@ -2085,9 +2086,9 @@ void PrintFontManager::initFontsAlias() ByteString aMap = GetCommandLineToken( 1, aLine ); // remove eventual quotes - aAlias.EraseLeadingChars( '"' ); + aAlias = comphelper::string::stripStart(aAlias, '"'); aAlias.EraseTrailingChars( '"' ); - aMap.EraseLeadingChars( '"' ); + aMap = comphelper::string::stripStart(aMap, '"'); aMap.EraseTrailingChars( '"' ); XLFDEntry aAliasEntry, aMapEntry; diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 7eec1f74d24d..e3b797005fce 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -34,6 +34,7 @@ #include <boost/unordered_map.hpp> +#include <comphelper/string.hxx> #include "vcl/ppdparser.hxx" #include "vcl/strhelper.hxx" #include "vcl/helper.hxx" @@ -604,13 +605,13 @@ String PPDParser::getPPDPrinterName( const String& rFile ) if( aCurLine.CompareIgnoreCaseToAscii( "*include:", 9 ) == COMPARE_EQUAL ) { aCurLine.Erase( 0, 9 ); - aCurLine.EraseLeadingChars( ' ' ); + aCurLine = comphelper::string::stripStart(aCurLine, ' '); aCurLine.EraseTrailingChars( ' ' ); - aCurLine.EraseLeadingChars( '\t' ); + aCurLine = comphelper::string::stripStart(aCurLine, '\t'); aCurLine.EraseTrailingChars( '\t' ); aCurLine.EraseTrailingChars( '\r' ); aCurLine.EraseTrailingChars( '\n' ); - aCurLine.EraseLeadingChars( '"' ); + aCurLine = comphelper::string::stripStart(aCurLine, '"'); aCurLine.EraseTrailingChars( '"' ); aStream.Close(); aStream.Open( getPPDFile( aCurLine ) ); @@ -703,13 +704,13 @@ PPDParser::PPDParser( const String& rFile ) : if( aCurLine.CompareIgnoreCaseToAscii( "*include:", 9 ) == COMPARE_EQUAL ) { aCurLine.Erase( 0, 9 ); - aCurLine.EraseLeadingChars( ' ' ); + aCurLine = comphelper::string::stripStart(aCurLine, ' '); aCurLine.EraseTrailingChars( ' ' ); - aCurLine.EraseLeadingChars( '\t' ); + aCurLine = comphelper::string::stripStart(aCurLine, '\t'); aCurLine.EraseTrailingChars( '\t' ); aCurLine.EraseTrailingChars( '\r' ); aCurLine.EraseTrailingChars( '\n' ); - aCurLine.EraseLeadingChars( '"' ); + aCurLine = comphelper::string::stripStart(aCurLine, '"'); aCurLine.EraseTrailingChars( '"' ); aStream.Close(); aStream.Open( getPPDFile( String( aCurLine, m_aFileEncoding ) ) ); |