Skip to content

fix(OdfFile): keep the ODF 1.3 sheet tab colour from ODS in XLSX - #406

Merged
chrip merged 4 commits into
mainfrom
fix/ods-xlsx-tab-color-odf13
Nov 27, 2026
Merged

chrip merged 4 commits into
mainfrom
fix/ods-xlsx-tab-color-odf13

Conversation

@chrip

@chrip chrip commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Sheet tab colours from current LibreOffice files were lost when an ODS
was opened: the editor showed every tab without its colour, and saving
the file back to ODS dropped the colours for good.

ODF 1.3 stores the tab colour as table:tab-color on the table style's
style:table-properties. LibreOffice writes that attribute when it
saves ODF 1.3 or later, its default format, and the older
tableooo:tab-color only for ODF 1.2 extended. The reader only knew
tableooo:tab-color.

The reader now reads table:tab-color as well and writes it to
sheetPr/tabColor. When a file has both attributes, table:tab-color
wins; tableooo:tab-color on its own is used as before.

Tests: four test_odf cases on one ODS with a sheet per case:
table:tab-color, tableooo:tab-color, both with different colours,
and no tab colour. The ODF 1.3 and the both-attributes cases fail
without the fix.

Review follow-up (second commit): a tab colour is taken only when its
value is # and six hex digits, the ODF colour type (LibreOffice also
ignores a value that is not # and six characters). An invalid
table:tab-color no longer hides a valid tableooo:tab-color, and a
value that is not a colour gives no tab colour instead of a black tab
or an invalid rgb in the XLSX. Two more test_odf cases on a second
ODS with one sheet per invalid value; both fail without the follow-up.
A value without # or with spaces around it is no colour either and is
now skipped, as in LibreOffice.

Assisted-by: ClaudeCode:claude-opus-5-5

🤖 Generated with Claude Code

Sheet tab colours from current LibreOffice files were lost when an ODS
was opened: the editor showed every tab without its colour, and saving
the file back to ODS dropped the colours for good.

ODF 1.3 stores the tab colour as table:tab-color on the table style's
style:table-properties. LibreOffice writes that attribute when it saves
ODF 1.3 or later, its default format, and the older tableooo:tab-color
only for ODF 1.2 extended. The reader only knew tableooo:tab-color.

Read table:tab-color as well and write it to sheetPr/tabColor. When a
file has both attributes, table:tab-color wins; tableooo:tab-color is
still used on its own as before.

Tested with four test_odf cases on one ODS with a sheet per case:
table:tab-color, tableooo:tab-color, both with different colours, and
no tab colour. The ODF 1.3 and the both-attributes cases fail without
the fix.

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 19, 2026 13:26
@chrip
chrip requested review from DmySyz and OlhaUshkalenko and removed request for a team November 19, 2026 13:26
@moodyjmz

Copy link
Copy Markdown
Member

Looks good. Minor, already on main and from reading the code: a malformed table:tab-color looks like it now hides a valid tableooo:tab-color next to it, and a value that isn't #-prefixed would become a black tab.

A table:tab-color value that is not a "#rrggbb" colour hid a valid
tableooo:tab-color on the same table style, and the sheet got a black
tab. Other invalid values gave a black tab as well, or an rgb attribute
that is not a colour in XLSX ("12", "GG0000"): color::get_hex_value()
falls back to black when it cannot read a value and passes short or
non-hex values through.

Take a tab colour only when its value is "#" and six hex digits, the
ODF colour type, and try tableooo:tab-color when table:tab-color is
missing or invalid. Without a valid value the sheet has no tab colour.
LibreOffice also ignores a value that is not "#" and six characters.

Tested with two new test_odf cases on a second ODS with a sheet per
invalid value: an invalid table:tab-color next to a valid
tableooo:tab-color, and four invalid values on their own. Both fail
without the fix.

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 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed with x2t: with table:tab-color="bluish" next to tableooo:tab-color="#ff0000" the sheet got a black tab, and
values like rgb(1,2,3) gave black too. Short or non-hex values (#12, #gg0000) even ended up as rgb="12" / rgb="GG0000" in the
XLSX.

The follow-up commit takes a tab colour only when it is # plus six hex digits, the ODF colour type (LibreOffice also ignores
values that aren't # plus six characters). An invalid
table:tab-color now falls back to tableooo:tab-color, and with no valid value the sheet has no tab colour. Two new tests cover the
fallback and four invalid values.

Assisted-by: ClaudeCode:claude-opus-5-5

Resolve the REUSE.toml conflict: keep the entries of this branch and the
ones added on main.

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>
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:20 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 16:44 — with GitHub Actions Active
@chrip
chrip deployed to build-cache November 27, 2026 16:45 — 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 17:35 — with GitHub Actions Active
@chrip
chrip merged commit 870dbde into main Nov 27, 2026
25 checks passed
@chrip
chrip deleted the fix/ods-xlsx-tab-color-odf13 branch November 27, 2026 17:36
@chrip
chrip deployed to build-cache November 27, 2026 17:36 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
build-cache — dbad3278 Deployed Nov 27, 2026 by chrip via prune #144
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.

3 participants