Skip to content

fix(OdfFile): cycle the default chart series colours - #459

Merged
chrip merged 2 commits into
mainfrom
fix/ooxml-odf-chart-many-series
Nov 27, 2026
Merged

chrip merged 2 commits into
mainfrom
fix/ooxml-odf-chart-many-series

Conversation

@chrip

@chrip chrip commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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 table default_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.cpp with a self-made fixture ExampleFiles/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, reads Object 1/content.xml, checks that all 70 series have a #rrggbb stroke 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

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
chrip requested a review from a team as a code owner November 26, 2026 16:38
@chrip
chrip requested review from Aiiaiiio and OlhaUshkalenko and removed request for a team November 26, 2026 16:38
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
chrip enabled auto-merge (squash) November 27, 2026 16:14
@chrip
chrip deployed to build-cache November 27, 2026 16:47 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 16:58 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 16:59 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 17:10 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 17:53 — with GitHub Actions Active
@chrip
chrip merged commit e697bb6 into main Nov 27, 2026
25 checks passed
@chrip
chrip deleted the fix/ooxml-odf-chart-many-series branch November 27, 2026 17:53
@chrip
chrip deployed to build-cache November 27, 2026 17:53 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
build-cache — 2140ba50 Deployed Nov 27, 2026 by chrip via prune #145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants