xmlDecodeDrawing.go 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // Copyright 2016 - 2019 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.8 or later.
  9. package excelize
  10. import "encoding/xml"
  11. // decodeCellAnchor directly maps the oneCellAnchor (One Cell Anchor Shape Size)
  12. // and twoCellAnchor (Two Cell Anchor Shape Size). This element specifies a two
  13. // cell anchor placeholder for a group, a shape, or a drawing element. It moves
  14. // with cells and its extents are in EMU units.
  15. type decodeCellAnchor struct {
  16. EditAs string `xml:"editAs,attr,omitempty"`
  17. Content string `xml:",innerxml"`
  18. }
  19. // decodeWsDr directly maps the root element for a part of this content type
  20. // shall wsDr. In order to solve the problem that the label structure is changed
  21. // after serialization and deserialization, two different structures are
  22. // defined. decodeWsDr just for deserialization.
  23. type decodeWsDr struct {
  24. A string `xml:"xmlns a,attr"`
  25. Xdr string `xml:"xmlns xdr,attr"`
  26. R string `xml:"xmlns r,attr"`
  27. OneCellAnchor []*decodeCellAnchor `xml:"oneCellAnchor,omitempty"`
  28. TwoCellAnchor []*decodeCellAnchor `xml:"twoCellAnchor,omitempty"`
  29. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing wsDr,omitempty"`
  30. }
  31. // decodeTwoCellAnchor directly maps the oneCellAnchor (One Cell Anchor Shape
  32. // Size) and twoCellAnchor (Two Cell Anchor Shape Size). This element specifies
  33. // a two cell anchor placeholder for a group, a shape, or a drawing element. It
  34. // moves with cells and its extents are in EMU units.
  35. type decodeTwoCellAnchor struct {
  36. From *decodeFrom `xml:"from"`
  37. To *decodeTo `xml:"to"`
  38. Pic *decodePic `xml:"pic,omitempty"`
  39. ClientData *decodeClientData `xml:"clientData"`
  40. }
  41. // decodeCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
  42. // element specifies non-visual canvas properties. This allows for additional
  43. // information that does not affect the appearance of the picture to be stored.
  44. type decodeCNvPr struct {
  45. ID int `xml:"id,attr"`
  46. Name string `xml:"name,attr"`
  47. Descr string `xml:"descr,attr"`
  48. Title string `xml:"title,attr,omitempty"`
  49. }
  50. // decodePicLocks directly maps the picLocks (Picture Locks). This element
  51. // specifies all locking properties for a graphic frame. These properties inform
  52. // the generating application about specific properties that have been
  53. // previously locked and thus should not be changed.
  54. type decodePicLocks struct {
  55. NoAdjustHandles bool `xml:"noAdjustHandles,attr,omitempty"`
  56. NoChangeArrowheads bool `xml:"noChangeArrowheads,attr,omitempty"`
  57. NoChangeAspect bool `xml:"noChangeAspect,attr"`
  58. NoChangeShapeType bool `xml:"noChangeShapeType,attr,omitempty"`
  59. NoCrop bool `xml:"noCrop,attr,omitempty"`
  60. NoEditPoints bool `xml:"noEditPoints,attr,omitempty"`
  61. NoGrp bool `xml:"noGrp,attr,omitempty"`
  62. NoMove bool `xml:"noMove,attr,omitempty"`
  63. NoResize bool `xml:"noResize,attr,omitempty"`
  64. NoRot bool `xml:"noRot,attr,omitempty"`
  65. NoSelect bool `xml:"noSelect,attr,omitempty"`
  66. }
  67. // decodeBlip directly maps the blip element in the namespace
  68. // http://purl.oclc.org/ooxml/officeDoc ument/relationships - This element
  69. // specifies the existence of an image (binary large image or picture) and
  70. // contains a reference to the image data.
  71. type decodeBlip struct {
  72. Embed string `xml:"embed,attr"`
  73. Cstate string `xml:"cstate,attr,omitempty"`
  74. R string `xml:"r,attr"`
  75. }
  76. // decodeStretch directly maps the stretch element. This element specifies that
  77. // a BLIP should be stretched to fill the target rectangle. The other option is
  78. // a tile where a BLIP is tiled to fill the available area.
  79. type decodeStretch struct {
  80. FillRect string `xml:"fillRect"`
  81. }
  82. // decodeOff directly maps the colOff and rowOff element. This element is used
  83. // to specify the column offset within a cell.
  84. type decodeOff struct {
  85. X int `xml:"x,attr"`
  86. Y int `xml:"y,attr"`
  87. }
  88. // decodeExt directly maps the ext element.
  89. type decodeExt struct {
  90. Cx int `xml:"cx,attr"`
  91. Cy int `xml:"cy,attr"`
  92. }
  93. // decodePrstGeom directly maps the prstGeom (Preset geometry). This element
  94. // specifies when a preset geometric shape should be used instead of a custom
  95. // geometric shape. The generating application should be able to render all
  96. // preset geometries enumerated in the ST_ShapeType list.
  97. type decodePrstGeom struct {
  98. Prst string `xml:"prst,attr"`
  99. }
  100. // decodeXfrm directly maps the xfrm (2D Transform for Graphic Frame). This
  101. // element specifies the transform to be applied to the corresponding graphic
  102. // frame. This transformation is applied to the graphic frame just as it would
  103. // be for a shape or group shape.
  104. type decodeXfrm struct {
  105. Off decodeOff `xml:"off"`
  106. Ext decodeExt `xml:"ext"`
  107. }
  108. // decodeCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing
  109. // Properties). This element specifies the non-visual properties for the picture
  110. // canvas. These properties are to be used by the generating application to
  111. // determine how certain properties are to be changed for the picture object in
  112. // question.
  113. type decodeCNvPicPr struct {
  114. PicLocks decodePicLocks `xml:"picLocks"`
  115. }
  116. // directly maps the nvPicPr (Non-Visual Properties for a Picture). This element
  117. // specifies all non-visual properties for a picture. This element is a
  118. // container for the non-visual identification properties, shape properties and
  119. // application properties that are to be associated with a picture. This allows
  120. // for additional information that does not affect the appearance of the picture
  121. // to be stored.
  122. type decodeNvPicPr struct {
  123. CNvPr decodeCNvPr `xml:"cNvPr"`
  124. CNvPicPr decodeCNvPicPr `xml:"cNvPicPr"`
  125. }
  126. // decodeBlipFill directly maps the blipFill (Picture Fill). This element
  127. // specifies the kind of picture fill that the picture object has. Because a
  128. // picture has a picture fill already by default, it is possible to have two
  129. // fills specified for a picture object.
  130. type decodeBlipFill struct {
  131. Blip decodeBlip `xml:"blip"`
  132. Stretch decodeStretch `xml:"stretch"`
  133. }
  134. // decodeSpPr directly maps the spPr (Shape Properties). This element specifies
  135. // the visual shape properties that can be applied to a picture. These are the
  136. // same properties that are allowed to describe the visual properties of a shape
  137. // but are used here to describe the visual appearance of a picture within a
  138. // document.
  139. type decodeSpPr struct {
  140. Xfrm decodeXfrm `xml:"a:xfrm"`
  141. PrstGeom decodePrstGeom `xml:"a:prstGeom"`
  142. }
  143. // decodePic elements encompass the definition of pictures within the DrawingML
  144. // framework. While pictures are in many ways very similar to shapes they have
  145. // specific properties that are unique in order to optimize for picture-
  146. // specific scenarios.
  147. type decodePic struct {
  148. NvPicPr decodeNvPicPr `xml:"nvPicPr"`
  149. BlipFill decodeBlipFill `xml:"blipFill"`
  150. SpPr decodeSpPr `xml:"spPr"`
  151. }
  152. // decodeFrom specifies the starting anchor.
  153. type decodeFrom struct {
  154. Col int `xml:"col"`
  155. ColOff int `xml:"colOff"`
  156. Row int `xml:"row"`
  157. RowOff int `xml:"rowOff"`
  158. }
  159. // decodeTo directly specifies the ending anchor.
  160. type decodeTo struct {
  161. Col int `xml:"col"`
  162. ColOff int `xml:"colOff"`
  163. Row int `xml:"row"`
  164. RowOff int `xml:"rowOff"`
  165. }
  166. // decodeClientData directly maps the clientData element. An empty element which
  167. // specifies (via attributes) certain properties related to printing and
  168. // selection of the drawing object. The fLocksWithSheet attribute (either true
  169. // or false) determines whether to disable selection when the sheet is
  170. // protected, and fPrintsWithSheet attribute (either true or false) determines
  171. // whether the object is printed when the sheet is printed.
  172. type decodeClientData struct {
  173. FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
  174. FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
  175. }