Repository navigation
fix(OdfFile): keep the ODF 1.3 sheet tab colour from ODS in XLSX - #406
Conversation
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>
|
Looks good. Minor, already on main and from reading the code: a malformed |
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>
|
Thanks, confirmed with x2t: with The follow-up commit takes a tab colour only when it is 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>
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-coloron the table style'sstyle:table-properties. LibreOffice writes that attribute when itsaves ODF 1.3 or later, its default format, and the older
tableooo:tab-coloronly for ODF 1.2 extended. The reader only knewtableooo:tab-color.The reader now reads
table:tab-coloras well and writes it tosheetPr/tabColor. When a file has both attributes,table:tab-colorwins;
tableooo:tab-coloron its own is used as before.Tests: four
test_odfcases 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 alsoignores a value that is not
#and six characters). An invalidtable:tab-colorno longer hides a validtableooo:tab-color, and avalue that is not a colour gives no tab colour instead of a black tab
or an invalid
rgbin the XLSX. Two moretest_odfcases on a secondODS 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 isnow skipped, as in LibreOffice.
Assisted-by: ClaudeCode:claude-opus-5-5
🤖 Generated with Claude Code