xmlTheme.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Copyright 2016 - 2023 The excelize Authors. All rights reserved. Use of
  2. // this source code is governed by a BSD-style license that can be found in
  3. // the LICENSE file.
  4. //
  5. // Package excelize providing a set of functions that allow you to write to and
  6. // read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and
  7. // writing spreadsheet documents generated by Microsoft Excel™ 2007 and later.
  8. // Supports complex components by high compatibility, and provided streaming
  9. // API for generating or reading data from a worksheet with huge amounts of
  10. // data. This library needs Go version 1.16 or later.
  11. package excelize
  12. import "encoding/xml"
  13. // xlsxTheme directly maps the theme element in the namespace
  14. // http://schemas.openxmlformats.org/drawingml/2006/main
  15. type xlsxTheme struct {
  16. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/main theme"`
  17. XMLNSa string `xml:"xmlns:a,attr"`
  18. XMLNSr string `xml:"xmlns:r,attr"`
  19. Name string `xml:"name,attr"`
  20. ThemeElements xlsxBaseStyles `xml:"themeElements"`
  21. ObjectDefaults xlsxObjectDefaults `xml:"objectDefaults"`
  22. ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"extraClrSchemeLst"`
  23. CustClrLst *xlsxInnerXML `xml:"custClrLst"`
  24. ExtLst *xlsxExtLst `xml:"extLst"`
  25. }
  26. // xlsxBaseStyles defines the theme elements for a theme, and is the workhorse
  27. // of the theme. The bulk of the shared theme information that is used by a
  28. // given document is defined here. Within this complex type is defined a color
  29. // scheme, a font scheme, and a style matrix (format scheme) that defines
  30. // different formatting options for different pieces of a document.
  31. type xlsxBaseStyles struct {
  32. ClrScheme xlsxColorScheme `xml:"clrScheme"`
  33. FontScheme xlsxFontScheme `xml:"fontScheme"`
  34. FmtScheme xlsxStyleMatrix `xml:"fmtScheme"`
  35. ExtLst *xlsxExtLst `xml:"extLst"`
  36. }
  37. // xlsxCTColor holds the actual color values that are to be applied to a given
  38. // diagram and how those colors are to be applied.
  39. type xlsxCTColor struct {
  40. ScrgbClr *xlsxInnerXML `xml:"scrgbClr"`
  41. SrgbClr *attrValString `xml:"srgbClr"`
  42. HslClr *xlsxInnerXML `xml:"hslClr"`
  43. SysClr *xlsxSysClr `xml:"sysClr"`
  44. SchemeClr *xlsxInnerXML `xml:"schemeClr"`
  45. PrstClr *xlsxInnerXML `xml:"prstClr"`
  46. }
  47. // xlsxColorScheme defines a set of colors for the theme. The set of colors
  48. // consists of twelve color slots that can each hold a color of choice.
  49. type xlsxColorScheme struct {
  50. Name string `xml:"name,attr"`
  51. Dk1 xlsxCTColor `xml:"dk1"`
  52. Lt1 xlsxCTColor `xml:"lt1"`
  53. Dk2 xlsxCTColor `xml:"dk2"`
  54. Lt2 xlsxCTColor `xml:"lt2"`
  55. Accent1 xlsxCTColor `xml:"accent1"`
  56. Accent2 xlsxCTColor `xml:"accent2"`
  57. Accent3 xlsxCTColor `xml:"accent3"`
  58. Accent4 xlsxCTColor `xml:"accent4"`
  59. Accent5 xlsxCTColor `xml:"accent5"`
  60. Accent6 xlsxCTColor `xml:"accent6"`
  61. Hlink xlsxCTColor `xml:"hlink"`
  62. FolHlink xlsxCTColor `xml:"folHlink"`
  63. ExtLst *xlsxExtLst `xml:"extLst"`
  64. }
  65. // objectDefaults element allows for the definition of default shape, line,
  66. // and textbox formatting properties. An application can use this information
  67. // to format a shape (or text) initially on insertion into a document.
  68. type xlsxObjectDefaults struct {
  69. ObjectDefaults string `xml:",innerxml"`
  70. }
  71. // xlsxExtraClrSchemeLst element is a container for the list of extra color
  72. // schemes present in a document.
  73. type xlsxExtraClrSchemeLst struct {
  74. ExtraClrSchemeLst string `xml:",innerxml"`
  75. }
  76. // xlsxCTSupplementalFont defines an additional font that is used for language
  77. // specific fonts in themes. For example, one can specify a font that gets used
  78. // only within the Japanese language context.
  79. type xlsxCTSupplementalFont struct {
  80. Script string `xml:"script,attr"`
  81. Typeface string `xml:"typeface,attr"`
  82. }
  83. // xlsxFontCollection defines a major and minor font which is used in the font
  84. // scheme. A font collection consists of a font definition for Latin, East
  85. // Asian, and complex script. On top of these three definitions, one can also
  86. // define a font for use in a specific language or languages.
  87. type xlsxFontCollection struct {
  88. Latin *xlsxCTTextFont `xml:"latin"`
  89. Ea *xlsxCTTextFont `xml:"ea"`
  90. Cs *xlsxCTTextFont `xml:"cs"`
  91. Font []xlsxCTSupplementalFont `xml:"font"`
  92. ExtLst *xlsxExtLst `xml:"extLst"`
  93. }
  94. // xlsxFontScheme element defines the font scheme within the theme. The font
  95. // scheme consists of a pair of major and minor fonts for which to use in a
  96. // document. The major font corresponds well with the heading areas of a
  97. // document, and the minor font corresponds well with the normal text or
  98. // paragraph areas.
  99. type xlsxFontScheme struct {
  100. Name string `xml:"name,attr"`
  101. MajorFont xlsxFontCollection `xml:"majorFont"`
  102. MinorFont xlsxFontCollection `xml:"minorFont"`
  103. ExtLst *xlsxExtLst `xml:"extLst"`
  104. }
  105. // xlsxStyleMatrix defines a set of formatting options, which can be referenced
  106. // by documents that apply a certain style to a given part of an object. For
  107. // example, in a given shape, say a rectangle, one can reference a themed line
  108. // style, themed effect, and themed fill that would be theme specific and
  109. // change when the theme is changed.
  110. type xlsxStyleMatrix struct {
  111. Name string `xml:"name,attr,omitempty"`
  112. FillStyleLst xlsxFillStyleLst `xml:"fillStyleLst"`
  113. LnStyleLst xlsxLnStyleLst `xml:"lnStyleLst"`
  114. EffectStyleLst xlsxEffectStyleLst `xml:"effectStyleLst"`
  115. BgFillStyleLst xlsxBgFillStyleLst `xml:"bgFillStyleLst"`
  116. }
  117. // xlsxFillStyleLst element defines a set of three fill styles that are used
  118. // within a theme. The three fill styles are arranged in order from subtle to
  119. // moderate to intense.
  120. type xlsxFillStyleLst struct {
  121. FillStyleLst string `xml:",innerxml"`
  122. }
  123. // xlsxLnStyleLst element defines a list of three line styles for use within a
  124. // theme. The three line styles are arranged in order from subtle to moderate
  125. // to intense versions of lines. This list makes up part of the style matrix.
  126. type xlsxLnStyleLst struct {
  127. LnStyleLst string `xml:",innerxml"`
  128. }
  129. // xlsxEffectStyleLst element defines a set of three effect styles that create
  130. // the effect style list for a theme. The effect styles are arranged in order
  131. // of subtle to moderate to intense.
  132. type xlsxEffectStyleLst struct {
  133. EffectStyleLst string `xml:",innerxml"`
  134. }
  135. // xlsxBgFillStyleLst element defines a list of background fills that are
  136. // used within a theme. The background fills consist of three fills, arranged
  137. // in order from subtle to moderate to intense.
  138. type xlsxBgFillStyleLst struct {
  139. BgFillStyleLst string `xml:",innerxml"`
  140. }
  141. // xlsxSysClr element specifies a color bound to predefined operating system
  142. // elements.
  143. type xlsxSysClr struct {
  144. Val string `xml:"val,attr"`
  145. LastClr string `xml:"lastClr,attr"`
  146. }