vmlDrawing.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. // vmlDrawing directly maps the root element in the file
  14. // xl/drawings/vmlDrawing%d.vml.
  15. type vmlDrawing struct {
  16. XMLName xml.Name `xml:"xml"`
  17. XMLNSv string `xml:"xmlns:v,attr"`
  18. XMLNSo string `xml:"xmlns:o,attr"`
  19. XMLNSx string `xml:"xmlns:x,attr"`
  20. XMLNSmv string `xml:"xmlns:mv,attr"`
  21. Shapelayout *xlsxShapelayout `xml:"o:shapelayout"`
  22. Shapetype *xlsxShapetype `xml:"v:shapetype"`
  23. Shape []xlsxShape `xml:"v:shape"`
  24. }
  25. // xlsxShapelayout directly maps the shapelayout element. This element contains
  26. // child elements that store information used in the editing and layout of
  27. // shapes.
  28. type xlsxShapelayout struct {
  29. Ext string `xml:"v:ext,attr"`
  30. IDmap *xlsxIDmap `xml:"o:idmap"`
  31. }
  32. // xlsxIDmap directly maps the idmap element.
  33. type xlsxIDmap struct {
  34. Ext string `xml:"v:ext,attr"`
  35. Data int `xml:"data,attr"`
  36. }
  37. // xlsxShape directly maps the shape element.
  38. type xlsxShape struct {
  39. XMLName xml.Name `xml:"v:shape"`
  40. ID string `xml:"id,attr"`
  41. Type string `xml:"type,attr"`
  42. Style string `xml:"style,attr"`
  43. Fillcolor string `xml:"fillcolor,attr"`
  44. Insetmode string `xml:"urn:schemas-microsoft-com:office:office insetmode,attr,omitempty"`
  45. Strokecolor string `xml:"strokecolor,attr,omitempty"`
  46. Val string `xml:",innerxml"`
  47. }
  48. // xlsxShapetype directly maps the shapetype element.
  49. type xlsxShapetype struct {
  50. ID string `xml:"id,attr"`
  51. Coordsize string `xml:"coordsize,attr"`
  52. Spt int `xml:"o:spt,attr"`
  53. Path string `xml:"path,attr"`
  54. Stroke *xlsxStroke `xml:"v:stroke"`
  55. VPath *vPath `xml:"v:path"`
  56. }
  57. // xlsxStroke directly maps the stroke element.
  58. type xlsxStroke struct {
  59. Joinstyle string `xml:"joinstyle,attr"`
  60. }
  61. // vPath directly maps the v:path element.
  62. type vPath struct {
  63. Gradientshapeok string `xml:"gradientshapeok,attr,omitempty"`
  64. Connecttype string `xml:"o:connecttype,attr"`
  65. }
  66. // vFill directly maps the v:fill element. This element must be defined within a
  67. // Shape element.
  68. type vFill struct {
  69. Angle int `xml:"angle,attr,omitempty"`
  70. Color2 string `xml:"color2,attr"`
  71. Type string `xml:"type,attr,omitempty"`
  72. Fill *oFill `xml:"o:fill"`
  73. }
  74. // oFill directly maps the o:fill element.
  75. type oFill struct {
  76. Ext string `xml:"v:ext,attr"`
  77. Type string `xml:"type,attr,omitempty"`
  78. }
  79. // vShadow directly maps the v:shadow element. This element must be defined
  80. // within a Shape element. In addition, the On attribute must be set to True.
  81. type vShadow struct {
  82. On string `xml:"on,attr"`
  83. Color string `xml:"color,attr,omitempty"`
  84. Obscured string `xml:"obscured,attr"`
  85. }
  86. // vTextbox directly maps the v:textbox element. This element must be defined
  87. // within a Shape element.
  88. type vTextbox struct {
  89. Style string `xml:"style,attr"`
  90. Div *xlsxDiv `xml:"div"`
  91. }
  92. // xlsxDiv directly maps the div element.
  93. type xlsxDiv struct {
  94. Style string `xml:"style,attr"`
  95. }
  96. // xClientData (Attached Object Data) directly maps the x:ClientData element.
  97. // This element specifies data associated with objects attached to a
  98. // spreadsheet. While this element might contain any of the child elements
  99. // below, only certain combinations are meaningful. The ObjectType attribute
  100. // determines the kind of object the element represents and which subset of
  101. // child elements is appropriate. Relevant groups are identified for each child
  102. // element.
  103. type xClientData struct {
  104. ObjectType string `xml:"ObjectType,attr"`
  105. MoveWithCells string `xml:"x:MoveWithCells,omitempty"`
  106. SizeWithCells string `xml:"x:SizeWithCells,omitempty"`
  107. Anchor string `xml:"x:Anchor"`
  108. AutoFill string `xml:"x:AutoFill"`
  109. Row int `xml:"x:Row"`
  110. Column int `xml:"x:Column"`
  111. }
  112. // decodeVmlDrawing defines the structure used to parse the file
  113. // xl/drawings/vmlDrawing%d.vml.
  114. type decodeVmlDrawing struct {
  115. Shape []decodeShape `xml:"urn:schemas-microsoft-com:vml shape"`
  116. }
  117. // decodeShape defines the structure used to parse the particular shape element.
  118. type decodeShape struct {
  119. Val string `xml:",innerxml"`
  120. }
  121. // encodeShape defines the structure used to re-serialization shape element.
  122. type encodeShape struct {
  123. Fill *vFill `xml:"v:fill"`
  124. Shadow *vShadow `xml:"v:shadow"`
  125. Path *vPath `xml:"v:path"`
  126. Textbox *vTextbox `xml:"v:textbox"`
  127. ClientData *xClientData `xml:"x:ClientData"`
  128. }