xmlTheme.go 5.9 KB

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