xmlDrawing.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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).
  12. // This element specifies non-visual canvas properties. This allows for
  13. // additional information that does not affect the appearance of the
  14. // 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
  23. // inform the generating application about specific properties that have
  24. // been 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.or g/ooxml/officeDoc ument/relationships -
  40. // This element specifies the existence of an image (binary large image or
  41. // picture) and 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
  48. // that a BLIP should be stretched to fill the target rectangle. The other
  49. // option is a 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
  54. // to 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 specifies
  65. // when a preset geometric shape should be used instead of a custom geometric shape.
  66. // The generating application should be able to render all preset geometries enumerated
  67. // 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 element
  72. // specifies the transform to be applied to the corresponding graphic frame. This
  73. // transformation is applied to the graphic frame just as it would be for a shape
  74. // 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 Properties).
  80. // This element specifies the non-visual properties for the picture canvas. These
  81. // properties are to be used by the generating application to determine how certain
  82. // properties are to be changed for the picture object in 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 specifies
  87. // all non-visual properties for a picture. This element is a container for the non-visual
  88. // identification properties, shape properties and application properties that are to be
  89. // associated with a picture. This allows for additional information that does not affect
  90. // the appearance of the picture to be stored.
  91. type xlsxNvPicPr struct {
  92. CNvPr xlsxCNvPr `xml:"xdr:cNvPr"`
  93. CNvPicPr xlsxCNvPicPr `xml:"xdr:cNvPicPr"`
  94. }
  95. // xlsxBlipFill directly maps the blipFill (Picture Fill). This element specifies the kind
  96. // of picture fill that the picture object has. Because a picture has a picture fill already
  97. // by default, it is possible to have two fills specified for a picture object.
  98. type xlsxBlipFill struct {
  99. Blip xlsxBlip `xml:"a:blip"`
  100. Stretch xlsxStretch `xml:"a:stretch"`
  101. }
  102. // xlsxSpPr directly maps the spPr (Shape Properties). This element specifies the visual shape
  103. // properties that can be applied to a picture. These are the same properties that are allowed
  104. // to describe the visual properties of a shape but are used here to describe the visual
  105. // appearance of a picture within a document.
  106. type xlsxSpPr struct {
  107. Xfrm xlsxXfrm `xml:"a:xfrm"`
  108. PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
  109. }
  110. // xlsxPic elements encompass the definition of pictures within the DrawingML framework. While
  111. // pictures are in many ways very similar to shapes they have specific properties that are unique
  112. // in order to optimize for picture- specific scenarios.
  113. type xlsxPic struct {
  114. NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
  115. BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
  116. SpPr xlsxSpPr `xml:"xdr:spPr"`
  117. }
  118. // xlsxFrom specifies the starting anchor.
  119. type xlsxFrom struct {
  120. Col int `xml:"xdr:col"`
  121. ColOff int `xml:"xdr:colOff"`
  122. Row int `xml:"xdr:row"`
  123. RowOff int `xml:"xdr:rowOff"`
  124. }
  125. // xlsxTo directly specifies the ending anchor.
  126. type xlsxTo struct {
  127. Col int `xml:"xdr:col"`
  128. ColOff int `xml:"xdr:colOff"`
  129. Row int `xml:"xdr:row"`
  130. RowOff int `xml:"xdr:rowOff"`
  131. }
  132. // xlsxClientData directly maps the clientData element. An empty element which specifies (via
  133. // attributes) certain properties related to printing and selection of the drawing object. The
  134. // fLocksWithSheet attribute (either true or false) determines whether to disable selection when
  135. // the sheet is protected, and fPrintsWithSheet attribute (either true or false) determines whether
  136. // the object is printed when the sheet is printed.
  137. type xlsxClientData struct {
  138. FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
  139. FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
  140. }
  141. // xlsxTwoCellAnchor directly maps the twoCellAnchor (Two Cell Anchor Shape Size). This element
  142. // specifies a two cell anchor placeholder for a group, a shape, or a drawing element. It moves
  143. // with cells and its extents are in EMU units.
  144. type xlsxTwoCellAnchor struct {
  145. EditAs string `xml:"editAs,attr,omitempty"`
  146. From *xlsxFrom `xml:"xdr:from"`
  147. To *xlsxTo `xml:"xdr:to"`
  148. Pic *xlsxPic `xml:"xdr:pic,omitempty"`
  149. GraphicFrame string `xml:",innerxml"`
  150. ClientData *xlsxClientData `xml:"xdr:clientData"`
  151. }
  152. // xlsxWsDr directly maps the root element for a part of this content type shall wsDr.
  153. type xlsxWsDr struct {
  154. TwoCellAnchor []*xlsxTwoCellAnchor `xml:"xdr:twoCellAnchor"`
  155. Xdr string `xml:"xmlns:xdr,attr"`
  156. A string `xml:"xmlns:a,attr"`
  157. }
  158. // encodeWsDr directly maps the element xdr:wsDr.
  159. type encodeWsDr struct {
  160. WsDr xlsxWsDr `xml:"xdr:wsDr"`
  161. }