This repository was archived by the owner on Aug 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 823
fix: Panic caused by the absence of LastClr #847
Open
shcabin
wants to merge
1
commit into
tealeg:master
Choose a base branch
from
shcabin:fix/lastClr_nil
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ func newTheme(themeXml xlsxTheme) *theme { | |
| for _, scheme := range clrSchemes { | ||
| var rgbColor string | ||
| if scheme.SysClr != nil { | ||
| rgbColor = scheme.SysClr.LastClr | ||
| rgbColor = scheme.SysClr.LastClr // LastClr is optional, so rgbColor may be an empty string | ||
| } else { | ||
| rgbColor = scheme.SrgbClr.Val | ||
| } | ||
|
|
@@ -31,7 +31,7 @@ func (t *theme) themeColor(index int64, tint float64) string { | |
| baseColor := t.colors[index] | ||
| if tint == 0 { | ||
| return "FF" + baseColor | ||
| } else { | ||
| } else if baseColor != "" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear that this won't create unexpected errors. See my comment above. The way in v3 would be to define the system colours in a lookup table and insert those values when lastClr is missing. |
||
| r, _ := strconv.ParseInt(baseColor[0:2], 16, 64) | ||
| g, _ := strconv.ParseInt(baseColor[2:4], 16, 64) | ||
| b, _ := strconv.ParseInt(baseColor[4:6], 16, 64) | ||
|
|
@@ -44,4 +44,5 @@ func (t *theme) themeColor(index int64, tint float64) string { | |
| br, bg, bb := HSLToRGB(h, s, l) | ||
| return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb) | ||
| } | ||
| return "" | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comment. I feel like we really need to make the underlying options for a colour transparent to the public interface of the library. At the moment all of this code is pointing towards a use case where we need to know a concrete aRGB value for the colour - the only case where you need that is if you're rendering the document somewhere and this seems to be a less likely use case than generating or modifying a document. In that case we'd be better off just preserving the stylistic information as it is. Sadly fixing that means creating a v4 and I don't have the time or inclination to tackle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the way we intend this code to be used, the right fix for this situation is to define the values for the systemColors and use those values when lastClr is omitted.