xmlDecodeDrawing.go 7.6 KB

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