Repository navigation
fix(OdfFile): cycle the default chart series colours - #459
Merged
Merged
Conversation
When a chart from an OOXML file is written to ODF, every series gets a default colour from a fixed table of 66 entries, picked by the series number. The number was not checked against the table size, so a chart with more than 66 series read past the end of the table: the extra series got an empty colour, and with a few hundred series the conversion stopped. The series number now wraps around the table, so series 67 and later start over at the first colour, as LibreOffice does with its default colour palette. Charts with fewer than 66 series are written as before. The new test converts an XLSX with a 70-series line chart to ODS and checks that every series has a colour and that series 67-70 continue the colour cycle. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
chrip
requested review from
Aiiaiiio and
OlhaUshkalenko
and removed request for
a team
November 26, 2026 16:38
DmySyz
approved these changes
Nov 27, 2026
Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Converting an OOXML file (XLSX, DOCX, PPTX) to ODF stopped when one of its charts had many series (a few hundred). With 67 to roughly a hundred series the conversion finished, but the series past the 66th got an empty colour (
svg:stroke-color="",draw:fill-color=""), which is not a valid ODF colour.Cause
odf_chart_context::Impl::set_default_series_color()(OdfFile/Writer/Format/odf_chart_context.cpp) gives each series a default colour from the static tabledefault_MS_series_colors[](66 entries: 11 colours repeated six times), indexed by the series counter without a bound check.Fix
Index the table modulo its size, so series 67 and later start over at the first colour. LibreOffice cycles its default chart palette the same way (
chart2/source/tools/ConfigColorScheme.cxx,getColorByIndex:nIndex % m_nNumberOfColors). Charts with fewer than 66 series get exactly the same colours as before.Tests
New
OdfFile/Test/test_odf/xlsx2ods_chart_many_series.cppwith a self-made fixtureExampleFiles/chart_line_70_series.xlsx(5 KB: one sheet, one line chart with 70 series, no explicit series colours; REUSE.toml annotation added).XlsxToOdsChartManySeries.SeriesBeyondTheDefaultColorsStartOver: converts to ODS, readsObject 1/content.xml, checks that all 70 series have a#rrggbbstroke colour and that series 67-70 continue the 11-colour cycle.Before the fix: FAILS (series 67-70 have an empty colour). After: PASSES. All other unit tests and the conversion tests pass unchanged.
Risks
Low. One line in one function; output changes only for charts with 66 or more series (and, in a chart with exactly 66 series, for the stock markers / drop lines that are coloured after the last series, which also read past the table before).
Assisted-by: ClaudeCode:claude-opus-5-5
🤖 Generated with Claude Code