xmlDrawing.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 http://purl.oclc.or
  39. // g/ooxml/officeDoc ument/relationships - This element specifies the existence
  40. // of an image (binary large image or picture) and contains a reference to the
  41. // 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 the visual
  106. // shape properties that can be applied to a picture. These are the same properties that
  107. // are allowed to describe the visual properties of a shape but are used here to describe
  108. // the visual appearance of a picture within a document.
  109. type xlsxSpPr struct {
  110. Xfrm xlsxXfrm `xml:"a:xfrm"`
  111. PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
  112. }
  113. // xlsxPic elements encompass the definition of pictures within the DrawingML
  114. // framework. While pictures are in many ways very similar to shapes they have
  115. // specific properties that are unique in order to optimize for picture-
  116. // specific scenarios.
  117. type xlsxPic struct {
  118. NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
  119. BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
  120. SpPr xlsxSpPr `xml:"xdr:spPr"`
  121. }
  122. // xlsxFrom specifies the starting anchor.
  123. type xlsxFrom struct {
  124. Col int `xml:"xdr:col"`
  125. ColOff int `xml:"xdr:colOff"`
  126. Row int `xml:"xdr:row"`
  127. RowOff int `xml:"xdr:rowOff"`
  128. }
  129. // xlsxTo directly specifies the ending anchor.
  130. type xlsxTo struct {
  131. Col int `xml:"xdr:col"`
  132. ColOff int `xml:"xdr:colOff"`
  133. Row int `xml:"xdr:row"`
  134. RowOff int `xml:"xdr:rowOff"`
  135. }
  136. // xlsxClientData directly maps the clientData element. An empty element which
  137. // specifies (via attributes) certain properties related to printing and
  138. // selection of the drawing object. The fLocksWithSheet attribute (either true
  139. // or false) determines whether to disable selection when the sheet is
  140. // protected, and fPrintsWithSheet attribute (either true or false) determines
  141. // whether the object is printed when the sheet is printed.
  142. type xlsxClientData struct {
  143. FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
  144. FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
  145. }
  146. // xlsxTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape
  147. // Size). This element specifies a two cell anchor placeholder for a group, a
  148. // shape, or a drawing element. It moves with cells and its extents are in EMU
  149. // units.
  150. type xlsxTwoCellAnchor struct {
  151. EditAs string `xml:"editAs,attr,omitempty"`
  152. From *xlsxFrom `xml:"xdr:from"`
  153. To *xlsxTo `xml:"xdr:to"`
  154. Pic *xlsxPic `xml:"xdr:pic,omitempty"`
  155. GraphicFrame string `xml:",innerxml"`
  156. ClientData *xlsxClientData `xml:"xdr:clientData"`
  157. }
  158. // xlsxWsDr directly maps the root element for a part of this content type shall
  159. // wsDr.
  160. type xlsxWsDr struct {
  161. TwoCellAnchor []*xlsxTwoCellAnchor `xml:"xdr:twoCellAnchor"`
  162. Xdr string `xml:"xmlns:xdr,attr"`
  163. A string `xml:"xmlns:a,attr"`
  164. }
  165. // encodeWsDr directly maps the element xdr:wsDr.
  166. type encodeWsDr struct {
  167. WsDr xlsxWsDr `xml:"xdr:wsDr"`
  168. }