diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-04-16 21:05:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-17 07:54:12 +0200 |
commit | e870d996efb4a856f667c601032e02e5b21c5b82 (patch) | |
tree | 1692d68d47018555452bbae484abe9d1b23dd17a | |
parent | 80a0d3b44cd6edb6419ab66588548ba169f2567b (diff) |
use more string_view
Change-Id: If4523dc2c89d1fb1c5e11665ee60044834fcecd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150458
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | oox/source/ppt/presentationfragmenthandler.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 10 | ||||
-rw-r--r-- | test/source/a11y/AccessibilityTools.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/core/XMLEmbeddedObjectImportContext.cxx | 6 |
4 files changed, 19 insertions, 16 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 5f35dbdfdb1c..7a5788259921 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -140,11 +140,11 @@ void PresentationFragmentHandler::importSlideNames(XmlFilterBase& rFilter, const { Reference<XDrawPage> xDrawPage(xDrawPages->getByIndex(i), UNO_QUERY); Reference<container::XNamed> xNamed(xDrawPage, UNO_QUERY_THROW); - OUString sRest; - if (xNamed->getName().startsWith(aTitleText, &sRest) - && (sRest.isEmpty() - || (sRest.startsWith(" (") && sRest.endsWith(")") - && o3tl::toInt32(sRest.subView(2, sRest.getLength() - 3)) > 0))) + std::u16string_view sRest; + if (o3tl::starts_with(xNamed->getName(), aTitleText, &sRest) + && (sRest.empty() + || (o3tl::starts_with(sRest, u" (") && o3tl::ends_with(sRest, u")") + && o3tl::toInt32(sRest.substr(2, sRest.size() - 3)) > 0))) nCount++; } Reference<container::XNamed> xName(rSlidePersist[nPage]->getPage(), UNO_QUERY_THROW); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 6ff2958f85b9..8e55d1f1ab99 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2272,17 +2272,17 @@ void SAL_CALL SdDrawPage::setName( const OUString& rName ) return; // check if this is the default 'page1234' name - OUString aNumber; - if(aName.startsWith( sEmptyPageName, &aNumber )) + std::u16string_view aNumber; + if(o3tl::starts_with(aName, sEmptyPageName, &aNumber )) { // ok, it maybe is, aNumber is the number part after 'page' // create the page number - sal_Int32 nPageNumber = aNumber.toInt32(); + sal_Int32 nPageNumber = o3tl::toInt32(aNumber); // check if there are non number characters in the number part - const sal_Int32 nChars = aNumber.getLength(); - const sal_Unicode* pString = aNumber.getStr(); + const sal_Int32 nChars = aNumber.size(); + const sal_Unicode* pString = aNumber.data(); sal_Int32 nChar; for( nChar = 0; nChar < nChars; nChar++, pString++ ) { diff --git a/test/source/a11y/AccessibilityTools.cxx b/test/source/a11y/AccessibilityTools.cxx index 15a7cec17bc3..33270505f3a6 100644 --- a/test/source/a11y/AccessibilityTools.cxx +++ b/test/source/a11y/AccessibilityTools.cxx @@ -34,6 +34,7 @@ #include <vcl/scheduler.hxx> #include <vcl/timer.hxx> #include <vcl/window.hxx> +#include <o3tl/string_view.hxx> using namespace css; @@ -165,9 +166,9 @@ bool AccessibilityTools::nameEquals(const uno::Reference<accessibility::XAccessi const std::u16string_view name) { auto ctxName = xCtx->getAccessibleName(); - OUString rest; + std::u16string_view rest; - if (!ctxName.startsWith(name, &rest)) + if (!o3tl::starts_with(ctxName, name, &rest)) return false; if (rest == u"") return true; @@ -193,7 +194,9 @@ bool AccessibilityTools::nameEquals(const uno::Reference<accessibility::XAccessi if (pVCLXAccessibleComponent) { auto windowType = pVCLXAccessibleComponent->GetWindow()->GetType(); - if (rest == u" (Type = " + OUString::number(static_cast<sal_Int32>(windowType)) + ")") + if (rest + == Concat2View(u" (Type = " + OUString::number(static_cast<sal_Int32>(windowType)) + + ")")) return true; } #endif diff --git a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx index 7f68a11fed20..980dd8e0572d 100644 --- a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx +++ b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx @@ -170,7 +170,7 @@ XMLEmbeddedObjectImportContext::XMLEmbeddedObjectImportContext( } } - OUString sClass; + std::u16string_view sClass; static std::u16string_view const prefixes[] = { u"application/vnd.oasis.openoffice.", u"application/x-vnd.oasis.openoffice.", @@ -178,13 +178,13 @@ XMLEmbeddedObjectImportContext::XMLEmbeddedObjectImportContext( u"application/x-vnd.oasis.opendocument."}; for (auto const & p: prefixes) { - if (sMime.startsWith(p, &sClass)) + if (o3tl::starts_with(sMime, p, &sClass)) { break; } } - if( !sClass.isEmpty() ) + if( !sClass.empty() ) { static const std::tuple<XMLTokenEnum, OUString, SvGUID> aServiceMap[] = { { XML_TEXT, XML_IMPORT_FILTER_WRITER, { SO3_SW_CLASSID } }, |