xmlDrawing.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. // Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
  2. // this source code is governed by a BSD-style license that can be found in
  3. // the LICENSE file.
  4. //
  5. // Package excelize providing a set of functions that allow you to write to
  6. // and read from XLSX / XLSM / XLTM files. Supports reading and writing
  7. // spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
  8. // complex components by high compatibility, and provided streaming API for
  9. // generating or reading data from a worksheet with huge amounts of data. This
  10. // library needs Go version 1.15 or later.
  11. package excelize
  12. import "encoding/xml"
  13. // Source relationship and namespace list, associated prefixes and schema in which it was
  14. // introduced.
  15. var (
  16. SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"}
  17. SourceRelationshipCompatibility = xml.Attr{Name: xml.Name{Local: "mc", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/markup-compatibility/2006"}
  18. SourceRelationshipChart20070802 = xml.Attr{Name: xml.Name{Local: "c14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"}
  19. SourceRelationshipChart2014 = xml.Attr{Name: xml.Name{Local: "c16", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2014/chart"}
  20. SourceRelationshipChart201506 = xml.Attr{Name: xml.Name{Local: "c16r2", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2015/06/chart"}
  21. NameSpaceSpreadSheet = xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"}
  22. NameSpaceSpreadSheetX14 = xml.Attr{Name: xml.Name{Local: "x14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}
  23. NameSpaceDrawingML = xml.Attr{Name: xml.Name{Local: "a", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"}
  24. NameSpaceDrawingMLChart = xml.Attr{Name: xml.Name{Local: "c", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/chart"}
  25. NameSpaceDrawingMLSpreadSheet = xml.Attr{Name: xml.Name{Local: "xdr", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"}
  26. NameSpaceSpreadSheetX15 = xml.Attr{Name: xml.Name{Local: "x15", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"}
  27. NameSpaceSpreadSheetExcel2006Main = xml.Attr{Name: xml.Name{Local: "xne", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/excel/2006/main"}
  28. NameSpaceMacExcel2008Main = xml.Attr{Name: xml.Name{Local: "mx", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/mac/excel/2008/main"}
  29. )
  30. // Source relationship and namespace.
  31. const (
  32. SourceRelationshipOfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
  33. SourceRelationshipChart = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
  34. SourceRelationshipComments = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
  35. SourceRelationshipImage = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
  36. SourceRelationshipTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
  37. SourceRelationshipDrawingML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
  38. SourceRelationshipDrawingVML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
  39. SourceRelationshipHyperLink = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
  40. SourceRelationshipWorkSheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
  41. SourceRelationshipChartsheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
  42. SourceRelationshipDialogsheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"
  43. SourceRelationshipPivotTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
  44. SourceRelationshipPivotCache = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
  45. SourceRelationshipSharedStrings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
  46. SourceRelationshipVBAProject = "http://schemas.microsoft.com/office/2006/relationships/vbaProject"
  47. NameSpaceXML = "http://www.w3.org/XML/1998/namespace"
  48. NameSpaceXMLSchemaInstance = "http://www.w3.org/2001/XMLSchema-instance"
  49. StrictSourceRelationship = "http://purl.oclc.org/ooxml/officeDocument/relationships"
  50. StrictSourceRelationshipOfficeDocument = "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument"
  51. StrictSourceRelationshipChart = "http://purl.oclc.org/ooxml/officeDocument/relationships/chart"
  52. StrictSourceRelationshipComments = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
  53. StrictSourceRelationshipImage = "http://purl.oclc.org/ooxml/officeDocument/relationships/image"
  54. StrictNameSpaceSpreadSheet = "http://purl.oclc.org/ooxml/spreadsheetml/main"
  55. NameSpaceDublinCore = "http://purl.org/dc/elements/1.1/"
  56. NameSpaceDublinCoreTerms = "http://purl.org/dc/terms/"
  57. NameSpaceDublinCoreMetadataIntiative = "http://purl.org/dc/dcmitype/"
  58. ContentTypeDrawing = "application/vnd.openxmlformats-officedocument.drawing+xml"
  59. ContentTypeDrawingML = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
  60. ContentTypeMacro = "application/vnd.ms-excel.sheet.macroEnabled.main+xml"
  61. ContentTypeSpreadSheetMLChartsheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"
  62. ContentTypeSpreadSheetMLComments = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
  63. ContentTypeSpreadSheetMLPivotCacheDefinition = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
  64. ContentTypeSpreadSheetMLPivotTable = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
  65. ContentTypeSpreadSheetMLSharedStrings = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
  66. ContentTypeSpreadSheetMLTable = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
  67. ContentTypeSpreadSheetMLWorksheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
  68. ContentTypeVBA = "application/vnd.ms-office.vbaProject"
  69. ContentTypeVML = "application/vnd.openxmlformats-officedocument.vmlDrawing"
  70. // ExtURIConditionalFormattings is the extLst child element
  71. // ([ISO/IEC29500-1:2016] section 18.2.10) of the worksheet element
  72. // ([ISO/IEC29500-1:2016] section 18.3.1.99) is extended by the addition of
  73. // new child ext elements ([ISO/IEC29500-1:2016] section 18.2.7)
  74. ExtURIConditionalFormattings = "{78C0D931-6437-407D-A8EE-F0AAD7539E65}"
  75. ExtURIDataValidations = "{CCE6A557-97BC-4B89-ADB6-D9C93CAAB3DF}"
  76. ExtURISparklineGroups = "{05C60535-1F16-4fd2-B633-F4F36F0B64E0}"
  77. ExtURISlicerListX14 = "{A8765BA9-456A-4DAB-B4F3-ACF838C121DE}"
  78. ExtURISlicerCachesListX14 = "{BBE1A952-AA13-448e-AADC-164F8A28A991}"
  79. ExtURISlicerListX15 = "{3A4CF648-6AED-40f4-86FF-DC5316D8AED3}"
  80. ExtURIProtectedRanges = "{FC87AEE6-9EDD-4A0A-B7FB-166176984837}"
  81. ExtURIIgnoredErrors = "{01252117-D84E-4E92-8308-4BE1C098FCBB}"
  82. ExtURIWebExtensions = "{F7C9EE02-42E1-4005-9D12-6889AFFD525C}"
  83. ExtURITimelineRefs = "{7E03D99C-DC04-49d9-9315-930204A7B6E9}"
  84. ExtURIDrawingBlip = "{28A0092B-C50C-407E-A947-70E740481C1C}"
  85. ExtURIMacExcelMX = "{64002731-A6B0-56B0-2670-7721B7C09600}"
  86. )
  87. // Excel specifications and limits
  88. const (
  89. StreamChunkSize = 1 << 24
  90. MaxFontFamilyLength = 31
  91. MaxFontSize = 409
  92. MaxFileNameLength = 207
  93. MaxColumnWidth = 255
  94. MaxRowHeight = 409
  95. TotalRows = 1048576
  96. TotalColumns = 16384
  97. TotalSheetHyperlinks = 65529
  98. TotalCellChars = 32767
  99. // pivotTableVersion should be greater than 3. One or more of the
  100. // PivotTables chosen are created in a version of Excel earlier than
  101. // Excel 2007 or in compatibility mode. Slicer can only be used with
  102. // PivotTables created in Excel 2007 or a newer version of Excel.
  103. pivotTableVersion = 3
  104. )
  105. var supportImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff"}
  106. // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
  107. // element specifies non-visual canvas properties. This allows for additional
  108. // information that does not affect the appearance of the picture to be stored.
  109. type xlsxCNvPr struct {
  110. ID int `xml:"id,attr"`
  111. Name string `xml:"name,attr"`
  112. Descr string `xml:"descr,attr"`
  113. Title string `xml:"title,attr,omitempty"`
  114. HlinkClick *xlsxHlinkClick `xml:"a:hlinkClick"`
  115. }
  116. // xlsxHlinkClick (Click Hyperlink) Specifies the on-click hyperlink
  117. // information to be applied to a run of text. When the hyperlink text is
  118. // clicked the link is fetched.
  119. type xlsxHlinkClick struct {
  120. R string `xml:"xmlns:r,attr,omitempty"`
  121. RID string `xml:"r:id,attr,omitempty"`
  122. InvalidURL string `xml:"invalidUrl,attr,omitempty"`
  123. Action string `xml:"action,attr,omitempty"`
  124. TgtFrame string `xml:"tgtFrame,attr,omitempty"`
  125. Tooltip string `xml:"tooltip,attr,omitempty"`
  126. History bool `xml:"history,attr,omitempty"`
  127. HighlightClick bool `xml:"highlightClick,attr,omitempty"`
  128. EndSnd bool `xml:"endSnd,attr,omitempty"`
  129. }
  130. // xlsxPicLocks directly maps the picLocks (Picture Locks). This element
  131. // specifies all locking properties for a graphic frame. These properties inform
  132. // the generating application about specific properties that have been
  133. // previously locked and thus should not be changed.
  134. type xlsxPicLocks struct {
  135. NoAdjustHandles bool `xml:"noAdjustHandles,attr,omitempty"`
  136. NoChangeArrowheads bool `xml:"noChangeArrowheads,attr,omitempty"`
  137. NoChangeAspect bool `xml:"noChangeAspect,attr"`
  138. NoChangeShapeType bool `xml:"noChangeShapeType,attr,omitempty"`
  139. NoCrop bool `xml:"noCrop,attr,omitempty"`
  140. NoEditPoints bool `xml:"noEditPoints,attr,omitempty"`
  141. NoGrp bool `xml:"noGrp,attr,omitempty"`
  142. NoMove bool `xml:"noMove,attr,omitempty"`
  143. NoResize bool `xml:"noResize,attr,omitempty"`
  144. NoRot bool `xml:"noRot,attr,omitempty"`
  145. NoSelect bool `xml:"noSelect,attr,omitempty"`
  146. }
  147. // xlsxBlip directly maps the blip element in the namespace
  148. // http://purl.oclc.org/ooxml/officeDoc ument/relationships - This element
  149. // specifies the existence of an image (binary large image or picture) and
  150. // contains a reference to the image data.
  151. type xlsxBlip struct {
  152. Embed string `xml:"r:embed,attr"`
  153. Cstate string `xml:"cstate,attr,omitempty"`
  154. R string `xml:"xmlns:r,attr"`
  155. }
  156. // xlsxStretch directly maps the stretch element. This element specifies that a
  157. // BLIP should be stretched to fill the target rectangle. The other option is a
  158. // tile where a BLIP is tiled to fill the available area.
  159. type xlsxStretch struct {
  160. FillRect string `xml:"a:fillRect"`
  161. }
  162. // xlsxOff directly maps the colOff and rowOff element. This element is used to
  163. // specify the column offset within a cell.
  164. type xlsxOff struct {
  165. X int `xml:"x,attr"`
  166. Y int `xml:"y,attr"`
  167. }
  168. // xlsxExt directly maps the ext element.
  169. type xlsxExt struct {
  170. Cx int `xml:"cx,attr"`
  171. Cy int `xml:"cy,attr"`
  172. }
  173. // xlsxPrstGeom directly maps the prstGeom (Preset geometry). This element
  174. // specifies when a preset geometric shape should be used instead of a custom
  175. // geometric shape. The generating application should be able to render all
  176. // preset geometries enumerated in the ST_ShapeType list.
  177. type xlsxPrstGeom struct {
  178. Prst string `xml:"prst,attr"`
  179. }
  180. // xlsxXfrm directly maps the xfrm (2D Transform for Graphic Frame). This
  181. // element specifies the transform to be applied to the corresponding graphic
  182. // frame. This transformation is applied to the graphic frame just as it would
  183. // be for a shape or group shape.
  184. type xlsxXfrm struct {
  185. Off xlsxOff `xml:"a:off"`
  186. Ext xlsxExt `xml:"a:ext"`
  187. }
  188. // xlsxCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing
  189. // Properties). This element specifies the non-visual properties for the picture
  190. // canvas. These properties are to be used by the generating application to
  191. // determine how certain properties are to be changed for the picture object in
  192. // question.
  193. type xlsxCNvPicPr struct {
  194. PicLocks xlsxPicLocks `xml:"a:picLocks"`
  195. }
  196. // directly maps the nvPicPr (Non-Visual Properties for a Picture). This element
  197. // specifies all non-visual properties for a picture. This element is a
  198. // container for the non-visual identification properties, shape properties and
  199. // application properties that are to be associated with a picture. This allows
  200. // for additional information that does not affect the appearance of the picture
  201. // to be stored.
  202. type xlsxNvPicPr struct {
  203. CNvPr xlsxCNvPr `xml:"xdr:cNvPr"`
  204. CNvPicPr xlsxCNvPicPr `xml:"xdr:cNvPicPr"`
  205. }
  206. // xlsxBlipFill directly maps the blipFill (Picture Fill). This element
  207. // specifies the kind of picture fill that the picture object has. Because a
  208. // picture has a picture fill already by default, it is possible to have two
  209. // fills specified for a picture object.
  210. type xlsxBlipFill struct {
  211. Blip xlsxBlip `xml:"a:blip"`
  212. Stretch xlsxStretch `xml:"a:stretch"`
  213. }
  214. // xlsxSpPr directly maps the spPr (Shape Properties). This element specifies
  215. // the visual shape properties that can be applied to a picture. These are the
  216. // same properties that are allowed to describe the visual properties of a shape
  217. // but are used here to describe the visual appearance of a picture within a
  218. // document.
  219. type xlsxSpPr struct {
  220. Xfrm xlsxXfrm `xml:"a:xfrm"`
  221. PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
  222. }
  223. // xlsxPic elements encompass the definition of pictures within the DrawingML
  224. // framework. While pictures are in many ways very similar to shapes they have
  225. // specific properties that are unique in order to optimize for picture-
  226. // specific scenarios.
  227. type xlsxPic struct {
  228. NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
  229. BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
  230. SpPr xlsxSpPr `xml:"xdr:spPr"`
  231. }
  232. // xlsxFrom specifies the starting anchor.
  233. type xlsxFrom struct {
  234. Col int `xml:"xdr:col"`
  235. ColOff int `xml:"xdr:colOff"`
  236. Row int `xml:"xdr:row"`
  237. RowOff int `xml:"xdr:rowOff"`
  238. }
  239. // xlsxTo directly specifies the ending anchor.
  240. type xlsxTo struct {
  241. Col int `xml:"xdr:col"`
  242. ColOff int `xml:"xdr:colOff"`
  243. Row int `xml:"xdr:row"`
  244. RowOff int `xml:"xdr:rowOff"`
  245. }
  246. // xdrClientData directly maps the clientData element. An empty element which
  247. // specifies (via attributes) certain properties related to printing and
  248. // selection of the drawing object. The fLocksWithSheet attribute (either true
  249. // or false) determines whether to disable selection when the sheet is
  250. // protected, and fPrintsWithSheet attribute (either true or false) determines
  251. // whether the object is printed when the sheet is printed.
  252. type xdrClientData struct {
  253. FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
  254. FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
  255. }
  256. // xdrCellAnchor directly maps the oneCellAnchor (One Cell Anchor Shape Size)
  257. // and twoCellAnchor (Two Cell Anchor Shape Size). This element specifies a two
  258. // cell anchor placeholder for a group, a shape, or a drawing element. It moves
  259. // with cells and its extents are in EMU units.
  260. type xdrCellAnchor struct {
  261. EditAs string `xml:"editAs,attr,omitempty"`
  262. Pos *xlsxPoint2D `xml:"xdr:pos"`
  263. From *xlsxFrom `xml:"xdr:from"`
  264. To *xlsxTo `xml:"xdr:to"`
  265. Ext *xlsxExt `xml:"xdr:ext"`
  266. Sp *xdrSp `xml:"xdr:sp"`
  267. Pic *xlsxPic `xml:"xdr:pic,omitempty"`
  268. GraphicFrame string `xml:",innerxml"`
  269. ClientData *xdrClientData `xml:"xdr:clientData"`
  270. }
  271. // xlsxPoint2D describes the position of a drawing element within a spreadsheet.
  272. type xlsxPoint2D struct {
  273. XMLName xml.Name `xml:"xdr:pos"`
  274. X int `xml:"x,attr"`
  275. Y int `xml:"y,attr"`
  276. }
  277. // xlsxWsDr directly maps the root element for a part of this content type shall
  278. // wsDr.
  279. type xlsxWsDr struct {
  280. XMLName xml.Name `xml:"xdr:wsDr"`
  281. AbsoluteAnchor []*xdrCellAnchor `xml:"xdr:absoluteAnchor"`
  282. OneCellAnchor []*xdrCellAnchor `xml:"xdr:oneCellAnchor"`
  283. TwoCellAnchor []*xdrCellAnchor `xml:"xdr:twoCellAnchor"`
  284. A string `xml:"xmlns:a,attr,omitempty"`
  285. Xdr string `xml:"xmlns:xdr,attr,omitempty"`
  286. R string `xml:"xmlns:r,attr,omitempty"`
  287. }
  288. // xlsxGraphicFrame (Graphic Frame) directly maps the xdr:graphicFrame element.
  289. // This element specifies the existence of a graphics frame. This frame contains
  290. // a graphic that was generated by an external source and needs a container in
  291. // which to be displayed on the slide surface.
  292. type xlsxGraphicFrame struct {
  293. XMLName xml.Name `xml:"xdr:graphicFrame"`
  294. Macro string `xml:"macro,attr"`
  295. NvGraphicFramePr xlsxNvGraphicFramePr `xml:"xdr:nvGraphicFramePr"`
  296. Xfrm xlsxXfrm `xml:"xdr:xfrm"`
  297. Graphic *xlsxGraphic `xml:"a:graphic"`
  298. }
  299. // xlsxNvGraphicFramePr (Non-Visual Properties for a Graphic Frame) directly
  300. // maps the xdr:nvGraphicFramePr element. This element specifies all non-visual
  301. // properties for a graphic frame. This element is a container for the non-
  302. // visual identification properties, shape properties and application properties
  303. // that are to be associated with a graphic frame. This allows for additional
  304. // information that does not affect the appearance of the graphic frame to be
  305. // stored.
  306. type xlsxNvGraphicFramePr struct {
  307. CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
  308. ChicNvGraphicFramePr string `xml:"xdr:cNvGraphicFramePr"`
  309. }
  310. // xlsxGraphic (Graphic Object) directly maps the a:graphic element. This
  311. // element specifies the existence of a single graphic object. Document authors
  312. // should refer to this element when they wish to persist a graphical object of
  313. // some kind. The specification for this graphical object is provided entirely
  314. // by the document author and referenced within the graphicData child element.
  315. type xlsxGraphic struct {
  316. GraphicData *xlsxGraphicData `xml:"a:graphicData"`
  317. }
  318. // xlsxGraphicData (Graphic Object Data) directly maps the a:graphicData
  319. // element. This element specifies the reference to a graphic object within the
  320. // document. This graphic object is provided entirely by the document authors
  321. // who choose to persist this data within the document.
  322. type xlsxGraphicData struct {
  323. URI string `xml:"uri,attr"`
  324. Chart *xlsxChart `xml:"c:chart,omitempty"`
  325. }
  326. // xlsxChart (Chart) directly maps the c:chart element.
  327. type xlsxChart struct {
  328. C string `xml:"xmlns:c,attr"`
  329. RID string `xml:"r:id,attr"`
  330. R string `xml:"xmlns:r,attr"`
  331. }
  332. // xdrSp (Shape) directly maps the xdr:sp element. This element specifies the
  333. // existence of a single shape. A shape can either be a preset or a custom
  334. // geometry, defined using the SpreadsheetDrawingML framework. In addition to a
  335. // geometry each shape can have both visual and non-visual properties attached.
  336. // Text and corresponding styling information can also be attached to a shape.
  337. // This shape is specified along with all other shapes within either the shape
  338. // tree or group shape elements.
  339. type xdrSp struct {
  340. Macro string `xml:"macro,attr"`
  341. Textlink string `xml:"textlink,attr"`
  342. NvSpPr *xdrNvSpPr `xml:"xdr:nvSpPr"`
  343. SpPr *xlsxSpPr `xml:"xdr:spPr"`
  344. Style *xdrStyle `xml:"xdr:style"`
  345. TxBody *xdrTxBody `xml:"xdr:txBody"`
  346. }
  347. // xdrNvSpPr (Non-Visual Properties for a Shape) directly maps the xdr:nvSpPr
  348. // element. This element specifies all non-visual properties for a shape. This
  349. // element is a container for the non-visual identification properties, shape
  350. // properties and application properties that are to be associated with a shape.
  351. // This allows for additional information that does not affect the appearance of
  352. // the shape to be stored.
  353. type xdrNvSpPr struct {
  354. CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
  355. CNvSpPr *xdrCNvSpPr `xml:"xdr:cNvSpPr"`
  356. }
  357. // xdrCNvSpPr (Connection Non-Visual Shape Properties) directly maps the
  358. // xdr:cNvSpPr element. This element specifies the set of non-visual properties
  359. // for a connection shape. These properties specify all data about the
  360. // connection shape which do not affect its display within a spreadsheet.
  361. type xdrCNvSpPr struct {
  362. TxBox bool `xml:"txBox,attr"`
  363. }
  364. // xdrStyle (Shape Style) directly maps the xdr:style element. The element
  365. // specifies the style that is applied to a shape and the corresponding
  366. // references for each of the style components such as lines and fills.
  367. type xdrStyle struct {
  368. LnRef *aRef `xml:"a:lnRef"`
  369. FillRef *aRef `xml:"a:fillRef"`
  370. EffectRef *aRef `xml:"a:effectRef"`
  371. FontRef *aFontRef `xml:"a:fontRef"`
  372. }
  373. // aRef directly maps the a:lnRef, a:fillRef and a:effectRef element.
  374. type aRef struct {
  375. Idx int `xml:"idx,attr"`
  376. ScrgbClr *aScrgbClr `xml:"a:scrgbClr"`
  377. SchemeClr *attrValString `xml:"a:schemeClr"`
  378. SrgbClr *attrValString `xml:"a:srgbClr"`
  379. }
  380. // aScrgbClr (RGB Color Model - Percentage Variant) directly maps the a:scrgbClr
  381. // element. This element specifies a color using the red, green, blue RGB color
  382. // model. Each component, red, green, and blue is expressed as a percentage from
  383. // 0% to 100%. A linear gamma of 1.0 is assumed.
  384. type aScrgbClr struct {
  385. R float64 `xml:"r,attr"`
  386. G float64 `xml:"g,attr"`
  387. B float64 `xml:"b,attr"`
  388. }
  389. // aFontRef (Font Reference) directly maps the a:fontRef element. This element
  390. // represents a reference to a themed font. When used it specifies which themed
  391. // font to use along with a choice of color.
  392. type aFontRef struct {
  393. Idx string `xml:"idx,attr"`
  394. SchemeClr *attrValString `xml:"a:schemeClr"`
  395. }
  396. // xdrTxBody (Shape Text Body) directly maps the xdr:txBody element. This
  397. // element specifies the existence of text to be contained within the
  398. // corresponding shape. All visible text and visible text related properties are
  399. // contained within this element. There can be multiple paragraphs and within
  400. // paragraphs multiple runs of text.
  401. type xdrTxBody struct {
  402. BodyPr *aBodyPr `xml:"a:bodyPr"`
  403. P []*aP `xml:"a:p"`
  404. }
  405. // formatPicture directly maps the format settings of the picture.
  406. type formatPicture struct {
  407. FPrintsWithSheet bool `json:"print_obj"`
  408. FLocksWithSheet bool `json:"locked"`
  409. NoChangeAspect bool `json:"lock_aspect_ratio"`
  410. Autofit bool `json:"autofit"`
  411. OffsetX int `json:"x_offset"`
  412. OffsetY int `json:"y_offset"`
  413. XScale float64 `json:"x_scale"`
  414. YScale float64 `json:"y_scale"`
  415. Hyperlink string `json:"hyperlink"`
  416. HyperlinkType string `json:"hyperlink_type"`
  417. Positioning string `json:"positioning"`
  418. }
  419. // formatShape directly maps the format settings of the shape.
  420. type formatShape struct {
  421. Type string `json:"type"`
  422. Width int `json:"width"`
  423. Height int `json:"height"`
  424. Format formatPicture `json:"format"`
  425. Color formatShapeColor `json:"color"`
  426. Paragraph []formatShapeParagraph `json:"paragraph"`
  427. }
  428. // formatShapeParagraph directly maps the format settings of the paragraph in
  429. // the shape.
  430. type formatShapeParagraph struct {
  431. Font Font `json:"font"`
  432. Text string `json:"text"`
  433. }
  434. // formatShapeColor directly maps the color settings of the shape.
  435. type formatShapeColor struct {
  436. Line string `json:"line"`
  437. Fill string `json:"fill"`
  438. Effect string `json:"effect"`
  439. }