xmlDrawing.go 8.3 KB

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