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:
@@ -620,7 +620,7 @@ void DataBrowser::RenewTable()
|
||||
GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() ));
|
||||
|
||||
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 )
|
||||
+ GetDataWindow().LogicToPixel(Point(8 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0), MapMode(MapUnit::MapAppFont)).X();
|
||||
sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount();
|
||||
|
@@ -732,7 +732,7 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
|
||||
sal_Int32 nPointIndex = o3tl::toInt32( ObjectIdentifier::getParticleID(rObjectCID) );
|
||||
|
||||
// replace data point index
|
||||
replaceParamterInString( aRet, "%POINTNUMBER", OUString::number( nPointIndex + 1 ));
|
||||
replaceParamterInString( aRet, u"%POINTNUMBER", OUString::number( nPointIndex + 1 ));
|
||||
|
||||
// replace data series index
|
||||
{
|
||||
@@ -744,11 +744,11 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
|
||||
if( aSeriesVector[nSeriesIndex] == xSeries )
|
||||
break;
|
||||
}
|
||||
replaceParamterInString( aRet, "%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) );
|
||||
replaceParamterInString( aRet, u"%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) );
|
||||
}
|
||||
|
||||
// replace point value
|
||||
replaceParamterInString( aRet, "%POINTVALUES", lcl_getDataPointValueText(
|
||||
replaceParamterInString( aRet, u"%POINTVALUES", lcl_getDataPointValueText(
|
||||
xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartDocument ) );
|
||||
}
|
||||
}
|
||||
@@ -760,7 +760,7 @@ OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectC
|
||||
if( !aHelpText.isEmpty())
|
||||
{
|
||||
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() )
|
||||
{
|
||||
OUString aRet = SchResId(STR_OBJECT_FOR_SERIES);
|
||||
replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType ) );
|
||||
replaceParamterInString( aRet, "%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartDocument ) );
|
||||
replaceParamterInString( aRet, u"%OBJECTNAME", getName( eObjectType ) );
|
||||
replaceParamterInString( aRet, u"%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartDocument ) );
|
||||
return aRet;
|
||||
}
|
||||
else
|
||||
@@ -854,7 +854,7 @@ OUString ObjectNameProvider::getName_ObjectForSeries(
|
||||
OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -508,7 +508,7 @@ private:
|
||||
void executeDispatch_LineColor(sal_uInt32 nColor);
|
||||
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,
|
||||
const css::uno::Sequence< css::beans::PropertyValue >& rArgs );
|
||||
|
@@ -2066,7 +2066,7 @@ css::uno::Reference<css::uno::XInterface> const & ChartController::getChartView(
|
||||
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();
|
||||
if (!pChartModel)
|
||||
@@ -2085,10 +2085,10 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a
|
||||
return;
|
||||
|
||||
// Get dimension index from CID
|
||||
sal_Int32 nStartPos = rCID.lastIndexOf('.');
|
||||
size_t nStartPos = rCID.rfind('.');
|
||||
nStartPos++;
|
||||
sal_Int32 nEndPos = rCID.getLength();
|
||||
std::u16string_view sDimensionIndex = rCID.subView(nStartPos, nEndPos - nStartPos);
|
||||
sal_Int32 nEndPos = rCID.size();
|
||||
std::u16string_view sDimensionIndex = rCID.substr(nStartPos, nEndPos - nStartPos);
|
||||
sal_Int32 nDimensionIndex = o3tl::toInt32(sDimensionIndex);
|
||||
|
||||
awt::Rectangle xRectangle {
|
||||
|
@@ -211,7 +211,7 @@ sal_Int16 getShortForLongAlso( const css::uno::Any& rAny );
|
||||
|
||||
OOO_DLLPUBLIC_CHARTTOOLS
|
||||
bool replaceParamterInString( OUString & rInOutResourceString,
|
||||
const OUString & rParamToReplace,
|
||||
std::u16string_view rParamToReplace,
|
||||
std::u16string_view rReplaceWith );
|
||||
|
||||
} //namespace chart
|
||||
|
@@ -177,8 +177,8 @@ public:
|
||||
bool isDragableObject() const;
|
||||
static bool isRotateableObject( 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 areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 );
|
||||
static bool areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 );//identical object is no sibling
|
||||
static bool areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 );
|
||||
|
||||
static OUString getStringForType( ObjectType eObjectType );
|
||||
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 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 getFullParentParticle( std::u16string_view rCID );
|
||||
|
||||
|
@@ -583,7 +583,7 @@ sal_Int16 getShortForLongAlso( const uno::Any& rAny )
|
||||
}
|
||||
|
||||
bool replaceParamterInString( OUString & rInOutResourceString,
|
||||
const OUString & rParamToReplace,
|
||||
std::u16string_view rParamToReplace,
|
||||
std::u16string_view rReplaceWith )
|
||||
{
|
||||
sal_Int32 nPos = rInOutResourceString.indexOf( rParamToReplace );
|
||||
@@ -591,7 +591,7 @@ bool replaceParamterInString( OUString & rInOutResourceString,
|
||||
return false;
|
||||
|
||||
rInOutResourceString = rInOutResourceString.replaceAt( nPos
|
||||
, rParamToReplace.getLength(), rReplaceWith );
|
||||
, rParamToReplace.size(), rReplaceWith );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -49,11 +49,11 @@ namespace
|
||||
{
|
||||
struct lcl_NumberedStringGenerator
|
||||
{
|
||||
lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
|
||||
lcl_NumberedStringGenerator( const OUString & rStub, std::u16string_view rWildcard ) :
|
||||
m_aStub( rStub ),
|
||||
m_nCounter( 0 ),
|
||||
m_nStubStartIndex( rStub.indexOf( rWildcard )),
|
||||
m_nWildcardLength( rWildcard.getLength())
|
||||
m_nWildcardLength( rWildcard.size())
|
||||
{
|
||||
}
|
||||
vector< uno::Any > operator()()
|
||||
@@ -114,12 +114,12 @@ void InternalData::createDefaultData()
|
||||
m_aRowLabels.clear();
|
||||
m_aRowLabels.reserve( m_nRowCount );
|
||||
generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
|
||||
lcl_NumberedStringGenerator( aRowName, "%ROWNUMBER" ));
|
||||
lcl_NumberedStringGenerator( aRowName, u"%ROWNUMBER" ));
|
||||
|
||||
m_aColumnLabels.clear();
|
||||
m_aColumnLabels.reserve( 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 )
|
||||
|
@@ -751,14 +751,14 @@ bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdenti
|
||||
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;
|
||||
sal_Int32 nLastSign1 = rCID1.lastIndexOf( '=' );
|
||||
sal_Int32 nLastSign2 = rCID2.lastIndexOf( '=' );
|
||||
if( nLastSign1 == rCID1.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
|
||||
size_t nLastSign1 = rCID1.rfind( '=' );
|
||||
size_t nLastSign2 = rCID2.rfind( '=' );
|
||||
if( nLastSign1 == rCID1.find( '=' ) )//CID cannot be sibling if only one "=" occurs
|
||||
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;
|
||||
else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) )
|
||||
bRet=false;
|
||||
@@ -781,14 +781,14 @@ bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2
|
||||
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 )
|
||||
return true;
|
||||
//draggable pie or donut segments need special treatment, as their CIDs do change with offset
|
||||
{
|
||||
if( rCID1.indexOf( m_aPieSegmentDragMethodServiceName ) < 0
|
||||
|| rCID2.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 )
|
||||
if( rCID1.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos
|
||||
|| rCID2.find( m_aPieSegmentDragMethodServiceName ) == std::u16string_view::npos )
|
||||
return false;
|
||||
|
||||
OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) );
|
||||
@@ -1063,16 +1063,16 @@ std::u16string_view ObjectIdentifier::getFullParentParticle( std::u16string_view
|
||||
return aRet;
|
||||
}
|
||||
|
||||
OUString ObjectIdentifier::getObjectID( const OUString& rCID )
|
||||
OUString ObjectIdentifier::getObjectID( std::u16string_view rCID )
|
||||
{
|
||||
OUString aRet;
|
||||
|
||||
sal_Int32 nStartPos = rCID.lastIndexOf('/');
|
||||
if( nStartPos>=0 )
|
||||
size_t nStartPos = rCID.rfind('/');
|
||||
if( nStartPos != std::u16string_view::npos )
|
||||
{
|
||||
nStartPos++;
|
||||
sal_Int32 nEndPos = rCID.getLength();
|
||||
aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
|
||||
size_t nEndPos = rCID.size();
|
||||
aRet = rCID.substr(nStartPos,nEndPos-nStartPos);
|
||||
}
|
||||
|
||||
return aRet;
|
||||
|
@@ -83,11 +83,11 @@ struct lcl_OUStringRestToInt32
|
||||
explicit lcl_OUStringRestToInt32( sal_Int32 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 o3tl::toInt32(rStr.subView( m_nPrefixLength ));
|
||||
return o3tl::toInt32(rStr.substr( m_nPrefixLength ));
|
||||
}
|
||||
private:
|
||||
sal_Int32 m_nPrefixLength;
|
||||
|
@@ -80,7 +80,7 @@ VCartesianAxis::~VCartesianAxis()
|
||||
|
||||
static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
|
||||
const AxisLabelProperties& rAxisLabelProperties,
|
||||
const OUString& rLabel,
|
||||
std::u16string_view rLabel,
|
||||
const tNameSequence& rPropNames,
|
||||
const tAnySequence& rPropValues,
|
||||
const bool bIsHorizontalAxis )
|
||||
@@ -89,10 +89,10 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
|
||||
bool bIsDirectionVertical = bIsHorizontalAxis && bTextHorizontal;
|
||||
const sal_Int32 nFullSize = bIsDirectionVertical ? rAxisLabelProperties.m_aFontReferenceSize.Height : rAxisLabelProperties.m_aFontReferenceSize.Width;
|
||||
|
||||
if( !nFullSize || !rLabel.getLength() )
|
||||
if( !nFullSize || rLabel.empty() )
|
||||
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;
|
||||
|
||||
@@ -105,16 +105,16 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( SvxShapeText& rShape2DText,
|
||||
|
||||
static const OUStringLiteral sDots = u"...";
|
||||
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
|
||||
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;
|
||||
if( !bCrop )
|
||||
return;
|
||||
|
||||
OUString aNewLabel = rLabel.copy( 0, nNewLen );
|
||||
OUString aNewLabel( rLabel.substr( 0, nNewLen ) );
|
||||
if( nNewLen > sDots.getLength() )
|
||||
aNewLabel += sDots;
|
||||
rShape2DText.setString( aNewLabel );
|
||||
|
@@ -2832,7 +2832,7 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries(
|
||||
{
|
||||
//label
|
||||
OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) );
|
||||
replaceParamterInString( aResStr, "%SERIESNAME", aLabelText );
|
||||
replaceParamterInString( aResStr, u"%SERIESNAME", aLabelText );
|
||||
aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties );
|
||||
|
||||
// symbol
|
||||
|
Reference in New Issue
Block a user