xmlDecodeDrawing.go 7.6 KB

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