vmlDrawing.go 4.4 KB

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