xmlDrawing.go 7.6 KB

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