summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/printer
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 /vcl/unx/generic/printer
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 'vcl/unx/generic/printer')
-rw-r--r--vcl/unx/generic/printer/cupsmgr.cxx9
-rw-r--r--vcl/unx/generic/printer/jobdata.cxx2
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx16
-rw-r--r--vcl/unx/generic/printer/printerinfomanager.cxx10
4 files changed, 20 insertions, 17 deletions
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx
index 7830323d22d7..6ac997d14c10 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -42,6 +42,7 @@
#include <algorithm>
#include <cstddef>
+#include <string_view>
using namespace psp;
using namespace osl;
@@ -673,7 +674,7 @@ namespace
std::unique_ptr<weld::Entry> m_xPassEdit;
public:
- RTSPWDialog(weld::Window* pParent, const OString& rServer, const OString& rUserName);
+ RTSPWDialog(weld::Window* pParent, std::string_view rServer, std::string_view rUserName);
OString getDomain() const
{
@@ -709,7 +710,7 @@ namespace
}
};
- RTSPWDialog::RTSPWDialog(weld::Window* pParent, const OString& rServer, const OString& rUserName)
+ RTSPWDialog::RTSPWDialog(weld::Window* pParent, std::string_view rServer, std::string_view rUserName)
: GenericDialogController(pParent, "vcl/ui/cupspassworddialog.ui", "CUPSPasswordDialog")
, m_xText(m_xBuilder->weld_label("text"))
, m_xDomainLabel(m_xBuilder->weld_label("label3"))
@@ -723,7 +724,7 @@ namespace
aText = aText.replaceFirst("%s", OStringToOUString(rServer, osl_getThreadTextEncoding()));
m_xText->set_label(aText);
m_xDomainEdit->set_text("WORKGROUP");
- if (rUserName.isEmpty())
+ if (rUserName.empty())
m_xUserEdit->grab_focus();
else
{
@@ -732,7 +733,7 @@ namespace
}
}
- bool AuthenticateQuery(const OString& rServer, OString& rUserName, OString& rPassword)
+ bool AuthenticateQuery(std::string_view rServer, OString& rUserName, OString& rPassword)
{
bool bRet = false;
diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index 5bbeceba0036..1e955bde21a0 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -221,7 +221,7 @@ bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, Jo
else if (aLine.startsWith(printerEquals))
{
bPrinter = true;
- rJobData.m_aPrinterName = OStringToOUString(aLine.copy(RTL_CONSTASCII_LENGTH(printerEquals)), RTL_TEXTENCODING_UTF8);
+ rJobData.m_aPrinterName = OStringToOUString(aLine.subView(RTL_CONSTASCII_LENGTH(printerEquals)), RTL_TEXTENCODING_UTF8);
}
else if (aLine.startsWith(orientatationEquals))
{
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 2dbd268ae57e..7b29c876a8c3 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -1091,7 +1091,8 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
nPos = aCurrentLine.indexOf(':');
if( nPos != -1 )
{
- aOption = OStringToOUString( aCurrentLine.copy( 1, nPos-1 ), RTL_TEXTENCODING_MS_1252 );
+ aOption = OStringToOUString(
+ aCurrentLine.subView( 1, nPos-1 ), RTL_TEXTENCODING_MS_1252 );
aOption = GetCommandLineToken( 1, aOption );
sal_Int32 nTransPos = aOption.indexOf( '/' );
if( nTransPos != -1 )
@@ -1143,7 +1144,7 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
nTransPos = aLine.indexOf('"');
if (nTransPos == -1)
nTransPos = aLine.getLength();
- aValue = OStringToOUString(aLine.copy(0, nTransPos), RTL_TEXTENCODING_MS_1252);
+ aValue = OStringToOUString(aLine.subView(0, nTransPos), RTL_TEXTENCODING_MS_1252);
// after the second doublequote can follow a / and a translation
if (nTransPos < aLine.getLength() - 2)
{
@@ -1173,7 +1174,7 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
nTransPos = aLine.indexOf('/');
if (nTransPos == -1)
nTransPos = aLine.getLength();
- aValue = OStringToOUString(aLine.copy(0, nTransPos), RTL_TEXTENCODING_MS_1252);
+ aValue = OStringToOUString(aLine.subView(0, nTransPos), RTL_TEXTENCODING_MS_1252);
if (nTransPos+1 < aLine.getLength())
aValueTranslation = handleTranslation( aLine.copy( nTransPos+1 ), bIsGlobalizedLine );
eType = eString;
@@ -1235,7 +1236,7 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
if (aLine.startsWith("*Default"))
{
SAL_INFO("vcl.unx.print", "Found a default: '" << aLine << "'");
- OUString aKey(OStringToOUString(aLine.copy(8), RTL_TEXTENCODING_MS_1252));
+ OUString aKey(OStringToOUString(aLine.subView(8), RTL_TEXTENCODING_MS_1252));
sal_Int32 nPos = aKey.indexOf( ':' );
if( nPos != -1 )
{
@@ -1272,7 +1273,7 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
}
}
-void PPDParser::parseOpenUI(const OString& rLine, const OString& rPPDGroup)
+void PPDParser::parseOpenUI(const OString& rLine, std::string_view rPPDGroup)
{
OUString aTranslation;
OString aKey = rLine;
@@ -1916,11 +1917,12 @@ void PPDContext::rebuildFromStreamBuffer(const std::vector<char> &rBuffer)
sal_Int32 nPos = aLine.indexOf(':');
if( nPos != -1 )
{
- const PPDKey* pKey = m_pParser->getKey( OStringToOUString( aLine.copy( 0, nPos ), RTL_TEXTENCODING_MS_1252 ) );
+ const PPDKey* pKey = m_pParser->getKey( OStringToOUString( aLine.subView( 0, nPos ), RTL_TEXTENCODING_MS_1252 ) );
if( pKey )
{
const PPDValue* pValue = nullptr;
- OUString aOption(OStringToOUString(aLine.copy(nPos+1), RTL_TEXTENCODING_MS_1252));
+ OUString aOption(
+ OStringToOUString(aLine.subView(nPos+1), RTL_TEXTENCODING_MS_1252));
if (aOption != "*nil")
pValue = pKey->getValue( aOption );
m_aCurrentValues[ pKey ] = pValue;
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index aae0f9f5f7b1..c6780b491f34 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -263,7 +263,7 @@ void PrinterInfoManager::initialize()
if (aKey.startsWith("PPD_"))
{
aValue = aConfig.ReadKey( aKey );
- const PPDKey* pKey = m_aGlobalDefaults.m_pParser->getKey(OStringToOUString(aKey.copy(4), RTL_TEXTENCODING_ISO_8859_1));
+ const PPDKey* pKey = m_aGlobalDefaults.m_pParser->getKey(OStringToOUString(aKey.subView(4), RTL_TEXTENCODING_ISO_8859_1));
if( pKey )
{
m_aGlobalDefaults.m_aContext.
@@ -329,10 +329,10 @@ void PrinterInfoManager::initialize()
// initialize to global defaults
aPrinter.m_aInfo = m_aGlobalDefaults;
- aPrinterName = OStringToOUString(aValue.copy(nNamePos+1),
+ aPrinterName = OStringToOUString(aValue.subView(nNamePos+1),
RTL_TEXTENCODING_UTF8);
aPrinter.m_aInfo.m_aPrinterName = aPrinterName;
- aPrinter.m_aInfo.m_aDriverName = OStringToOUString(aValue.copy(0, nNamePos), RTL_TEXTENCODING_UTF8);
+ aPrinter.m_aInfo.m_aDriverName = OStringToOUString(aValue.subView(0, nNamePos), RTL_TEXTENCODING_UTF8);
// set parser, merge settings
// don't do this for CUPS printers as this is done
@@ -448,7 +448,7 @@ void PrinterInfoManager::initialize()
if( aKey.startsWith("PPD_") && aPrinter.m_aInfo.m_pParser )
{
aValue = aConfig.ReadKey( aKey );
- const PPDKey* pKey = aPrinter.m_aInfo.m_pParser->getKey(OStringToOUString(aKey.copy(4), RTL_TEXTENCODING_ISO_8859_1));
+ const PPDKey* pKey = aPrinter.m_aInfo.m_pParser->getKey(OStringToOUString(aKey.subView(4), RTL_TEXTENCODING_ISO_8859_1));
if( pKey )
{
aPrinter.m_aInfo.m_aContext.
@@ -828,7 +828,7 @@ static void standardSysQueueTokenHandler(
if( nAftPos != -1 )
{
// get the queue name between fore and aft tokens
- OUString aSysQueue( OStringToOUString( line.copy( nPos, nAftPos - nPos ), aEncoding ) );
+ OUString aSysQueue( OStringToOUString( line.subView( nPos, nAftPos - nPos ), aEncoding ) );
// do not insert duplicates (e.g. lpstat tends to produce such lines)
if( aUniqueSet.insert( aSysQueue ).second )
{