xmlDrawing.go 8.2 KB

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