xmlDecodeDrawing.go 8.1 KB

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