Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
90fe8dad
Kaydet (Commit)
90fe8dad
authored
Agu 14, 2011
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add a jdk 1.5-alike string replace to comphelper::string
üst
3324eca4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
32 deletions
+106
-32
string.hxx
comphelper/inc/comphelper/string.hxx
+24
-1
test_string.cxx
comphelper/qa/string/test_string.cxx
+30
-0
string.cxx
comphelper/source/misc/string.cxx
+44
-0
dp_gui_extensioncmdqueue.cxx
desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+6
-29
string.hxx
tools/inc/tools/string.hxx
+2
-2
No files found.
comphelper/inc/comphelper/string.hxx
Dosyayı görüntüle @
90fe8dad
...
...
@@ -110,6 +110,30 @@ COMPHELPER_DLLPUBLIC ::rtl::OUString&
::
rtl
::
OUString
const
&
replace
,
sal_Int32
beginAt
=
0
,
sal_Int32
*
replacedAt
=
NULL
);
/** Replaces each substring of this OString that matches the search OString
with the specified replacement OString
@param rIn The input OString
@param rSearch The substring to be replaced
@param rReplace The replacement substring
@return The resulting OString
*/
COMPHELPER_DLLPUBLIC
rtl
::
OString
replace
(
const
rtl
::
OString
&
rIn
,
const
rtl
::
OString
&
rSearch
,
const
rtl
::
OString
&
rReplace
);
/** Replaces each substring of this OUString that matches the search OUString
with the specified replacement OUString
@param rIn The input OUString
@param rSearch The substring to be replaced
@param rReplace The replacement substring
@return The resulting OUString
*/
COMPHELPER_DLLPUBLIC
rtl
::
OUString
replace
(
const
rtl
::
OUString
&
rIn
,
const
rtl
::
OUString
&
rSearch
,
const
rtl
::
OUString
&
rReplace
);
/** Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.
...
...
@@ -213,7 +237,6 @@ COMPHELPER_DLLPUBLIC bool isAsciiDecimalString(const rtl::OString &rString);
*/
COMPHELPER_DLLPUBLIC
bool
isAsciiDecimalString
(
const
rtl
::
OUString
&
rString
);
}
}
#endif
...
...
comphelper/qa/string/test_string.cxx
Dosyayı görüntüle @
90fe8dad
...
...
@@ -43,11 +43,13 @@ class TestString: public CppUnit::TestFixture
public
:
void
test
();
void
testNatural
();
void
testReplace
();
void
testDecimalStringToNumber
();
CPPUNIT_TEST_SUITE
(
TestString
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST
(
testNatural
);
CPPUNIT_TEST
(
testReplace
);
CPPUNIT_TEST
(
testDecimalStringToNumber
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -288,6 +290,34 @@ void TestString::testNatural()
);
}
void
TestString
::
testReplace
()
{
::
rtl
::
OString
aIn
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa"
));
::
rtl
::
OString
aOut
;
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"aa"
)),
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"b"
)));
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"ba"
)));
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(),
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"whatever"
)));
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa"
)));
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa"
)),
rtl
::
OString
());
CPPUNIT_ASSERT
(
aOut
.
isEmpty
());
aIn
=
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa foo aaa foo bbb"
));
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"foo"
)),
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"bar"
)));
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa bar aaa bar bbb"
)));
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestString
);
}
...
...
comphelper/source/misc/string.cxx
Dosyayı görüntüle @
90fe8dad
...
...
@@ -36,6 +36,8 @@
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/strbuf.hxx>
#include <sal/types.h>
#include <comphelper/string.hxx>
...
...
@@ -94,6 +96,48 @@ rtl::OUString searchAndReplaceAsciiL(
return
_source
;
}
namespace
{
template
<
typename
T
,
typename
O
>
T
tmpl_replace
(
const
T
&
rIn
,
const
T
&
rSearch
,
const
T
&
rReplace
)
{
if
(
rIn
.
isEmpty
()
||
rSearch
.
isEmpty
())
return
rIn
;
O
aRet
;
sal_Int32
nFromIndex
=
0
;
while
(
nFromIndex
<
rIn
.
getLength
())
{
sal_Int32
nIndex
=
rIn
.
indexOf
(
rSearch
,
nFromIndex
);
if
(
nIndex
==
-
1
)
{
aRet
.
append
(
rIn
.
copy
(
nFromIndex
));
break
;
}
aRet
.
append
(
rIn
.
copy
(
nFromIndex
,
nIndex
-
nFromIndex
));
aRet
.
append
(
rReplace
);
nFromIndex
=
nIndex
+
rSearch
.
getLength
();
}
return
aRet
.
makeStringAndClear
();
}
}
rtl
::
OString
replace
(
const
rtl
::
OString
&
rIn
,
const
rtl
::
OString
&
rSearch
,
const
rtl
::
OString
&
rReplace
)
{
return
tmpl_replace
<
rtl
::
OString
,
rtl
::
OStringBuffer
>
(
rIn
,
rSearch
,
rReplace
);
}
rtl
::
OUString
replace
(
const
rtl
::
OUString
&
rIn
,
const
rtl
::
OUString
&
rSearch
,
const
rtl
::
OUString
&
rReplace
)
{
return
tmpl_replace
<
rtl
::
OUString
,
rtl
::
OUStringBuffer
>
(
rIn
,
rSearch
,
rReplace
);
}
sal_uInt32
decimalStringToNumber
(
::
rtl
::
OUString
const
&
str
)
{
...
...
desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
Dosyayı görüntüle @
90fe8dad
...
...
@@ -77,6 +77,7 @@
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/implbase3.hxx"
#include "comphelper/anytostring.hxx"
#include "comphelper/string.hxx"
#include "vcl/msgbox.hxx"
#include "toolkit/helper/vclunohelper.hxx"
#include "comphelper/processfactory.hxx"
...
...
@@ -250,9 +251,6 @@ public:
void
stop
();
bool
isBusy
();
static
OUString
searchAndReplaceAll
(
const
OUString
&
rSource
,
const
OUString
&
rWhat
,
const
OUString
&
rWith
);
private
:
Thread
(
Thread
&
);
// not defined
void
operator
=
(
Thread
&
);
// not defined
...
...
@@ -902,7 +900,7 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv
rCmdEnv
->
setWarnUser
(
bWarnUser
);
uno
::
Reference
<
deployment
::
XExtensionManager
>
xExtMgr
=
m_pManager
->
getExtensionManager
();
uno
::
Reference
<
task
::
XAbortChannel
>
xAbortChannel
(
xExtMgr
->
createAbortChannel
()
);
OUString
sTitle
=
searchAndReplaceAll
(
m_sAddingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
sName
);
OUString
sTitle
=
comphelper
::
string
::
replace
(
m_sAddingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
sName
);
rCmdEnv
->
progressSection
(
sTitle
,
xAbortChannel
);
try
...
...
@@ -929,7 +927,7 @@ void ExtensionCmdQueue::Thread::_removeExtension( ::rtl::Reference< ProgressCmdE
{
uno
::
Reference
<
deployment
::
XExtensionManager
>
xExtMgr
=
m_pManager
->
getExtensionManager
();
uno
::
Reference
<
task
::
XAbortChannel
>
xAbortChannel
(
xExtMgr
->
createAbortChannel
()
);
OUString
sTitle
=
searchAndReplaceAll
(
m_sRemovingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
OUString
sTitle
=
comphelper
::
string
::
replace
(
m_sRemovingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
rCmdEnv
->
progressSection
(
sTitle
,
xAbortChannel
);
OUString
id
(
dp_misc
::
getIdentifier
(
xPackage
)
);
...
...
@@ -1012,7 +1010,7 @@ void ExtensionCmdQueue::Thread::_enableExtension( ::rtl::Reference< ProgressCmdE
uno
::
Reference
<
deployment
::
XExtensionManager
>
xExtMgr
=
m_pManager
->
getExtensionManager
();
uno
::
Reference
<
task
::
XAbortChannel
>
xAbortChannel
(
xExtMgr
->
createAbortChannel
()
);
OUString
sTitle
=
searchAndReplaceAll
(
m_sEnablingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
OUString
sTitle
=
comphelper
::
string
::
replace
(
m_sEnablingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
rCmdEnv
->
progressSection
(
sTitle
,
xAbortChannel
);
try
...
...
@@ -1034,7 +1032,7 @@ void ExtensionCmdQueue::Thread::_disableExtension( ::rtl::Reference< ProgressCmd
uno
::
Reference
<
deployment
::
XExtensionManager
>
xExtMgr
=
m_pManager
->
getExtensionManager
();
uno
::
Reference
<
task
::
XAbortChannel
>
xAbortChannel
(
xExtMgr
->
createAbortChannel
()
);
OUString
sTitle
=
searchAndReplaceAll
(
m_sDisablingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
OUString
sTitle
=
comphelper
::
string
::
replace
(
m_sDisablingPackages
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
rCmdEnv
->
progressSection
(
sTitle
,
xAbortChannel
);
try
...
...
@@ -1056,7 +1054,7 @@ void ExtensionCmdQueue::Thread::_acceptLicense( ::rtl::Reference< ProgressCmdEnv
uno
::
Reference
<
deployment
::
XExtensionManager
>
xExtMgr
=
m_pManager
->
getExtensionManager
();
uno
::
Reference
<
task
::
XAbortChannel
>
xAbortChannel
(
xExtMgr
->
createAbortChannel
()
);
OUString
sTitle
=
searchAndReplaceAll
(
m_sAcceptLicense
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
OUString
sTitle
=
comphelper
::
string
::
replace
(
m_sAcceptLicense
,
OUSTR
(
"%EXTENSION_NAME"
),
xPackage
->
getDisplayName
()
);
rCmdEnv
->
progressSection
(
sTitle
,
xAbortChannel
);
try
...
...
@@ -1089,27 +1087,6 @@ void ExtensionCmdQueue::Thread::_insert(const TExtensionCmd& rExtCmd)
m_wakeup
.
set
();
}
//------------------------------------------------------------------------------
OUString
ExtensionCmdQueue
::
Thread
::
searchAndReplaceAll
(
const
OUString
&
rSource
,
const
OUString
&
rWhat
,
const
OUString
&
rWith
)
{
OUString
aRet
(
rSource
);
sal_Int32
nLen
=
rWhat
.
getLength
();
if
(
!
nLen
)
return
aRet
;
sal_Int32
nIndex
=
rSource
.
indexOf
(
rWhat
);
while
(
nIndex
!=
-
1
)
{
aRet
=
aRet
.
replaceAt
(
nIndex
,
nLen
,
rWith
);
nIndex
=
aRet
.
indexOf
(
rWhat
,
nIndex
+
rWith
.
getLength
()
);
}
return
aRet
;
}
//------------------------------------------------------------------------------
ExtensionCmdQueue
::
ExtensionCmdQueue
(
DialogHelper
*
pDialogHelper
,
TheExtensionManager
*
pManager
,
...
...
tools/inc/tools/string.hxx
Dosyayı görüntüle @
90fe8dad
...
...
@@ -169,10 +169,10 @@ private:
// of ByteString(sal_Char);
ByteString
(
const
UniString
&
rUniStr
,
xub_StrLen
nPos
,
xub_StrLen
nLen
,
rtl_TextEncoding
eTextEncoding
,
sal_uInt32
nCvtFlags
=
UNISTRING_TO_BYTESTRING_CVTFLAGS
);
sal_uInt32
nCvtFlags
=
UNISTRING_TO_BYTESTRING_CVTFLAGS
);
//not implemented, to detect use of removed methods without compiler making something to fit
ByteString
(
const
sal_Unicode
*
pUniStr
,
xub_StrLen
nLen
,
rtl_TextEncoding
eTextEncoding
,
sal_uInt32
nCvtFlags
=
UNISTRING_TO_BYTESTRING_CVTFLAGS
);
sal_uInt32
nCvtFlags
=
UNISTRING_TO_BYTESTRING_CVTFLAGS
);
//not implemented, to detect use of removed methods without compiler making somethiing to fit
void
Assign
(
int
);
// not implemented; to detect misuses of
// Assign(sal_Char)
void
operator
=
(
int
);
// not implemented; to detect misuses
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment