use more string_view in chart2

Change-Id: I2afe0b5f82d1704a29bc80a969ee099eec90d3a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140590
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2022-09-26 13:06:44 +02:00
parent b419eb4bd4
commit d9e044f04a
12 changed files with 46 additions and 46 deletions

View File

@@ -620,7 +620,7 @@ void DataBrowser::RenewTable()
GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() )); GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() ));
OUString aDefaultSeriesName(SchResId(STR_COLUMN_LABEL)); OUString aDefaultSeriesName(SchResId(STR_COLUMN_LABEL));
replaceParamterInString( aDefaultSeriesName, "%COLUMNNUMBER", OUString::number( 24 ) ); replaceParamterInString( aDefaultSeriesName, u"%COLUMNNUMBER", OUString::number( 24 ) );
sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName ) sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName )
+ GetDataWindow().LogicToPixel(Point(8 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0), MapMode(MapUnit::MapAppFont)).X(); + GetDataWindow().LogicToPixel(Point(8 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0), MapMode(MapUnit::MapAppFont)).X();
sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount(); sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount();

View File

@@ -732,7 +732,7 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
sal_Int32 nPointIndex = o3tl::toInt32( ObjectIdentifier::getParticleID(rObjectCID) ); sal_Int32 nPointIndex = o3tl::toInt32( ObjectIdentifier::getParticleID(rObjectCID) );
// replace data point index // replace data point index
replaceParamterInString( aRet, "%POINTNUMBER", OUString::number( nPointIndex + 1 )); replaceParamterInString( aRet, u"%POINTNUMBER", OUString::number( nPointIndex + 1 ));
// replace data series index // replace data series index
{ {
@@ -744,11 +744,11 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
if( aSeriesVector[nSeriesIndex] == xSeries ) if( aSeriesVector[nSeriesIndex] == xSeries )
break; break;
} }
replaceParamterInString( aRet, "%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) ); replaceParamterInString( aRet, u"%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) );
} }
// replace point value // replace point value
replaceParamterInString( aRet, "%POINTVALUES", lcl_getDataPointValueText( replaceParamterInString( aRet, u"%POINTVALUES", lcl_getDataPointValueText(
xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartDocument ) ); xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartDocument ) );
} }
} }
@@ -760,7 +760,7 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
if( !aHelpText.isEmpty()) if( !aHelpText.isEmpty())
{ {
aRet = SchResId( STR_STATUS_OBJECT_MARKED ); aRet = SchResId( STR_STATUS_OBJECT_MARKED );
replaceParamterInString( aRet, "%OBJECTNAME", aHelpText ); replaceParamterInString( aRet, u"%OBJECTNAME", aHelpText );
} }
} }
@@ -843,8 +843,8 @@ OUString ObjectNameProvider::getName_ObjectForSeries(
if( xSeries.is() ) if( xSeries.is() )
{ {
OUString aRet = SchResId(STR_OBJECT_FOR_SERIES); OUString aRet = SchResId(STR_OBJECT_FOR_SERIES);
replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType ) ); replaceParamterInString( aRet, u"%OBJECTNAME", getName( eObjectType ) );
replaceParamterInString( aRet, "%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartDocument ) ); replaceParamterInString( aRet, u"%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartDocument ) );
return aRet; return aRet;
} }
else else
@@ -854,7 +854,7 @@ OUString ObjectNameProvider::getName_ObjectForSeries(
OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType )
{ {
OUString aRet = SchResId(STR_OBJECT_FOR_ALL_SERIES); OUString aRet = SchResId(STR_OBJECT_FOR_ALL_SERIES);
replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType, true /*bPlural*/ ) ); replaceParamterInString( aRet, u"%OBJECTNAME", getName( eObjectType, true /*bPlural*/ ) );
return aRet; return aRet;
} }

View File

@@ -508,7 +508,7 @@ private:
void executeDispatch_LineColor(sal_uInt32 nColor); void executeDispatch_LineColor(sal_uInt32 nColor);
void executeDispatch_LineWidth(sal_uInt32 nWidth); void executeDispatch_LineWidth(sal_uInt32 nWidth);
void sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle); void sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle);
void impl_ShapeControllerDispatch( const css::util::URL& rURL, void impl_ShapeControllerDispatch( const css::util::URL& rURL,
const css::uno::Sequence< css::beans::PropertyValue >& rArgs ); const css::uno::Sequence< css::beans::PropertyValue >& rArgs );

View File

@@ -2066,7 +2066,7 @@ css::uno::Reference<css::uno::XInterface> const & ChartController::getChartView(
return m_xChartView; return m_xChartView;
} }
void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle) void ChartController::sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle)
{ {
ChartModel* pChartModel = m_aModel->getModel().get(); ChartModel* pChartModel = m_aModel->getModel().get();
if (!pChartModel) if (!pChartModel)
@@ -2085,10 +2085,10 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a
return; return;
// Get dimension index from CID // Get dimension index from CID
sal_Int32 nStartPos = rCID.lastIndexOf('.'); size_t nStartPos = rCID.rfind('.');
nStartPos++; nStartPos++;
sal_Int32 nEndPos = rCID.getLength(); sal_Int32 nEndPos = rCID.size();
std::u16string_view sDimensionIndex = rCID.subView(nStartPos, nEndPos - nStartPos); std::u16string_view sDimensionIndex = rCID.substr(nStartPos, nEndPos - nStartPos);
sal_Int32 nDimensionIndex = o3tl::toInt32(sDimensionIndex); sal_Int32 nDimensionIndex = o3tl::toInt32(sDimensionIndex);
awt::Rectangle xRectangle { awt::Rectangle xRectangle {

View File

@@ -211,7 +211,7 @@ sal_Int16 getShortForLongAlso( const css::uno::Any& rAny );
OOO_DLLPUBLIC_CHARTTOOLS OOO_DLLPUBLIC_CHARTTOOLS
bool replaceParamterInString( OUString & rInOutResourceString, bool replaceParamterInString( OUString & rInOutResourceString,
const OUString & rParamToReplace, std::u16string_view rParamToReplace,
std::u16string_view rReplaceWith ); std::u16string_view rReplaceWith );
} //namespace chart } //namespace chart

View File

@@ -177,8 +177,8 @@ public:
bool isDragableObject() const; bool isDragableObject() const;
static bool isRotateableObject( std::u16string_view rClassifiedIdentifier ); static bool isRotateableObject( std::u16string_view rClassifiedIdentifier );
static bool isMultiClickObject( std::u16string_view rClassifiedIdentifier ); static bool isMultiClickObject( std::u16string_view rClassifiedIdentifier );
static bool areSiblings( const OUString& rCID1, const OUString& rCID2 );//identical object is no sibling static bool areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 );//identical object is no sibling
static bool areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 ); static bool areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 );
static OUString getStringForType( ObjectType eObjectType ); static OUString getStringForType( ObjectType eObjectType );
static ObjectType getObjectType( std::u16string_view rCID ); static ObjectType getObjectType( std::u16string_view rCID );
@@ -193,7 +193,7 @@ public:
static OUString createDataCurveCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine ); static OUString createDataCurveCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine );
static OUString createDataCurveEquationCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex ); static OUString createDataCurveEquationCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex );
SAL_DLLPRIVATE static OUString getObjectID( const OUString& rCID ); SAL_DLLPRIVATE static OUString getObjectID( std::u16string_view rCID );
static std::u16string_view getParticleID( std::u16string_view rCID ); static std::u16string_view getParticleID( std::u16string_view rCID );
static std::u16string_view getFullParentParticle( std::u16string_view rCID ); static std::u16string_view getFullParentParticle( std::u16string_view rCID );

View File

@@ -583,7 +583,7 @@ sal_Int16 getShortForLongAlso( const uno::Any& rAny )
} }
bool replaceParamterInString( OUString & rInOutResourceString, bool replaceParamterInString( OUString & rInOutResourceString,
const OUString & rParamToReplace, std::u16string_view rParamToReplace,
std::u16string_view rReplaceWith ) std::u16string_view rReplaceWith )
{ {
sal_Int32 nPos = rInOutResourceString.indexOf( rParamToReplace ); sal_Int32 nPos = rInOutResourceString.indexOf( rParamToReplace );
@@ -591,7 +591,7 @@ bool replaceParamterInString( OUString & rInOutResourceString,
return false; return false;
rInOutResourceString = rInOutResourceString.replaceAt( nPos rInOutResourceString = rInOutResourceString.replaceAt( nPos
, rParamToReplace.getLength(), rReplaceWith ); , rParamToReplace.size(), rReplaceWith );
return true; return true;
} }

View File

@@ -49,11 +49,11 @@ namespace
{ {
struct lcl_NumberedStringGenerator struct lcl_NumberedStringGenerator
{ {
lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) : lcl_NumberedStringGenerator( const OUString & rStub, std::u16string_view rWildcard ) :
m_aStub( rStub ), m_aStub( rStub ),
m_nCounter( 0 ), m_nCounter( 0 ),
m_nStubStartIndex( rStub.indexOf( rWildcard )), m_nStubStartIndex( rStub.indexOf( rWildcard )),
m_nWildcardLength( rWildcard.getLength()) m_nWildcardLength( rWildcard.size())
{ {
} }
vector< uno::Any > operator()() vector< uno::Any > operator()()
@@ -114,12 +114,12 @@ void InternalData::createDefaultData()
m_aRowLabels.clear(); m_aRowLabels.clear();
m_aRowLabels.reserve( m_nRowCount ); m_aRowLabels.reserve( m_nRowCount );
generate_n( back_inserter( m_aRowLabels ), m_nRowCount, generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" )); lcl_NumberedStringGenerator( aRowName, u"%ROWNUMBER" ));
m_aColumnLabels.clear(); m_aColumnLabels.clear();
m_aColumnLabels.reserve( m_nColumnCount ); m_aColumnLabels.reserve( m_nColumnCount );
generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount, generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
lcl_NumberedStringGenerator( aColName, "%COLUMNNUMBER" )); lcl_NumberedStringGenerator( aColName, u"%COLUMNNUMBER" ));
} }
void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows ) void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )

View File

@@ -751,14 +751,14 @@ bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdenti
return bRet; return bRet;
} }
bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2 ) bool ObjectIdentifier::areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 )
{ {
bool bRet=false; bool bRet=false;
sal_Int32 nLastSign1 = rCID1.lastIndexOf( '=' ); size_t nLastSign1 = rCID1.rfind( '=' );
sal_Int32 nLastSign2 = rCID2.lastIndexOf( '=' ); size_t nLastSign2 = rCID2.rfind( '=' );
if( nLastSign1 == rCID1.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs if( nLastSign1 == rCID1.find( '=' ) )//CID cannot be sibling if only one "=" occurs
bRet=false; bRet=false;
else if( nLastSign2 == rCID2.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs else if( nLastSign2 == rCID2.find( '=' ) )//CID cannot be sibling if only one "=" occurs
bRet=false; bRet=false;
else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) ) else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) )
bRet=false; bRet=false;
@@ -781,14 +781,14 @@ bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2
return bRet; return bRet;
} }
bool ObjectIdentifier::areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 ) bool ObjectIdentifier::areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 )
{ {
if( rCID1 == rCID2 ) if( rCID1 == rCID2 )
return true; return true;
//draggable pie or donut segments need special treatment, as their CIDs do change with offset //draggable pie or donut segments need special treatment, as their CIDs do change with offset
{ {
if( rCID1.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 if( rCID1.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos
|| rCID2.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 ) || rCID2.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos )
return false; return false;
OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) ); OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) );
@@ -1063,16 +1063,16 @@ std::u16string_view ObjectIdentifier::getFullParentParticle( std::u16string_view
return aRet; return aRet;
} }
OUString ObjectIdentifier::getObjectID( const OUString& rCID ) OUString ObjectIdentifier::getObjectID( std::u16string_view rCID )
{ {
OUString aRet; OUString aRet;
sal_Int32 nStartPos = rCID.lastIndexOf('/'); size_t nStartPos = rCID.rfind('/');
if( nStartPos>=0 ) if( nStartPos != std::u16string_view::npos )
{ {
nStartPos++; nStartPos++;
sal_Int32 nEndPos = rCID.getLength(); size_t nEndPos = rCID.size();
aRet = rCID.copy(nStartPos,nEndPos-nStartPos); aRet = rCID.substr(nStartPos,nEndPos-nStartPos);
} }
return aRet; return aRet;

View File

@@ -83,11 +83,11 @@ struct lcl_OUStringRestToInt32
explicit lcl_OUStringRestToInt32( sal_Int32 nPrefixLength ) : explicit lcl_OUStringRestToInt32( sal_Int32 nPrefixLength ) :
m_nPrefixLength( nPrefixLength ) m_nPrefixLength( nPrefixLength )
{} {}
sal_Int32 operator() ( const OUString & rStr ) sal_Int32 operator() ( std::u16string_view rStr )
{ {
if( m_nPrefixLength > rStr.getLength() ) if( m_nPrefixLength > static_cast<sal_Int32>(rStr.size()) )
return 0; return 0;
return o3tl::toInt32(rStr.subView( m_nPrefixLength )); return o3tl::toInt32(rStr.substr( m_nPrefixLength ));
} }
private: private:
sal_Int32 m_nPrefixLength; sal_Int32 m_nPrefixLength;

View File

@@ -80,7 +80,7 @@ VCartesianAxis::~VCartesianAxis()
static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText, static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
const AxisLabelProperties& rAxisLabelProperties, const AxisLabelProperties& rAxisLabelProperties,
const OUString& rLabel, std::u16string_view rLabel,
const tNameSequence& rPropNames, const tNameSequence& rPropNames,
const tAnySequence& rPropValues, const tAnySequence& rPropValues,
const bool bIsHorizontalAxis ) const bool bIsHorizontalAxis )
@@ -89,10 +89,10 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
bool bIsDirectionVertical = bIsHorizontalAxis && bTextHorizontal; bool bIsDirectionVertical = bIsHorizontalAxis && bTextHorizontal;
const sal_Int32 nFullSize = bIsDirectionVertical ? rAxisLabelProperties.m_aFontReferenceSize.Height : rAxisLabelProperties.m_aFontReferenceSize.Width; const sal_Int32 nFullSize = bIsDirectionVertical ? rAxisLabelProperties.m_aFontReferenceSize.Height : rAxisLabelProperties.m_aFontReferenceSize.Width;
if( !nFullSize || !rLabel.getLength() ) if( !nFullSize || rLabel.empty() )
return; return;
const sal_Int32 nAvgCharWidth = rShape2DText.getSize().Width / rLabel.getLength(); const sal_Int32 nAvgCharWidth = rShape2DText.getSize().Width / rLabel.size();
sal_Int32 nMaxLabelsSize = bIsDirectionVertical ? rAxisLabelProperties.m_aMaximumSpaceForLabels.Height : rAxisLabelProperties.m_aMaximumSpaceForLabels.Width; sal_Int32 nMaxLabelsSize = bIsDirectionVertical ? rAxisLabelProperties.m_aMaximumSpaceForLabels.Height : rAxisLabelProperties.m_aMaximumSpaceForLabels.Width;
@@ -105,16 +105,16 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
static const OUStringLiteral sDots = u"..."; static const OUStringLiteral sDots = u"...";
const sal_Int32 nCharsToRemove = ( nTextSize - nMaxLabelsSize ) / nAvgCharWidth + 1; const sal_Int32 nCharsToRemove = ( nTextSize - nMaxLabelsSize ) / nAvgCharWidth + 1;
sal_Int32 nNewLen = rLabel.getLength() - nCharsToRemove - sDots.getLength(); sal_Int32 nNewLen = rLabel.size() - nCharsToRemove - sDots.getLength();
// Prevent from showing only dots // Prevent from showing only dots
if (nNewLen < 0) if (nNewLen < 0)
nNewLen = ( rLabel.getLength() >= sDots.getLength() ) ? sDots.getLength() : rLabel.getLength(); nNewLen = ( sal_Int32(rLabel.size()) >= sDots.getLength() ) ? sDots.getLength() : rLabel.size();
bool bCrop = nCharsToRemove > 0; bool bCrop = nCharsToRemove > 0;
if( !bCrop ) if( !bCrop )
return; return;
OUString aNewLabel = rLabel.copy( 0, nNewLen ); OUString aNewLabel( rLabel.substr( 0, nNewLen ) );
if( nNewLen > sDots.getLength() ) if( nNewLen > sDots.getLength() )
aNewLabel += sDots; aNewLabel += sDots;
rShape2DText.setString( aNewLabel ); rShape2DText.setString( aNewLabel );

View File

@@ -2832,7 +2832,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries(
{ {
//label //label
OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) ); OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) );
replaceParamterInString( aResStr, "%SERIESNAME", aLabelText ); replaceParamterInString( aResStr, u"%SERIESNAME", aLabelText );
aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties ); aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties );
// symbol // symbol