我整天都在战斗。在我的styles.xml文件中,我具有如下所示的颜色信息:
ECMA 376将主题颜色引用定义为:
好的,听起来很简单。这是我的clrScheme xml的摘录:
索引零是黑色,并且他们想要变暗吗?我可以告诉您,在应用色调后,颜色应为#F2F2F2。
我的困惑是theme =“0”到底是什么意思?不可能意味着使#000000变暗。检查MSDN只会使我更加困惑。从http://msdn.microsoft.com/en-us/library/dd560821.aspx
实际上,如果您从零开始计数,则第三个条目是Light2。黑暗2是第二个条目。这里有人可以帮我阐明一下这个问题吗? theme =“0”到底是什么意思?
这是我一直在使用以应用色调的VB6代码。您可以将其粘贴到vba编辑器中,然后运行test子程序。
Public Type tRGB
R As Byte
G As Byte
B As Byte
End Type
Public Type tHSL
H As Double
S As Double
L As Double
End Type
Sub TestRgbTint()
Dim c As tRGB
RGB_Hex2Type "ffffff", c
RGB_ApplyTint c, -0.249977111117893
Debug.Print Hex(c.R) & Hex(c.G) & Hex(c.B)
End Sub
Public Sub RGB_Hex2Type(ByVal HexString As String, RGB As tRGB)
'Remove the alpha channel if it exists
If Len(HexString) = 8 Then
HexString = mID(HexString, 3)
End If
RGB.R = CByte("&H" & Left(HexString, 2))
RGB.G = CByte("&H" & mID(HexString, 3, 2))
RGB.B = CByte("&H" & Right(HexString, 2))
End Sub
Public Sub RGB_ApplyTint(RGB As tRGB, tint As Double)
Const HLSMAX = 1#
Dim HSL As tHSL
If tint = 0 Then Exit Sub
RGB2HSL RGB, HSL
If tint < 0 Then
HSL.L = HSL.L * (1# + tint)
Else
HSL.L = HSL.L * (1# - tint) + (HLSMAX - HLSMAX * (1# - tint))
End If
HSL2RGB HSL, RGB
End Sub
Public Sub HSL2RGB(HSL As tHSL, RGB As tRGB)
HSL2RGB_ByVal HSL.H, HSL.S, HSL.L, RGB
End Sub
Private Sub HSL2RGB_ByVal(ByVal H As Double, ByVal S As Double, ByVal L As Double, RGB As tRGB)
Dim v As Double
Dim R As Double, G As Double, B As Double
'Default color to gray
R = L
G = L
B = L
If L < 0.5 Then
v = L * (1# + S)
Else
v = L + S - L * S
End If
If v > 0 Then
Dim m As Double, sv As Double
Dim sextant As Integer
Dim fract As Double, vsf As Double, mid1 As Double, mid2 As Double
m = L + L - v
sv = (v - m) / v
H = H * 6#
sextant = Int(H)
fract = H - sextant
vsf = v * sv * fract
mid1 = m + vsf
mid2 = v - vsf
Select Case sextant
Case 0
R = v
G = mid1
B = m
Case 1
R = mid2
G = v
B = m
Case 2
R = m
G = v
B = mid1
Case 3
R = m
G = mid2
B = v
Case 4
R = mid1
G = m
B = v
Case 5
R = v
G = m
B = mid2
End Select
End If
RGB.R = R * 255#
RGB.G = G * 255#
RGB.B = B * 255#
End Sub
Public Sub RGB2HSL(RGB As tRGB, HSL As tHSL)
Dim R As Double, G As Double, B As Double
Dim v As Double, m As Double, vm As Double
Dim r2 As Double, g2 As Double, b2 As Double
R = RGB.R / 255#
G = RGB.G / 255#
B = RGB.B / 255#
'Default to black
HSL.H = 0
HSL.S = 0
HSL.L = 0
v = IIf(R > G, R, G)
v = IIf(v > B, v, B)
m = IIf(R < G, R, G)
m = IIf(m < B, m, B)
HSL.L = (m + v) / 2#
If HSL.L < 0 Then
Exit Sub
End If
vm = v - m
HSL.S = vm
If HSL.S > 0 Then
If HSL.L <= 0.5 Then
HSL.S = HSL.S / (v + m)
Else
HSL.S = HSL.S / (2# - v - m)
End If
Else
Exit Sub
End If
r2 = (v - R) / vm
g2 = (v - G) / vm
b2 = (v - B) / vm
If R = v Then
If G = m Then
HSL.H = 5# + b2
Else
HSL.H = 1# - g2
End If
ElseIf G = v Then
If B = m Then
HSL.H = 1# + r2
Else
HSL.H = 3# - b2
End If
Else
If R = m Then
HSL.H = 3# + g2
Else
HSL.H = 5# - r2
End If
End If
HSL.H = HSL.H / 6#
End Sub
最佳答案
我从odf-converter.sourceforge.net checkout 了xsl,看起来好像切换了0和1以及切换了2和3。这是xsl部分:
<xsl:variable name="theme">
<xsl:choose>
<xsl:when test="@theme = 0">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="@theme = 1">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:when test="@theme = 2">
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:when test="@theme = 3">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@theme"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
现在一切都在匹配。注意0 = 1、1 = 0、2 = 3、3 = 2开关。
关于vb6 - SpreadsheetML中的主题困惑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2760976/