SF_Chart.xba 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Chart" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
  4. REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
  5. REM === The SFDocuments library is one of the associated libraries. ===
  6. REM === Full documentation is available on https://help.libreoffice.org/ ===
  7. REM =======================================================================================================================
  8. Option Compatible
  9. Option ClassModule
  10. Option Explicit
  11. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  12. &apos;&apos;&apos; SF_Chart
  13. &apos;&apos;&apos; ========
  14. &apos;&apos;&apos;
  15. &apos;&apos;&apos; The SF_Chart module is focused on the description of chart documents
  16. &apos;&apos;&apos; stored in Calc sheets.
  17. &apos;&apos;&apos; With this service, many chart types and chart characteristics available
  18. &apos;&apos;&apos; in the user interface can be read or modified.
  19. &apos;&apos;&apos;
  20. &apos;&apos;&apos; Definitions
  21. &apos;&apos;&apos; Charts have 2 distinct names:
  22. &apos;&apos;&apos; - an internal name, given by the LibreOffice application
  23. &apos;&apos;&apos; - an optional user-defined name
  24. &apos;&apos;&apos; In the scope of the ScriptForge libraries, the chart name is the name given by the user.
  25. &apos;&apos;&apos; Only when there is no user name, the internal name may be used instead.
  26. &apos;&apos;&apos;
  27. &apos;&apos;&apos; Service invocation from the &quot;Calc&quot; service
  28. &apos;&apos;&apos; Either make a new chart
  29. &apos;&apos;&apos; calc.CreateChart(ChartName, SheetName, &quot;SheetX.A1:C8&quot;)
  30. &apos;&apos;&apos; or select an existing one
  31. &apos;&apos;&apos; calc.Charts(SheetName, ChartName)
  32. &apos;&apos;&apos;
  33. &apos;&apos;&apos; Detailed user documentation:
  34. &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_chart.html?DbPAR=BASIC
  35. &apos;&apos;&apos;
  36. &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
  37. REM ================================================================== EXCEPTIONS
  38. Private Const CHARTEXPORTERROR = &quot;CHARTEXPORTERROR&quot;
  39. REM ============================================================= PRIVATE MEMBERS
  40. Private [Me] As Object
  41. Private [_Parent] As Object &apos; Parent Calc document
  42. Private ObjectType As String &apos; Must be CHART
  43. Private ServiceName As String
  44. &apos; Chart description
  45. Private _SheetName As String &apos; Name of the Calc sheet containing the chart
  46. Private _DrawIndex As Long &apos; Index of the chart in the sheet&apos;s draw page
  47. Private _ChartName As String &apos; User name
  48. Private _PersistentName As String &apos; Internal name
  49. Private _Shape As Object &apos; com.sun.star.drawing.XShape
  50. Private _Chart As Object &apos; com.sun.star.table.XTableChart
  51. Private _ChartObject As Object &apos; com.sun.star.lang.XComponent - ScChartObj
  52. Private _Diagram As Object &apos; com.sun.star.chart.XDiagram
  53. REM ============================================================ MODULE CONSTANTS
  54. REM ====================================================== CONSTRUCTOR/DESTRUCTOR
  55. REM -----------------------------------------------------------------------------
  56. Private Sub Class_Initialize()
  57. Set [Me] = Nothing
  58. Set [_Parent] = Nothing
  59. ObjectType = &quot;CHART&quot;
  60. ServiceName = &quot;SFDocuments.Chart&quot;
  61. _SheetName = &quot;&quot;
  62. _DrawIndex = -1
  63. _ChartName = &quot;&quot;
  64. _PersistentName = &quot;&quot;
  65. Set _Shape = Nothing
  66. Set _Chart = Nothing
  67. Set _ChartObject = Nothing
  68. Set _Diagram = Nothing
  69. End Sub &apos; SFDocuments.SF_Chart Constructor
  70. REM -----------------------------------------------------------------------------
  71. Private Sub Class_Terminate()
  72. Call Class_Initialize()
  73. End Sub &apos; SFDocuments.SF_Chart Destructor
  74. REM -----------------------------------------------------------------------------
  75. Public Function Dispose() As Variant
  76. Call Class_Terminate()
  77. Set Dispose = Nothing
  78. End Function &apos; SFDocuments.SF_Chart Explicit Destructor
  79. REM ================================================================== PROPERTIES
  80. REM -----------------------------------------------------------------------------
  81. Property Get ChartType() As Variant
  82. &apos;&apos;&apos; The ChartType property specifies the type of chart as a string among next values:
  83. &apos;&apos;&apos; Pie, Bar, Donut, Column, Area, Line, XY, Bubble, Net
  84. ChartType = _PropertyGet(&quot;ChartType&quot;)
  85. End Property &apos; SFDocuments.SF_Chart.ChartType (get)
  86. REM -----------------------------------------------------------------------------
  87. Property Let ChartType(Optional ByVal pvChartType As Variant)
  88. &apos;&apos;&apos; Set the updatable property ChartType
  89. _PropertySet(&quot;ChartType&quot;, pvChartType)
  90. End Property &apos; SFDocuments.SF_Chart.ChartType (let)
  91. REM -----------------------------------------------------------------------------
  92. Property Get Deep() As Variant
  93. &apos;&apos;&apos; If True, determines that in a three-dimensional bar chart the bars of each series are arranged behind each other in the z-direction.
  94. &apos;&apos;&apos; If False the arrangement of bars is like in two-dimensional bar charts.
  95. &apos;&apos;&apos; Bar and Column chart types only
  96. Deep = _PropertyGet(&quot;Deep&quot;)
  97. End Property &apos; SFDocuments.SF_Chart.Deep (get)
  98. REM -----------------------------------------------------------------------------
  99. Property Let Deep(Optional ByVal pvDeep As Variant)
  100. &apos;&apos;&apos; Set the updatable property Deep
  101. _PropertySet(&quot;Deep&quot;, pvDeep)
  102. End Property &apos; SFDocuments.SF_Chart.Deep (let)
  103. REM -----------------------------------------------------------------------------
  104. Property Get Dim3D() As Variant
  105. &apos;&apos;&apos; The Dim3D property specifies if the chart is displayed with 3D elements
  106. &apos;&apos;&apos; String or Boolean
  107. &apos;&apos;&apos; When String, must be 1 of next values: Bar, Cylinder, Cone or Pyramid
  108. &apos;&apos;&apos; When Boolean True, Bar is assumed; when False, no 3D to be applied
  109. Dim3D = _PropertyGet(&quot;Dim3D&quot;)
  110. End Property &apos; SFDocuments.SF_Chart.Dim3D (get)
  111. REM -----------------------------------------------------------------------------
  112. Property Let Dim3D(Optional ByVal pvDim3D As Variant)
  113. &apos;&apos;&apos; Set the updatable property Dim3D
  114. _PropertySet(&quot;Dim3D&quot;, pvDim3D)
  115. End Property &apos; SFDocuments.SF_Chart.Dim3D (let)
  116. REM -----------------------------------------------------------------------------
  117. Property Get Exploded() As Variant
  118. &apos;&apos;&apos; the offset by which pie segments in a PieDiagram (pie or donut) are dragged outside from the center.
  119. &apos;&apos;&apos; This value is given in percent of the radius.
  120. Exploded = _PropertyGet(&quot;Exploded&quot;)
  121. End Property &apos; SFDocuments.SF_Chart.Exploded (get)_ChartObject
  122. REM -----------------------------------------------------------------------------
  123. Property Let Exploded(Optional ByVal pvExploded As Variant)
  124. &apos;&apos;&apos; Set the updatable property Exploded
  125. _PropertySet(&quot;Exploded&quot;, pvExploded)
  126. End Property &apos; SFDocuments.SF_Chart.Exploded (let)
  127. REM -----------------------------------------------------------------------------
  128. Property Get Filled() As Variant
  129. &apos;&apos;&apos; When True, the Net diagram is said of FilledNet type
  130. &apos;&apos;&apos; Net chart type only
  131. Filled = _PropertyGet(&quot;Filled&quot;)
  132. End Property &apos; SFDocuments.SF_Chart.Filled (get)
  133. REM -----------------------------------------------------------------------------
  134. Property Let Filled(Optional ByVal pvFilled As Variant)
  135. &apos;&apos;&apos; Set the updatable property Filled
  136. _PropertySet(&quot;Filled&quot;, pvFilled)
  137. End Property &apos; SFDocuments.SF_Chart.Filled (let)
  138. REM -----------------------------------------------------------------------------
  139. Property Get Legend() As Variant
  140. &apos;&apos;&apos; Specifies if the chart has a legend
  141. Legend = _PropertyGet(&quot;Legend&quot;)
  142. End Property &apos; SFDocuments.SF_Chart.Legend (get)
  143. REM -----------------------------------------------------------------------------
  144. Property Let Legend(Optional ByVal pvLegend As Variant)
  145. &apos;&apos;&apos; Set the updatable property Legend
  146. _PropertySet(&quot;Legend&quot;, pvLegend)
  147. End Property &apos; SFDocuments.SF_Chart.Legend (let)
  148. REM -----------------------------------------------------------------------------
  149. Property Get Percent() As Variant
  150. &apos;&apos;&apos; When True, the series of the diagram are stacked and each category sums up to 100%.
  151. &apos;&apos;&apos; Area, Bar, Bubble, Column and Net chart types only_ChartObject
  152. Percent = _PropertyGet(&quot;Percent&quot;)
  153. End Property &apos; SFDocuments.SF_Chart.Percent (get)
  154. REM -----------------------------------------------------------------------------
  155. Property Let Percent(Optional ByVal pvPercent As Variant)
  156. &apos;&apos;&apos; Set the updatable property Percent
  157. _PropertySet(&quot;Percent&quot;, pvPercent)
  158. End Property &apos; SFDocuments.SF_Chart.Percent (let)
  159. REM -----------------------------------------------------------------------------
  160. Property Get Stacked() As Variant
  161. &apos;&apos;&apos; When True, the series of the diagram are stacked.
  162. &apos;&apos;&apos; Area, Bar, Bubble, Column and Net chart types only
  163. Stacked = _PropertyGet(&quot;Stacked&quot;)
  164. End Property &apos; SFDocuments.SF_Chart.Stacked (get)
  165. REM -----------------------------------------------------------------------------
  166. Property Let Stacked(Optional ByVal pvStacked As Variant)
  167. &apos;&apos;&apos; Set the updatable property Stacked
  168. _PropertySet(&quot;Stacked&quot;, pvStacked)
  169. End Property &apos; SFDocuments.SF_Chart.Stacked (let)
  170. REM -----------------------------------------------------------------------------
  171. Property Get Title() As Variant
  172. &apos;&apos;&apos; Specifies the main title of the chart
  173. Title = _PropertyGet(&quot;Title&quot;)
  174. End Property &apos; SFDocuments.SF_Chart.Title (get)
  175. REM -----------------------------------------------------------------------------
  176. Property Let Title(Optional ByVal pvTitle As Variant)
  177. &apos;&apos;&apos; Set the updatable property Title
  178. _PropertySet(&quot;Title&quot;, pvTitle)
  179. End Property &apos; SFDocuments.SF_Chart.Title (let)
  180. REM -----------------------------------------------------------------------------
  181. Property Get XTitle() As Variant
  182. &apos;&apos;&apos; Specifies the main XTitle of the chart
  183. XTitle = _PropertyGet(&quot;XTitle&quot;)
  184. End Property &apos; SFDocuments.SF_Chart.XTitle (get)
  185. REM -----------------------------------------------------------------------------
  186. Property Let XTitle(Optional ByVal pvXTitle As Variant)
  187. &apos;&apos;&apos; Set the updatable property XTitle
  188. _PropertySet(&quot;XTitle&quot;, pvXTitle)
  189. End Property &apos; SFDocuments.SF_Chart.XTitle (let)
  190. REM -----------------------------------------------------------------------------
  191. Property Get YTitle() As Variant
  192. &apos;&apos;&apos; Specifies the main YTitle of the chart
  193. YTitle = _PropertyGet(&quot;YTitle&quot;)
  194. End Property &apos; SFDocuments.SF_Chart.YTitle (get)
  195. REM -----------------------------------------------------------------------------
  196. Property Let YTitle(Optional ByVal pvYTitle As Variant)
  197. &apos;&apos;&apos; Set the updatable property YTitle
  198. _PropertySet(&quot;YTitle&quot;, pvYTitle)
  199. End Property &apos; SFDocuments.SF_Chart.YTitle (let)
  200. REM -----------------------------------------------------------------------------
  201. Property Get XChartObj() As Variant
  202. &apos;&apos;&apos; com.sun.star.lang.XComponent - ScChartObj
  203. ChartType = _PropertyGet(&quot;XChartObj&quot;)
  204. End Property &apos; SFDocuments.SF_Chart.XChartObj (get)
  205. REM -----------------------------------------------------------------------------
  206. Property Get XDiagram() As Variant
  207. &apos;&apos;&apos; com.sun.star.chart.XDiagram
  208. ChartType = _PropertyGet(&quot;XDiagram&quot;)
  209. End Property &apos; SFDocuments.SF_Chart.XDiagram (get)
  210. REM -----------------------------------------------------------------------------
  211. Property Get XShape() As Variant
  212. &apos;&apos;&apos; com.sun.star.drawing.XShape
  213. ChartType = _PropertyGet(&quot;XShape&quot;)
  214. End Property &apos; SFDocuments.SF_Chart.XShape (get)
  215. REM -----------------------------------------------------------------------------
  216. Property Get XTableChart() As Variant
  217. &apos;&apos;&apos; com.sun.star.table.XTableChart
  218. ChartType = _PropertyGet(&quot;XTableChart&quot;)
  219. End Property &apos; SFDocuments.SF_Chart.XTableChart (get)
  220. REM ===================================================================== METHODS
  221. REM -----------------------------------------------------------------------------
  222. Public Function ExportToFile(Optional ByVal FileName As Variant _
  223. , Optional ByVal ImageType As Variant _
  224. , Optional ByVal Overwrite As Variant _
  225. ) As Boolean
  226. &apos;&apos;&apos; Store the chart as an image to the given file location
  227. &apos;&apos;&apos; Args:
  228. &apos;&apos;&apos; FileName: Identifies the file where to save. It must follow the SF_FileSystem.FileNaming notation
  229. &apos;&apos;&apos; ImageType: the name of the targeted image type
  230. &apos;&apos;&apos; Allowed values: gif, jpeg, png (default), svg and tiff
  231. &apos;&apos;&apos; Overwrite: True if the destination file may be overwritten (default = False)
  232. &apos;&apos;&apos; Returns:
  233. &apos;&apos;&apos; False if the document could not be saved
  234. &apos;&apos;&apos; Exceptions:
  235. &apos;&apos;&apos; CHARTEXPORTERROR The destination has its readonly attribute set or overwriting rejected
  236. &apos;&apos;&apos; Examples:
  237. &apos;&apos;&apos; oChart.ExportToFile(&quot;C:\Me\Chart2.gif&quot;, ImageType := &quot;gif&quot;, Overwrite := True)
  238. Dim bSaved As Boolean &apos; return value
  239. Dim oSfa As Object &apos; com.sun.star.ucb.SimpleFileAccess
  240. Dim sFile As String &apos; Alias of FileName
  241. Dim vStoreArguments As Variant &apos; Array of com.sun.star.beans.PropertyValue
  242. Dim FSO As Object &apos; SF_FileSystem
  243. Dim oExport As Object &apos; com.sun.star.drawing.GraphicExportFilter
  244. Dim vImageTypes As Variant &apos; Array of permitted image types
  245. Dim vMimeTypes As Variant &apos; Array of corresponding mime types in the same order as vImageTypes
  246. Const cstImageTypes = &quot;gif,jpeg,png,svg,tiff&quot;
  247. Const cstMimeTypes = &quot;image/gif,image/jpeg,image/png,image/svg+xml,image/tiff&quot;
  248. Const cstThisSub = &quot;SFDocuments.Chart.ExportToFile&quot;
  249. Const cstSubArgs = &quot;FileName, [ImageType=&quot;&quot;png&quot;&quot;|&quot;&quot;gif&quot;&quot;|&quot;&quot;jpeg&quot;&quot;|&quot;&quot;svg&quot;&quot;|&quot;&quot;tiff&quot;&quot;], [Overwrite=False]&quot;
  250. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo CatchError
  251. bSaved = False
  252. Check:
  253. If IsMissing(ImageType) Or IsEmpty(ImageType) Then ImageType = &quot;png&quot;
  254. If IsMissing(Overwrite) Or IsEmpty(Overwrite) Then Overwrite = False
  255. vImageTypes = Split(cstImageTypes, &quot;,&quot;)
  256. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  257. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  258. If Not ScriptForge.SF_Utils._ValidateFile(FileName, &quot;FileName&quot;) Then GoTo Finally
  259. If Not ScriptForge.SF_Utils._Validate(ImageType, &quot;ImageType&quot;, V_STRING, vImageTypes) Then GoTo Finally
  260. If Not ScriptForge.SF_Utils._Validate(Overwrite, &quot;Overwrite&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  261. End If
  262. &apos; Check destination file overwriting
  263. Set FSO = CreateScriptService(&quot;FileSystem&quot;)
  264. sFile = FSO._ConvertToUrl(FileName)
  265. If FSO.FileExists(FileName) Then
  266. If Overwrite = False Then GoTo CatchError
  267. Set oSfa = ScriptForge.SF_Utils._GetUNOService(&quot;FileAccess&quot;)
  268. If oSfa.isReadonly(sFile) Then GoTo CatchError
  269. End If
  270. Try:
  271. &apos; Setup arguments
  272. vMimeTypes = Split(cstMimeTypes, &quot;,&quot;)
  273. vStoreArguments = Array( _
  274. ScriptForge.SF_Utils._MakePropertyValue(&quot;URL&quot;, sFile) _
  275. , ScriptForge.SF_Utils._MakePropertyValue(&quot;MediaType&quot; _
  276. , vMimeTypes(ScriptForge.SF_Array.IndexOf(vImageTypes, ImageType, CaseSensitive := False))) _
  277. )
  278. &apos; Export with the com.sun.star.drawing.GraphicExportFilter UNO service
  279. Set oExport = ScriptForge.SF_Utils._GetUNOService(&quot;GraphicExportFilter&quot;)
  280. With oExport
  281. .setSourceDocument(_Shape)
  282. .filter(vStoreArguments)
  283. End With
  284. bSaved = True
  285. Finally:
  286. ExportToFile = bSaved
  287. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  288. Exit Function
  289. Catch:
  290. GoTo Finally
  291. CatchError:
  292. ScriptForge.SF_Exception.RaiseFatal(CHARTEXPORTERROR, &quot;FileName&quot;, FileName, &quot;Overwrite&quot;, Overwrite)
  293. GoTo Finally
  294. End Function &apos; SFDocuments.SF_Chart.ExportToFile
  295. REM -----------------------------------------------------------------------------
  296. Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
  297. &apos;&apos;&apos; Return the actual value of the given property
  298. &apos;&apos;&apos; Args:
  299. &apos;&apos;&apos; PropertyName: the name of the property as a string
  300. &apos;&apos;&apos; Returns:
  301. &apos;&apos;&apos; The actual value of the property
  302. &apos;&apos;&apos; If the property does not exist, returns Null
  303. &apos;&apos;&apos; Exceptions:
  304. &apos;&apos;&apos; ARGUMENTERROR The property does not exist
  305. Const cstThisSub = &quot;SFDocuments.Chart.GetProperty&quot;
  306. Const cstSubArgs = &quot;&quot;
  307. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  308. GetProperty = Null
  309. Check:
  310. If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  311. If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  312. End If
  313. Try:
  314. GetProperty = _PropertyGet(PropertyName)
  315. Finally:
  316. SF_Utils._ExitFunction(cstThisSub)
  317. Exit Function
  318. Catch:
  319. GoTo Finally
  320. End Function &apos; SFDocuments.SF_Chart.GetProperty
  321. REM -----------------------------------------------------------------------------
  322. Public Function Methods() As Variant
  323. &apos;&apos;&apos; Return the list of public methods of the Chart service as an array
  324. Methods = Array( _
  325. &quot;ExportToFile&quot; _
  326. , &quot;Resize&quot; _
  327. )
  328. End Function &apos; SFDocuments.SF_Chart.Methods
  329. REM -----------------------------------------------------------------------------
  330. Public Function Properties() As Variant
  331. &apos;&apos;&apos; Return the list or properties of the Chart class as an array
  332. Properties = Array( _
  333. &quot;ChartType&quot; _
  334. , &quot;Deep&quot; _
  335. , &quot;Dim3D&quot; _
  336. , &quot;Exploded&quot; _
  337. , &quot;Filled&quot; _
  338. , &quot;Legend&quot; _
  339. , &quot;Percent&quot; _
  340. , &quot;Stacked&quot; _
  341. , &quot;Title&quot; _
  342. , &quot;XChartObj&quot; _
  343. , &quot;XDiagram&quot; _
  344. , &quot;XShape&quot; _
  345. , &quot;XTableChart&quot; _
  346. , &quot;XTitle&quot; _
  347. , &quot;YTitle&quot; _
  348. )
  349. End Function &apos; SFDocuments.SF_Chart.Properties
  350. REM -----------------------------------------------------------------------------
  351. Public Function Resize(Optional ByVal XPos As Variant _
  352. , Optional ByVal YPos As Variant _
  353. , Optional ByVal Width As Variant _
  354. , Optional ByVal Height As Variant _
  355. ) As Boolean
  356. &apos;&apos;&apos; Move the topleft corner of a chart to new coordinates and/or modify its dimensions
  357. &apos;&apos;&apos; All distances are expressed in 1/100th mm
  358. &apos;&apos;&apos; Args:
  359. &apos;&apos;&apos; XPos : the vertical distance from the topleft corner
  360. &apos;&apos;&apos; YPos : the horizontal distance from the topleft corner
  361. &apos;&apos;&apos; Width : the horizontal width of the shape containing the chart
  362. &apos;&apos;&apos; Height : the vertical height of the shape containing the chart
  363. &apos;&apos;&apos; Negative or missing arguments are left unchanged
  364. &apos;&apos;&apos; Returns:
  365. &apos;&apos;&apos; True when successful
  366. &apos;&apos;&apos; Examples:
  367. &apos;&apos;&apos; oChart.Resize(1000, 2000, Height := 6000) &apos; Width is not changed
  368. Dim bResize As Boolean &apos; Return value
  369. Dim oPosition As Object &apos; com.sun.star.awt.Point
  370. Dim oSize As Object &apos; com.sun.star.awt.Size
  371. Const cstThisSub = &quot;SFDocuments.Chart.Resize&quot;
  372. Const cstSubArgs = &quot;[XPos], [YPos], [Width], [Height]&quot;
  373. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  374. bResize = False
  375. Check:
  376. If IsMissing(XPos) Or IsEmpty(XPos) Then XPos = -1
  377. If IsMissing(YPos) Or IsEmpty(YPos) Then YPos = -1
  378. If IsMissing(Height) Or IsEmpty(Height) Then Height = -1
  379. If IsMissing(Width) Or IsEmpty(Width) Then Width = -1
  380. If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  381. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  382. If Not ScriptForge.SF_Utils._Validate(XPos, &quot;XPos&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  383. If Not ScriptForge.SF_Utils._Validate(YPos, &quot;YPos&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  384. If Not ScriptForge.SF_Utils._Validate(Width, &quot;Width&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  385. If Not ScriptForge.SF_Utils._Validate(Height, &quot;Height&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  386. End If
  387. Try:
  388. With _Shape
  389. &apos; Get the current values
  390. Set oPosition = .Position
  391. Set oSize = .Size
  392. &apos; Modify relevant elements
  393. If XPos &gt;= 0 Then oPosition.X = CLng(XPos)
  394. If YPos &gt;= 0 Then oPosition.Y = CLng(YPos)
  395. If Width &gt; 0 Then oSize.Width = CLng(Width)
  396. If Height &gt; 0 Then oSize.Height = CLng(Height)
  397. &apos; Rewrite
  398. .setPosition(oPosition)
  399. .setSize(oSize)
  400. End With
  401. bResize = True
  402. Finally:
  403. Resize = bResize
  404. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  405. Exit Function
  406. Catch:
  407. GoTo Finally
  408. End Function &apos; SF_Documents.SF_Chart.Resize
  409. REM -----------------------------------------------------------------------------
  410. Public Function SetProperty(Optional ByVal PropertyName As Variant _
  411. , Optional ByRef Value As Variant _
  412. ) As Boolean
  413. &apos;&apos;&apos; Set a new value to the given property
  414. &apos;&apos;&apos; Args:
  415. &apos;&apos;&apos; PropertyName: the name of the property as a string
  416. &apos;&apos;&apos; Value: its new value
  417. &apos;&apos;&apos; Exceptions
  418. &apos;&apos;&apos; ARGUMENTERROR The property does not exist
  419. Const cstThisSub = &quot;SFDocuments.Chart.SetProperty&quot;
  420. Const cstSubArgs = &quot;PropertyName, Value&quot;
  421. If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  422. SetProperty = False
  423. Check:
  424. If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
  425. If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
  426. End If
  427. Try:
  428. SetProperty = _PropertySet(PropertyName, Value)
  429. Finally:
  430. SF_Utils._ExitFunction(cstThisSub)
  431. Exit Function
  432. Catch:
  433. GoTo Finally
  434. End Function &apos; SFDocuments.SF_Chart.SetProperty
  435. REM =========================================================== PRIVATE FUNCTIONS
  436. REM -----------------------------------------------------------------------------
  437. Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
  438. &apos;&apos;&apos; Return the value of the named property
  439. &apos;&apos;&apos; Args:
  440. &apos;&apos;&apos; psProperty: the name of the property
  441. Static oSession As Object &apos; Alias of SF_Session
  442. Dim vData As Variant &apos; Data points array of values
  443. Dim cstThisSub As String
  444. Const cstSubArgs = &quot;&quot;
  445. cstThisSub = &quot;SFDocuments.Chart.get&quot; &amp; psProperty
  446. SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  447. If Not [_Parent]._IsStillAlive() Then GoTo Finally
  448. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  449. Select Case UCase(psProperty)
  450. Case UCase(&quot;ChartType&quot;)
  451. With _Diagram
  452. Select Case .DiagramType
  453. Case &quot;com.sun.star.chart.BarDiagram&quot;
  454. If .Vertical Then _PropertyGet = &quot;Bar&quot; Else _PropertyGet = &quot;Column&quot;
  455. Case &quot;com.sun.star.chart.PieDiagram&quot;
  456. _PropertyGet = &quot;Pie&quot;
  457. Case &quot;com.sun.star.chart.DonutDiagram&quot;
  458. _PropertyGet = &quot;Donut&quot;
  459. Case &quot;com.sun.star.chart.AreaDiagram&quot;
  460. _PropertyGet = &quot;Area&quot;
  461. Case &quot;com.sun.star.chart.LineDiagram&quot;
  462. _PropertyGet = &quot;Line&quot;
  463. Case &quot;com.sun.star.chart.XYDiagram&quot;
  464. _PropertyGet = &quot;XY&quot;
  465. Case &quot;com.sun.star.chart.BubbleDiagram&quot;
  466. _PropertyGet = &quot;Bubble&quot;
  467. Case &quot;com.sun.star.chart.NetDiagram&quot;, &quot;com.sun.star.chart.FilledNetDiagram&quot;
  468. _PropertyGet = &quot;Net&quot;
  469. Case Else
  470. _PropertyGet = &quot;&quot;
  471. End Select
  472. End With
  473. Case UCase(&quot;Deep&quot;)
  474. If oSession.HasUnoProperty(_Diagram, &quot;Deep&quot;) Then _PropertyGet = _Diagram.Deep Else _PropertyGet = False
  475. Case UCase(&quot;Dim3D&quot;)
  476. If oSession.HasUnoProperty(_Diagram, &quot;Dim3D&quot;) Then
  477. If _Diagram.Dim3D Then
  478. If oSession.HasUnoProperty(_Diagram, &quot;SolidType&quot;) Then
  479. Select Case _Diagram.SolidType
  480. Case com.sun.star.chart.ChartSolidType.RECTANGULAR_SOLID : _PropertyGet = &quot;Bar&quot;
  481. Case com.sun.star.chart.ChartSolidType.CYLINDER : _PropertyGet = &quot;Cylinder&quot;
  482. Case com.sun.star.chart.ChartSolidType.CONE : _PropertyGet = &quot;Cone&quot;
  483. Case com.sun.star.chart.ChartSolidType.PYRAMID : _PropertyGet = &quot;Pyramid&quot;
  484. End Select
  485. Else
  486. _PropertyGet = _Diagram.Dim3D
  487. End If
  488. Else
  489. _PropertyGet = False
  490. End If
  491. Else
  492. _PropertyGet = False
  493. End If
  494. Case UCase(&quot;Exploded&quot;)
  495. If oSession.HasUnoProperty(_ChartObject, &quot;Data&quot;) Then
  496. &apos; All data points are presumed exploded with the same coefficient. Determine the (0, 0)th
  497. With _ChartObject
  498. vData = .Data.Data
  499. _PropertyGet = 0
  500. If IsArray(vData) Then
  501. If UBound(vData) &gt;= 0 Then
  502. If IsArray(vData(0)) Then
  503. If UBound(vData(0)) &gt;= 0 Then _PropertyGet = _Diagram.getDataPointProperties(0, 0).SegmentOffset
  504. End If
  505. End If
  506. End If
  507. End With
  508. End If
  509. Case UCase(&quot;Filled&quot;)
  510. _PropertyGet = ( _Diagram.DiagramType = &quot;com.sun.star.chart.FilledNetDiagram&quot; )
  511. Case UCase(&quot;Legend&quot;)
  512. If oSession.HasUnoProperty(_ChartObject, &quot;HasLegend&quot;) Then _PropertyGet = _ChartObject.HasLegend Else _PropertyGet = False
  513. Case UCase(&quot;Percent&quot;)
  514. If oSession.HasUnoProperty(_Diagram, &quot;Percent&quot;) Then _PropertyGet = _Diagram.Percent Else _PropertyGet = False
  515. Case UCase(&quot;Stacked&quot;)
  516. If oSession.HasUnoProperty(_Diagram, &quot;Stacked&quot;) Then _PropertyGet = _Diagram.Stacked Else _PropertyGet = False
  517. Case UCase(&quot;Title&quot;)
  518. If oSession.HasUnoProperty(_ChartObject, &quot;HasMainTitle&quot;) Then
  519. If _ChartObject.HasMainTitle Then _PropertyGet = _ChartObject.Title.String Else _PropertyGet = &quot;&quot;
  520. End If
  521. Case UCase(&quot;XTitle&quot;)
  522. If oSession.HasUnoProperty(_Diagram, &quot;HasXAxisTitle&quot;) Then
  523. If _Diagram.HasXAxisTitle Then _PropertyGet = _Diagram.XAxisTitle.String Else _PropertyGet = &quot;&quot;
  524. End If
  525. Case UCase(&quot;YTitle&quot;)
  526. If oSession.HasUnoProperty(_Diagram, &quot;HasYAxisTitle&quot;) Then
  527. If _Diagram.HasYAxisTitle Then _PropertyGet = _Diagram.YAxisTitle.String Else _PropertyGet = &quot;&quot;
  528. End If
  529. Case UCase(&quot;XChartObj&quot;)
  530. Set _PropertyGet = _ChartObject
  531. Case UCase(&quot;XDiagram&quot;)
  532. Set _PropertyGet = _Diagram
  533. Case UCase(&quot;XShape&quot;)
  534. Set _PropertyGet = _Shape
  535. Case UCase(&quot;XTableChart&quot;)
  536. Set _PropertyGet = _Chart
  537. Case Else
  538. _PropertyGet = Null
  539. End Select
  540. Finally:
  541. SF_Utils._ExitFunction(cstThisSub)
  542. Exit Function
  543. End Function &apos; SFDocuments.SF_Chart._PropertyGet
  544. REM -----------------------------------------------------------------------------
  545. Private Function _PropertySet(Optional ByVal psProperty As String _
  546. , Optional ByVal pvValue As Variant _
  547. ) As Boolean
  548. &apos;&apos;&apos; Set the new value of the named property
  549. &apos;&apos;&apos; Args:
  550. &apos;&apos;&apos; psProperty: the name of the property
  551. &apos;&apos;&apos; pvValue: the new value of the given property
  552. Dim bSet As Boolean &apos; Return value
  553. Static oSession As Object &apos; Alias of SF_Session
  554. Dim sChartType As String &apos; Diagram type
  555. Dim bDim3D As Boolean &apos; Alias of Dim3D property of diagram
  556. Dim bVertical As Boolean &apos; When True, chart type is a bar, not a column
  557. Dim vData As Variant &apos; Data points array of values
  558. Dim i As Long, j As Long
  559. Const cstChart = &quot;com.sun.star.chart.&quot;
  560. Dim cstThisSub As String
  561. Const cstSubArgs = &quot;Value&quot;
  562. If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
  563. bSet = False
  564. cstThisSub = &quot;SFDocuments.Chart.set&quot; &amp; psProperty
  565. ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
  566. If Not [_Parent]._IsStillAlive() Then GoTo Catch
  567. bSet = True
  568. If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
  569. Select Case UCase(psProperty)
  570. Case UCase(&quot;ChartType&quot;)
  571. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ChartType&quot;, V_STRING _
  572. , Array(&quot;Bar&quot;, &quot;Column&quot;, &quot;Pie&quot;, &quot;Donut&quot;, &quot;Area&quot;, &quot;Line&quot;, &quot;XY&quot;, &quot;Bubble&quot;, &quot;Net&quot;) _
  573. ) Then GoTo Finally
  574. With _Diagram
  575. &apos; Specify the targeted chart type
  576. Select Case UCase(pvValue)
  577. Case &quot;BAR&quot;, &quot;COLUMN&quot; : sChartType = cstChart &amp; &quot;BarDiagram&quot;
  578. Case &quot;PIE&quot; : sChartType = cstChart &amp; &quot;PieDiagram&quot;
  579. Case &quot;DONUT&quot; : sChartType = cstChart &amp; &quot;DonutDiagram&quot;
  580. Case &quot;AREA&quot; : sChartType = cstChart &amp; &quot;AreaDiagram&quot;
  581. Case &quot;LINE&quot; : sChartType = cstChart &amp; &quot;LineDiagram&quot;
  582. Case &quot;XY&quot; : sChartType = cstChart &amp; &quot;XYDiagram&quot;
  583. Case &quot;BUBBLE&quot; : sChartType = cstChart &amp; &quot;BubbleDiagram&quot;
  584. Case &quot;NET&quot; : sChartType = cstChart &amp; &quot;NetDiagram&quot;
  585. End Select
  586. &apos; If there is no change, do nothing
  587. If sChartType &lt;&gt; .DiagramType Then
  588. &apos; Some combinations old type =&gt; new type require the cancellation of 3D graphs
  589. bDim3D = .Dim3D
  590. .Dim3D = False
  591. _ChartObject.createInstance(sChartType)
  592. Set _Diagram = _ChartObject.Diagram
  593. .Dim3D = bDim3D
  594. End If
  595. If UCase(pvValue) = &quot;BAR&quot; Or UCase(pvValue) = &quot;COLUMN&quot; Then .Vertical = ( UCase(pvValue) = &quot;BAR&quot; )
  596. End With
  597. Case UCase(&quot;Deep&quot;)
  598. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Deep&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  599. If oSession.HasUnoProperty(_Diagram, &quot;Deep&quot;) Then _Diagram.Deep = pvValue
  600. Case UCase(&quot;Dim3D&quot;)
  601. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Dim3D&quot;, Array(ScriptForge.V_Boolean, V_STRING) _
  602. , Array(False, True, &quot;Bar&quot;, &quot;Cylinder&quot;, &quot;Cone&quot;, &quot;Pyramid&quot;) _
  603. ) Then GoTo Finally
  604. With _Diagram
  605. If oSession.HasUnoProperty(_Diagram, &quot;Dim3D&quot;) Then
  606. If _Diagram.DiagramType = &quot;com.sun.star.chart.BubbleDiagram&quot; Then
  607. .Dim3D = False &apos; Force False value to avoid empty graph
  608. ElseIf VarType(pvValue) = V_STRING Then
  609. bVertical = .Vertical
  610. .Dim3D = True
  611. .Vertical = bVertical
  612. If oSession.HasUnoProperty(_Diagram, &quot;SolidType&quot;) Then
  613. If .DiagramType = cstChart &amp; &quot;BarDiagram&quot; Then
  614. Select Case UCase(pvValue)
  615. Case &quot;BAR&quot; : .SolidType = com.sun.star.chart.ChartSolidType.RECTANGULAR_SOLID
  616. Case &quot;CYLINDER&quot; : .SolidType = com.sun.star.chart.ChartSolidType.CYLINDER
  617. Case &quot;CONE&quot; : .SolidType = com.sun.star.chart.ChartSolidType.CONE
  618. Case &quot;PYRAMID&quot; : .SolidType = com.sun.star.chart.ChartSolidType.PYRAMID
  619. End Select
  620. Else
  621. .SolidType = 0
  622. End If
  623. End If
  624. Else &apos; Boolean
  625. If oSession.HasUnoProperty(_Diagram, &quot;SolidType&quot;) Then .SolidType = 0
  626. .Dim3D = pvValue
  627. End If
  628. End If
  629. End With
  630. Case UCase(&quot;Exploded&quot;)
  631. If oSession.HasUnoProperty(_ChartObject, &quot;Data&quot;) And _Diagram.DiagramType &lt;&gt; &quot;com.sun.star.chart.BubbleDiagram&quot; Then
  632. &apos; All data points are presumed exploded with the same coefficient
  633. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Exploded&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
  634. With _ChartObject
  635. vData = .Data.Data
  636. If IsArray(vData) Then
  637. For i = 0 To UBound(vData)
  638. If IsArray(vData(i)) Then
  639. For j = 0 To UBound(vData(i))
  640. _Diagram.getDataPointProperties(i, j).SegmentOffset = CLng(pvValue)
  641. Next j
  642. End If
  643. Next i
  644. End If
  645. End With
  646. End If
  647. Case UCase(&quot;Filled&quot;)
  648. &apos; Flipflop between NetDiagram and FilledNetDiagram
  649. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Filled&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  650. With _Diagram
  651. &apos; Specify the targeted chart type
  652. sChartType = cstChart &amp; Iif(pvValue, &quot;Filled&quot;, &quot;&quot;) &amp; &quot;NetDiagram&quot;
  653. &apos; If there is no change, do nothing
  654. If sChartType &lt;&gt; .DiagramType then
  655. &apos; Do not apply if the chart type not = &quot;Net&quot;
  656. If (pvValue And .DiagramType = cstChart &amp; &quot;NetDiagram&quot;) _
  657. Or (Not pvValue And .DiagramType = cstChart &amp; &quot;FilledNetDiagram&quot;) Then
  658. &apos; Some combinations old type =&gt; new type require the cancellation of 3D graphs
  659. bDim3D = .Dim3D
  660. .Dim3D = False
  661. _ChartObject.createInstance(sChartType)
  662. Set _Diagram = _ChartObject.Diagram
  663. .Dim3D = bDim3D
  664. End If
  665. End If
  666. End With
  667. Case UCase(&quot;Legend&quot;)
  668. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Legend&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  669. If oSession.HasUnoProperty(_ChartObject, &quot;HasLegend&quot;) Then _ChartObject.HasLegend = pvValue
  670. Case UCase(&quot;Percent&quot;)
  671. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Percent&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  672. If oSession.HasUnoProperty(_Diagram, &quot;Percent&quot;) Then
  673. _Diagram.Stacked = pvValue
  674. _Diagram.Percent = pvValue
  675. End If
  676. Case UCase(&quot;Stacked&quot;)
  677. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Stacked&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
  678. If oSession.HasUnoProperty(_Diagram, &quot;Stacked&quot;) Then
  679. _Diagram.Stacked = pvValue
  680. If Not pvValue Then _Diagram.Percent = False
  681. End If
  682. Case UCase(&quot;Title&quot;)
  683. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Title&quot;, V_STRING) Then GoTo Finally
  684. If oSession.HasUnoProperty(_ChartObject, &quot;HasMainTitle&quot;) Then
  685. _ChartObject.HasMainTitle = ( Len(pvValue) &gt; 0 )
  686. If Len(pvValue) &gt; 0 Then _ChartObject.Title.String = pvValue
  687. End If
  688. Case UCase(&quot;XTitle&quot;)
  689. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;XTitle&quot;, V_STRING) Then GoTo Finally
  690. If oSession.HasUnoProperty(_Diagram, &quot;HasXAxisTitle&quot;) Then
  691. _Diagram.HasXAxisTitle = ( Len(pvValue) &gt; 0 )
  692. If Len(pvValue) &gt; 0 Then _Diagram.XAxisTitle.String = pvValue
  693. End If
  694. Case UCase(&quot;YTitle&quot;)
  695. If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;YTitle&quot;, V_STRING) Then GoTo Finally
  696. If oSession.HasUnoProperty(_Diagram, &quot;HasYAxisTitle&quot;) Then
  697. _Diagram.HasYAxisTitle = ( Len(pvValue) &gt; 0 )
  698. If Len(pvValue) &gt; 0 Then _Diagram.YAxisTitle.String = pvValue
  699. End If
  700. Case Else
  701. bSet = False
  702. End Select
  703. Finally:
  704. _PropertySet = bSet
  705. ScriptForge.SF_Utils._ExitFunction(cstThisSub)
  706. Exit Function
  707. Catch:
  708. bSet = False
  709. GoTo Finally
  710. End Function &apos; SFDocuments.SF_FormControl._PropertySet
  711. REM -----------------------------------------------------------------------------
  712. Private Function _Repr() As String
  713. &apos;&apos;&apos; Convert the Chart instance to a readable string, typically for debugging purposes (DebugPrint ...)
  714. &apos;&apos;&apos; Args:
  715. &apos;&apos;&apos; Return:
  716. &apos;&apos;&apos; &quot;[Chart]: Name - Type
  717. _Repr = &quot;[Chart]: &quot; &amp; ChartName &amp; &quot; - &quot; &amp; ChartType
  718. End Function &apos; SFDocuments.SF_Chart._Repr
  719. REM ============================================ END OF SFDOCUMENTS.SF_CHART
  720. </script:module>