summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx2
-rw-r--r--compilerplugins/clang/stringview.cxx83
-rw-r--r--compilerplugins/clang/test/stringview.cxx12
-rw-r--r--cui/source/dialogs/FontFeaturesDialog.cxx4
-rw-r--r--extensions/source/propctrlr/browserline.cxx2
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx2
-rw-r--r--i18nutil/source/utility/unicode.cxx2
-rw-r--r--include/rtl/strbuf.hxx28
-rw-r--r--include/rtl/ustrbuf.hxx87
-rw-r--r--l10ntools/source/helper.cxx2
-rw-r--r--l10ntools/source/localize.cxx4
-rw-r--r--l10ntools/source/po.cxx4
-rw-r--r--linguistic/source/hyphdsp.cxx2
-rw-r--r--lotuswordpro/source/filter/lwptools.cxx4
-rw-r--r--oox/source/dump/dumperbase.cxx2
-rw-r--r--sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx8
-rw-r--r--sc/source/core/tool/address.cxx2
-rw-r--r--sc/source/core/tool/compiler.cxx2
-rw-r--r--sc/source/core/tool/rangeutl.cxx2
-rw-r--r--sc/source/filter/dif/difimp.cxx8
-rw-r--r--svl/source/numbers/zformat.cxx4
-rw-r--r--svl/source/numbers/zforscan.cxx2
-rw-r--r--sw/source/core/text/txtfrm.cxx10
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx2
-rw-r--r--sw/source/filter/ascii/ascatr.cxx4
-rw-r--r--tools/source/inet/inetmime.cxx6
-rw-r--r--ucb/source/ucp/file/bc.cxx2
-rw-r--r--ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx6
-rw-r--r--vcl/source/control/edit.cxx2
-rw-r--r--vcl/source/control/longcurr.cxx2
-rw-r--r--vcl/source/treelist/treelistbox.cxx2
-rw-r--r--xmloff/source/meta/xmlmetai.cxx2
-rw-r--r--xmloff/source/style/xmlnumfi.cxx4
33 files changed, 257 insertions, 53 deletions
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index b5faa312d46b..29f2b83efbec 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -170,7 +170,7 @@ OUString lcl_getIndexStringAfterString( const OUString& rString, const OUString&
sal_Int32 nNextColon = rString.indexOf( ':', nIndexStart );
if( nNextColon != -1 )
nIndexEnd = nNextColon;
- aRet = rString.copy(nIndexStart,nIndexEnd-nIndexStart);
+ aRet = rString.subView(nIndexStart,nIndexEnd-nIndexStart);
}
return aRet.makeStringAndClear();
diff --git a/compilerplugins/clang/stringview.cxx b/compilerplugins/clang/stringview.cxx
index abfc87f78fd6..5df91dcad054 100644
--- a/compilerplugins/clang/stringview.cxx
+++ b/compilerplugins/clang/stringview.cxx
@@ -51,8 +51,11 @@ public:
bool VisitFunctionDecl(FunctionDecl const*);
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const*);
bool VisitImplicitCastExpr(ImplicitCastExpr const*);
+ bool VisitCXXMemberCallExpr(CXXMemberCallExpr const*);
+ bool VisitCXXConstructExpr(CXXConstructExpr const*);
private:
+ void handleSubExprThatCouldBeView(Expr const* expr);
void handleCXXConstructExpr(CXXConstructExpr const* expr);
void handleCXXMemberCallExpr(CXXMemberCallExpr const* expr);
};
@@ -88,6 +91,20 @@ bool StringView::VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* cxxOperator
check(cxxOperatorCallExpr->getArg(1));
else if (op == OO_Subscript)
check(cxxOperatorCallExpr->getArg(0));
+ else if (op == OO_Equal)
+ {
+ if (loplugin::TypeCheck(cxxOperatorCallExpr->getType())
+ .Class("OUStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace()
+ || loplugin::TypeCheck(cxxOperatorCallExpr->getType())
+ .Class("OStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace())
+ {
+ check(cxxOperatorCallExpr->getArg(1));
+ }
+ }
return true;
}
@@ -111,12 +128,18 @@ bool StringView::VisitImplicitCastExpr(ImplicitCastExpr const* expr)
{
return true;
}
- auto const e = expr->getSubExprAsWritten()->IgnoreParens();
+ handleSubExprThatCouldBeView(expr->getSubExprAsWritten());
+ return true;
+}
+
+void StringView::handleSubExprThatCouldBeView(Expr const* subExpr)
+{
+ auto const e = subExpr->IgnoreParens();
auto const tc = loplugin::TypeCheck(e->getType());
if (!(tc.Class("OString").Namespace("rtl").GlobalNamespace()
|| tc.Class("OUString").Namespace("rtl").GlobalNamespace()))
{
- return true;
+ return;
}
if (auto const e1 = dyn_cast<CXXConstructExpr>(e))
{
@@ -138,7 +161,6 @@ bool StringView::VisitImplicitCastExpr(ImplicitCastExpr const* expr)
{
handleCXXMemberCallExpr(e3);
}
- return true;
}
void StringView::handleCXXConstructExpr(CXXConstructExpr const* expr)
@@ -229,6 +251,61 @@ void StringView::handleCXXMemberCallExpr(CXXMemberCallExpr const* expr)
<< expr->getSourceRange();
}
+/** check for calls to O[U]StringBuffer::append that could be passed as a
+ std::u16string_view */
+bool StringView::VisitCXXMemberCallExpr(CXXMemberCallExpr const* expr)
+{
+ if (ignoreLocation(expr))
+ {
+ return true;
+ }
+ if (!loplugin::TypeCheck(expr->getType())
+ .Class("OUStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace()
+ && !loplugin::TypeCheck(expr->getType())
+ .Class("OStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace())
+ {
+ return true;
+ }
+ auto const dc = loplugin::DeclCheck(expr->getMethodDecl());
+ if (dc.Function("append") || dc.Function("indexOf") || dc.Function("lastIndexOf"))
+ {
+ handleSubExprThatCouldBeView(compat::IgnoreImplicit(expr->getArg(0)));
+ }
+ else if (dc.Function("insert"))
+ {
+ handleSubExprThatCouldBeView(compat::IgnoreImplicit(expr->getArg(1)));
+ }
+ return true;
+}
+
+/** check for calls to O[U]StringBuffer constructor that could be passed as a
+ std::u16string_view */
+bool StringView::VisitCXXConstructExpr(CXXConstructExpr const* expr)
+{
+ if (ignoreLocation(expr))
+ {
+ return true;
+ }
+ if (!loplugin::TypeCheck(expr->getType())
+ .Class("OUStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace()
+ && !loplugin::TypeCheck(expr->getType())
+ .Class("OStringBuffer")
+ .Namespace("rtl")
+ .GlobalNamespace())
+ {
+ return true;
+ }
+ if (expr->getNumArgs() > 0)
+ handleSubExprThatCouldBeView(compat::IgnoreImplicit(expr->getArg(0)));
+ return true;
+}
+
loplugin::Plugin::Registration<StringView> stringview("stringview");
}
diff --git a/compilerplugins/clang/test/stringview.cxx b/compilerplugins/clang/test/stringview.cxx
index d40ee50175a1..142bba799008 100644
--- a/compilerplugins/clang/test/stringview.cxx
+++ b/compilerplugins/clang/test/stringview.cxx
@@ -140,4 +140,16 @@ void f5(char const* s1, sal_Int32 n1, char16_t const* s2, sal_Int32 n2)
call_view(OUString(OUString::number(0)));
}
+void f5(OUString s)
+{
+ // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
+ OUStringBuffer buf(s.copy(5));
+ // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
+ buf = s.copy(5);
+ // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
+ buf.append(s.copy(12));
+ // expected-error@+1 {{instead of an 'rtl::OUString', pass a 'std::u16string_view' [loplugin:stringview]}}
+ buf.append(OUString(std::u16string_view(u"foo")));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx
index b9120b0371c8..fae448b6a283 100644
--- a/cui/source/dialogs/FontFeaturesDialog.cxx
+++ b/cui/source/dialogs/FontFeaturesDialog.cxx
@@ -182,7 +182,7 @@ OUString FontFeaturesDialog::createFontNameWithFeatures()
if (sal_uInt32(rItem.m_xCheck->get_active()) != rItem.m_nDefault)
{
if (!bFirst)
- sNameSuffix.append(OUString(vcl::font::FeatureSeparator));
+ sNameSuffix.append(vcl::font::FeatureSeparator);
else
bFirst = false;
@@ -197,7 +197,7 @@ OUString FontFeaturesDialog::createFontNameWithFeatures()
if (nSelection != int(rItem.m_nDefault))
{
if (!bFirst)
- sNameSuffix.append(OUString(vcl::font::FeatureSeparator));
+ sNameSuffix.append(vcl::font::FeatureSeparator);
else
bFirst = false;
diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx
index 5f185c594243..8618ecffc8fe 100644
--- a/extensions/source/propctrlr/browserline.cxx
+++ b/extensions/source/propctrlr/browserline.cxx
@@ -188,7 +188,7 @@ namespace pcr
if (AllSettings::GetLayoutRTL())
{
sal_Unicode const cRTL_mark = 0x200F;
- aText.append( OUString(cRTL_mark) );
+ aText.append( cRTL_mark );
}
m_xFtTitle->set_label(aText.makeStringAndClear());
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 85edc3833025..96c0056d35c0 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -63,7 +63,7 @@ namespace framework
static OUString lcl_getKeyString(const css::awt::KeyEvent& aKeyEvent)
{
const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of an identifier...
- OUStringBuffer sKeyBuffer((KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex));
+ OUStringBuffer sKeyBuffer((KeyMapping::get().mapCodeToIdentifier(aKeyEvent.KeyCode)).subView(nBeginIndex));
if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT )
sKeyBuffer.append("_SHIFT");
diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx
index f944d69c40e2..6a4fdd061f9d 100644
--- a/i18nutil/source/utility/unicode.cxx
+++ b/i18nutil/source/utility/unicode.cxx
@@ -1007,7 +1007,7 @@ OUString ToggleUnicodeCodepoint::StringToReplace()
nUnicode = sIn.copy(0, nUPlus).toUInt32(16);
//prevent creating control characters or invalid Unicode values
if( !rtl::isUnicodeCodePoint(nUnicode) || nUnicode < 0x20 )
- maInput = sIn.copy(nUPlus);
+ maInput = sIn.subView(nUPlus);
sIn = sIn.copy(nUPlus+2);
nUPlus = sIn.indexOf("U+");
}
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 2f2df8624f25..28f48a221ee5 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -132,6 +132,17 @@ public:
@param value the initial string value.
*/
+#if defined LIBO_INTERNAL_ONLY
+ explicit OStringBuffer(std::string_view sv)
+ : pData(nullptr)
+ , nCapacity( sv.length() + 16 )
+ {
+ if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
+ throw std::bad_alloc();
+ }
+ rtl_stringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
+ }
+#endif
OStringBuffer(const OString& value)
: pData(NULL)
, nCapacity( value.getLength() + 16 )
@@ -251,6 +262,17 @@ public:
@since LibreOffice 5.3
*/
+#if defined LIBO_INTERNAL_ONLY
+ OStringBuffer & operator =(std::string_view string) {
+ sal_Int32 n = string.length();
+ if (n >= nCapacity) {
+ ensureCapacity(n + 16); //TODO: check for overflow
+ }
+ std::memcpy(pData->buffer, string.data(), n + 1);
+ pData->length = n;
+ return *this;
+ }
+#endif
OStringBuffer & operator =(OString const & string) {
sal_Int32 n = string.getLength();
if (n >= nCapacity) {
@@ -764,6 +786,12 @@ public:
@param str a string.
@return this string buffer.
*/
+#if defined LIBO_INTERNAL_ONLY
+ OStringBuffer & insert(sal_Int32 offset, std::string_view str)
+ {
+ return insert( offset, str.data(), str.length() );
+ }
+#endif
OStringBuffer & insert(sal_Int32 offset, const OString & str)
{
return insert( offset, str.getStr(), str.getLength() );
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index bd7f77b503b7..080e2ea96259 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -133,6 +133,17 @@ public:
@param value the initial contents of the buffer.
*/
+#if defined LIBO_INTERNAL_ONLY
+ explicit OUStringBuffer(std::u16string_view sv)
+ : pData(nullptr)
+ , nCapacity( sv.length() + 16 )
+ {
+ if (sv.size() > sal_uInt32(std::numeric_limits<sal_Int32>::max())) {
+ throw std::bad_alloc();
+ }
+ rtl_uStringbuffer_newFromStr_WithLength( &pData, sv.data(), sv.length() );
+ }
+#endif
OUStringBuffer(const OUString& value)
: pData(NULL)
, nCapacity( value.getLength() + 16 )
@@ -257,6 +268,19 @@ public:
@since LibreOffice 5.3
*/
+#if defined LIBO_INTERNAL_ONLY
+ OUStringBuffer & operator =(std::u16string_view string) {
+ sal_Int32 n = string.length();
+ if (n >= nCapacity) {
+ ensureCapacity(n + 16); //TODO: check for overflow
+ }
+ std::memcpy(
+ pData->buffer, string.data(),
+ (n + 1) * sizeof (sal_Unicode));
+ pData->length = n;
+ return *this;
+ }
+#endif
OUStringBuffer & operator =(OUString const & string) {
sal_Int32 n = string.getLength();
if (n >= nCapacity) {
@@ -955,6 +979,12 @@ public:
@param str a string.
@return this string buffer.
*/
+#if defined LIBO_INTERNAL_ONLY
+ OUStringBuffer & insert(sal_Int32 offset, std::u16string_view str)
+ {
+ return insert( offset, str.data(), str.length() );
+ }
+#endif
OUStringBuffer & insert(sal_Int32 offset, const OUString & str)
{
return insert( offset, str.getStr(), str.getLength() );
@@ -1406,6 +1436,15 @@ public:
returned. If it does not occur as a substring starting
at fromIndex or beyond, -1 is returned.
*/
+#if defined LIBO_INTERNAL_ONLY
+ sal_Int32 indexOf( std::u16string_view str, sal_Int32 fromIndex = 0 ) const
+ {
+ assert( fromIndex >= 0 && fromIndex <= pData->length );
+ sal_Int32 ret = rtl_ustr_indexOfStr_WithLength( pData->buffer+fromIndex, pData->length-fromIndex,
+ str.data(), str.length() );
+ return (ret < 0 ? ret : ret+fromIndex);
+ }
+#endif
sal_Int32 indexOf( const OUString & str, sal_Int32 fromIndex = 0 ) const
{
assert( fromIndex >= 0 && fromIndex <= pData->length );
@@ -1475,6 +1514,13 @@ public:
the last such substring is returned. If it does not occur as
a substring, -1 is returned.
*/
+#if defined LIBO_INTERNAL_ONLY
+ sal_Int32 lastIndexOf( std::u16string_view str ) const
+ {
+ return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
+ str.data(), str.length() );
+ }
+#endif
sal_Int32 lastIndexOf( const OUString & str ) const
{
return rtl_ustr_lastIndexOfStr_WithLength( pData->buffer, pData->length,
@@ -1607,6 +1653,47 @@ public:
{
return stripStart(c) + stripEnd(c);
}
+
+#if defined LIBO_INTERNAL_ONLY
+ /**
+ Returns a std::u16string_view that is a view of a substring of this string.
+
+ The substring begins at the specified beginIndex. If
+ beginIndex is negative or be greater than the length of
+ this string, behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex ) const
+ {
+ assert(beginIndex >= 0);
+ assert(beginIndex <= getLength());
+ return subView(beginIndex, getLength() - beginIndex);
+ }
+
+ /**
+ Returns a std::u16string_view that is a view of a substring of this string.
+
+ The substring begins at the specified beginIndex and contains count
+ characters. If either beginIndex or count are negative,
+ or beginIndex + count are greater than the length of this string
+ then behaviour is undefined.
+
+ @param beginIndex the beginning index, inclusive.
+ @param count the number of characters.
+ @return the specified substring.
+ */
+ SAL_WARN_UNUSED_RESULT std::u16string_view subView( sal_Int32 beginIndex, sal_Int32 count ) const
+ {
+ assert(beginIndex >= 0);
+ assert(count >= 0);
+ assert(beginIndex <= getLength());
+ assert(count <= getLength() - beginIndex);
+ return std::u16string_view(pData->buffer, sal_uInt32(pData->length)).substr(beginIndex, count);
+ }
+#endif
+
/**
Returns a new string buffer that is a substring of this string.
diff --git a/l10ntools/source/helper.cxx b/l10ntools/source/helper.cxx
index 80b079e27151..2dce070b90fc 100644
--- a/l10ntools/source/helper.cxx
+++ b/l10ntools/source/helper.cxx
@@ -25,7 +25,7 @@ OString escapeAll(
sal_Int32 nUnEscapedOne = rUnEscaped.indexOf(rText[nIndex]);
if( nUnEscapedOne != -1 )
{
- sReturn.append(rEscaped.copy(nUnEscapedOne*2,2));
+ sReturn.append(rEscaped.subView(nUnEscapedOne*2,2));
}
else
sReturn.append(rText[nIndex]);
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 3cb8c8df2657..3401a7429658 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -93,14 +93,14 @@ void handleCommand(
{
auto const env = getenv("SRC_ROOT");
assert(env != nullptr);
- buf.append(OString(env));
+ buf.append(env);
buf.append("/solenv/bin/");
}
else
{
auto const env = getenv("WORKDIR_FOR_BUILD");
assert(env != nullptr);
- buf.append(OString(env));
+ buf.append(env);
buf.append("/LinkTarget/Executable/");
}
buf.append(rExecutable.data());
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index 7b8a1cacb3c1..8d47a7d39410 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -116,7 +116,7 @@ namespace
}
GenPoEntry::GenPoEntry()
- : m_sExtractCom( OString() )
+ : m_sExtractCom()
, m_sReferences( std::vector<OString>() )
, m_sMsgCtxt( OString() )
, m_sMsgId( OString() )
@@ -181,7 +181,7 @@ void GenPoEntry::readFromFile(std::ifstream& rIFStream)
{
m_sExtractCom.append("\n");
}
- m_sExtractCom.append(sLine.copy(3));
+ m_sExtractCom.append(sLine.subView(3));
}
else if (sLine.startsWith("#: "))
{
diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx
index fe9906a260a6..4036d0c2d5b0 100644
--- a/linguistic/source/hyphdsp.cxx
+++ b/linguistic/source/hyphdsp.cxx
@@ -161,7 +161,7 @@ Reference<XHyphenatedWord> HyphenatorDispatcher::buildHyphWord(
if (endhyphpat > -1)
{
OUStringBuffer aTmp2 ( aTmp.copy(0, std::max (nHyphenationPos + 1 - split, 0) ) );
- aTmp2.append( aText.copy( nOrigHyphPos + 1, endhyphpat - nOrigHyphPos - 1) );
+ aTmp2.append( aText.subView( nOrigHyphPos + 1, endhyphpat - nOrigHyphPos - 1) );
nHyphenPos = aTmp2.getLength();
aTmp2.append( aTmp.copy( nHyphenationPos + 1 ) );
//! take care of #i22591#
diff --git a/lotuswordpro/source/filter/lwptools.cxx b/lotuswordpro/source/filter/lwptools.cxx
index 6c84aaab51eb..254d7fc7f6eb 100644
--- a/lotuswordpro/source/filter/lwptools.cxx
+++ b/lotuswordpro/source/filter/lwptools.cxx
@@ -154,7 +154,7 @@ void LwpTools::QuickReadUnicode(LwpObjectStream* pObjStrm,
if(sublen)
{
unibuf[sublen] = '\0';
- strBuf.append( OUString(unibuf) );
+ strBuf.append( unibuf );
sublen = 0;
}
}
@@ -165,7 +165,7 @@ void LwpTools::QuickReadUnicode(LwpObjectStream* pObjStrm,
if(sublen>=1023 || readLen==strlen)
{
unibuf[sublen] = '\0';
- strBuf.append( OUString(unibuf) );
+ strBuf.append( unibuf );
sublen = 0;
}
}
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index c6d61bb21186..a60512e5a587 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -1966,7 +1966,7 @@ void OutputObjectBase::writeStringItem( const String& rName, const OUString& rDa
mxOut->writeAscii( "(len=" );
mxOut->writeDec( rData.getLength() );
mxOut->writeAscii( ")," );
- OUStringBuffer aValue( rData.copy( 0, ::std::min( rData.getLength(), OOX_DUMP_MAXSTRLEN ) ) );
+ OUStringBuffer aValue( rData.subView( 0, ::std::min( rData.getLength(), OOX_DUMP_MAXSTRLEN ) ) );
StringHelper::enclose( aValue, OOX_DUMP_STRQUOTE );
mxOut->writeString( aValue.makeStringAndClear() );
if( rData.getLength() > OOX_DUMP_MAXSTRLEN )
diff --git a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx
index 80643df2eba0..2a4f35e2e793 100644
--- a/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx
+++ b/sal/qa/rtl/oustringbuffer/test_oustringbuffer_utf32.cxx
@@ -86,13 +86,13 @@ void test::oustringbuffer::Utf32::appendUtf32() {
int const str3Len = 6;
sal_Unicode const str3[str3Len] = { 'a', 'b', 'c', 'd', 0xD800, 0xDC00 };
OStringBuffer message;
- OUStringBuffer buf1(OUString(str1, str1Len));
+ OUStringBuffer buf1(std::u16string_view(str1, str1Len));
buf1.appendUtf32('d');
OUString res1(buf1.makeStringAndClear());
createMessage(message, res1, OUString(str2, str2Len));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
message.getStr(), OUString(str2, str2Len), res1);
- OUStringBuffer buf2(OUString(str2, str2Len));
+ OUStringBuffer buf2(std::u16string_view(str2, str2Len));
buf2.appendUtf32(0x10000);
OUString res2(buf2.makeStringAndClear());
createMessage(message, res2, OUString(str3, str3Len));
@@ -108,13 +108,13 @@ void test::oustringbuffer::Utf32::insertUtf32() {
int const str3Len = 6;
sal_Unicode const str3[str3Len] = { 'a', 'b', 0xDBFF, 0xDFFF, 'd', 'c' };
OStringBuffer message;
- OUStringBuffer buf1(OUString(str1, str1Len));
+ OUStringBuffer buf1(std::u16string_view(str1, str1Len));
buf1.insertUtf32(2, 'd');
OUString res1(buf1.makeStringAndClear());
createMessage(message, res1, OUString(str2, str2Len));
CPPUNIT_ASSERT_EQUAL_MESSAGE(
message.getStr(), OUString(str2, str2Len), res1);
- OUStringBuffer buf2(OUString(str2, str2Len));
+ OUStringBuffer buf2(std::u16string_view(str2, str2Len));
buf2.insertUtf32(2, 0x10FFFF);
OUString res2(buf2.makeStringAndClear());
createMessage(message, res2, OUString(str3, str3Len));
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index c7a16a8aeb49..f3ab5f917f9d 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -57,7 +57,7 @@ const sal_Unicode* parseQuotedNameWithBuffer( const sal_Unicode* pStart, const s
// Push all the characters up to the current, but skip the very first
// character which is the opening quote.
- OUStringBuffer aBuf(OUString(pStart+1, p-pStart-1));
+ OUStringBuffer aBuf(std::u16string_view(pStart+1, p-pStart-1));
++p; // Skip the 2nd quote.
sal_Unicode cPrev = 0;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 32ff094ab348..24c594667231 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1551,7 +1551,7 @@ struct ConventionXL_OOX : public ConventionXL_A1
{
rBuffer.append('\'');
ConventionXL_OOX::makeExternalDocStr( rBuffer, nFileId);
- rBuffer.append( aQuotedTab.copy(1));
+ rBuffer.append( aQuotedTab.subView(1));
}
else
{
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index dfcdb30875ee..401ad6ad5722 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -809,7 +809,7 @@ void ScRangeStringConverter::GetStringFromXMLRangeString( OUString& rString, con
{
// initialize buffer with table name...
sal_Int32 nDotPos = IndexOf(aBeginCell, '.', 0);
- OUStringBuffer aBuf = aBeginCell.copy(0, nDotPos);
+ OUStringBuffer aBuf(aBeginCell.subView(0, nDotPos));
if (nEndCellDotPos == 0)
{
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index be95f26b06a4..2e68d4ba57ec 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -358,7 +358,7 @@ TOPIC DifParser::GetNextTopic()
OSL_ENSURE( aLine.getLength() >= 2,
"+GetNextTopic(): <String> is too short!" );
if( aLine.getLength() > 2 )
- m_aData.append(aLine.copy(1, aLine.getLength() - 2));
+ m_aData.append(aLine.subView(1, aLine.getLength() - 2));
else
m_aData.truncate();
eS = S_END;
@@ -530,7 +530,7 @@ DATASET DifParser::GetNextDataset()
// Single line string
if( nLineLength >= 2 && pLine[nLineLength - 1] == '"' )
{
- m_aData = aLine.copy( 1, nLineLength - 2 );
+ m_aData = aLine.subView( 1, nLineLength - 2 );
lcl_DeEscapeQuotesDif(m_aData);
eRet = D_STRING;
}
@@ -538,7 +538,7 @@ DATASET DifParser::GetNextDataset()
else
{
// Multiline string
- m_aData = aLine.copy( 1 );
+ m_aData = aLine.subView( 1 );
bool bContinue = true;
while ( bContinue )
{
@@ -557,7 +557,7 @@ DATASET DifParser::GetNextDataset()
}
else if( pLine[nLineLength - 1] == '"' )
{
- m_aData.append(aLine.copy(0, nLineLength -1));
+ m_aData.append(aLine.subView(0, nLineLength -1));
lcl_DeEscapeQuotesDif(m_aData);
eRet = D_STRING;
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index df8569b13dc6..85a34f28e842 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1966,7 +1966,7 @@ OUString SvNumberformat::StripNewCurrencyDelimiters( const OUString& rStr )
sal_Int32 nEnd;
if ( (nEnd = GetQuoteEnd( rStr, nPos )) >= 0 )
{
- aTmp.append(rStr.copy( nStartPos, ++nEnd - nStartPos ));
+ aTmp.append(rStr.subView( nStartPos, ++nEnd - nStartPos ));
nStartPos = nEnd;
}
else
@@ -2651,7 +2651,7 @@ bool SvNumberformat::ImpGetScientificOutput(double fNumber,
++nExpStart;
break;
}
- ExpStr = sStr.toString().copy( nExpStart ); // part following the "E+"
+ ExpStr = sStr.subView( nExpStart ); // part following the "E+"
sStr.truncate( nExPos );
if ( rInfo.nCntPre != 1 ) // rescale Exp
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 5edbf931b927..c3f97d89c949 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -887,7 +887,7 @@ short ImpSvNumberformatScan::Next_Symbol( const OUString& rStr,
{
nLen = sKeyword[eType].getLength();
// Preserve a locale's keyword's case as entered.
- sSymbolBuffer = rStr.copy( nPos-1, nLen);
+ sSymbolBuffer = rStr.subView( nPos-1, nLen);
}
if ((eType == NF_KEY_E || IsAmbiguousE(eType)) && nPos < rStr.getLength())
{
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index c06ea3ef2713..6a63cc26500b 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -918,7 +918,7 @@ static TextFrameIndex UpdateMergedParaForInsert(MergedPara & rMerged,
if (it->nStart <= nIndex && nIndex <= it->nEnd)
{ // note: this can happen only once
text.insert(nTFIndex + (nIndex - it->nStart),
- rNode.GetText().copy(nIndex, nLen));
+ rNode.GetText().subView(nIndex, nLen));
it->nEnd += nLen;
nInserted = nLen;
assert(!bInserted);
@@ -945,7 +945,7 @@ static TextFrameIndex UpdateMergedParaForInsert(MergedPara & rMerged,
if (nIndex < it->nStart)
{
text.insert(nTFIndex,
- rNode.GetText().copy(nIndex, it->nStart - nIndex));
+ rNode.GetText().subView(nIndex, it->nStart - nIndex));
nInserted += it->nStart - nIndex;
it->nStart = nIndex;
bInserted = true;
@@ -963,7 +963,7 @@ static TextFrameIndex UpdateMergedParaForInsert(MergedPara & rMerged,
if (pNext && pNext->nStart <= nIndex + nLen)
{
text.insert(nTFIndex,
- rNode.GetText().copy(it->nEnd, pNext->nStart - it->nEnd));
+ rNode.GetText().subView(it->nEnd, pNext->nStart - it->nEnd));
nTFIndex += pNext->nStart - it->nEnd;
nInserted += pNext->nStart - it->nEnd;
pNext->nStart = it->nStart;
@@ -972,7 +972,7 @@ static TextFrameIndex UpdateMergedParaForInsert(MergedPara & rMerged,
else
{
text.insert(nTFIndex,
- rNode.GetText().copy(it->nEnd, nIndex + nLen - it->nEnd));
+ rNode.GetText().subView(it->nEnd, nIndex + nLen - it->nEnd));
nTFIndex += nIndex + nLen - it->nEnd;
nInserted += nIndex + nLen - it->nEnd;
it->nEnd = nIndex + nLen;
@@ -1000,7 +1000,7 @@ static TextFrameIndex UpdateMergedParaForInsert(MergedPara & rMerged,
if (!bInserted)
{ // must be in a gap
rMerged.extents.emplace(itInsert, const_cast<SwTextNode*>(&rNode), nIndex, nIndex + nLen);
- text.insert(nTFIndex, rNode.GetText().copy(nIndex, nLen));
+ text.insert(nTFIndex, rNode.GetText().subView(nIndex, nLen));
nInserted = nLen;
if (rMerged.extents.size() == 1 // also if it was empty!
|| rMerged.pParaPropsNode->GetIndex() < rNode.GetIndex())
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 57b30d59cb45..9575652feec1 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3355,7 +3355,7 @@ OUString SwTextNode::GetExpandText(SwRootFrame const*const pLayout,
const sal_Int32 nExpandBegin = aConversionMap.ConvertToViewPosition( nIdx );
sal_Int32 nEnd = nLen == -1 ? GetText().getLength() : nIdx + nLen;
const sal_Int32 nExpandEnd = aConversionMap.ConvertToViewPosition( nEnd );
- OUStringBuffer aText(aExpandText.copy(nExpandBegin, nExpandEnd-nExpandBegin));
+ OUStringBuffer aText(aExpandText.subView(nExpandBegin, nExpandEnd-nExpandBegin));
// remove dummy characters of Input Fields
comphelper::string::remove(aText, CH_TXT_ATR_INPUTFIELDSTART);
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index da433d4272e0..4b5086983d1e 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -316,14 +316,14 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
{
if (nNextAttr <= curRedline.first)
{
- buf.append(aStr.copy(nStrPos, nNextAttr - nStrPos));
+ buf.append(aStr.subView(nStrPos, nNextAttr - nStrPos));
break;
}
else if (nStrPos < curRedline.second)
{
if (nStrPos < curRedline.first)
{
- buf.append(aStr.copy(nStrPos, curRedline.first - nStrPos));
+ buf.append(aStr.subView(nStrPos, curRedline.first - nStrPos));
}
if (curRedline.second <= nNextAttr)
{
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 215bea673cb2..f7265523b6e2 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -1290,7 +1290,7 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody)
bDone = true;
break;
}
- sText.append(rBody.copy(
+ sText.append(rBody.subView(
(pEncodedTextCopyBegin - pBegin),
(q - 1 - pEncodedTextCopyBegin)));
sText.append(char(nDigit1 << 4 | nDigit2));
@@ -1301,7 +1301,7 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody)
case '?':
if (q - pEncodedTextBegin > 1)
- sText.append(rBody.copy(
+ sText.append(rBody.subView(
(pEncodedTextCopyBegin - pBegin),
(q - 1 - pEncodedTextCopyBegin)));
else
@@ -1310,7 +1310,7 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody)
break;
case '_':
- sText.append(rBody.copy(
+ sText.append(rBody.subView(
(pEncodedTextCopyBegin - pBegin),
(q - 1 - pEncodedTextCopyBegin)));
sText.append(' ');
diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index 4d0a7b26fc3e..2f88d029e721 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -728,7 +728,7 @@ BaseContent::setPropertyValues(
"Invalid URL!" );
OUStringBuffer aBuf(
- m_aUncPath.copy( 0, nLastSlash + 1 ) );
+ m_aUncPath.subView( 0, nLastSlash + 1 ) );
if ( !NewTitle.isEmpty() )
{
diff --git a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx
index cf03274c5952..2b7eafb0210b 100644
--- a/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx
@@ -63,17 +63,17 @@ namespace
inXML[ end - 1 ] == '/' )
{
// copy from original buffer - preserve case.
- buf.append( in.copy( start, end - start ) );
+ buf.append( in.subView( start, end - start ) );
}
else
{
// copy from original buffer - preserve case.
- buf.append( in.copy( start, end - start + 4 ) );
+ buf.append( in.subView( start, end - start + 4 ) );
}
start = end + 4;
end = inXML.indexOf( "dav:", start );
}
- buf.append( inXML.copy( start ) );
+ buf.append( inXML.subView( start ) );
return buf.makeStringAndClear();
}
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 5699124a9cde..93fb2151d25f 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2077,7 +2077,7 @@ void Edit::Command( const CommandEvent& rCEvt )
{
// restore old characters
const sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen;
- maText.insert( mpIMEInfos->nPos + nNewIMETextLen, mpIMEInfos->aOldTextAfterStartPos.copy( nNewIMETextLen, nRestore ) );
+ maText.insert( mpIMEInfos->nPos + nNewIMETextLen, mpIMEInfos->aOldTextAfterStartPos.subView( nNewIMETextLen, nRestore ) );
}
else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx
index 5025c1d68ef0..e141ce610741 100644
--- a/vcl/source/control/longcurr.cxx
+++ b/vcl/source/control/longcurr.cxx
@@ -119,7 +119,7 @@ bool ImplCurrencyGetValue( const OUString& rStr, BigInt& rValue,
if ( nDecPos != -1 )
{
- aStr1 = aStr.copy( 0, nDecPos );
+ aStr1 = aStr.subView( 0, nDecPos );
aStr2.append(std::u16string_view(aStr).substr(nDecPos+1));
}
else
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 5211bb56ecc1..4cc062295d1c 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1302,7 +1302,7 @@ OUString SvTreeListBox::SearchEntryTextWithHeadTitle( SvTreeListEntry* pEntry )
}
if (!sRet.isEmpty())
- sRet = sRet.copy(0, sRet.getLength() - 1);
+ sRet.remove(sRet.getLength() - 1, 1);
return sRet.makeStringAndClear();
}
diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx
index 14721440bf9b..6e2a485ca828 100644
--- a/xmloff/source/meta/xmlmetai.cxx
+++ b/xmloff/source/meta/xmlmetai.cxx
@@ -244,7 +244,7 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno:
if ( nEnd != -1 )
{
OUStringBuffer sBuffer(
- i_rBuildId.copy( nBegin+1, nEnd-nBegin-1 ) );
+ i_rBuildId.subView( nBegin+1, nEnd-nBegin-1 ) );
const OUString sBuildCompare(
"$Build-" );
nBegin = i_rBuildId.indexOf( sBuildCompare, nEnd );
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index 1e54872ada83..652ff02b6a2b 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -1832,9 +1832,9 @@ void SvXMLNumFormatContext::AddCurrency( const OUString& rContent, LanguageType
// remove both quotes from aFormatCode
OUString aOld = aFormatCode.makeStringAndClear();
if ( nFirst > 0 )
- aFormatCode.append( aOld.copy( 0, nFirst ) );
+ aFormatCode.append( aOld.subView( 0, nFirst ) );
if ( nLength > nFirst + 2 )
- aFormatCode.append( aOld.copy( nFirst + 1, nLength - nFirst - 2 ) );
+ aFormatCode.append( aOld.subView( nFirst + 1, nLength - nFirst - 2 ) );
}
}
}