diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-16 10:13:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-16 12:12:31 +0200 |
commit | 4a96fb8ec0130e1036913093836bcf28bc37a49b (patch) | |
tree | e7aad9be4ca417e9e64f688cc99bee0638037741 /desktop | |
parent | f33b6e341fb7dd1ab3acd4fe5457b716be316e89 (diff) |
loplugin:bufferadd loosen some constraints
and extend O*StringView to have a constructor that takes a pointer and a
length
Change-Id: I6120e96280f030757e855a6596efdae438b7e1e8
Reviewed-on: https://gerrit.libreoffice.org/80872
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/manager/dp_activepackages.cxx | 33 | ||||
-rw-r--r-- | desktop/source/deployment/registry/component/dp_component.cxx | 15 | ||||
-rw-r--r-- | desktop/source/deployment/registry/dp_backenddb.cxx | 54 | ||||
-rw-r--r-- | desktop/source/splash/splash.cxx | 7 |
4 files changed, 50 insertions, 59 deletions
diff --git a/desktop/source/deployment/manager/dp_activepackages.cxx b/desktop/source/deployment/manager/dp_activepackages.cxx index f520e3301ea0..ab2cbf0d4a9f 100644 --- a/desktop/source/deployment/manager/dp_activepackages.cxx +++ b/desktop/source/deployment/manager/dp_activepackages.cxx @@ -47,18 +47,14 @@ namespace { -static char const separator = static_cast< char >( - static_cast< unsigned char >(0xFF)); +constexpr const char separator[] = "\xff"; OString oldKey(OUString const & fileName) { return OUStringToOString(fileName, RTL_TEXTENCODING_UTF8); } OString newKey(OUString const & id) { - OStringBuffer b; - b.append(separator); - b.append(OUStringToOString(id, RTL_TEXTENCODING_UTF8)); - return b.makeStringAndClear(); + return separator + OUStringToOString(id, RTL_TEXTENCODING_UTF8); } ::dp_manager::ActivePackages::Data decodeOldData( @@ -168,7 +164,7 @@ ActivePackages::Entries ActivePackages::getEntries() const { ::dp_misc::t_string2string_map m(m_map.getEntries()); for (auto const& elem : m) { - if (!elem.first.isEmpty() && elem.first[0] == separator) { + if (!elem.first.isEmpty() && elem.first[0] == separator[0]) { es.emplace_back( OUString( elem.first.getStr() + 1, elem.first.getLength() - 1, @@ -190,18 +186,17 @@ ActivePackages::Entries ActivePackages::getEntries() const { void ActivePackages::put(OUString const & id, Data const & data) { #if HAVE_FEATURE_EXTENSIONS - OStringBuffer b; - b.append( - OUStringToOString(data.temporaryName, RTL_TEXTENCODING_UTF8)); - b.append(separator); - b.append(OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8)); - b.append(separator); - b.append(OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8)); - b.append(separator); - b.append(OUStringToOString(data.version, RTL_TEXTENCODING_UTF8)); - b.append(separator); - b.append(OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8)); - m_map.put(newKey(id), b.makeStringAndClear()); + OString b = + OUStringToOString(data.temporaryName, RTL_TEXTENCODING_UTF8) + + separator + + OUStringToOString(data.fileName, RTL_TEXTENCODING_UTF8) + + separator + + OUStringToOString(data.mediaType, RTL_TEXTENCODING_UTF8) + + separator + + OUStringToOString(data.version, RTL_TEXTENCODING_UTF8) + + separator + + OUStringToOString(data.failedPrerequisites, RTL_TEXTENCODING_UTF8); + m_map.put(newKey(id), b); #else (void) id; (void) data; diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index 42de7f9dd042..54ac54daa987 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -916,14 +916,13 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv ) space = true; // write native rc: - OStringBuffer buf2; - buf2.append("ORIGIN="); - buf2.append(osOrigin); - buf2.append(LF); - buf2.append( "UNO_SERVICES=?$ORIGIN/" ); - buf2.append( OUStringToOString( - sNativeRDB, RTL_TEXTENCODING_ASCII_US ) ); - buf2.append(LF); + OString buf2 = + "ORIGIN=" + + osOrigin + + OString(LF) + + "UNO_SERVICES=?$ORIGIN/" + + OUStringToOString( sNativeRDB, RTL_TEXTENCODING_ASCII_US ) + + OString(LF); const Reference<io::XInputStream> xData( ::xmlscript::createInputStream( diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 606479447c2a..6361742576b1 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -156,15 +156,15 @@ void BackendDb::removeEntry(OUString const & url) { const OUString sKeyElement = getKeyElementName(); const OUString sPrefix = getNSPrefix(); - OUStringBuffer sExpression(500); - sExpression.append(sPrefix); - sExpression.append(":"); - sExpression.append(sKeyElement); - sExpression.append("[@url = \""); - sExpression.append(url); - sExpression.append("\"]"); - - removeElement(sExpression.makeStringAndClear()); + OUString sExpression = + sPrefix + + ":" + + sKeyElement + + "[@url = \"" + + url + + "\"]"; + + removeElement(sExpression); } void BackendDb::revokeEntry(OUString const & url) @@ -242,18 +242,18 @@ Reference<css::xml::dom::XNode> BackendDb::getKeyElement( { const OUString sPrefix = getNSPrefix(); const OUString sKeyElement = getKeyElementName(); - OUStringBuffer sExpression(500); - sExpression.append(sPrefix); - sExpression.append(":"); - sExpression.append(sKeyElement); - sExpression.append("[@url = \""); - sExpression.append(url); - sExpression.append("\"]"); + OUString sExpression = + sPrefix + + ":" + + sKeyElement + + "[@url = \"" + + url + + "\"]"; const Reference<css::xml::dom::XDocument> doc = getDocument(); const Reference<css::xml::dom::XNode> root = doc->getFirstChild(); const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); - return xpathApi->selectSingleNode(root, sExpression.makeStringAndClear()); + return xpathApi->selectSingleNode(root, sExpression); } catch(const css::uno::Exception &) { @@ -575,18 +575,18 @@ std::vector<OUString> BackendDb::getOneChildFromAllEntries( Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI(); const OUString sPrefix = getNSPrefix(); const OUString sKeyElement = getKeyElementName(); - OUStringBuffer buf(512); - buf.append(sPrefix); - buf.append(":"); - buf.append(sKeyElement); - buf.append("/"); - buf.append(sPrefix); - buf.append(":"); - buf.append(name); - buf.append("/text()"); + OUString sNodeSelectExpr = + sPrefix + + ":" + + sKeyElement + + "/" + + sPrefix + + ":" + + name + + "/text()"; Reference<css::xml::dom::XNodeList> nodes = - xpathApi->selectNodeList(root, buf.makeStringAndClear()); + xpathApi->selectNodeList(root, sNodeSelectExpr); if (nodes.is()) { sal_Int32 length = nodes->getLength(); diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx index b5b3568e12e3..c34673f3e881 100644 --- a/desktop/source/splash/splash.cxx +++ b/desktop/source/splash/splash.cxx @@ -477,16 +477,13 @@ void SplashScreen::SetScreenBitmap(BitmapEx &rBitmap) // create file name from screen resolution information OStringBuffer aStrBuf( 128 ); - OStringBuffer aResBuf( 32 ); aStrBuf.append( "intro_" ); if ( !_sAppName.isEmpty() ) { aStrBuf.append( OUStringToOString(_sAppName, RTL_TEXTENCODING_UTF8) ); aStrBuf.append( "_" ); } - aResBuf.append( OString::number( nWidth )); - aResBuf.append( "x" ); - aResBuf.append( OString::number( nHeight )); + OString aResBuf = OString::number( nWidth ) + "x" + OString::number( nHeight ); aStrBuf.append( aResBuf.getStr() ); if (Application::LoadBrandBitmap (aStrBuf.makeStringAndClear().getStr(), rBitmap)) @@ -494,7 +491,7 @@ void SplashScreen::SetScreenBitmap(BitmapEx &rBitmap) aStrBuf.append( "intro_" ); aStrBuf.append( aResBuf.getStr() ); - if (Application::LoadBrandBitmap (aResBuf.makeStringAndClear().getStr(), rBitmap)) + if (Application::LoadBrandBitmap (aResBuf.getStr(), rBitmap)) return; (void)Application::LoadBrandBitmap ("intro", rBitmap); |