add string::strip, can replace EraseLeadingAndTrailingChars
This commit is contained in:
@@ -260,6 +260,26 @@ COMPHELPER_DLLPUBLIC rtl::OString stripEnd(const rtl::OString &rIn,
|
|||||||
COMPHELPER_DLLPUBLIC rtl::OUString stripEnd(const rtl::OUString &rIn,
|
COMPHELPER_DLLPUBLIC rtl::OUString stripEnd(const rtl::OUString &rIn,
|
||||||
sal_Unicode c);
|
sal_Unicode c);
|
||||||
|
|
||||||
|
/** Strips occurrences of a character from the start and end of the source string
|
||||||
|
|
||||||
|
@param rIn The input OString
|
||||||
|
@param c The character to be stripped from the start and end
|
||||||
|
|
||||||
|
@return The resulting OString
|
||||||
|
*/
|
||||||
|
COMPHELPER_DLLPUBLIC rtl::OString strip(const rtl::OString &rIn,
|
||||||
|
sal_Char c);
|
||||||
|
|
||||||
|
/** Strips occurrences of a character from the start and end of the source string
|
||||||
|
|
||||||
|
@param rIn The input OUString
|
||||||
|
@param c The character to be stripped from the start and end
|
||||||
|
|
||||||
|
@return The resulting OUString
|
||||||
|
*/
|
||||||
|
COMPHELPER_DLLPUBLIC rtl::OUString strip(const rtl::OUString &rIn,
|
||||||
|
sal_Unicode c);
|
||||||
|
|
||||||
/** Returns a token in the OString
|
/** Returns a token in the OString
|
||||||
|
|
||||||
@param token the number of the token to return
|
@param token the number of the token to return
|
||||||
|
@@ -51,6 +51,7 @@ public:
|
|||||||
void testRemove();
|
void testRemove();
|
||||||
void testStripStart();
|
void testStripStart();
|
||||||
void testStripEnd();
|
void testStripEnd();
|
||||||
|
void testStrip();
|
||||||
void testToken();
|
void testToken();
|
||||||
void testDecimalStringToNumber();
|
void testDecimalStringToNumber();
|
||||||
void testIsdigitAsciiString();
|
void testIsdigitAsciiString();
|
||||||
@@ -66,6 +67,7 @@ public:
|
|||||||
CPPUNIT_TEST(testRemove);
|
CPPUNIT_TEST(testRemove);
|
||||||
CPPUNIT_TEST(testStripStart);
|
CPPUNIT_TEST(testStripStart);
|
||||||
CPPUNIT_TEST(testStripEnd);
|
CPPUNIT_TEST(testStripEnd);
|
||||||
|
CPPUNIT_TEST(testStrip);
|
||||||
CPPUNIT_TEST(testToken);
|
CPPUNIT_TEST(testToken);
|
||||||
CPPUNIT_TEST(testDecimalStringToNumber);
|
CPPUNIT_TEST(testDecimalStringToNumber);
|
||||||
CPPUNIT_TEST(testIsdigitAsciiString);
|
CPPUNIT_TEST(testIsdigitAsciiString);
|
||||||
@@ -474,6 +476,26 @@ void TestString::testStripEnd()
|
|||||||
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab")));
|
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestString::testStrip()
|
||||||
|
{
|
||||||
|
::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("abc"));
|
||||||
|
::rtl::OString aOut;
|
||||||
|
|
||||||
|
aOut = ::comphelper::string::strip(aIn, 'b');
|
||||||
|
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("abc")));
|
||||||
|
|
||||||
|
aOut = ::comphelper::string::strip(aIn, 'c');
|
||||||
|
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("ab")));
|
||||||
|
|
||||||
|
aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aaa"));
|
||||||
|
aOut = ::comphelper::string::strip(aIn, 'a');
|
||||||
|
CPPUNIT_ASSERT(aOut.isEmpty());
|
||||||
|
|
||||||
|
aIn = rtl::OString(RTL_CONSTASCII_STRINGPARAM("aba"));
|
||||||
|
aOut = ::comphelper::string::strip(aIn, 'a');
|
||||||
|
CPPUNIT_ASSERT(aOut.equalsL(RTL_CONSTASCII_STRINGPARAM("b")));
|
||||||
|
}
|
||||||
|
|
||||||
void TestString::testToken()
|
void TestString::testToken()
|
||||||
{
|
{
|
||||||
::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12"));
|
::rtl::OString aIn(RTL_CONSTASCII_STRINGPARAM("10.11.12"));
|
||||||
|
@@ -231,6 +231,16 @@ rtl::OUString stripEnd(const rtl::OUString &rIn, sal_Unicode c)
|
|||||||
return tmpl_stripEnd<rtl::OUString, sal_Unicode>(rIn, c);
|
return tmpl_stripEnd<rtl::OUString, sal_Unicode>(rIn, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtl::OString strip(const rtl::OString &rIn, sal_Char c)
|
||||||
|
{
|
||||||
|
return stripEnd(stripStart(rIn, c), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl::OUString strip(const rtl::OUString &rIn, sal_Unicode c)
|
||||||
|
{
|
||||||
|
return stripEnd(stripStart(rIn, c), c);
|
||||||
|
}
|
||||||
|
|
||||||
sal_uInt32 decimalStringToNumber(
|
sal_uInt32 decimalStringToNumber(
|
||||||
::rtl::OUString const & str )
|
::rtl::OUString const & str )
|
||||||
{
|
{
|
||||||
|
@@ -354,7 +354,7 @@ void Export::InitLanguages( bool bMergeMode ){
|
|||||||
ByteStringBoolHashMap aEnvLangs;
|
ByteStringBoolHashMap aEnvLangs;
|
||||||
for ( sal_uInt16 x = 0; x < sLanguages.GetTokenCount( ',' ); x++ ){
|
for ( sal_uInt16 x = 0; x < sLanguages.GetTokenCount( ',' ); x++ ){
|
||||||
sTmp = getToken(getToken(sLanguages, x, ','), 0, '=');
|
sTmp = getToken(getToken(sLanguages, x, ','), 0, '=');
|
||||||
sTmp.EraseLeadingAndTrailingChars();
|
sTmp = comphelper::string::strip(sTmp, ' ');
|
||||||
if( bMergeMode && !isAllowed( sTmp ) ){}
|
if( bMergeMode && !isAllowed( sTmp ) ){}
|
||||||
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) ){
|
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) ){
|
||||||
aLanguages.push_back( sTmp );
|
aLanguages.push_back( sTmp );
|
||||||
@@ -371,7 +371,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){
|
|||||||
ByteStringBoolHashMap aEnvLangs;
|
ByteStringBoolHashMap aEnvLangs;
|
||||||
for ( sal_uInt16 x = 0; x < sForcedLanguages.GetTokenCount( ',' ); x++ ){
|
for ( sal_uInt16 x = 0; x < sForcedLanguages.GetTokenCount( ',' ); x++ ){
|
||||||
sTmp = getToken(getToken(sForcedLanguages, x, ','), 0, '=');
|
sTmp = getToken(getToken(sForcedLanguages, x, ','), 0, '=');
|
||||||
sTmp.EraseLeadingAndTrailingChars();
|
sTmp = comphelper::string::strip(sTmp, ' ');
|
||||||
if( bMergeMode && isAllowed( sTmp ) ){}
|
if( bMergeMode && isAllowed( sTmp ) ){}
|
||||||
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) )
|
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) )
|
||||||
aForcedLanguages.push_back( sTmp );
|
aForcedLanguages.push_back( sTmp );
|
||||||
|
@@ -216,7 +216,7 @@ MergeDataFile::MergeDataFile(
|
|||||||
ByteString sPFO = sLine.GetToken( 1, '\t', rIdx ); // 7
|
ByteString sPFO = sLine.GetToken( 1, '\t', rIdx ); // 7
|
||||||
sPFO = sHACK;
|
sPFO = sHACK;
|
||||||
ByteString nLANG = sLine.GetToken( 1, '\t', rIdx ); // 9
|
ByteString nLANG = sLine.GetToken( 1, '\t', rIdx ); // 9
|
||||||
nLANG.EraseLeadingAndTrailingChars();
|
nLANG = comphelper::string::strip(nLANG, ' ');
|
||||||
const ByteString sTEXT = sLine.GetToken( 0, '\t', rIdx ); // 10
|
const ByteString sTEXT = sLine.GetToken( 0, '\t', rIdx ); // 10
|
||||||
const ByteString sQHTEXT = sLine.GetToken( 1, '\t', rIdx ); // 12
|
const ByteString sQHTEXT = sLine.GetToken( 1, '\t', rIdx ); // 12
|
||||||
const ByteString sTITLE = sLine.GetToken( 0, '\t', rIdx ); // 13
|
const ByteString sTITLE = sLine.GetToken( 0, '\t', rIdx ); // 13
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include <tools/string.hxx>
|
#include <tools/string.hxx>
|
||||||
#include <tools/urlobj.hxx>
|
#include <tools/urlobj.hxx>
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <comphelper/string.hxx>
|
||||||
#include <unotools/ucbstreamhelper.hxx>
|
#include <unotools/ucbstreamhelper.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
|
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
|
||||||
@@ -88,7 +89,7 @@ static sal_Bool getTag(const ByteString &rLine,
|
|||||||
if (nPos == STRING_NOTFOUND)
|
if (nPos == STRING_NOTFOUND)
|
||||||
return sal_False;
|
return sal_False;
|
||||||
|
|
||||||
rTagValue = rLine.Copy( nPos + sal::static_int_cast< xub_StrLen >(strlen( pTagName )) ).EraseLeadingAndTrailingChars();
|
rTagValue = comphelper::string::strip(rLine.Copy(nPos + sal::static_int_cast< xub_StrLen >(strlen( pTagName ))), ' ');
|
||||||
return sal_True;
|
return sal_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -682,7 +682,15 @@ void SvxFontPrevWindow::Paint( const Rectangle& )
|
|||||||
if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
|
if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
|
||||||
{
|
{
|
||||||
using namespace com::sun::star::i18n::ScriptType;
|
using namespace com::sun::star::i18n::ScriptType;
|
||||||
pImpl->aText = rFont.GetName();
|
|
||||||
|
//If we're showing multiple sample texts, then they're all
|
||||||
|
//sample texts. If only showing Latin, continue to use
|
||||||
|
//the fontname as the preview
|
||||||
|
if ((pImpl->m_bCJKEnabled) || (pImpl->m_bCTLEnabled))
|
||||||
|
pImpl->aText = makeRepresentativeTextForFont(LATIN, rFont);
|
||||||
|
else
|
||||||
|
pImpl->aText = rFont.GetName();
|
||||||
|
|
||||||
if (pImpl->m_bCJKEnabled)
|
if (pImpl->m_bCJKEnabled)
|
||||||
{
|
{
|
||||||
if (pImpl->aText.Len())
|
if (pImpl->aText.Len())
|
||||||
|
Reference in New Issue
Block a user