xmlDrawing.go 23 KB

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