diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-28 17:56:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-29 16:42:33 +0100 |
commit | 042033f1e6da22616cb76c8d950c20c9efecbad5 (patch) | |
tree | 26b3f1f42d067506f44550b410f3fb9640616a5b /package | |
parent | ccfd8e9d09f9ac0a0ea92d0f378391006faaf934 (diff) |
loplugin:stringviewparam: operator +
Change-Id: I044dd21b63d7eb03224675584fa143009c6b6008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108418
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipPackageFolder.hxx | 4 | ||||
-rw-r--r-- | package/qa/cppunit/test_package.cxx | 4 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 14 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.hxx | 5 | ||||
-rw-r--r-- | package/source/xstor/xstorage.cxx | 23 | ||||
-rw-r--r-- | package/source/xstor/xstorage.hxx | 8 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 3 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageFolder.cxx | 8 |
8 files changed, 39 insertions, 30 deletions
diff --git a/package/inc/ZipPackageFolder.hxx b/package/inc/ZipPackageFolder.hxx index c99f8f2a6b27..96d486fc6e3c 100644 --- a/package/inc/ZipPackageFolder.hxx +++ b/package/inc/ZipPackageFolder.hxx @@ -26,6 +26,8 @@ #include "HashMaps.hxx" #include "ZipPackageEntry.hxx" #include <cppuhelper/implbase.hxx> + +#include <string_view> #include <vector> class ZipOutputStream; @@ -52,7 +54,7 @@ public: const OUString& GetVersion() const { return m_sVersion; } void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; } - bool LookForUnexpectedODF12Streams( const OUString& aPath ); + bool LookForUnexpectedODF12Streams( std::u16string_view aPath ); void setChildStreamsTypeByExtension( const css::beans::StringPair& aPair ); diff --git a/package/qa/cppunit/test_package.cxx b/package/qa/cppunit/test_package.cxx index 29a8d9281cb5..62c718421c7c 100644 --- a/package/qa/cppunit/test_package.cxx +++ b/package/qa/cppunit/test_package.cxx @@ -51,7 +51,7 @@ namespace void PackageTest::setUp() { BootstrapFixtureBase::setUp(); - OUString aURL = m_directories.getURLFromSrc("/package/qa/cppunit/data/a2z.zip"); + OUString aURL = m_directories.getURLFromSrc(u"/package/qa/cppunit/data/a2z.zip"); uno::Sequence<beans::NamedValue> aNVs(1); aNVs[0].Name = "URL"; @@ -93,7 +93,7 @@ namespace void PackageTest::test() { testDir(OUString(), - m_directories.getURLFromSrc("/package/qa/cppunit/data/")); + m_directories.getURLFromSrc(u"/package/qa/cppunit/data/")); } void PackageTest::verifyStreams( std::vector<std::vector<char>> &aBuffers ) diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 408003386ea2..9655240c4602 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -984,7 +984,7 @@ void OWriteStream_Impl::ReadRelInfoIfNecessary() if ( m_xOrigRelInfoStream.is() ) m_aOrigRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence( m_xOrigRelInfoStream, - "_rels/*.rels", + u"_rels/*.rels", m_xContext ); // in case of success the stream must be thrown away, that means that the OrigRelInfo is initialized @@ -1009,7 +1009,7 @@ void OWriteStream_Impl::ReadRelInfoIfNecessary() if ( m_xNewRelInfoStream.is() ) m_aNewRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence( m_xNewRelInfoStream, - "_rels/*.rels", + u"_rels/*.rels", m_xContext ); m_nRelInfoStatus = RELINFO_CHANGED_STREAM_READ; @@ -1496,7 +1496,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar CreateReadonlyCopyBasedOnData( xDataToCopy, m_aProps, xTargetStream ); } -void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStorage >& xRelStorage, const OUString& aOrigStreamName, const OUString& aNewStreamName ) +void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStorage >& xRelStorage, std::u16string_view aOrigStreamName, std::u16string_view aNewStreamName ) { // at this point of time the old stream must be already cleaned OSL_ENSURE( m_nStorageType == embed::StorageFormats::OFOPXML, "The method should be used only with OFOPXML format!" ); @@ -1504,17 +1504,17 @@ void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStora if ( m_nStorageType != embed::StorageFormats::OFOPXML ) return; - OSL_ENSURE( !aOrigStreamName.isEmpty() && !aNewStreamName.isEmpty() && xRelStorage.is(), + OSL_ENSURE( !aOrigStreamName.empty() && !aNewStreamName.empty() && xRelStorage.is(), "Wrong relation persistence information is provided!" ); - if ( !xRelStorage.is() || aOrigStreamName.isEmpty() || aNewStreamName.isEmpty() ) + if ( !xRelStorage.is() || aOrigStreamName.empty() || aNewStreamName.empty() ) throw uno::RuntimeException(); if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN ) throw io::IOException(); // TODO: - OUString aOrigRelStreamName = aOrigStreamName + ".rels"; - OUString aNewRelStreamName = aNewStreamName + ".rels"; + OUString aOrigRelStreamName = OUString::Concat(aOrigStreamName) + ".rels"; + OUString aNewRelStreamName = OUString::Concat(aNewStreamName) + ".rels"; bool bRenamed = aOrigRelStreamName != aNewRelStreamName; if ( m_nRelInfoStatus == RELINFO_CHANGED diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx index 3c8bbbf2aed5..ecb810c32529 100644 --- a/package/source/xstor/owriteablestream.hxx +++ b/package/source/xstor/owriteablestream.hxx @@ -47,6 +47,7 @@ #include <vector> #include <memory> +#include <string_view> #include "ocompinstream.hxx" @@ -214,8 +215,8 @@ public: void CommitStreamRelInfo( const css::uno::Reference< css::embed::XStorage >& xRelStorage, - const OUString& aOrigStreamName, - const OUString& aNewStreamName ); + std::u16string_view aOrigStreamName, + std::u16string_view aNewStreamName ); void ReadRelInfoIfNecessary(); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 8a13fd82b32d..13e93c9da9ad 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -22,6 +22,7 @@ #include <sal/log.hxx> #include <cassert> +#include <string_view> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/embed/ElementModes.hpp> @@ -525,13 +526,14 @@ void OStorage_Impl::ReadRelInfoIfNecessary() if ( m_nRelInfoStatus == RELINFO_NO_INIT ) { // Init from original stream - uno::Reference< io::XInputStream > xRelInfoStream = GetRelInfoStreamForName( OUString() ); + uno::Reference< io::XInputStream > xRelInfoStream + = GetRelInfoStreamForName( std::u16string_view() ); try { if ( xRelInfoStream.is() ) m_aRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence( xRelInfoStream, - "_rels/.rels", + u"_rels/.rels", m_xContext ); m_nRelInfoStatus = RELINFO_READ; } @@ -548,7 +550,7 @@ void OStorage_Impl::ReadRelInfoIfNecessary() if ( m_xNewRelInfoStream.is() ) m_aRelInfo = ::comphelper::OFOPXMLHelper::ReadRelationsInfoSequence( m_xNewRelInfoStream, - "_rels/.rels", + u"_rels/.rels", m_xContext ); m_nRelInfoStatus = RELINFO_CHANGED_STREAM_READ; @@ -1579,14 +1581,14 @@ void OStorage_Impl::CloneStreamElement( const OUString& aStreamName, pElement->m_xStream->GetCopyOfLastCommit(xTargetStream); } -void OStorage_Impl::RemoveStreamRelInfo( const OUString& aOriginalName ) +void OStorage_Impl::RemoveStreamRelInfo( std::u16string_view aOriginalName ) { // this method should be used only in OStorage_Impl::Commit() method // the aOriginalName can be empty, in this case the storage relation info should be removed if ( m_nStorageType == embed::StorageFormats::OFOPXML && m_xRelStorage.is() ) { - OUString aRelStreamName = aOriginalName + ".rels"; + OUString aRelStreamName = OUString::Concat(aOriginalName) + ".rels"; if ( m_xRelStorage->hasByName( aRelStreamName ) ) m_xRelStorage->removeElement( aRelStreamName ); @@ -1619,7 +1621,7 @@ void OStorage_Impl::CreateRelStorage() m_xRelStorage.set( static_cast<embed::XStorage*>(pResultStorage) ); } -void OStorage_Impl::CommitStreamRelInfo( const OUString &rName, SotElement_Impl const * pStreamElement ) +void OStorage_Impl::CommitStreamRelInfo( std::u16string_view rName, SotElement_Impl const * pStreamElement ) { // this method should be used only in OStorage_Impl::Commit() method @@ -1629,7 +1631,7 @@ void OStorage_Impl::CommitStreamRelInfo( const OUString &rName, SotElement_Impl if (m_nStorageType == embed::StorageFormats::OFOPXML && pStreamElement->m_xStream) { - SAL_WARN_IF( rName.isEmpty(), "package.xstor", "The name must not be empty!" ); + SAL_WARN_IF( rName.empty(), "package.xstor", "The name must not be empty!" ); if ( !m_xRelStorage.is() ) { @@ -1641,14 +1643,15 @@ void OStorage_Impl::CommitStreamRelInfo( const OUString &rName, SotElement_Impl } } -uno::Reference< io::XInputStream > OStorage_Impl::GetRelInfoStreamForName( const OUString& aName ) +uno::Reference< io::XInputStream > OStorage_Impl::GetRelInfoStreamForName( + std::u16string_view aName ) { if ( m_nStorageType == embed::StorageFormats::OFOPXML ) { ReadContents(); if ( m_xRelStorage.is() ) { - OUString aRelStreamName = aName + ".rels"; + OUString aRelStreamName = OUString::Concat(aName) + ".rels"; if ( m_xRelStorage->hasByName( aRelStreamName ) ) { uno::Reference< io::XStream > xStream = m_xRelStorage->openStreamElement( aRelStreamName, embed::ElementModes::READ ); @@ -1700,7 +1703,7 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain m_nRelInfoStatus = RELINFO_READ; } else if (m_xRelStorage.is()) - RemoveStreamRelInfo(OUString()); // remove own rel info + RemoveStreamRelInfo(std::u16string_view()); // remove own rel info } else if (m_nRelInfoStatus == RELINFO_CHANGED_STREAM_READ || m_nRelInfoStatus == RELINFO_CHANGED_STREAM) diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index 959a7aea72e6..cddaa7d6fbe1 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -53,6 +53,7 @@ #include <vector> #include <memory> +#include <string_view> namespace com::sun::star::uno { class XComponentContext; @@ -249,10 +250,11 @@ struct OStorage_Impl const ::comphelper::SequenceAsHashMap& aEncryptionData, css::uno::Reference< css::io::XStream >& xTargetStream ); - void RemoveStreamRelInfo( const OUString& aOriginalName ); + void RemoveStreamRelInfo( std::u16string_view aOriginalName ); void CreateRelStorage(); - void CommitStreamRelInfo( const OUString& rName, SotElement_Impl const * pStreamElement ); - css::uno::Reference< css::io::XInputStream > GetRelInfoStreamForName( const OUString& aName ); + void CommitStreamRelInfo( std::u16string_view rName, SotElement_Impl const * pStreamElement ); + css::uno::Reference< css::io::XInputStream > GetRelInfoStreamForName( + std::u16string_view aName ); void CommitRelInfo( const css::uno::Reference< css::container::XNameContainer >& xNewPackageFolder ); static void completeStorageStreamCopy_Impl( diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index d2b76ef12098..c65e63c5cf43 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -70,6 +70,7 @@ #include <cstring> #include <memory> +#include <string_view> #include <vector> #include <comphelper/processfactory.hxx> @@ -427,7 +428,7 @@ void ZipPackage::parseManifest() m_xRootFolder->removeByName( sMimetype ); } - m_bInconsistent = m_xRootFolder->LookForUnexpectedODF12Streams( OUString() ); + m_bInconsistent = m_xRootFolder->LookForUnexpectedODF12Streams( std::u16string_view() ); bool bODF12AndNewer = ( m_xRootFolder->GetVersion().compareTo( u"" ODFVER_012_TEXT ) >= 0 ); if ( !m_bForceRecovery && bODF12AndNewer ) diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index c95849df91a0..f867b4571b91 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -79,7 +79,7 @@ ZipPackageFolder::~ZipPackageFolder() { } -bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath ) +bool ZipPackageFolder::LookForUnexpectedODF12Streams( std::u16string_view aPath ) { bool bHasUnexpected = false; @@ -89,7 +89,7 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath ) if ( rInfo.bFolder ) { - if ( aPath == "META-INF/" ) + if ( aPath == u"META-INF/" ) { // META-INF is not allowed to contain subfolders bHasUnexpected = true; @@ -102,7 +102,7 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath ) } else { - if ( aPath == "META-INF/" ) + if ( aPath == u"META-INF/" ) { if ( rShortName != "manifest.xml" && rShortName.indexOf( "signatures" ) == -1 ) @@ -117,7 +117,7 @@ bool ZipPackageFolder::LookForUnexpectedODF12Streams( const OUString& aPath ) { // the stream is not in META-INF and is not registered in manifest.xml, // check whether it is an internal part of the package format - if ( !aPath.isEmpty() || rShortName != "mimetype" ) + if ( !aPath.empty() || rShortName != "mimetype" ) { // if it is not "mimetype" from the root it is not a part of the package bHasUnexpected = true; |