summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-11 17:44:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-11 21:25:10 +0100
commit35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch)
treebb78f4f13f131f0cb206a9707cc3cfc495a3876a /sc
parent0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff)
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/formulalogger.hxx3
-rw-r--r--sc/qa/unit/helper/csv_handler.hxx6
-rw-r--r--sc/source/core/tool/address.cxx2
-rw-r--r--sc/source/core/tool/formulalogger.cxx2
-rw-r--r--sc/source/core/tool/interpr1.cxx2
-rw-r--r--sc/source/core/tool/interpr7.cxx5
-rw-r--r--sc/source/filter/excel/xelink.cxx9
-rw-r--r--sc/source/filter/excel/xestream.cxx2
-rw-r--r--sc/source/filter/excel/xestring.cxx7
-rw-r--r--sc/source/filter/html/htmlpars.cxx2
-rw-r--r--sc/source/filter/inc/htmlpars.hxx3
-rw-r--r--sc/source/filter/inc/xestream.hxx6
-rw-r--r--sc/source/filter/inc/xestring.hxx8
-rw-r--r--sc/source/filter/oox/numberformatsbuffer.cxx2
-rw-r--r--sc/source/ui/miscdlgs/mtrindlg.cxx4
15 files changed, 39 insertions, 24 deletions
diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx
index cfc01449c2a8..75b86e9f996d 100644
--- a/sc/inc/formulalogger.hxx
+++ b/sc/inc/formulalogger.hxx
@@ -11,6 +11,7 @@
#include <rtl/ustring.hxx>
#include <memory>
+#include <string_view>
#include <vector>
#include <config_options_calc.h>
@@ -45,7 +46,7 @@ class FormulaLogger
void writeAscii( const char* s );
void writeAscii( const char* s, size_t n );
- void write( const OUString& ou );
+ void write( std::u16string_view ou );
void write( sal_Int32 n );
void sync();
diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index 8d24c38edaa3..dafc8a931393 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -10,6 +10,10 @@
#ifndef INCLUDED_SC_QA_UNIT_HELPER_CSV_HANDLER_HXX
#define INCLUDED_SC_QA_UNIT_HELPER_CSV_HANDLER_HXX
+#include <sal/config.h>
+
+#include <string_view>
+
#include "qahelper.hxx"
#include <patattr.hxx>
@@ -45,7 +49,7 @@ inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab)
OString::number(nRow);
}
-inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rExpectedString, const OUString& rString)
+inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, std::u16string_view rExpectedString, std::u16string_view rString)
{
return createErrorMessage(nCol, nRow, nTab) + "; Expected: '"
+ OUStringToOString(rExpectedString, RTL_TEXTENCODING_UTF8) + "' Found: '"
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index e595e7003155..c7a16a8aeb49 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2007,7 +2007,7 @@ static void lcl_string_append(OUStringBuffer &rString, const OUString &sString)
rString.append(sString);
}
-static void lcl_string_append(OStringBuffer &rString, const OUString &sString)
+static void lcl_string_append(OStringBuffer &rString, std::u16string_view sString)
{
rString.append(OUStringToOString( sString, RTL_TEXTENCODING_UTF8 ));
}
diff --git a/sc/source/core/tool/formulalogger.cxx b/sc/source/core/tool/formulalogger.cxx
index f32017b4d4c3..46465b56195a 100644
--- a/sc/source/core/tool/formulalogger.cxx
+++ b/sc/source/core/tool/formulalogger.cxx
@@ -297,7 +297,7 @@ void FormulaLogger::writeAscii( const char* s, size_t n )
mpLogFile->write(s, n, nBytes);
}
-void FormulaLogger::write( const OUString& ou )
+void FormulaLogger::write( std::u16string_view ou )
{
OString s = OUStringToOString(ou, RTL_TEXTENCODING_UTF8).getStr();
writeAscii(s.getStr(), s.getLength());
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 38bcc983c36e..b55f1172f704 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3462,7 +3462,7 @@ void ScInterpreter::ScCode()
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |
RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |
RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE;
- PushInt( static_cast<unsigned char>(OUStringToOString(OUString(aStr[0]), osl_getThreadTextEncoding(), convertFlags).toChar()) );
+ PushInt( static_cast<unsigned char>(OUStringToOString(OUStringChar(aStr[0]), osl_getThreadTextEncoding(), convertFlags).toChar()) );
}
}
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index acdea080b7b0..d50a084acb75 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -30,6 +30,7 @@
#include <cstring>
#include <memory>
+#include <string_view>
using namespace com::sun::star;
@@ -178,13 +179,13 @@ void ScInterpreter::ScFilterXML()
xmlNsPtr ns = reinterpret_cast<xmlNsPtr>(pNodeSet->nodeTab[nNode]);
xmlNodePtr cur = reinterpret_cast<xmlNodePtr>(ns->next);
std::shared_ptr<xmlChar> pChar2(xmlNodeGetContent(cur), xmlFree);
- aResult = OStringToOUString(OString(reinterpret_cast<char*>(pChar2.get())), RTL_TEXTENCODING_UTF8);
+ aResult = OStringToOUString(std::string_view(reinterpret_cast<char*>(pChar2.get())), RTL_TEXTENCODING_UTF8);
}
else
{
xmlNodePtr cur = pNodeSet->nodeTab[nNode];
std::shared_ptr<xmlChar> pChar2(xmlNodeGetContent(cur), xmlFree);
- aResult = OStringToOUString(OString(reinterpret_cast<char*>(pChar2.get())), RTL_TEXTENCODING_UTF8);
+ aResult = OStringToOUString(std::string_view(reinterpret_cast<char*>(pChar2.get())), RTL_TEXTENCODING_UTF8);
}
if (xResMat)
xResMat->PutString( mrStrPool.intern( aResult), 0, nNode);
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 85afc7d6e307..c84cd6364dc4 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -38,6 +38,7 @@
#include <vector>
#include <memory>
+#include <string_view>
using ::std::unique_ptr;
using ::std::vector;
@@ -274,7 +275,7 @@ public:
private:
/** Initializes the record data with the passed encoded URL. */
- void Init( const OUString& rEncUrl );
+ void Init( std::u16string_view rEncUrl );
/** Writes the contents of the EXTERNSHEET record. */
virtual void WriteBody( XclExpStream& rStrm ) override;
@@ -1457,14 +1458,14 @@ void XclExpExternSheetBase::WriteExtNameBufferXml( XclExpXmlStream& rStrm )
XclExpExternSheet::XclExpExternSheet( const XclExpRoot& rRoot, sal_Unicode cCode ) :
XclExpExternSheetBase( rRoot, EXC_ID_EXTERNSHEET )
{
- Init( OUString(cCode) );
+ Init( OUStringChar(cCode) );
}
XclExpExternSheet::XclExpExternSheet( const XclExpRoot& rRoot, const OUString& rTabName ) :
XclExpExternSheetBase( rRoot, EXC_ID_EXTERNSHEET )
{
// reference to own sheet: \03<sheetname>
- Init(OUStringChar(EXC_EXTSH_TABNAME) + rTabName);
+ Init(OUString(OUStringChar(EXC_EXTSH_TABNAME) + rTabName));
}
void XclExpExternSheet::Save( XclExpStream& rStrm )
@@ -1475,7 +1476,7 @@ void XclExpExternSheet::Save( XclExpStream& rStrm )
WriteExtNameBuffer( rStrm );
}
-void XclExpExternSheet::Init( const OUString& rEncUrl )
+void XclExpExternSheet::Init( std::u16string_view rEncUrl )
{
OSL_ENSURE_BIFF( GetBiff() <= EXC_BIFF5 );
maTabName.AssignByte( rEncUrl, GetTextEncoding(), XclStrFlags::EightBitLength );
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index c0a2646461bf..f7b0c77f1381 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -932,7 +932,7 @@ sax_fastparser::FSHelperPtr XclExpXmlStream::GetStreamForPath( const OUString& s
return maOpenedStreamMap[ sPath ].second;
}
-void XclExpXmlStream::WriteAttribute(sal_Int32 nAttr, const OUString& sVal)
+void XclExpXmlStream::WriteAttribute(sal_Int32 nAttr, std::u16string_view sVal)
{
GetCurrentStream()->write(" ")->writeId(nAttr)->write("=\"")->writeEscaped(sVal)->write("\"");
}
diff --git a/sc/source/filter/excel/xestring.cxx b/sc/source/filter/excel/xestring.cxx
index ff5abf3c6a51..db85728ef7ef 100644
--- a/sc/source/filter/excel/xestring.cxx
+++ b/sc/source/filter/excel/xestring.cxx
@@ -119,7 +119,8 @@ void XclExpString::Assign( sal_Unicode cChar )
}
void XclExpString::AssignByte(
- const OUString& rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags, sal_uInt16 nMaxLen )
+ std::u16string_view rString, rtl_TextEncoding eTextEnc, XclStrFlags nFlags,
+ sal_uInt16 nMaxLen )
{
// length may differ from length of rString
OString aByteStr(OUStringToOString(rString, eTextEnc));
@@ -133,9 +134,9 @@ void XclExpString::Append( const OUString& rString )
BuildAppend( rString.getStr(), rString.getLength() );
}
-void XclExpString::AppendByte( const OUString& rString, rtl_TextEncoding eTextEnc )
+void XclExpString::AppendByte( std::u16string_view rString, rtl_TextEncoding eTextEnc )
{
- if (!rString.isEmpty())
+ if (!rString.empty())
{
// length may differ from length of rString
OString aByteStr(OUStringToOString(rString, eTextEnc));
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 0fa8aa59caac..13b00a60bb30 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -3091,7 +3091,7 @@ public:
}
-void ScHTMLQueryParser::ParseStyle(const OUString& rStrm)
+void ScHTMLQueryParser::ParseStyle(std::u16string_view rStrm)
{
OString aStr = OUStringToOString(rStrm, RTL_TEXTENCODING_UTF8);
CSSHandler aHdl;
diff --git a/sc/source/filter/inc/htmlpars.hxx b/sc/source/filter/inc/htmlpars.hxx
index 95243021d6d4..9e1c071a3238 100644
--- a/sc/source/filter/inc/htmlpars.hxx
+++ b/sc/source/filter/inc/htmlpars.hxx
@@ -23,6 +23,7 @@
#include <memory>
#include <map>
#include <stack>
+#include <string_view>
#include <unordered_map>
#include <vector>
#include <o3tl/sorted_vector.hxx>
@@ -600,7 +601,7 @@ private:
/** Closes the current table, regardless on opening tag. */
void CloseTable( const HtmlImportInfo& rInfo );
- static void ParseStyle(const OUString& rStrm);
+ static void ParseStyle(std::u16string_view rStrm);
DECL_LINK( HTMLImportHdl, HtmlImportInfo&, void );
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index bbcdf7740f4f..65245db83d77 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -22,6 +22,8 @@
#include <map>
#include <stack>
+#include <string_view>
+
#include <rtl/strbuf.hxx>
#include <oox/core/xmlfilterbase.hxx>
@@ -328,8 +330,8 @@ private:
virtual ::oox::ole::VbaProject* implCreateVbaProject() const override;
virtual OUString SAL_CALL getImplementationName() override;
ScDocShell *getDocShell();
- void WriteAttribute(sal_Int32 nAttr, const OUString& sVal);
- void WriteAttribute(sal_Int32 nAttr, const OString& sVal)
+ void WriteAttribute(sal_Int32 nAttr, std::u16string_view sVal);
+ void WriteAttribute(sal_Int32 nAttr, std::string_view sVal)
{
WriteAttribute(nAttr, OStringToOUString(sVal, RTL_TEXTENCODING_UTF8));
}
diff --git a/sc/source/filter/inc/xestring.hxx b/sc/source/filter/inc/xestring.hxx
index 9dfbe4be2b90..196ac4a83600 100644
--- a/sc/source/filter/inc/xestring.hxx
+++ b/sc/source/filter/inc/xestring.hxx
@@ -20,6 +20,10 @@
#ifndef INCLUDED_SC_SOURCE_FILTER_INC_XESTRING_HXX
#define INCLUDED_SC_SOURCE_FILTER_INC_XESTRING_HXX
+#include <sal/config.h>
+
+#include <string_view>
+
#include "xlstring.hxx"
#include "ftools.hxx"
@@ -78,7 +82,7 @@ public:
@param nFlags Modifiers for string export.
@param nMaxLen The maximum number of characters to store in this string. */
void AssignByte(
- const OUString& rString,
+ std::u16string_view rString,
rtl_TextEncoding eTextEnc,
XclStrFlags nFlags = XclStrFlags::NONE,
sal_uInt16 nMaxLen = EXC_STR_MAXLEN );
@@ -91,7 +95,7 @@ public:
/** Appends a string. Uses the string flags used in constructor or last Assign().
@descr This object must be a BIFF2-BIFF7 byte string. */
- void AppendByte( const OUString& rString, rtl_TextEncoding eTextEnc );
+ void AppendByte( std::u16string_view rString, rtl_TextEncoding eTextEnc );
/** Appends a character. Uses the string flags used in constructor or last Assign().
@descr This object must be a BIFF2-BIFF7 byte string. */
void AppendByte( sal_Unicode cChar, rtl_TextEncoding eTextEnc );
diff --git a/sc/source/filter/oox/numberformatsbuffer.cxx b/sc/source/filter/oox/numberformatsbuffer.cxx
index 922b0ccb93a1..70146cd0747c 100644
--- a/sc/source/filter/oox/numberformatsbuffer.cxx
+++ b/sc/source/filter/oox/numberformatsbuffer.cxx
@@ -1934,7 +1934,7 @@ void NumberFormat::setFormatCode( const OUString& rFmtCode )
void NumberFormat::setFormatCode( const Locale& rLocale, const char* pcFmtCode )
{
maModel.maLocale = rLocale;
- maModel.maFmtCode = OStringToOUString( OString( pcFmtCode ), RTL_TEXTENCODING_UTF8 );
+ maModel.maFmtCode = OStringToOUString( std::string_view( pcFmtCode ), RTL_TEXTENCODING_UTF8 );
maModel.mnPredefId = -1;
}
diff --git a/sc/source/ui/miscdlgs/mtrindlg.cxx b/sc/source/ui/miscdlgs/mtrindlg.cxx
index 4226be64eee7..b7b3a43beb59 100644
--- a/sc/source/ui/miscdlgs/mtrindlg.cxx
+++ b/sc/source/ui/miscdlgs/mtrindlg.cxx
@@ -30,8 +30,8 @@ ScMetricInputDlg::ScMetricInputDlg( weld::Window* pParent,
tools::Long nMaximum,
tools::Long nMinimum)
- : GenericDialogController(pParent, OStringToOUString("modules/scalc/ui/" +
- sDialogName.toAsciiLowerCase() + ".ui", RTL_TEXTENCODING_UTF8), sDialogName)
+ : GenericDialogController(pParent, "modules/scalc/ui/" + OStringToOUString(
+ sDialogName.toAsciiLowerCase(), RTL_TEXTENCODING_UTF8) + ".ui", sDialogName)
, m_xEdValue(m_xBuilder->weld_metric_spin_button("value", FieldUnit::CM))
, m_xBtnDefVal(m_xBuilder->weld_check_button("default"))
{