Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
99e91e19
excelize
项目概览
xuri
/
excelize
通知
13
Star
2
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
99e91e19
编写于
1月 30, 2024
作者:
X
xxxwang1983
提交者:
GitHub
1月 30, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
This closes #1794, add new GetBaseColor function (#1798)
Co-authored-by:
N
wangjingwei
<
wang.jingwei@joyratel.com
>
上级
9a685537
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
18 deletion
+29
-18
styles.go
styles.go
+29
-18
未找到文件。
styles.go
浏览文件 @
99e91e19
...
...
@@ -1369,14 +1369,11 @@ var (
}
)
// getThemeColor provides a function to convert theme color or index color to
// RGB color.
func
(
f
*
File
)
getThemeColor
(
clr
*
xlsxColor
)
string
{
var
RGB
string
if
clr
==
nil
||
f
.
Theme
==
nil
{
return
RGB
}
if
clrScheme
:=
f
.
Theme
.
ThemeElements
.
ClrScheme
;
clr
.
Theme
!=
nil
{
// GetBaseColor returns the preferred hex color code by giving hex color code,
// indexed color, and theme color.
func
(
f
*
File
)
GetBaseColor
(
hexColor
string
,
indexedColor
int
,
themeColor
*
int
)
string
{
if
f
.
Theme
!=
nil
&&
themeColor
!=
nil
{
clrScheme
:=
f
.
Theme
.
ThemeElements
.
ClrScheme
if
val
,
ok
:=
map
[
int
]
*
string
{
0
:
&
clrScheme
.
Lt1
.
SysClr
.
LastClr
,
1
:
&
clrScheme
.
Dk1
.
SysClr
.
LastClr
,
...
...
@@ -1388,21 +1385,35 @@ func (f *File) getThemeColor(clr *xlsxColor) string {
7
:
clrScheme
.
Accent4
.
SrgbClr
.
Val
,
8
:
clrScheme
.
Accent5
.
SrgbClr
.
Val
,
9
:
clrScheme
.
Accent6
.
SrgbClr
.
Val
,
}[
*
clr
.
Theme
];
ok
&&
val
!=
nil
{
return
strings
.
TrimPrefix
(
ThemeColor
(
*
val
,
clr
.
Tint
),
"FF"
)
}[
*
themeColor
];
ok
&&
val
!=
nil
{
return
*
val
}
}
if
len
(
hexColor
)
==
6
{
return
hexColor
}
if
len
(
hexColor
)
==
8
{
return
strings
.
TrimPrefix
(
hexColor
,
"FF"
)
}
if
len
(
clr
.
RGB
)
==
6
{
return
clr
.
RGB
if
f
.
Styles
!=
nil
&&
f
.
Styles
.
Colors
!=
nil
&&
f
.
Styles
.
Colors
.
IndexedColors
!=
nil
&&
indexedColor
<
len
(
f
.
Styles
.
Colors
.
IndexedColors
.
RgbColor
)
{
return
strings
.
TrimPrefix
(
f
.
Styles
.
Colors
.
IndexedColors
.
RgbColor
[
indexedColor
]
.
RGB
,
"FF"
)
}
if
len
(
clr
.
RGB
)
==
8
{
return
strings
.
TrimPrefix
(
clr
.
RGB
,
"FF"
)
if
indexedColor
<
len
(
IndexedColorMapping
)
{
return
IndexedColorMapping
[
indexedColor
]
}
if
f
.
Styles
.
Colors
!=
nil
&&
f
.
Styles
.
Colors
.
IndexedColors
!=
nil
&&
clr
.
Indexed
<
len
(
f
.
Styles
.
Colors
.
IndexedColors
.
RgbColor
)
{
return
strings
.
TrimPrefix
(
ThemeColor
(
strings
.
TrimPrefix
(
f
.
Styles
.
Colors
.
IndexedColors
.
RgbColor
[
clr
.
Indexed
]
.
RGB
,
"FF"
),
clr
.
Tint
),
"FF"
)
return
hexColor
}
// getThemeColor provides a function to convert theme color or index color to
// RGB color.
func
(
f
*
File
)
getThemeColor
(
clr
*
xlsxColor
)
string
{
var
RGB
string
if
clr
==
nil
||
f
.
Theme
==
nil
{
return
RGB
}
if
clr
.
Indexed
<
len
(
IndexedColorMapping
)
{
return
strings
.
TrimPrefix
(
ThemeColor
(
IndexedColorMapping
[
clr
.
Indexed
]
,
clr
.
Tint
),
"FF"
)
if
RGB
=
f
.
GetBaseColor
(
clr
.
RGB
,
clr
.
Indexed
,
clr
.
Theme
);
RGB
!=
""
{
RGB
=
strings
.
TrimPrefix
(
ThemeColor
(
RGB
,
clr
.
Tint
),
"FF"
)
}
return
RGB
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录