drop String::Reverse
Change-Id: Ie06635dc1f242241d48f9d6de4f592898e605bf2
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
|
||||
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/string.hxx>
|
||||
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
@@ -3122,8 +3123,7 @@ RTLFUNC(StrReverse)
|
||||
return;
|
||||
}
|
||||
|
||||
String aStr = pSbxVariable->GetString();
|
||||
aStr.Reverse();
|
||||
rtl::OUString aStr = comphelper::string::reverseString(pSbxVariable->GetString());
|
||||
rPar.Get(0)->PutString( aStr );
|
||||
}
|
||||
|
||||
|
@@ -226,6 +226,21 @@ COMPHELPER_DLLPUBLIC sal_Int32 getTokenCount(const rtl::OString &rIn, sal_Char c
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC sal_Int32 getTokenCount(const rtl::OUString &rIn, sal_Unicode cTok);
|
||||
|
||||
/** Reverse an OUString
|
||||
|
||||
@param rIn the input OUString
|
||||
@return the reversed input
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC rtl::OUString reverseString(const rtl::OUString &rStr);
|
||||
|
||||
/** Reverse an OString
|
||||
|
||||
@param rIn the input OString
|
||||
@return the reversed input
|
||||
*/
|
||||
COMPHELPER_DLLPUBLIC rtl::OString reverseString(const rtl::OString &rStr);
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename B> B& truncateToLength(B& rBuffer, sal_Int32 nLen)
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
void testTokenCount();
|
||||
void testDecimalStringToNumber();
|
||||
void testIsdigitAsciiString();
|
||||
void testIndexOfL();
|
||||
void testReverseString();
|
||||
|
||||
CPPUNIT_TEST_SUITE(TestString);
|
||||
CPPUNIT_TEST(testNatural);
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
CPPUNIT_TEST(testTokenCount);
|
||||
CPPUNIT_TEST(testDecimalStringToNumber);
|
||||
CPPUNIT_TEST(testIsdigitAsciiString);
|
||||
CPPUNIT_TEST(testReverseString);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
};
|
||||
|
||||
@@ -396,6 +397,14 @@ void TestString::testTokenCount()
|
||||
CPPUNIT_ASSERT(nOut == 0);
|
||||
}
|
||||
|
||||
void TestString::testReverseString()
|
||||
{
|
||||
::rtl::OString aIn("ABC");
|
||||
::rtl::OString aOut = ::comphelper::string::reverseString(aIn);
|
||||
|
||||
CPPUNIT_ASSERT(aOut == "CBA");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestString);
|
||||
|
||||
}
|
||||
|
@@ -438,6 +438,32 @@ rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen)
|
||||
return string_alloc<rtl_String, sal_Char>(nLen);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T, typename O> T tmpl_reverseString(const T &rIn)
|
||||
{
|
||||
if (rIn.isEmpty())
|
||||
return rIn;
|
||||
|
||||
sal_Int32 i = rIn.getLength();
|
||||
O sBuf(i);
|
||||
while (i)
|
||||
sBuf.append(rIn[--i]);
|
||||
return sBuf.makeStringAndClear();
|
||||
}
|
||||
}
|
||||
|
||||
rtl::OUString reverseString(const rtl::OUString &rStr)
|
||||
{
|
||||
return tmpl_reverseString<rtl::OUString, rtl::OUStringBuffer>(rStr);
|
||||
}
|
||||
|
||||
rtl::OString reverseString(const rtl::OString &rStr)
|
||||
{
|
||||
return tmpl_reverseString<rtl::OString, rtl::OStringBuffer>(rStr);
|
||||
}
|
||||
|
||||
|
||||
} }
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -2557,8 +2557,7 @@ void SvtFileDialog::implArrangeControls()
|
||||
sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilter )
|
||||
{
|
||||
String aEmpty;
|
||||
String aReversePath( rPath );
|
||||
aReversePath.Reverse();
|
||||
String aReversePath = comphelper::string::reverseString(rPath);
|
||||
sal_uInt16 nQuestionMarkPos = rPath.Search( '?' );
|
||||
|
||||
if ( nQuestionMarkPos != STRING_NOTFOUND )
|
||||
@@ -2607,12 +2606,12 @@ sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilt
|
||||
// cut off filter
|
||||
rFilter = aReversePath;
|
||||
rFilter.Erase( nPathTokenPos );
|
||||
rFilter.Reverse();
|
||||
rFilter = comphelper::string::reverseString(rFilter);
|
||||
|
||||
// determine folder
|
||||
rPath = aReversePath;
|
||||
rPath.Erase( 0, nPathTokenPos );
|
||||
rPath.Reverse();
|
||||
rPath = comphelper::string::reverseString(rPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/sheet/ExternalLinkInfo.hpp>
|
||||
#include <com/sun/star/sheet/ExternalLinkType.hpp>
|
||||
#include <comphelper/string.hxx>
|
||||
#include <sfx2/objsh.hxx>
|
||||
#include <tools/urlobj.hxx>
|
||||
|
||||
@@ -2016,8 +2017,7 @@ void ScColToAlpha( rtl::OUStringBuffer& rBuf, SCCOL nCol )
|
||||
}
|
||||
aStr += static_cast<sal_Unicode>( 'A' +
|
||||
static_cast<sal_uInt16>(nCol));
|
||||
aStr.Reverse();
|
||||
rBuf.append( aStr);
|
||||
rBuf.append(comphelper::string::reverseString(aStr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include <com/sun/star/table/TableBorder.hpp>
|
||||
#include <com/sun/star/table/BorderLine2.hpp>
|
||||
|
||||
#include <comphelper/string.hxx>
|
||||
|
||||
#include <cppuhelper/typeprovider.hxx>
|
||||
#include <svl/style.hxx>
|
||||
#include <svl/itemset.hxx>
|
||||
@@ -1664,8 +1666,7 @@ static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
|
||||
}
|
||||
aStr += static_cast<sal_Unicode>( 'A' +
|
||||
static_cast<sal_uInt16>(nCol));
|
||||
aStr.Reverse();
|
||||
aBuf.append( aStr);
|
||||
aBuf.append(comphelper::string::reverseString(aStr));
|
||||
}
|
||||
aBuf.append( OUString::valueOf(nRow+1) );
|
||||
return aBuf.makeStringAndClear();
|
||||
|
@@ -247,7 +247,6 @@ public:
|
||||
|
||||
UniString& EraseLeadingChars( sal_Unicode c = ' ' );
|
||||
UniString& EraseTrailingChars( sal_Unicode c = ' ' );
|
||||
UniString& Reverse();
|
||||
|
||||
UniString& ToLowerAscii();
|
||||
UniString& ToUpperAscii();
|
||||
|
@@ -155,30 +155,6 @@ xub_StrLen STRING::SearchAndReplace( STRCODE c, STRCODE cRep, xub_StrLen nIndex
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
STRING& STRING::Reverse()
|
||||
{
|
||||
DBG_CHKTHIS( STRING, DBGCHECKSTRING );
|
||||
|
||||
if ( !mpData->mnLen )
|
||||
return *this;
|
||||
|
||||
// Daten kopieren, wenn noetig
|
||||
ImplCopyData();
|
||||
|
||||
// Reverse
|
||||
sal_Int32 nCount = mpData->mnLen / 2;
|
||||
for ( sal_Int32 i = 0; i < nCount; ++i )
|
||||
{
|
||||
STRCODE cTemp = mpData->maStr[i];
|
||||
mpData->maStr[i] = mpData->maStr[mpData->mnLen-i-1];
|
||||
mpData->maStr[mpData->mnLen-i-1] = cTemp;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
STRING& STRING::Insert( const STRING& rStr, xub_StrLen nPos, xub_StrLen nLen,
|
||||
xub_StrLen nIndex )
|
||||
{
|
||||
|
Reference in New Issue
Block a user