use more string_view in xmloff
Change-Id: I0d860fa6e3d3261f3393e912b27930066dd93f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132972 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -45,7 +45,7 @@ class XMLOFF_DLLPUBLIC SvUnoAttributeContainer final :
|
||||
private:
|
||||
std::unique_ptr<SvXMLAttrContainerData> mpContainer;
|
||||
|
||||
SAL_DLLPRIVATE sal_uInt16 getIndexByName(const OUString& aName )
|
||||
SAL_DLLPRIVATE sal_uInt16 getIndexByName(std::u16string_view aName )
|
||||
const;
|
||||
|
||||
public:
|
||||
|
@@ -395,7 +395,7 @@ private:
|
||||
|
||||
/// explode a field master name into field type and field name
|
||||
static void ExplodeFieldMasterName(
|
||||
const OUString& sMasterName, /// name as returned by SO API
|
||||
std::u16string_view sMasterName, /// name as returned by SO API
|
||||
OUString& sFieldType, /// out: field type
|
||||
OUString& sVarName); /// out: variable name
|
||||
|
||||
|
@@ -86,15 +86,15 @@ OUString lcl_getGeneratorFromModelOrItsParent( const uno::Reference< frame::XMod
|
||||
return aGenerator;
|
||||
}
|
||||
|
||||
sal_Int32 lcl_getBuildIDFromGenerator( const OUString& rGenerator )
|
||||
sal_Int32 lcl_getBuildIDFromGenerator( std::u16string_view rGenerator )
|
||||
{
|
||||
//returns -1 if nothing found
|
||||
sal_Int32 nBuildId = -1;
|
||||
static const OUStringLiteral sBuildCompare( u"$Build-" );
|
||||
sal_Int32 nBegin = rGenerator.indexOf( sBuildCompare );
|
||||
if( nBegin >= 0 )
|
||||
size_t nBegin = rGenerator.find( sBuildCompare );
|
||||
if( nBegin != std::u16string_view::npos )
|
||||
{
|
||||
OUString sBuildId( rGenerator.copy( nBegin + sBuildCompare.getLength() ) );
|
||||
OUString sBuildId( rGenerator.substr( nBegin + sBuildCompare.getLength() ) );
|
||||
nBuildId = sBuildId.toInt32();
|
||||
}
|
||||
return nBuildId;
|
||||
|
@@ -56,12 +56,12 @@ sal_Bool SAL_CALL SvUnoAttributeContainer::hasElements()
|
||||
return mpContainer->GetAttrCount() != 0;
|
||||
}
|
||||
|
||||
sal_uInt16 SvUnoAttributeContainer::getIndexByName(const OUString& aName ) const
|
||||
sal_uInt16 SvUnoAttributeContainer::getIndexByName(std::u16string_view aName ) const
|
||||
{
|
||||
const sal_uInt16 nAttrCount = mpContainer->GetAttrCount();
|
||||
|
||||
sal_Int32 nPos = aName.indexOf( ':' );
|
||||
if( nPos == -1 )
|
||||
size_t nPos = aName.find( ':' );
|
||||
if( nPos == std::u16string_view::npos )
|
||||
{
|
||||
for( sal_uInt16 nAttr = 0; nAttr < nAttrCount; nAttr++ )
|
||||
{
|
||||
@@ -72,8 +72,8 @@ sal_uInt16 SvUnoAttributeContainer::getIndexByName(const OUString& aName ) const
|
||||
}
|
||||
else
|
||||
{
|
||||
const OUString aPrefix( aName.copy( 0L, nPos ) );
|
||||
const OUString aLName( aName.copy( nPos+1 ) );
|
||||
const std::u16string_view aPrefix( aName.substr( 0L, nPos ) );
|
||||
const std::u16string_view aLName( aName.substr( nPos+1 ) );
|
||||
|
||||
for( sal_uInt16 nAttr = 0; nAttr < nAttrCount; nAttr++ )
|
||||
{
|
||||
|
@@ -265,11 +265,11 @@ public:
|
||||
bool mbExportTextNumberElement;
|
||||
bool mbNullDateInitialized;
|
||||
|
||||
void SetSchemeOf( const OUString& rOrigFileName )
|
||||
void SetSchemeOf( std::u16string_view rOrigFileName )
|
||||
{
|
||||
sal_Int32 nSep = rOrigFileName.indexOf(':');
|
||||
if( nSep != -1 )
|
||||
msPackageURIScheme = rOrigFileName.copy( 0, nSep );
|
||||
size_t nSep = rOrigFileName.find(':');
|
||||
if( nSep != std::u16string_view::npos )
|
||||
msPackageURIScheme = rOrigFileName.substr( 0, nSep );
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -90,6 +90,7 @@
|
||||
|
||||
#include <o3tl/any.hxx>
|
||||
#include <o3tl/typed_flags_set.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
|
||||
#include <rtl/math.hxx>
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
@@ -2408,22 +2409,22 @@ void XMLShapeExport::ImpExportPolygonShape(
|
||||
namespace
|
||||
{
|
||||
|
||||
OUString getNameFromStreamURL(OUString const & rURL)
|
||||
OUString getNameFromStreamURL(std::u16string_view rURL)
|
||||
{
|
||||
static const OUStringLiteral sPackageURL(u"vnd.sun.star.Package:");
|
||||
static constexpr std::u16string_view sPackageURL(u"vnd.sun.star.Package:");
|
||||
|
||||
OUString sResult;
|
||||
|
||||
if (rURL.match(sPackageURL))
|
||||
if (o3tl::starts_with(rURL, sPackageURL))
|
||||
{
|
||||
OUString sRequestedName = rURL.copy(sPackageURL.getLength());
|
||||
sal_Int32 nLastIndex = sRequestedName.lastIndexOf('/') + 1;
|
||||
if ((nLastIndex > 0) && (nLastIndex < sRequestedName.getLength()))
|
||||
sRequestedName = sRequestedName.copy(nLastIndex);
|
||||
nLastIndex = sRequestedName.lastIndexOf('.');
|
||||
if (nLastIndex >= 0)
|
||||
sRequestedName = sRequestedName.copy(0, nLastIndex);
|
||||
if (!sRequestedName.isEmpty())
|
||||
std::u16string_view sRequestedName = rURL.substr(sPackageURL.size());
|
||||
size_t nLastIndex = sRequestedName.rfind('/') + 1;
|
||||
if ((nLastIndex > 0) && (nLastIndex < sRequestedName.size()))
|
||||
sRequestedName = sRequestedName.substr(nLastIndex);
|
||||
nLastIndex = sRequestedName.rfind('.');
|
||||
if (nLastIndex != std::u16string_view::npos)
|
||||
sRequestedName = sRequestedName.substr(0, nLastIndex);
|
||||
if (!sRequestedName.empty())
|
||||
sResult = sRequestedName;
|
||||
}
|
||||
|
||||
|
@@ -2847,19 +2847,19 @@ void XMLTextFieldExport::ExportDataBaseElement(
|
||||
|
||||
// explode a field master name into field type and field name
|
||||
void XMLTextFieldExport::ExplodeFieldMasterName(
|
||||
const OUString& sMasterName, OUString& sFieldType, OUString& sVarName)
|
||||
std::u16string_view sMasterName, OUString& sFieldType, OUString& sVarName)
|
||||
{
|
||||
sal_Int32 nLength = gsFieldMasterPrefix.getLength();
|
||||
sal_Int32 nSeparator = sMasterName.indexOf('.', nLength);
|
||||
size_t nSeparator = sMasterName.find('.', nLength);
|
||||
|
||||
// '.' found?
|
||||
if (nSeparator <= nLength) {
|
||||
if (static_cast<sal_Int32>(nSeparator) == nLength || nSeparator == std::u16string_view::npos) {
|
||||
SAL_WARN("xmloff.text", "no field var name!");
|
||||
}
|
||||
else
|
||||
{
|
||||
sFieldType = sMasterName.copy(nLength, nSeparator-nLength);
|
||||
sVarName = sMasterName.copy(nSeparator+1);
|
||||
sFieldType = sMasterName.substr(nLength, nSeparator-nLength);
|
||||
sVarName = sMasterName.substr(nSeparator+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user