summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/inc/dp_misc.h8
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx2
-rw-r--r--desktop/source/app/dispatchwatcher.cxx3
-rw-r--r--desktop/source/deployment/manager/dp_activepackages.cxx5
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx8
-rw-r--r--desktop/source/lib/init.cxx10
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_app.cxx14
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx20
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_misc.cxx22
9 files changed, 50 insertions, 42 deletions
diff --git a/desktop/inc/dp_misc.h b/desktop/inc/dp_misc.h
index 2953cd53cfde..0d9eadb90cb3 100644
--- a/desktop/inc/dp_misc.h
+++ b/desktop/inc/dp_misc.h
@@ -19,6 +19,10 @@
#pragma once
+#include <sal/config.h>
+
+#include <string_view>
+
#include <osl/mutex.hxx>
#include <osl/process.h>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -106,13 +110,13 @@ oslProcess raiseProcess( OUString const & appURL,
as target encoding.
*/
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-void writeConsole(OUString const & sText);
+void writeConsole(std::u16string_view sText);
/** writes the argument to the console using the error stream.
Otherwise the same as writeConsole.
*/
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
-void writeConsoleError(OUString const & sText);
+void writeConsoleError(std::u16string_view sText);
/** reads from the console.
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8a5b3f54d81a..82586de384b1 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2084,7 +2084,7 @@ void DesktopLOKTest::testGetFontSubset()
rtl_UriEncodeKeepEscapes,
RTL_TEXTENCODING_UTF8
);
- OString aCommand = OUStringToOString(".uno:FontSubset&name=" + aFontName, RTL_TEXTENCODING_UTF8);
+ OString aCommand = ".uno:FontSubset&name=" + OUStringToOString(aFontName, RTL_TEXTENCODING_UTF8);
boost::property_tree::ptree aTree;
char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, aCommand.getStr());
std::stringstream aStream(pJSON);
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 50b92ecb7834..9ab77f399ec4 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -61,6 +61,7 @@
#include <osl/thread.hxx>
#include <osl/file.hxx>
#include <iostream>
+#include <string_view>
using namespace ::osl;
using namespace ::com::sun::star::uno;
@@ -89,7 +90,7 @@ struct DispatchHolder
Reference< XDispatch > xDispatch;
};
-std::shared_ptr<const SfxFilter> impl_lookupExportFilterForUrl( const OUString& rUrl, const OUString& rFactory )
+std::shared_ptr<const SfxFilter> impl_lookupExportFilterForUrl( std::u16string_view rUrl, const OUString& rFactory )
{
// create the list of filters
OUStringBuffer sQuery(256);
diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx
index b301bc5ad22b..c1c5f2b28dba 100644
--- a/desktop/source/deployment/manager/dp_activepackages.cxx
+++ b/desktop/source/deployment/manager/dp_activepackages.cxx
@@ -21,6 +21,7 @@
#include <sal/config.h>
+#include <string_view>
#include <utility>
#include <osl/diagnose.h>
@@ -44,11 +45,11 @@ namespace {
constexpr const char separator[] = "\xff";
-OString oldKey(OUString const & fileName) {
+OString oldKey(std::u16string_view fileName) {
return OUStringToOString(fileName, RTL_TEXTENCODING_UTF8);
}
-OString newKey(OUString const & id) {
+OString newKey(std::u16string_view id) {
return separator + OUStringToOString(id, RTL_TEXTENCODING_UTF8);
}
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 21b9d4b4496b..81785e536a40 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -455,19 +455,19 @@ Reference<XInterface> resolveUnoURL(
return nullptr; // warning C4715
}
-static void writeConsoleWithStream(OUString const & sText, FILE * stream)
+static void writeConsoleWithStream(std::u16string_view sText, FILE * stream)
{
OString s = OUStringToOString(sText, osl_getThreadTextEncoding());
fprintf(stream, "%s", s.getStr());
fflush(stream);
}
-void writeConsole(OUString const & sText)
+void writeConsole(std::u16string_view sText)
{
writeConsoleWithStream(sText, stdout);
}
-void writeConsoleError(OUString const & sText)
+void writeConsoleError(std::u16string_view sText)
{
writeConsoleWithStream(sText, stderr);
}
@@ -479,7 +479,7 @@ OUString readConsole()
// read one char less so that the last char in buf is always zero
if (fgets(buf, 1024, stdin) != nullptr)
{
- OUString value = OStringToOUString(OString(buf), osl_getThreadTextEncoding());
+ OUString value = OStringToOUString(std::string_view(buf), osl_getThreadTextEncoding());
return value.trim();
}
throw css::uno::RuntimeException("reading from stdin failed");
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e1e8ac652d3f..cc2cee9913c0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -31,6 +31,8 @@
#include <algorithm>
#include <memory>
#include <iostream>
+#include <string_view>
+
#include <boost/property_tree/json_parser.hpp>
#include <boost/algorithm/string.hpp>
@@ -283,7 +285,7 @@ static char *convertOString(const OString &rStr)
return pMemory;
}
-static char *convertOUString(const OUString &aStr)
+static char *convertOUString(std::u16string_view aStr)
{
return convertOString(OUStringToOString(aStr, RTL_TEXTENCODING_UTF8));
}
@@ -3492,7 +3494,7 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig
return;
}
- SfxLokHelper::postExtTextEventAsync(pWindow, nType, OUString::fromUtf8(OString(pText, strlen(pText))));
+ SfxLokHelper::postExtTextEventAsync(pWindow, nType, OUString::fromUtf8(std::string_view(pText, strlen(pText))));
}
static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter)
@@ -4584,7 +4586,7 @@ static char* getFonts (const char* pCommand)
return pJson;
}
-static char* getFontSubset (const OString& aFontName)
+static char* getFontSubset (std::string_view aFontName)
{
OUString aFoundFont(::rtl::Uri::decode(OStringToOUString(aFontName, RTL_TEXTENCODING_UTF8), rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8));
SfxObjectShell* pDocSh = SfxObjectShell::Current();
@@ -5053,7 +5055,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
}
else if (aCommand.startsWith(aFontSubset))
{
- return getFontSubset(OString(pCommand + aFontSubset.getLength()));
+ return getFontSubset(std::string_view(pCommand + aFontSubset.getLength()));
}
else
{
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index 53b2a23aec91..857902dd4f4e 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -70,8 +70,8 @@ struct ExtensionName
};
-const char s_usingText [] =
-"\n"
+const char16_t s_usingText [] =
+u"\n"
"using: " APP_NAME " add <options> extension-path...\n"
" " APP_NAME " validate <options> extension-identifier...\n"
" " APP_NAME " remove <options> extension-identifier...\n"
@@ -231,7 +231,7 @@ extern "C" int unopkg_main()
return 0;
}
else if (isOption( info_version, &nPos )) {
- dp_misc::writeConsole("\n" APP_NAME " Version 3.3\n");
+ dp_misc::writeConsole(u"\n" APP_NAME " Version 3.3\n");
return 0;
}
//consume all bootstrap variables which may occur before the sub-command
@@ -271,12 +271,12 @@ extern "C" int unopkg_main()
if (cmdArg[ 0 ] == '-')
{
// is option:
- dp_misc::writeConsoleError(
+ dp_misc::writeConsoleError(OUString(
"\nERROR: unexpected option " +
cmdArg +
"!\n Use " APP_NAME " " +
toString(info_help) +
- " to print all options.\n");
+ " to print all options.\n"));
return 1;
}
else
@@ -478,7 +478,7 @@ extern "C" int unopkg_main()
vec_packages.size(), false);
dp_misc::writeConsole(
- "All deployed " + repository + " extensions:\n\n");
+ OUString("All deployed " + repository + " extensions:\n\n"));
}
else
{
@@ -612,7 +612,7 @@ extern "C" int unopkg_main()
catch (const LockFileException & e)
{
// No logger since it requires UNO which we don't have here
- dp_misc::writeConsoleError(e.Message + "\n");
+ dp_misc::writeConsoleError(OUString(e.Message + "\n"));
bShowFailedMsg = false;
}
catch (const css::uno::Exception & e ) {
diff --git a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
index 98a957c014e8..1d4907b9a263 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_cmdenv.cxx
@@ -139,9 +139,9 @@ void CommandEnvironmentImpl::printLicense(
OUString sNewLine("\n");
- dp_misc::writeConsole(sNewLine + sNewLine + s1 + sNewLine + sNewLine);
- dp_misc::writeConsole(sLicense + sNewLine + sNewLine);
- dp_misc::writeConsole(s2 + sNewLine);
+ dp_misc::writeConsole(OUString(sNewLine + sNewLine + s1 + sNewLine + sNewLine));
+ dp_misc::writeConsole(OUString(sLicense + sNewLine + sNewLine));
+ dp_misc::writeConsole(OUString(s2 + sNewLine));
dp_misc::writeConsole(s3);
//the user may enter "yes" or "no", we compare in a case insensitive way
@@ -168,7 +168,7 @@ void CommandEnvironmentImpl::printLicense(
}
else
{
- dp_misc::writeConsole(sNewLine + sNewLine + s4 + sNewLine);
+ dp_misc::writeConsole(OUString(sNewLine + sNewLine + s4 + sNewLine));
}
}
while(true);
@@ -254,7 +254,7 @@ void CommandEnvironmentImpl::handle(
{
OUString sMsg(DpResId(RID_STR_UNSUPPORTED_PLATFORM));
sMsg = sMsg.replaceAll("%Name", platExc.package->getDisplayName());
- dp_misc::writeConsole("\n" + sMsg + "\n\n");
+ dp_misc::writeConsole(OUString("\n" + sMsg + "\n\n"));
approve = true;
}
else {
@@ -272,7 +272,7 @@ void CommandEnvironmentImpl::handle(
if (abort && m_option_verbose)
{
OUString msg = ::comphelper::anyToString(request);
- dp_misc::writeConsoleError("\nERROR: " + msg + "\n");
+ dp_misc::writeConsoleError(OUString("\nERROR: " + msg + "\n"));
}
// select:
@@ -339,15 +339,15 @@ void CommandEnvironmentImpl::update_( Any const & Status )
for ( sal_Int32 n = 0; n < m_logLevel; ++n )
{
if (bUseErr)
- dp_misc::writeConsoleError(" ");
+ dp_misc::writeConsoleError(u" ");
else
- dp_misc::writeConsole(" ");
+ dp_misc::writeConsole(u" ");
}
if (bUseErr)
- dp_misc::writeConsoleError(msg + "\n");
+ dp_misc::writeConsoleError(OUString(msg + "\n"));
else
- dp_misc::writeConsole(msg + "\n");
+ dp_misc::writeConsole(OUString(msg + "\n"));
}
diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
index f4c691fec9aa..3b16dc59855e 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx
@@ -227,7 +227,7 @@ namespace {
void printf_space( sal_Int32 space )
{
while (space--)
- dp_misc::writeConsole(" ");
+ dp_misc::writeConsole(u" ");
}
@@ -235,7 +235,7 @@ void printf_line(
OUString const & name, OUString const & value, sal_Int32 level )
{
printf_space( level );
- dp_misc::writeConsole(name + ": " + value + "\n");
+ dp_misc::writeConsole(OUString(name + ": " + value + "\n"));
}
@@ -282,13 +282,13 @@ void printf_package(
Sequence< Reference<deployment::XPackage> > seq(
xPackage->getBundle( Reference<task::XAbortChannel>(), xCmdEnv ) );
printf_space( level + 1 );
- dp_misc::writeConsole("bundled Packages: {\n");
+ dp_misc::writeConsole(u"bundled Packages: {\n");
std::vector<Reference<deployment::XPackage> >vec_bundle;
::comphelper::sequenceToContainer(vec_bundle, seq);
printf_packages( vec_bundle, std::vector<bool>(vec_bundle.size()),
xCmdEnv, level + 2 );
printf_space( level + 1 );
- dp_misc::writeConsole("}\n");
+ dp_misc::writeConsole(u"}\n");
}
} // anon namespace
@@ -300,7 +300,7 @@ static void printf_unaccepted_licenses(
dp_misc::getIdentifier(ext) );
printf_line( "Identifier", id, 0 );
printf_space(1);
- dp_misc::writeConsole("License not accepted\n\n");
+ dp_misc::writeConsole(u"License not accepted\n\n");
}
@@ -314,7 +314,7 @@ void printf_packages(
if (allExtensions.empty())
{
printf_space( level );
- dp_misc::writeConsole("<none>\n");
+ dp_misc::writeConsole(u"<none>\n");
}
else
{
@@ -325,7 +325,7 @@ void printf_packages(
printf_unaccepted_licenses(extension);
else
printf_package( extension, xCmdEnv, level );
- dp_misc::writeConsole("\n");
+ dp_misc::writeConsole(u"\n");
++index;
}
}
@@ -365,16 +365,16 @@ Reference<XComponentContext> connectToOffice(
if (verbose)
{
- dp_misc::writeConsole(
+ dp_misc::writeConsole(OUString(
"Raising process: " + appURL +
"\nArguments: --nologo --nodefault " + args[2] +
- "\n");
+ "\n"));
}
::dp_misc::raiseProcess( appURL, args );
if (verbose)
- dp_misc::writeConsole("OK. Connecting...");
+ dp_misc::writeConsole(u"OK. Connecting...");
OUString sUnoUrl = "uno:pipe,name=" + pipeId + ";urp;StarOffice.ComponentContext";
Reference<XComponentContext> xRet(
@@ -382,7 +382,7 @@ Reference<XComponentContext> connectToOffice(
sUnoUrl, xLocalComponentContext ),
UNO_QUERY_THROW );
if (verbose)
- dp_misc::writeConsole("OK.\n");
+ dp_misc::writeConsole(u"OK.\n");
return xRet;
}