tdf#145538: Use range-based loops for palette and range fills
Replace index-only loops where we copy from containers into UNO or diagram structures using an explicit sequence index / output pointer: - BasicColorConfig: vector of property keys into Sequence OUString. - ChartColorScheme: palette colors into uno color sequence buffer. - RangeHighlighter: HighlightedRange list from OUString vectors. Verified: make -j4 basctl chart2 Change-Id: If4a4a8747fadc772329d3ccc3f03778406b140ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204659 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
This commit is contained in:
committed by
Jonathan Clark
parent
d16d0cf5c0
commit
71aa55e61a
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <BasicColorConfig.hxx>
|
||||
#include <officecfg/Office/BasicIDE.hxx>
|
||||
#include <algorithm>
|
||||
|
||||
namespace basctl
|
||||
{
|
||||
@@ -59,10 +60,7 @@ ColorScheme BasicColorConfig::GetColorScheme(const OUString& rScheme)
|
||||
|
||||
css::uno::Sequence<OUString> aPropNames(aVecPropNames.size());
|
||||
OUString* pPropNames = aPropNames.getArray();
|
||||
for (size_t i = 0; i < aVecPropNames.size(); i++)
|
||||
{
|
||||
pPropNames[i] = aVecPropNames[i];
|
||||
}
|
||||
std::copy(aVecPropNames.begin(), aVecPropNames.end(), pPropNames);
|
||||
css::uno::Sequence<css::uno::Any> aColors = GetProperties(aPropNames);
|
||||
|
||||
ColorScheme aColorScheme;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <ChartColorScheme.hxx>
|
||||
#include <algorithm>
|
||||
|
||||
namespace chart
|
||||
{
|
||||
@@ -28,10 +29,8 @@ ChartColorScheme::ChartColorScheme(const ChartColorPalette& rPalette)
|
||||
m_nNumberOfColors = rPalette.size();
|
||||
m_aColorSequence.realloc(m_nNumberOfColors);
|
||||
sal_Int64* pColors = m_aColorSequence.getArray();
|
||||
for (size_t i = 0; i < rPalette.size(); ++i)
|
||||
{
|
||||
pColors[i] = static_cast<sal_Int32>(rPalette[i]);
|
||||
}
|
||||
std::transform(rPalette.begin(), rPalette.end(), pColors,
|
||||
[](Color const& rColor) { return static_cast<sal_Int32>(rColor); });
|
||||
}
|
||||
|
||||
::sal_Int32 SAL_CALL ChartColorScheme::getColorByIndex(::sal_Int32 nIndex)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <comphelper/diagnose_ex.hxx>
|
||||
#include <tools/color.hxx>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
@@ -53,14 +54,12 @@ void lcl_fillRanges(
|
||||
sal_Int32 nIndex = -1 )
|
||||
{
|
||||
rOutRanges.realloc( aRangeStrings.size());
|
||||
auto pOutRanges = rOutRanges.getArray();
|
||||
for( size_t i=0; i<aRangeStrings.size(); ++i )
|
||||
{
|
||||
pOutRanges[i].RangeRepresentation = aRangeStrings[i];
|
||||
pOutRanges[i].PreferredColor = sal_Int32(nPreferredColor);
|
||||
pOutRanges[i].AllowMerginigWithOtherRanges = false;
|
||||
pOutRanges[i].Index = nIndex;
|
||||
}
|
||||
std::transform(aRangeStrings.begin(), aRangeStrings.end(), rOutRanges.getArray(),
|
||||
[nPreferredColor, nIndex](const OUString& rRange) {
|
||||
return chart2::data::HighlightedRange{
|
||||
rRange, /*index*/ nIndex, sal_Int32(nPreferredColor),
|
||||
/*allow merging*/ false };
|
||||
});
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@@ -192,15 +191,13 @@ void RangeHighlighter::fillRangesForDiagram( const rtl::Reference< Diagram > & x
|
||||
{
|
||||
std::vector< OUString > aSelectedRanges( DataSourceHelper::getUsedDataRanges( xDiagram ));
|
||||
m_aSelectedRanges.realloc( aSelectedRanges.size());
|
||||
auto pSelectedRanges = m_aSelectedRanges.getArray();
|
||||
// @todo: merge ranges
|
||||
for( size_t i=0; i<aSelectedRanges.size(); ++i )
|
||||
{
|
||||
pSelectedRanges[i].RangeRepresentation = aSelectedRanges[i];
|
||||
pSelectedRanges[i].Index = -1;
|
||||
pSelectedRanges[i].PreferredColor = sal_Int32(defaultPreferredColor);
|
||||
pSelectedRanges[i].AllowMerginigWithOtherRanges = true;
|
||||
}
|
||||
std::transform(aSelectedRanges.begin(), aSelectedRanges.end(), m_aSelectedRanges.getArray(),
|
||||
[](const OUString& rRange) {
|
||||
return chart2::data::HighlightedRange{
|
||||
rRange, /*index*/ -1, sal_Int32(defaultPreferredColor),
|
||||
/*allow merging*/ true };
|
||||
});
|
||||
}
|
||||
|
||||
void RangeHighlighter::fillRangesForDataSeries( const uno::Reference< chart2::XDataSeries > & xSeries )
|
||||
|
||||
Reference in New Issue
Block a user