vmlDrawing.go 4.9 KB

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