diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-29 11:06:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-01 08:30:18 +0200 |
commit | 5200a73627d13e2997f81b53f61e143e77e328ee (patch) | |
tree | f95c8346d061ecd0ad33d574895d18e169662785 /sd | |
parent | b90d3d316dd9c720c83180b31f6bbd7003fead78 (diff) |
use more string_view in various
found by examining uses of OUString::copy() for likely places
Change-Id: I6ff20e7b273ad6005410b82719183c1122f8c018
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133617
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/core/stlsheet.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/dlg/unchss.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/futempl.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 37 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/view/sdview2.cxx | 2 |
7 files changed, 36 insertions, 34 deletions
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index feff63dbf69a..48ae9b58c458 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -402,7 +402,7 @@ SdStyleSheet* SdStyleSheet::GetRealStyleSheet() const sal_Int32 nPos = aStyleName.indexOf(aOutlineStr); if (nPos >= 0) { - OUString aNumStr(aStyleName.copy(aOutlineStr.getLength())); + std::u16string_view aNumStr(aStyleName.subView(aOutlineStr.getLength())); aInternalName = STR_LAYOUT_OUTLINE + aNumStr; } } @@ -464,7 +464,7 @@ SdStyleSheet* SdStyleSheet::GetPseudoStyleSheet() const sal_Int32 nPos = aStyleName.indexOf(aOutlineStr); if (nPos != -1) { - OUString aNumStr(aStyleName.copy(aOutlineStr.getLength())); + std::u16string_view aNumStr(aStyleName.subView(aOutlineStr.getLength())); aStyleName = SdResId(STR_PSEUDOSHEET_OUTLINE) + aNumStr; } } diff --git a/sd/source/ui/dlg/unchss.cxx b/sd/source/ui/dlg/unchss.cxx index 5f17840d7963..7d963cddfb11 100644 --- a/sd/source/ui/dlg/unchss.cxx +++ b/sd/source/ui/dlg/unchss.cxx @@ -83,7 +83,7 @@ StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc, nPos = aName.indexOf(aOutlineStr); if (nPos != -1) { - OUString aNumStr(aName.copy(aOutlineStr.getLength())); + std::u16string_view aNumStr(aName.subView(aOutlineStr.getLength())); aName = STR_LAYOUT_OUTLINE + aNumStr; } } diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx index 21f19f3e725f..2c0c22ecde09 100644 --- a/sd/source/ui/func/futempl.cxx +++ b/sd/source/ui/func/futempl.cxx @@ -46,6 +46,7 @@ #include <svx/xflgrit.hxx> #include <svx/xflftrit.hxx> #include <svx/xflhtit.hxx> +#include <o3tl/string_view.hxx> #include <app.hrc> #include <stlsheet.hxx> #include <sdpage.hxx> @@ -336,8 +337,8 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) { OUString aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE)); // determine number, mind the blank between name and number - OUString aNumStr(aName.copy(aOutlineStr.getLength() + 1)); - sal_uInt16 nLevel = static_cast<sal_uInt16>(aNumStr.toInt32()); + std::u16string_view aNumStr(aName.subView(aOutlineStr.getLength() + 1)); + sal_uInt16 nLevel = static_cast<sal_uInt16>(o3tl::toInt32(aNumStr)); switch (nLevel) { case 1: ePO = PresentationObjects::Outline_1; break; diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 6fbcf5263118..c63d1362b10b 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -53,6 +53,7 @@ #include <editeng/UnoForbiddenCharsTable.hxx> #include <svx/svdoutl.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <o3tl/unit_conversion.hxx> #include <svx/UnoNamespaceMap.hxx> #include <svx/svdlayer.hxx> @@ -954,76 +955,76 @@ css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create( if( aServiceSpecifier.startsWith( "com.sun.star.presentation.") ) { - const OUString aType( aServiceSpecifier.copy(26) ); + const std::u16string_view aType( aServiceSpecifier.subView(26) ); rtl::Reference<SvxShape> pShape; SdrObjKind nType = SdrObjKind::Text; // create a shape wrapper - if( aType.startsWith( "TitleTextShape" ) ) + if( o3tl::starts_with(aType, u"TitleTextShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "OutlinerShape" ) ) + else if( o3tl::starts_with(aType, u"OutlinerShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "SubtitleShape" ) ) + else if( o3tl::starts_with(aType, u"SubtitleShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "GraphicObjectShape" ) ) + else if( o3tl::starts_with(aType, u"GraphicObjectShape" ) ) { nType = SdrObjKind::Graphic; } - else if( aType.startsWith( "PageShape" ) ) + else if( o3tl::starts_with(aType, u"PageShape" ) ) { nType = SdrObjKind::Page; } - else if( aType.startsWith( "OLE2Shape" ) ) + else if( o3tl::starts_with(aType, u"OLE2Shape" ) ) { nType = SdrObjKind::OLE2; } - else if( aType.startsWith( "ChartShape" ) ) + else if( o3tl::starts_with(aType, u"ChartShape" ) ) { nType = SdrObjKind::OLE2; } - else if( aType.startsWith( "CalcShape" ) ) + else if( o3tl::starts_with(aType, u"CalcShape" ) ) { nType = SdrObjKind::OLE2; } - else if( aType.startsWith( "TableShape" ) ) + else if( o3tl::starts_with(aType, u"TableShape" ) ) { nType = SdrObjKind::Table; } - else if( aType.startsWith( "OrgChartShape" ) ) + else if( o3tl::starts_with(aType, u"OrgChartShape" ) ) { nType = SdrObjKind::OLE2; } - else if( aType.startsWith( "NotesShape" ) ) + else if( o3tl::starts_with(aType, u"NotesShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "HandoutShape" ) ) + else if( o3tl::starts_with(aType, u"HandoutShape" ) ) { nType = SdrObjKind::Page; } - else if( aType.startsWith( "FooterShape" ) ) + else if( o3tl::starts_with(aType, u"FooterShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "HeaderShape" ) ) + else if( o3tl::starts_with(aType, u"HeaderShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "SlideNumberShape" ) ) + else if( o3tl::starts_with(aType, u"SlideNumberShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "DateTimeShape" ) ) + else if( o3tl::starts_with(aType, u"DateTimeShape" ) ) { nType = SdrObjKind::Text; } - else if( aType.startsWith( "MediaShape" ) ) + else if( o3tl::starts_with(aType, u"MediaShape" ) ) { nType = SdrObjKind::Media; } diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index a095dd4d8bad..29736f6a633e 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -1278,8 +1278,8 @@ void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno sal_Int32 nPos = aStrBookmark.lastIndexOf( '#' ); if( nPos >= 0 ) { - OUString aURL( aStrBookmark.copy( 0, nPos+1 ) ); - aURL += getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) ); + OUString aURL = aStrBookmark.subView( 0, nPos+1 ) + + getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) ); aStrBookmark = aURL; } } @@ -1531,8 +1531,8 @@ uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName ) sal_Int32 nPos = aString.lastIndexOf( '#' ); if( nPos >= 0 ) { - OUString aURL( aString.copy( 0, nPos+1 ) ); - aURL += getPageApiNameFromUiName( aString.copy( nPos+1 ) ); + OUString aURL = aString.subView( 0, nPos+1 ) + + getPageApiNameFromUiName( aString.copy( nPos+1 ) ); aString = aURL; } pProperties->Name = gaStrBookmark; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index bc042babe8d5..a2adb7a7f75d 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -74,6 +74,7 @@ #include <vcl/dibtools.hxx> #include <tools/debug.hxx> #include <tools/stream.hxx> +#include <o3tl/string_view.hxx> using ::com::sun::star::animations::XAnimationNode; using ::com::sun::star::animations::XAnimationNodeSupplier; @@ -2172,16 +2173,15 @@ OUString getUiNameFromPageApiNameImpl( const OUString& rApiName ) const OUString aDefPageName( sEmptyPageName ); if( rApiName.startsWith( aDefPageName ) ) { - OUString aNumber( rApiName.copy( aDefPageName.getLength() ) ); + std::u16string_view aNumber( rApiName.subView( aDefPageName.getLength() ) ); // 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(); - sal_Int32 nChar; - for( nChar = 0; nChar < nChars; nChar++, pString++ ) + const size_t nChars = aNumber.size(); + const sal_Unicode* pString = aNumber.data(); + for( size_t nChar = 0; nChar < nChars; nChar++, pString++ ) { if((*pString < '0') || (*pString > '9')) { diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index 3a40d4065d93..a5b3d44132b6 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -731,7 +731,7 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, sal_Int32 nIndex = aBookmark.indexOf( '#' ); if( nIndex != -1 ) { - const OUString aDocName( aBookmark.copy( 0, nIndex ) ); + const std::u16string_view aDocName( aBookmark.subView( 0, nIndex ) ); if (mpDocSh->GetMedium()->GetName() == aDocName || aDocName == mpDocSh->GetName()) { |