From a069fac4a08f93db74799d00f047e04f1a0735cd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 19 Nov 2021 09:50:52 +0200 Subject: loplugin:stringliteraldefine in comphelper Change-Id: I60ccd6049db65fef2397798ab916b0d1e24c0fdc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125531 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sot/source/base/exchange.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sot') diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx index 6594fcde6156..18c5cd291f9a 100644 --- a/sot/source/base/exchange.cxx +++ b/sot/source/base/exchange.cxx @@ -43,7 +43,7 @@ namespace { */ struct DataFlavorRepresentation { - const char* pMimeType; + OUString pMimeType; const char* pName; const css::uno::Type* pType; }; @@ -261,11 +261,11 @@ SotClipboardFormatId SotExchange::RegisterFormatMimeType( const OUString& rMimeT const DataFlavorRepresentation *pFormatArray_Impl = FormatArray_Impl(); // test the default first - name for( SotClipboardFormatId i = SotClipboardFormatId::STRING; i <= SotClipboardFormatId::FILE_LIST; ++i ) - if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) + if( rMimeType.equals( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) return i; for( SotClipboardFormatId i = SotClipboardFormatId::RTF; i <= SotClipboardFormatId::USER_END; ++i ) - if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) + if( rMimeType.equals( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) return i; // then in the dynamic list @@ -320,7 +320,7 @@ bool SotExchange::GetFormatDataFlavor( SotClipboardFormatId nFormat, DataFlavor& if( SotClipboardFormatId::USER_END >= nFormat ) { const DataFlavorRepresentation& rData = FormatArray_Impl()[static_cast(nFormat)]; - rFlavor.MimeType = OUString::createFromAscii( rData.pMimeType ); + rFlavor.MimeType = rData.pMimeType; rFlavor.HumanPresentableName = OUString::createFromAscii( rData.pName ); rFlavor.DataType = *rData.pType; @@ -359,7 +359,7 @@ OUString SotExchange::GetFormatMimeType( SotClipboardFormatId nFormat ) { OUString sMimeType; if( SotClipboardFormatId::USER_END >= nFormat ) - sMimeType = OUString::createFromAscii( FormatArray_Impl()[static_cast(nFormat)].pMimeType ); + sMimeType = FormatArray_Impl()[static_cast(nFormat)].pMimeType; else { tDataFlavorList& rL = InitFormats_Impl(); @@ -385,14 +385,14 @@ SotClipboardFormatId SotExchange::GetFormatIdFromMimeType( const OUString& rMime { const DataFlavorRepresentation *pFormatArray_Impl = FormatArray_Impl(); for( SotClipboardFormatId i = SotClipboardFormatId::STRING; i <= SotClipboardFormatId::FILE_LIST; ++i ) - if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) + if( rMimeType.equals( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) return i; // BM: the chart format 105 ("StarChartDocument 5.0") was written // only into 5.1 chart documents - in 5.0 and 5.2 it was 42 ("StarChart 5.0") // The registry only contains the entry for the 42 format id. for( SotClipboardFormatId i = SotClipboardFormatId::RTF; i <= SotClipboardFormatId::USER_END; ++i ) - if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) + if( rMimeType.equals( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) return ( (i == SotClipboardFormatId::STARCHARTDOCUMENT_50) ? SotClipboardFormatId::STARCHART_50 : i ); @@ -423,7 +423,7 @@ SotClipboardFormatId SotExchange::GetFormat( const DataFlavor& rFlavor ) const DataFlavorRepresentation *pFormatArray_Impl = FormatArray_Impl(); for( SotClipboardFormatId i = SotClipboardFormatId::STRING; i <= SotClipboardFormatId::FILE_LIST; ++i ) - if( rMimeType.equalsAscii( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) + if( rMimeType.equals( pFormatArray_Impl[ static_cast(i) ].pMimeType ) ) return i; // BM: the chart format 105 ("StarChartDocument 5.0") was written @@ -431,9 +431,9 @@ SotClipboardFormatId SotExchange::GetFormat( const DataFlavor& rFlavor ) // The registry only contains the entry for the 42 format id. for( SotClipboardFormatId i = SotClipboardFormatId::RTF; i <= SotClipboardFormatId::USER_END; ++i ) { - const char* const pFormatMimeType = pFormatArray_Impl[ static_cast(i) ].pMimeType; - const sal_Int32 nFormatMimeTypeLen = rtl_str_getLength( pFormatMimeType ); - if( rMimeType.matchAsciiL( pFormatMimeType, nFormatMimeTypeLen ) && + const OUString& pFormatMimeType = pFormatArray_Impl[ static_cast(i) ].pMimeType; + const sal_Int32 nFormatMimeTypeLen = pFormatMimeType.getLength(); + if( rMimeType.match( pFormatMimeType ) && ( rMimeType.getLength() == nFormatMimeTypeLen || rMimeType[ nFormatMimeTypeLen ] == ';' ) ) return ( (i == SotClipboardFormatId::STARCHARTDOCUMENT_50) -- cgit