xmlTheme.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Copyright 2016 - 2021 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
  6. // and read from XLSX / XLSM / XLTM files. Supports reading and writing
  7. // spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
  8. // complex components by high compatibility, and provided streaming API for
  9. // generating or reading data from a worksheet with huge amounts of data. This
  10. // library needs Go version 1.15 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. ThemeElements xlsxThemeElements `xml:"themeElements"`
  17. ObjectDefaults xlsxObjectDefaults `xml:"objectDefaults"`
  18. ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"extraClrSchemeLst"`
  19. ExtLst *xlsxExtLst `xml:"extLst"`
  20. }
  21. // objectDefaults element allows for the definition of default shape, line,
  22. // and textbox formatting properties. An application can use this information
  23. // to format a shape (or text) initially on insertion into a document.
  24. type xlsxObjectDefaults struct {
  25. ObjectDefaults string `xml:",innerxml"`
  26. }
  27. // xlsxExtraClrSchemeLst element is a container for the list of extra color
  28. // schemes present in a document.
  29. type xlsxExtraClrSchemeLst struct {
  30. ExtraClrSchemeLst string `xml:",innerxml"`
  31. }
  32. // xlsxThemeElements directly maps the element defines the theme formatting
  33. // options for the theme and is the workhorse of the theme. This is where the
  34. // bulk of the shared theme information is contained and used by a document.
  35. // This element contains the color scheme, font scheme, and format scheme
  36. // elements which define the different formatting aspects of what a theme
  37. // defines.
  38. type xlsxThemeElements struct {
  39. ClrScheme xlsxClrScheme `xml:"clrScheme"`
  40. FontScheme xlsxFontScheme `xml:"fontScheme"`
  41. FmtScheme xlsxFmtScheme `xml:"fmtScheme"`
  42. }
  43. // xlsxClrScheme element specifies the theme color, stored in the document's
  44. // Theme part to which the value of this theme color shall be mapped. This
  45. // mapping enables multiple theme colors to be chained together.
  46. type xlsxClrScheme struct {
  47. Name string `xml:"name,attr"`
  48. Children []xlsxClrSchemeEl `xml:",any"`
  49. }
  50. // xlsxFontScheme element defines the font scheme within the theme. The font
  51. // scheme consists of a pair of major and minor fonts for which to use in a
  52. // document. The major font corresponds well with the heading areas of a
  53. // document, and the minor font corresponds well with the normal text or
  54. // paragraph areas.
  55. type xlsxFontScheme struct {
  56. Name string `xml:"name,attr"`
  57. MajorFont xlsxMajorFont `xml:"majorFont"`
  58. MinorFont xlsxMinorFont `xml:"minorFont"`
  59. ExtLst *xlsxExtLst `xml:"extLst"`
  60. }
  61. // xlsxMajorFont element defines the set of major fonts which are to be used
  62. // under different languages or locals.
  63. type xlsxMajorFont struct {
  64. Children []xlsxFontSchemeEl `xml:",any"`
  65. }
  66. // xlsxMinorFont element defines the set of minor fonts that are to be used
  67. // under different languages or locals.
  68. type xlsxMinorFont struct {
  69. Children []xlsxFontSchemeEl `xml:",any"`
  70. }
  71. // xlsxFmtScheme element contains the background fill styles, effect styles,
  72. // fill styles, and line styles which define the style matrix for a theme. The
  73. // style matrix consists of subtle, moderate, and intense fills, lines, and
  74. // effects. The background fills are not generally thought of to directly be
  75. // associated with the matrix, but do play a role in the style of the overall
  76. // document. Usually, a given object chooses a single line style, a single
  77. // fill style, and a single effect style in order to define the overall final
  78. // look of the object.
  79. type xlsxFmtScheme struct {
  80. Name string `xml:"name,attr"`
  81. FillStyleLst xlsxFillStyleLst `xml:"fillStyleLst"`
  82. LnStyleLst xlsxLnStyleLst `xml:"lnStyleLst"`
  83. EffectStyleLst xlsxEffectStyleLst `xml:"effectStyleLst"`
  84. BgFillStyleLst xlsxBgFillStyleLst `xml:"bgFillStyleLst"`
  85. }
  86. // xlsxFillStyleLst element defines a set of three fill styles that are used
  87. // within a theme. The three fill styles are arranged in order from subtle to
  88. // moderate to intense.
  89. type xlsxFillStyleLst struct {
  90. FillStyleLst string `xml:",innerxml"`
  91. }
  92. // xlsxLnStyleLst element defines a list of three line styles for use within a
  93. // theme. The three line styles are arranged in order from subtle to moderate
  94. // to intense versions of lines. This list makes up part of the style matrix.
  95. type xlsxLnStyleLst struct {
  96. LnStyleLst string `xml:",innerxml"`
  97. }
  98. // xlsxEffectStyleLst element defines a set of three effect styles that create
  99. // the effect style list for a theme. The effect styles are arranged in order
  100. // of subtle to moderate to intense.
  101. type xlsxEffectStyleLst struct {
  102. EffectStyleLst string `xml:",innerxml"`
  103. }
  104. // xlsxBgFillStyleLst element defines a list of background fills that are
  105. // used within a theme. The background fills consist of three fills, arranged
  106. // in order from subtle to moderate to intense.
  107. type xlsxBgFillStyleLst struct {
  108. BgFillStyleLst string `xml:",innerxml"`
  109. }
  110. // xlsxClrScheme specifies the theme color, stored in the document's Theme
  111. // part to which the value of this theme color shall be mapped. This mapping
  112. // enables multiple theme colors to be chained together.
  113. type xlsxClrSchemeEl struct {
  114. XMLName xml.Name
  115. SysClr *xlsxSysClr `xml:"sysClr"`
  116. SrgbClr *attrValString `xml:"srgbClr"`
  117. }
  118. // xlsxFontSchemeEl directly maps the major and minor font of the style's font
  119. // scheme.
  120. type xlsxFontSchemeEl struct {
  121. XMLName xml.Name
  122. Script string `xml:"script,attr,omitempty"`
  123. Typeface string `xml:"typeface,attr"`
  124. Panose string `xml:"panose,attr,omitempty"`
  125. PitchFamily string `xml:"pitchFamily,attr,omitempty"`
  126. Charset string `xml:"charset,attr,omitempty"`
  127. }
  128. // xlsxSysClr element specifies a color bound to predefined operating system
  129. // elements.
  130. type xlsxSysClr struct {
  131. Val string `xml:"val,attr"`
  132. LastClr string `xml:"lastClr,attr"`
  133. }