use more string_view in xmloff

Change-Id: Ieef49d049760e557d341f1991f28333b09220c1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140336
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-09-21 11:09:46 +02:00
parent 70f8bddf87
commit 776ea34dee
19 changed files with 98 additions and 97 deletions

View File

@ -52,7 +52,7 @@ public:
// Helper to check if the local maProperties contains the given // Helper to check if the local maProperties contains the given
// FillStyle tag and if the FillStyle there is different from FillStyle_NONE // FillStyle tag and if the FillStyle there is different from FillStyle_NONE
bool doNewDrawingLayerFillStyleDefinitionsExist( bool doNewDrawingLayerFillStyleDefinitionsExist(
const OUString& rFillStyleTag) const; std::u16string_view rFillStyleTag) const;
protected: protected:

View File

@ -159,7 +159,7 @@ public:
// insert a string without special whitespace processing enabled // insert a string without special whitespace processing enabled
void InsertString( const OUString& rChars ); void InsertString( const OUString& rChars );
// insert a string with special whitespace processing enabled // insert a string with special whitespace processing enabled
void InsertString( const OUString& rChars, void InsertString( std::u16string_view rChars,
bool& rIgnoreLeadingSpace ); bool& rIgnoreLeadingSpace );
// Delete current paragraph // Delete current paragraph
void DeleteParagraph(); void DeleteParagraph();

View File

@ -394,7 +394,7 @@ public:
static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap); static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
static OUString getNamespaceURIFromToken( sal_Int32 nToken ); static OUString getNamespaceURIFromToken( sal_Int32 nToken );
static OUString getNamespacePrefixFromURI( const OUString& rURI ); static OUString getNamespacePrefixFromURI( const OUString& rURI );
static sal_Int32 getTokenFromName(const OUString& sName); static sal_Int32 getTokenFromName(std::u16string_view sName);
SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; } SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; }
const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; } const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; }
@ -421,7 +421,7 @@ public:
css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const; css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
bool IsPackageURL( const OUString& rURL ) const; bool IsPackageURL( std::u16string_view rURL ) const;
OUString ResolveEmbeddedObjectURL( const OUString& rURL, OUString ResolveEmbeddedObjectURL( const OUString& rURL,
std::u16string_view rClassId ); std::u16string_view rClassId );
css::uno::Reference< css::io::XOutputStream > css::uno::Reference< css::io::XOutputStream >

View File

@ -54,7 +54,7 @@ public:
public: public:
void FinishMetaElement(); void FinishMetaElement();
static void setBuildId(const OUString & rGenerator, static void setBuildId(std::u16string_view rGenerator,
const css::uno::Reference< css::beans::XPropertySet>& xImportInfo ); const css::uno::Reference< css::beans::XPropertySet>& xImportInfo );
}; };

View File

@ -155,7 +155,7 @@ namespace xmloff::EnhancedCustomShapeToken {
EAS_NotFound EAS_NotFound
}; };
EnhancedCustomShapeTokenEnum EASGet( const OUString& ); EnhancedCustomShapeTokenEnum EASGet( std::u16string_view );
EnhancedCustomShapeTokenEnum EASGet( sal_Int32 nToken ); EnhancedCustomShapeTokenEnum EASGet( sal_Int32 nToken );
OUString EASGet( const EnhancedCustomShapeTokenEnum ); OUString EASGet( const EnhancedCustomShapeTokenEnum );
} }

View File

@ -171,32 +171,32 @@ void lcl_removeEmptyChartTypeGroups( const uno::Reference< chart2::XChartDocumen
} }
} }
uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const OUString& rStr, bool bAddOneToEachOldIndex ) uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( std::u16string_view rStr, bool bAddOneToEachOldIndex )
{ {
const sal_Unicode aSpace( ' ' ); const sal_Unicode aSpace( ' ' );
// count number of entries // count number of entries
::std::vector< sal_Int32 > aVec; ::std::vector< sal_Int32 > aVec;
sal_Int32 nLastPos = 0; size_t nLastPos = 0;
sal_Int32 nPos = 0; size_t nPos = 0;
while( nPos != -1 ) while( nPos != std::u16string_view::npos )
{ {
nPos = rStr.indexOf( aSpace, nLastPos ); nPos = rStr.find( aSpace, nLastPos );
if( nPos > nLastPos ) if( nPos > nLastPos )
{ {
aVec.push_back( o3tl::toInt32(rStr.subView( nLastPos, (nPos - nLastPos) )) ); aVec.push_back( o3tl::toInt32(rStr.substr( nLastPos, (nPos - nLastPos) )) );
} }
if( nPos != -1 ) if( nPos != std::u16string_view::npos )
nLastPos = nPos + 1; nLastPos = nPos + 1;
} }
// last entry // last entry
if( nLastPos != 0 && if( nLastPos != 0 &&
rStr.getLength() > nLastPos ) rStr.size() > nLastPos )
{ {
aVec.push_back( o3tl::toInt32(rStr.subView( nLastPos )) ); aVec.push_back( o3tl::toInt32(rStr.substr( nLastPos )) );
} }
const sal_Int32 nVecSize = aVec.size(); const size_t nVecSize = aVec.size();
uno::Sequence< sal_Int32 > aSeq( nVecSize ); uno::Sequence< sal_Int32 > aSeq( nVecSize );
if(!bAddOneToEachOldIndex) if(!bAddOneToEachOldIndex)
@ -623,8 +623,8 @@ static void lcl_ApplyDataFromRectangularRangeToDiagram(
, css::chart::ChartDataRowSource eDataRowSource , css::chart::ChartDataRowSource eDataRowSource
, bool bRowHasLabels, bool bColHasLabels , bool bRowHasLabels, bool bColHasLabels
, bool bSwitchOnLabelsAndCategoriesForOwnData , bool bSwitchOnLabelsAndCategoriesForOwnData
, const OUString& sColTrans , std::u16string_view sColTrans
, const OUString& sRowTrans ) , std::u16string_view sRowTrans )
{ {
if( !xNewDoc.is() ) if( !xNewDoc.is() )
return; return;
@ -660,12 +660,12 @@ static void lcl_ApplyDataFromRectangularRangeToDiagram(
beans::PropertyState_DIRECT_VALUE ) beans::PropertyState_DIRECT_VALUE )
}; };
if( !sColTrans.isEmpty() || !sRowTrans.isEmpty() ) if( !sColTrans.empty() || !sRowTrans.empty() )
{ {
aArgs.realloc( aArgs.getLength() + 1 ); aArgs.realloc( aArgs.getLength() + 1 );
aArgs.getArray()[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue( aArgs.getArray()[ sal::static_int_cast<sal_uInt32>(aArgs.getLength()) - 1 ] = beans::PropertyValue(
"SequenceMapping", "SequenceMapping",
-1, uno::Any( !sColTrans.isEmpty() -1, uno::Any( !sColTrans.empty()
? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ? lcl_getNumberSequenceFromString( sColTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() )
: lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ), : lcl_getNumberSequenceFromString( sRowTrans, bHasCateories && !xNewDoc->hasInternalDataProvider() ) ),
beans::PropertyState_DIRECT_VALUE ); beans::PropertyState_DIRECT_VALUE );

View File

@ -271,7 +271,7 @@ OUString GetChartTypeByClassName(
} }
XMLTokenEnum getTokenByChartType( XMLTokenEnum getTokenByChartType(
const OUString & rChartTypeService, bool bUseOldNames ) std::u16string_view rChartTypeService, bool bUseOldNames )
{ {
XMLTokenEnum eResult = XML_TOKEN_INVALID; XMLTokenEnum eResult = XML_TOKEN_INVALID;
OUString aPrefix, aPostfix; OUString aPrefix, aPostfix;
@ -287,15 +287,15 @@ XMLTokenEnum getTokenByChartType(
aPostfix = "ChartType"; aPostfix = "ChartType";
} }
if( rChartTypeService.match( aPrefix )) if( o3tl::starts_with(rChartTypeService, aPrefix))
{ {
sal_Int32 nSkip = aPrefix.getLength(); sal_Int32 nSkip = aPrefix.getLength();
SAL_WARN_IF( rChartTypeService.getLength() < nSkip, "xmloff.chart", "ChartTypeService.getLength() < nSkip" ); SAL_WARN_IF( static_cast<sal_Int32>(rChartTypeService.size()) < nSkip, "xmloff.chart", "ChartTypeService.getLength() < nSkip" );
sal_Int32 nTypeLength = rChartTypeService.getLength() - nSkip - aPostfix.getLength(); sal_Int32 nTypeLength = rChartTypeService.size() - nSkip - aPostfix.getLength();
// if postfix matches and leaves a non-empty type // if postfix matches and leaves a non-empty type
if( nTypeLength > 0 && rChartTypeService.match( aPostfix, nSkip + nTypeLength )) if( nTypeLength > 0 && o3tl::starts_with(rChartTypeService.substr(nSkip + nTypeLength), aPostfix) )
{ {
std::u16string_view aServiceName( rChartTypeService.subView( nSkip, nTypeLength )); std::u16string_view aServiceName( rChartTypeService.substr( nSkip, nTypeLength ));
if ( aServiceName == u"Line" ) if ( aServiceName == u"Line" )
eResult = XML_LINE; eResult = XML_LINE;
@ -323,7 +323,7 @@ XMLTokenEnum getTokenByChartType(
} }
} }
if( eResult == XML_TOKEN_INVALID && !rChartTypeService.isEmpty() ) if( eResult == XML_TOKEN_INVALID && !rChartTypeService.empty() )
eResult = XML_ADD_IN; eResult = XML_ADD_IN;
return eResult; return eResult;

View File

@ -72,7 +72,7 @@ namespace SchXMLTools
std::u16string_view rClassName, bool bUseOldNames ); std::u16string_view rClassName, bool bUseOldNames );
::xmloff::token::XMLTokenEnum getTokenByChartType( ::xmloff::token::XMLTokenEnum getTokenByChartType(
const OUString & rChartTypeService, bool bUseOldNames ); std::u16string_view rChartTypeService, bool bUseOldNames );
OUString GetNewChartTypeName( const OUString & rOldChartTypeName ); OUString GetNewChartTypeName( const OUString & rOldChartTypeName );

View File

@ -1236,7 +1236,7 @@ const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
return mxDashHelper; return mxDashHelper;
} }
bool SvXMLImport::IsPackageURL( const OUString& rURL ) const bool SvXMLImport::IsPackageURL( std::u16string_view rURL ) const
{ {
// if, and only if, only parts are imported, then we're in a package // if, and only if, only parts are imported, then we're in a package
@ -1247,7 +1247,7 @@ bool SvXMLImport::IsPackageURL( const OUString& rURL ) const
// TODO: from this point extract to own static function // TODO: from this point extract to own static function
// Some quick tests: Some may rely on the package structure! // Some quick tests: Some may rely on the package structure!
sal_Int32 nLen = rURL.getLength(); size_t nLen = rURL.size();
if( nLen > 0 && '/' == rURL[0] ) if( nLen > 0 && '/' == rURL[0] )
// RFC2396 net_path or abs_path // RFC2396 net_path or abs_path
return false; return false;
@ -1263,7 +1263,7 @@ bool SvXMLImport::IsPackageURL( const OUString& rURL ) const
} }
// Now check for a RFC2396 schema // Now check for a RFC2396 schema
sal_Int32 nPos = 1; size_t nPos = 1;
while( nPos < nLen ) while( nPos < nLen )
{ {
switch( rURL[nPos] ) switch( rURL[nPos] )
@ -2001,10 +2001,10 @@ OUString SvXMLImport::getNamespacePrefixFromURI( const OUString& rURI )
return OUString(); return OUString();
} }
sal_Int32 SvXMLImport::getTokenFromName( const OUString& rName ) sal_Int32 SvXMLImport::getTokenFromName( std::u16string_view rName )
{ {
Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>( Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>(
OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr()), rName.getLength() ); OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr()), rName.size() );
return xTokenHandler->getTokenFromUTF8( aLocalNameSeq ); return xTokenHandler->getTokenFromUTF8( aLocalNameSeq );
} }

View File

@ -181,10 +181,10 @@ static const TypeNameHashMap& GetNameHashMap()
return aHashMap; return aHashMap;
} }
EnhancedCustomShapeTokenEnum EASGet( const OUString& rShapeType ) EnhancedCustomShapeTokenEnum EASGet( std::u16string_view rShapeType )
{ {
EnhancedCustomShapeTokenEnum eRetValue = EAS_NotFound; EnhancedCustomShapeTokenEnum eRetValue = EAS_NotFound;
int i, nLen = rShapeType.getLength(); size_t i, nLen = rShapeType.size();
std::unique_ptr<char[]> pBuf(new char[ nLen + 1 ]); std::unique_ptr<char[]> pBuf(new char[ nLen + 1 ]);
for ( i = 0; i < nLen; i++ ) for ( i = 0; i < nLen; i++ )
pBuf[ i ] = static_cast<char>(rShapeType[ i ]); pBuf[ i ] = static_cast<char>(rShapeType[ i ]);

View File

@ -171,10 +171,10 @@ static void GetB3DVector( std::vector< css::beans::PropertyValue >& rDest,
} }
} }
static bool GetEquationName( const OUString& rEquation, const sal_Int32 nStart, OUString& rEquationName ) static bool GetEquationName( std::u16string_view rEquation, const sal_Int32 nStart, OUString& rEquationName )
{ {
sal_Int32 nIndex = nStart; sal_Int32 nIndex = nStart;
while( nIndex < rEquation.getLength() ) while( nIndex < static_cast<sal_Int32>(rEquation.size()) )
{ {
sal_Unicode nChar = rEquation[ nIndex ]; sal_Unicode nChar = rEquation[ nIndex ];
if ( if (
@ -190,13 +190,13 @@ static bool GetEquationName( const OUString& rEquation, const sal_Int32 nStart,
} }
bool bValid = ( nIndex - nStart ) != 0; bool bValid = ( nIndex - nStart ) != 0;
if ( bValid ) if ( bValid )
rEquationName = rEquation.copy( nStart, nIndex - nStart ); rEquationName = rEquation.substr( nStart, nIndex - nStart );
return bValid; return bValid;
} }
static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParameter, sal_Int32& nIndex, const OUString& rParaString ) static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParameter, sal_Int32& nIndex, std::u16string_view rParaString )
{ {
if ( nIndex >= rParaString.getLength() ) if ( nIndex >= static_cast<sal_Int32>(rParaString.size()) )
return false; return false;
bool bValid = true; bool bValid = true;
@ -226,62 +226,62 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam
else if ( rParaString[ nIndex ] > '9' ) else if ( rParaString[ nIndex ] > '9' )
{ {
bNumberRequired = false; bNumberRequired = false;
if ( rParaString.matchIgnoreAsciiCase( "left", nIndex ) ) if ( o3tl::matchIgnoreAsciiCase( rParaString, u"left", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LEFT; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LEFT;
nIndex += 4; nIndex += 4;
} }
else if ( rParaString.matchIgnoreAsciiCase( "top", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"top", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::TOP; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::TOP;
nIndex += 3; nIndex += 3;
} }
else if ( rParaString.matchIgnoreAsciiCase( "right", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"right", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::RIGHT; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::RIGHT;
nIndex += 5; nIndex += 5;
} }
else if ( rParaString.matchIgnoreAsciiCase( "bottom", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"bottom", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::BOTTOM; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::BOTTOM;
nIndex += 6; nIndex += 6;
} }
else if ( rParaString.matchIgnoreAsciiCase( "xstretch", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"xstretch", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::XSTRETCH; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::XSTRETCH;
nIndex += 8; nIndex += 8;
} }
else if ( rParaString.matchIgnoreAsciiCase( "ystretch", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"ystretch", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::YSTRETCH; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::YSTRETCH;
nIndex += 8; nIndex += 8;
} }
else if ( rParaString.matchIgnoreAsciiCase( "hasstroke", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"hasstroke", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HASSTROKE; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HASSTROKE;
nIndex += 9; nIndex += 9;
} }
else if ( rParaString.matchIgnoreAsciiCase( "hasfill", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"hasfill", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HASFILL; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HASFILL;
nIndex += 7; nIndex += 7;
} }
else if ( rParaString.matchIgnoreAsciiCase( "width", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"width", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::WIDTH; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::WIDTH;
nIndex += 5; nIndex += 5;
} }
else if ( rParaString.matchIgnoreAsciiCase( "height", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"height", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HEIGHT; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::HEIGHT;
nIndex += 6; nIndex += 6;
} }
else if ( rParaString.matchIgnoreAsciiCase( "logwidth", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"logwidth", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LOGWIDTH; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LOGWIDTH;
nIndex += 8; nIndex += 8;
} }
else if ( rParaString.matchIgnoreAsciiCase( "logheight", nIndex ) ) else if ( o3tl::matchIgnoreAsciiCase( rParaString, u"logheight", nIndex ) )
{ {
rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT; rParameter.Type = css::drawing::EnhancedCustomShapeParameterType::LOGHEIGHT;
nIndex += 9; nIndex += 9;
@ -301,7 +301,7 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam
bool bDot = false; // set if there is a dot included bool bDot = false; // set if there is a dot included
bool bEnd = false; // set for each value that can not be part of a double/integer bool bEnd = false; // set for each value that can not be part of a double/integer
while( ( nIndex < rParaString.getLength() ) && bValid ) while( ( nIndex < static_cast<sal_Int32>(rParaString.size()) ) && bValid )
{ {
switch( rParaString[ nIndex ] ) switch( rParaString[ nIndex ] )
{ {
@ -383,7 +383,7 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam
bValid = false; bValid = false;
if ( bValid ) if ( bValid )
{ {
std::u16string_view aNumber( rParaString.subView( nStartIndex, nIndex - nStartIndex ) ); std::u16string_view aNumber( rParaString.substr( nStartIndex, nIndex - nStartIndex ) );
if ( bE || bDot ) if ( bE || bDot )
{ {
double fAttrDouble; double fAttrDouble;
@ -409,7 +409,7 @@ static bool GetNextParameter( css::drawing::EnhancedCustomShapeParameter& rParam
const sal_Unicode aSpace(' '); const sal_Unicode aSpace(' ');
const sal_Unicode aCommata(','); const sal_Unicode aCommata(',');
while(nIndex < rParaString.getLength()) while(nIndex < static_cast<sal_Int32>(rParaString.size()))
{ {
const sal_Unicode aCandidate(rParaString[nIndex]); const sal_Unicode aCandidate(rParaString[nIndex]);
@ -503,7 +503,7 @@ static void GetSizeSequence( std::vector< css::beans::PropertyValue >& rDest,
} }
static void GetEnhancedParameter( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:handle-position static void GetEnhancedParameter( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:handle-position
const OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) std::u16string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp )
{ {
sal_Int32 nIndex = 0; sal_Int32 nIndex = 0;
css::drawing::EnhancedCustomShapeParameter aParameter; css::drawing::EnhancedCustomShapeParameter aParameter;
@ -517,7 +517,7 @@ static void GetEnhancedParameter( std::vector< css::beans::PropertyValue >& rDes
} }
static void GetEnhancedParameterPair( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:handle-position static void GetEnhancedParameterPair( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:handle-position
const OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) std::u16string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp )
{ {
sal_Int32 nIndex = 0; sal_Int32 nIndex = 0;
css::drawing::EnhancedCustomShapeParameterPair aParameterPair; css::drawing::EnhancedCustomShapeParameterPair aParameterPair;
@ -532,7 +532,7 @@ static void GetEnhancedParameterPair( std::vector< css::beans::PropertyValue >&
} }
static sal_Int32 GetEnhancedParameterPairSequence( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:glue-points static sal_Int32 GetEnhancedParameterPairSequence( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:glue-points
const OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) std::u16string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp )
{ {
std::vector< css::drawing::EnhancedCustomShapeParameterPair > vParameter; std::vector< css::drawing::EnhancedCustomShapeParameterPair > vParameter;
css::drawing::EnhancedCustomShapeParameterPair aParameter; css::drawing::EnhancedCustomShapeParameterPair aParameter;
@ -554,7 +554,7 @@ static sal_Int32 GetEnhancedParameterPairSequence( std::vector< css::beans::Prop
} }
static void GetEnhancedRectangleSequence( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:text-areas static void GetEnhancedRectangleSequence( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:text-areas
const OUString& rValue, const EnhancedCustomShapeTokenEnum eDestProp ) std::u16string_view rValue, const EnhancedCustomShapeTokenEnum eDestProp )
{ {
std::vector< css::drawing::EnhancedCustomShapeTextFrame > vTextFrame; std::vector< css::drawing::EnhancedCustomShapeTextFrame > vTextFrame;
css::drawing::EnhancedCustomShapeTextFrame aParameter; css::drawing::EnhancedCustomShapeTextFrame aParameter;
@ -579,7 +579,7 @@ static void GetEnhancedRectangleSequence( std::vector< css::beans::PropertyValue
static void static void
GetEnhancedPath(std::vector<css::beans::PropertyValue>& rDest, // e.g. draw:enhanced-path GetEnhancedPath(std::vector<css::beans::PropertyValue>& rDest, // e.g. draw:enhanced-path
const OUString& rValue, std::u16string_view rType) std::u16string_view rValue, std::u16string_view rType)
{ {
std::vector< css::drawing::EnhancedCustomShapeParameterPair > vCoordinates; std::vector< css::drawing::EnhancedCustomShapeParameterPair > vCoordinates;
std::vector< css::drawing::EnhancedCustomShapeSegment > vSegments; std::vector< css::drawing::EnhancedCustomShapeSegment > vSegments;
@ -592,7 +592,7 @@ GetEnhancedPath(std::vector<css::beans::PropertyValue>& rDest, // e.g. draw:enha
bool bValid = true; bool bValid = true;
while( bValid && ( nIndex < rValue.getLength() ) ) while( bValid && ( nIndex < static_cast<sal_Int32>(rValue.size()) ) )
{ {
switch( rValue[ nIndex ] ) switch( rValue[ nIndex ] )
{ {
@ -850,7 +850,7 @@ GetEnhancedPath(std::vector<css::beans::PropertyValue>& rDest, // e.g. draw:enha
} }
static void GetAdjustmentValues( std::vector< css::beans::PropertyValue >& rDest, // draw:adjustments static void GetAdjustmentValues( std::vector< css::beans::PropertyValue >& rDest, // draw:adjustments
const OUString& rValue ) std::u16string_view rValue )
{ {
std::vector< css::drawing::EnhancedCustomShapeAdjustmentValue > vAdjustmentValue; std::vector< css::drawing::EnhancedCustomShapeAdjustmentValue > vAdjustmentValue;
css::drawing::EnhancedCustomShapeParameter aParameter; css::drawing::EnhancedCustomShapeParameter aParameter;

View File

@ -1126,7 +1126,7 @@ void SdXMLStylesContext::ImpSetGraphicStyles() const
{ {
uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("graphics"), uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("graphics"), uno::UNO_QUERY_THROW );
ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::SD_GRAPHICS_ID, OUString()); ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::SD_GRAPHICS_ID, u"");
} }
catch( uno::Exception& ) catch( uno::Exception& )
{ {
@ -1140,7 +1140,7 @@ void SdXMLStylesContext::ImpSetCellStyles() const
{ {
uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xGraphicPageStyles( GetSdImport().GetLocalDocStyleFamilies()->getByName("cell"), uno::UNO_QUERY_THROW );
ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::TABLE_CELL, OUString()); ImpSetGraphicStyles(xGraphicPageStyles, XmlStyleFamily::TABLE_CELL, u"");
} }
catch( uno::Exception& ) catch( uno::Exception& )
{ {
@ -1182,9 +1182,9 @@ static bool canSkipReset(std::u16string_view rName, const XMLPropStyleContext* p
// help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles() // help function used by ImpSetGraphicStyles() and ImpSetMasterPageStyles()
void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAccess > const & xPageStyles, XmlStyleFamily nFamily, const OUString& rPrefix) const void SdXMLStylesContext::ImpSetGraphicStyles( uno::Reference< container::XNameAccess > const & xPageStyles, XmlStyleFamily nFamily, std::u16string_view rPrefix) const
{ {
sal_Int32 nPrefLen(rPrefix.getLength()); sal_Int32 nPrefLen(rPrefix.size());
sal_uInt32 a; sal_uInt32 a;

View File

@ -175,7 +175,7 @@ class SdXMLStylesContext : public SvXMLStylesContext
void ImpSetGraphicStyles() const; void ImpSetGraphicStyles() const;
void ImpSetCellStyles() const; void ImpSetCellStyles() const;
void ImpSetGraphicStyles( css::uno::Reference< css::container::XNameAccess > const & xPageStyles, void ImpSetGraphicStyles( css::uno::Reference< css::container::XNameAccess > const & xPageStyles,
XmlStyleFamily nFamily, const OUString& rPrefix) const; XmlStyleFamily nFamily, std::u16string_view rPrefix) const;
protected: protected:
using SvXMLStylesContext::CreateStyleChildContext; using SvXMLStylesContext::CreateStyleChildContext;

View File

@ -30,6 +30,7 @@
#include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentProperties.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <o3tl/string_view.hxx>
#include <rtl/character.hxx> #include <rtl/character.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <utility> #include <utility>
@ -228,29 +229,29 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SvXMLMetaDocumentContex
return nullptr; return nullptr;
} }
void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo ) void SvXMLMetaDocumentContext::setBuildId(std::u16string_view i_rBuildId, const uno::Reference<beans::XPropertySet>& xImportInfo )
{ {
OUString sBuildId; OUString sBuildId;
// skip to second product // skip to second product
sal_Int32 nBegin = i_rBuildId.indexOf( ' ' ); size_t nBegin = i_rBuildId.find( ' ' );
if ( nBegin != -1 ) if ( nBegin != std::u16string_view::npos )
{ {
// skip to build information // skip to build information
nBegin = i_rBuildId.indexOf( '/', nBegin ); nBegin = i_rBuildId.find( '/', nBegin );
if ( nBegin != -1 ) if ( nBegin != std::u16string_view::npos )
{ {
sal_Int32 nEnd = i_rBuildId.indexOf( 'm', nBegin ); size_t nEnd = i_rBuildId.find( 'm', nBegin );
if ( nEnd != -1 ) if ( nEnd != std::u16string_view::npos )
{ {
OUStringBuffer sBuffer( OUStringBuffer sBuffer(
i_rBuildId.subView( nBegin+1, nEnd-nBegin-1 ) ); i_rBuildId.substr( nBegin+1, nEnd-nBegin-1 ) );
static const OUStringLiteral sBuildCompare( static const OUStringLiteral sBuildCompare(
u"$Build-" ); u"$Build-" );
nBegin = i_rBuildId.indexOf( sBuildCompare, nEnd ); nBegin = i_rBuildId.find( sBuildCompare, nEnd );
if ( nBegin != -1 ) if ( nBegin != std::u16string_view::npos )
{ {
sBuffer.append( '$' ); sBuffer.append( '$' );
sBuffer.append( i_rBuildId.subView(nBegin + sBuildCompare.getLength()) ); sBuffer.append( i_rBuildId.substr(nBegin + sBuildCompare.getLength()) );
sBuildId = sBuffer.makeStringAndClear(); sBuildId = sBuffer.makeStringAndClear();
} }
} }
@ -259,15 +260,15 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno:
if ( sBuildId.isEmpty() ) if ( sBuildId.isEmpty() )
{ {
if ( i_rBuildId.startsWith("StarOffice 7") if ( o3tl::starts_with(i_rBuildId, u"StarOffice 7")
|| i_rBuildId.startsWith("StarSuite 7") || o3tl::starts_with(i_rBuildId, u"StarSuite 7")
|| i_rBuildId.startsWith("StarOffice 6") || o3tl::starts_with(i_rBuildId, u"StarOffice 6")
|| i_rBuildId.startsWith("StarSuite 6") || o3tl::starts_with(i_rBuildId, u"StarSuite 6")
|| i_rBuildId.startsWith("OpenOffice.org 1")) || o3tl::starts_with(i_rBuildId, u"OpenOffice.org 1"))
{ {
sBuildId = "645$8687"; sBuildId = "645$8687";
} }
else if (i_rBuildId.startsWith("NeoOffice/2")) else if (o3tl::starts_with(i_rBuildId, u"NeoOffice/2"))
{ {
sBuildId = "680$9134"; // fake NeoOffice as OpenOffice.org 2.2 release sBuildId = "680$9134"; // fake NeoOffice as OpenOffice.org 2.2 release
} }
@ -275,12 +276,12 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno:
// "LibreOffice_project" was hard-coded since LO 3.3.0 // "LibreOffice_project" was hard-coded since LO 3.3.0
// see utl::DocInfoHelper::GetGeneratorString() // see utl::DocInfoHelper::GetGeneratorString()
if (i_rBuildId.indexOf("LibreOffice_project/") != -1) if (i_rBuildId.find(u"LibreOffice_project/") != std::u16string_view::npos)
{ {
OUStringBuffer sNumber; OUStringBuffer sNumber;
auto const firstSlash = i_rBuildId.indexOf("/"); size_t const firstSlash = i_rBuildId.find('/');
assert(firstSlash != -1); assert(firstSlash != std::u16string_view::npos);
for (sal_Int32 i = firstSlash + 1; i < i_rBuildId.getLength(); ++i) for (size_t i = firstSlash + 1; i < i_rBuildId.size(); ++i)
{ {
if (rtl::isAsciiDigit(i_rBuildId[i])) if (rtl::isAsciiDigit(i_rBuildId[i]))
{ {

View File

@ -543,9 +543,9 @@ void XMLPropStyleContext::Finish( bool bOverwrite )
} }
bool XMLPropStyleContext::doNewDrawingLayerFillStyleDefinitionsExist( bool XMLPropStyleContext::doNewDrawingLayerFillStyleDefinitionsExist(
const OUString& rFillStyleTag) const std::u16string_view rFillStyleTag) const
{ {
if(!maProperties.empty() && rFillStyleTag.getLength()) if(!maProperties.empty() && !rFillStyleTag.empty())
{ {
// no & to avoid non-obvious UAF due to the 2nd temp Reference // no & to avoid non-obvious UAF due to the 2nd temp Reference
const rtl::Reference<XMLPropertySetMapper> rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper(); const rtl::Reference<XMLPropertySetMapper> rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper();

View File

@ -1947,10 +1947,10 @@ void SvXMLNumFormatContext::AddNfKeyword( sal_uInt16 nIndex )
} }
} }
static bool lcl_IsAtEnd( OUStringBuffer& rBuffer, const OUString& rToken ) static bool lcl_IsAtEnd( OUStringBuffer& rBuffer, std::u16string_view rToken )
{ {
sal_Int32 nBufLen = rBuffer.getLength(); sal_Int32 nBufLen = rBuffer.getLength();
sal_Int32 nTokLen = rToken.getLength(); sal_Int32 nTokLen = rToken.size();
if ( nTokLen > nBufLen ) if ( nTokLen > nBufLen )
return false; return false;

View File

@ -710,7 +710,7 @@ void XMLTextImportHelper::InsertString( const OUString& rChars )
} }
} }
void XMLTextImportHelper::InsertString( const OUString& rChars, void XMLTextImportHelper::InsertString( std::u16string_view rChars,
bool& rIgnoreLeadingSpace ) bool& rIgnoreLeadingSpace )
{ {
assert(m_xImpl->m_xText.is()); assert(m_xImpl->m_xText.is());
@ -718,7 +718,7 @@ void XMLTextImportHelper::InsertString( const OUString& rChars,
if (!m_xImpl->m_xText.is()) if (!m_xImpl->m_xText.is())
return; return;
sal_Int32 nLen = rChars.getLength(); sal_Int32 nLen = rChars.size();
OUStringBuffer sChars( nLen ); OUStringBuffer sChars( nLen );
for( sal_Int32 i=0; i < nLen; i++ ) for( sal_Int32 i=0; i < nLen; i++ )

View File

@ -32,14 +32,14 @@ using namespace ::com::sun::star::xml::sax;
using namespace ::xmloff::token; using namespace ::xmloff::token;
XMLTokenEnum XMLFormPropOASISTransformerContext::GetValueType( XMLTokenEnum XMLFormPropOASISTransformerContext::GetValueType(
const OUString& rValue ) std::u16string_view rValue )
{ {
XMLTokenEnum eRet = XML_DOUBLE; XMLTokenEnum eRet = XML_DOUBLE;
bool bNeg = false; bool bNeg = false;
sal_uInt32 nVal = 0; sal_uInt32 nVal = 0;
sal_Int32 nPos = 0; sal_Int32 nPos = 0;
sal_Int32 nLen = rValue.getLength(); sal_Int32 nLen = rValue.size();
// skip white space // skip white space
while( nPos < nLen && ' ' == rValue[nPos] ) while( nPos < nLen && ' ' == rValue[nPos] )

View File

@ -27,7 +27,7 @@ class XMLFormPropOASISTransformerContext :
bool const m_bIsList; bool const m_bIsList;
bool const m_bIsListValue; bool const m_bIsListValue;
static ::xmloff::token::XMLTokenEnum GetValueType( const OUString& rValue ); static ::xmloff::token::XMLTokenEnum GetValueType( std::u16string_view rValue );
public: public:
XMLFormPropOASISTransformerContext( XMLTransformerBase& rTransformer, XMLFormPropOASISTransformerContext( XMLTransformerBase& rTransformer,