summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-14 11:48:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-14 21:13:00 +0200
commit4475483b92da89f6ab7fa503c6db920b7b50d1b7 (patch)
treefb881733ddaba22fff30e2246c9b860068969da0 /sd
parent003e2873e4463974e59e1f909f9250cde743851f (diff)
use more string_view in sd
Change-Id: I301f3d8a6634df8be5fdd42649c0c265da8f9099 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133004 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/SVGExportTests.cxx10
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx4
-rw-r--r--sd/source/ui/docshell/docshel4.cxx21
-rw-r--r--sd/source/ui/inc/DrawDocShell.hxx2
-rw-r--r--sd/source/ui/inc/DrawViewShell.hxx2
-rw-r--r--sd/source/ui/inc/unopage.hxx2
-rw-r--r--sd/source/ui/unoidl/unopage.cxx10
-rw-r--r--sd/source/ui/view/drviewsh.cxx2
8 files changed, 27 insertions, 26 deletions
diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx
index d43815264d26..4878eca27972 100644
--- a/sd/qa/unit/SVGExportTests.cxx
+++ b/sd/qa/unit/SVGExportTests.cxx
@@ -46,13 +46,13 @@ bool isValidBitmapId(const OUString& sId)
return std::regex_match(sId.toUtf8().getStr(), aRegEx);
}
-BitmapChecksum getBitmapChecksumFromId(const OUString& sId)
+BitmapChecksum getBitmapChecksumFromId(std::u16string_view sId)
{
- sal_Int32 nStart = sId.indexOf("(") + 1;
- sal_Int32 nCount = sId.indexOf(")") - nStart;
- bool bIsValidRange = nStart > 0 && nCount > 0;
+ size_t nStart = sId.find(u"(") + 1;
+ size_t nCount = sId.find(u")") - nStart;
+ bool bIsValidRange = nStart > 0 && nStart != std::u16string_view::npos && nCount > 0;
CPPUNIT_ASSERT(bIsValidRange);
- OUString sChecksum = sId.copy( nStart, nCount );
+ OUString sChecksum( sId.substr( nStart, nCount ) );
return sChecksum.toUInt64();
}
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 4207f6bbce7f..9ce85a102f83 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2676,9 +2676,9 @@ void SdTiledRenderingTest::testSlideDuplicateUndo()
namespace
{
-void lcl_extractHandleParameters(const OString& selection, sal_uInt32& id, sal_uInt32& x, sal_uInt32& y)
+void lcl_extractHandleParameters(std::string_view selection, sal_uInt32& id, sal_uInt32& x, sal_uInt32& y)
{
- OString extraInfo = selection.copy(selection.indexOf("{"));
+ OString extraInfo( selection.substr(selection.find("{")) );
std::stringstream aStream(extraInfo.getStr());
boost::property_tree::ptree aTree;
boost::property_tree::read_json(aStream, aTree);
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index 6150321ca33a..6fe599e44197 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -72,6 +72,7 @@
#include <sdhtmlfilter.hxx>
#include <sdpdffilter.hxx>
#include <framework/FrameworkHelper.hxx>
+#include <o3tl/string_view.hxx>
#include <sfx2/zoomitem.hxx>
@@ -698,7 +699,7 @@ SfxStyleSheetBasePool* DrawDocShell::GetStyleSheetPool()
return mpDoc->GetStyleSheetPool();
}
-void DrawDocShell::GotoBookmark(const OUString& rBookmark)
+void DrawDocShell::GotoBookmark(std::u16string_view rBookmark)
{
auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell );
if (!pDrawViewShell)
@@ -710,28 +711,28 @@ void DrawDocShell::GotoBookmark(const OUString& rBookmark)
sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND;
SdrObject* pObj = nullptr;
- static const OUStringLiteral sInteraction( u"action?" );
- if ( rBookmark.match( sInteraction ) )
+ static constexpr std::u16string_view sInteraction( u"action?" );
+ if ( o3tl::starts_with(rBookmark, sInteraction ) )
{
- static const OUStringLiteral sJump( u"jump=" );
- if ( rBookmark.match( sJump, sInteraction.getLength() ) )
+ static constexpr std::u16string_view sJump( u"jump=" );
+ if ( o3tl::starts_with(rBookmark.substr( sInteraction.size() ), sJump ) )
{
- OUString aDestination( rBookmark.copy( sInteraction.getLength() + sJump.getLength() ) );
- if ( aDestination.match( "firstslide" ) )
+ std::u16string_view aDestination( rBookmark.substr( sInteraction.size() + sJump.size() ) );
+ if ( o3tl::starts_with(aDestination, u"firstslide" ) )
{
nPageNumber = 1;
}
- else if ( aDestination.match( "lastslide" ) )
+ else if ( o3tl::starts_with(aDestination, u"lastslide" ) )
{
nPageNumber = mpDoc->GetPageCount() - 2;
}
- else if ( aDestination.match( "previousslide" ) )
+ else if ( o3tl::starts_with(aDestination, u"previousslide" ) )
{
SdPage* pPage = pDrawViewShell->GetActualPage();
nPageNumber = pPage->GetPageNum();
nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND;
}
- else if ( aDestination.match( "nextslide" ) )
+ else if ( o3tl::starts_with(aDestination, u"nextslide" ) )
{
SdPage* pPage = pDrawViewShell->GetActualPage();
nPageNumber = pPage->GetPageNum() + 2;
diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx
index 5f15ffe9922f..15fa5ebd41ad 100644
--- a/sd/source/ui/inc/DrawDocShell.hxx
+++ b/sd/source/ui/inc/DrawDocShell.hxx
@@ -124,7 +124,7 @@ public:
void Disconnect(sd::ViewShell const * pViewSh);
void UpdateTablePointers();
- void GotoBookmark(const OUString& rBookmark);
+ void GotoBookmark(std::u16string_view rBookmark);
BitmapEx GetPagePreviewBitmap(SdPage* pPage);
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 44bb83d44979..c56a0f33e604 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -253,7 +253,7 @@ public:
bool IsSelected(sal_uInt16 nPage);
bool IsVisible(sal_uInt16 nPage);
- void GotoBookmark(const OUString& rBookmark);
+ void GotoBookmark(std::u16string_view rBookmark);
//Realize multi-selection of objects, If object is marked, the
//corresponding entry is set true, else the corresponding entry is set
//false.
diff --git a/sd/source/ui/inc/unopage.hxx b/sd/source/ui/inc/unopage.hxx
index 993a6634cc68..af09e5982c65 100644
--- a/sd/source/ui/inc/unopage.hxx
+++ b/sd/source/ui/inc/unopage.hxx
@@ -70,7 +70,7 @@ protected:
virtual void getBackground( css::uno::Any& rValue );
OUString getBookmarkURL() const;
- void setBookmarkURL( OUString const & rURL );
+ void setBookmarkURL( std::u16string_view rURL );
void SetLeftBorder( sal_Int32 nValue );
void SetRightBorder( sal_Int32 nValue );
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index d5576855f923..bc042babe8d5 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1553,17 +1553,17 @@ OUString SdGenericDrawPage::getBookmarkURL() const
return aRet.makeStringAndClear();
}
-void SdGenericDrawPage::setBookmarkURL( OUString const & rURL )
+void SdGenericDrawPage::setBookmarkURL( std::u16string_view rURL )
{
if( !SvxFmDrawPage::mpPage )
return;
- sal_Int32 nIndex = rURL.indexOf( '#' );
- if( nIndex == -1 )
+ size_t nIndex = rURL.find( '#' );
+ if( nIndex == std::u16string_view::npos )
return;
- const OUString aFileName( rURL.copy( 0, nIndex ) );
- const OUString aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 ) ) );
+ const OUString aFileName( rURL.substr( 0, nIndex ) );
+ const OUString aBookmarkName( SdDrawPage::getUiNameFromPageApiName( OUString(rURL.substr( nIndex+1 )) ) );
if( !aFileName.isEmpty() && !aBookmarkName.isEmpty() )
{
diff --git a/sd/source/ui/view/drviewsh.cxx b/sd/source/ui/view/drviewsh.cxx
index 418ebadf0dfb..c0e09a4787de 100644
--- a/sd/source/ui/view/drviewsh.cxx
+++ b/sd/source/ui/view/drviewsh.cxx
@@ -29,7 +29,7 @@
namespace sd {
-void DrawViewShell::GotoBookmark(const OUString& rBookmark)
+void DrawViewShell::GotoBookmark(std::u16string_view rBookmark)
{
::sd::DrawDocShell* pDocSh = GetDocSh();
if( pDocSh )