drop String::Reverse
Change-Id: Ie06635dc1f242241d48f9d6de4f592898e605bf2
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <comphelper/processfactory.hxx>
|
#include <comphelper/processfactory.hxx>
|
||||||
|
#include <comphelper/string.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/uno/Sequence.hxx>
|
#include <com/sun/star/uno/Sequence.hxx>
|
||||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||||
@@ -3122,8 +3123,7 @@ RTLFUNC(StrReverse)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String aStr = pSbxVariable->GetString();
|
rtl::OUString aStr = comphelper::string::reverseString(pSbxVariable->GetString());
|
||||||
aStr.Reverse();
|
|
||||||
rPar.Get(0)->PutString( aStr );
|
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);
|
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
|
namespace detail
|
||||||
{
|
{
|
||||||
template<typename B> B& truncateToLength(B& rBuffer, sal_Int32 nLen)
|
template<typename B> B& truncateToLength(B& rBuffer, sal_Int32 nLen)
|
||||||
|
@@ -53,7 +53,7 @@ public:
|
|||||||
void testTokenCount();
|
void testTokenCount();
|
||||||
void testDecimalStringToNumber();
|
void testDecimalStringToNumber();
|
||||||
void testIsdigitAsciiString();
|
void testIsdigitAsciiString();
|
||||||
void testIndexOfL();
|
void testReverseString();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(TestString);
|
CPPUNIT_TEST_SUITE(TestString);
|
||||||
CPPUNIT_TEST(testNatural);
|
CPPUNIT_TEST(testNatural);
|
||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
CPPUNIT_TEST(testTokenCount);
|
CPPUNIT_TEST(testTokenCount);
|
||||||
CPPUNIT_TEST(testDecimalStringToNumber);
|
CPPUNIT_TEST(testDecimalStringToNumber);
|
||||||
CPPUNIT_TEST(testIsdigitAsciiString);
|
CPPUNIT_TEST(testIsdigitAsciiString);
|
||||||
|
CPPUNIT_TEST(testReverseString);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -396,6 +397,14 @@ void TestString::testTokenCount()
|
|||||||
CPPUNIT_ASSERT(nOut == 0);
|
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);
|
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);
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -2557,8 +2557,7 @@ void SvtFileDialog::implArrangeControls()
|
|||||||
sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilter )
|
sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilter )
|
||||||
{
|
{
|
||||||
String aEmpty;
|
String aEmpty;
|
||||||
String aReversePath( rPath );
|
String aReversePath = comphelper::string::reverseString(rPath);
|
||||||
aReversePath.Reverse();
|
|
||||||
sal_uInt16 nQuestionMarkPos = rPath.Search( '?' );
|
sal_uInt16 nQuestionMarkPos = rPath.Search( '?' );
|
||||||
|
|
||||||
if ( nQuestionMarkPos != STRING_NOTFOUND )
|
if ( nQuestionMarkPos != STRING_NOTFOUND )
|
||||||
@@ -2607,12 +2606,12 @@ sal_Bool SvtFileDialog::IsolateFilterFromPath_Impl( String& rPath, String& rFilt
|
|||||||
// cut off filter
|
// cut off filter
|
||||||
rFilter = aReversePath;
|
rFilter = aReversePath;
|
||||||
rFilter.Erase( nPathTokenPos );
|
rFilter.Erase( nPathTokenPos );
|
||||||
rFilter.Reverse();
|
rFilter = comphelper::string::reverseString(rFilter);
|
||||||
|
|
||||||
// determine folder
|
// determine folder
|
||||||
rPath = aReversePath;
|
rPath = aReversePath;
|
||||||
rPath.Erase( 0, nPathTokenPos );
|
rPath.Erase( 0, nPathTokenPos );
|
||||||
rPath.Reverse();
|
rPath = comphelper::string::reverseString(rPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
#include <com/sun/star/sheet/ExternalLinkInfo.hpp>
|
#include <com/sun/star/sheet/ExternalLinkInfo.hpp>
|
||||||
#include <com/sun/star/sheet/ExternalLinkType.hpp>
|
#include <com/sun/star/sheet/ExternalLinkType.hpp>
|
||||||
|
#include <comphelper/string.hxx>
|
||||||
#include <sfx2/objsh.hxx>
|
#include <sfx2/objsh.hxx>
|
||||||
#include <tools/urlobj.hxx>
|
#include <tools/urlobj.hxx>
|
||||||
|
|
||||||
@@ -2016,8 +2017,7 @@ void ScColToAlpha( rtl::OUStringBuffer& rBuf, SCCOL nCol )
|
|||||||
}
|
}
|
||||||
aStr += static_cast<sal_Unicode>( 'A' +
|
aStr += static_cast<sal_Unicode>( 'A' +
|
||||||
static_cast<sal_uInt16>(nCol));
|
static_cast<sal_uInt16>(nCol));
|
||||||
aStr.Reverse();
|
rBuf.append(comphelper::string::reverseString(aStr));
|
||||||
rBuf.append( aStr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include <com/sun/star/table/TableBorder.hpp>
|
#include <com/sun/star/table/TableBorder.hpp>
|
||||||
#include <com/sun/star/table/BorderLine2.hpp>
|
#include <com/sun/star/table/BorderLine2.hpp>
|
||||||
|
|
||||||
|
#include <comphelper/string.hxx>
|
||||||
|
|
||||||
#include <cppuhelper/typeprovider.hxx>
|
#include <cppuhelper/typeprovider.hxx>
|
||||||
#include <svl/style.hxx>
|
#include <svl/style.hxx>
|
||||||
#include <svl/itemset.hxx>
|
#include <svl/itemset.hxx>
|
||||||
@@ -1664,8 +1666,7 @@ static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
|
|||||||
}
|
}
|
||||||
aStr += static_cast<sal_Unicode>( 'A' +
|
aStr += static_cast<sal_Unicode>( 'A' +
|
||||||
static_cast<sal_uInt16>(nCol));
|
static_cast<sal_uInt16>(nCol));
|
||||||
aStr.Reverse();
|
aBuf.append(comphelper::string::reverseString(aStr));
|
||||||
aBuf.append( aStr);
|
|
||||||
}
|
}
|
||||||
aBuf.append( OUString::valueOf(nRow+1) );
|
aBuf.append( OUString::valueOf(nRow+1) );
|
||||||
return aBuf.makeStringAndClear();
|
return aBuf.makeStringAndClear();
|
||||||
|
@@ -247,7 +247,6 @@ public:
|
|||||||
|
|
||||||
UniString& EraseLeadingChars( sal_Unicode c = ' ' );
|
UniString& EraseLeadingChars( sal_Unicode c = ' ' );
|
||||||
UniString& EraseTrailingChars( sal_Unicode c = ' ' );
|
UniString& EraseTrailingChars( sal_Unicode c = ' ' );
|
||||||
UniString& Reverse();
|
|
||||||
|
|
||||||
UniString& ToLowerAscii();
|
UniString& ToLowerAscii();
|
||||||
UniString& ToUpperAscii();
|
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,
|
STRING& STRING::Insert( const STRING& rStr, xub_StrLen nPos, xub_StrLen nLen,
|
||||||
xub_StrLen nIndex )
|
xub_StrLen nIndex )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user