xmlTheme.go 6.0 KB

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