ShowInfoDialog.xba 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <!--
  4. * This file is part of the LibreOffice project.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. *
  10. * This file incorporates work covered by the following license notice:
  11. *
  12. * Licensed to the Apache Software Foundation (ASF) under one or more
  13. * contributor license agreements. See the NOTICE file distributed
  14. * with this work for additional information regarding copyright
  15. * ownership. The ASF licenses this file to you under the Apache
  16. * License, Version 2.0 (the "License"); you may not use this file
  17. * except in compliance with the License. You may obtain a copy of
  18. * the License at http://www.apache.org/licenses/LICENSE-2.0 .
  19. -->
  20. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ShowInfoDialog" script:language="StarBasic">REM ***** BASIC *****
  21. Dim oWnd As Object
  22. Dim oWnd2 As Object
  23. Dim oWnd3 As Object
  24. Dim oDoc as Object
  25. Sub ShowInfoMain
  26. prop() = GetShowInfoProperties()
  27. Init(prop(0).Value, prop(1).Value, prop(2).Value, prop(3).Value, prop(4).Value, prop(5).Value, prop(6).Value, prop(7).Value, prop(8).Value)
  28. End Sub
  29. Sub Init(tFieldText As String, windowX, windowY, windowWidth, windowHeight, tFieldX, tFieldY, tFieldWidth, tFieldHeight)
  30. toolkit = createUnoService(&quot;com.sun.star.awt.Toolkit&quot;)
  31. Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
  32. Dim oBounds As new com.sun.star.awt.Rectangle
  33. oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
  34. oWndDescr.WindowServiceName = &quot;&quot;
  35. oWndDescr.ParentIndex = 0
  36. &apos;officeX = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.X
  37. &apos;officeY = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.Y
  38. &apos;officeWidth = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Width
  39. &apos;officeHeight = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Height
  40. officeWidth = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Width
  41. officeHeight = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Height
  42. &apos;dialogWidth = myTutoShowDialog.getPosSize().Width
  43. &apos;dialogHeight = myTutoShowDialog.getPosSize().Height
  44. X = officeWidth - windowWidth - windowX
  45. Y = officeHeight - windowHeight - windowY
  46. oBounds.X = X : oBounds.Y = Y
  47. oBounds.Width = windowWidth : oBounds.Height = windowHeight
  48. oWndDescr.Bounds = oBounds
  49. oWndDescr.Parent = thisComponent.CurrentController.Frame.ContainerWindow
  50. with com.sun.star.awt.WindowAttribute
  51. oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  52. end with
  53. oWnd = toolkit.createWindow(oWndDescr)
  54. Dim oWndDescr3 As new com.sun.star.awt.WindowDescriptor
  55. Dim oBounds3 As new com.sun.star.awt.Rectangle
  56. oWndDescr3.Type = com.sun.star.awt.WindowClass.TOP
  57. oWndDescr3.WindowServiceName = &quot;fixedimage&quot; &apos;&quot;fixedtext&quot;
  58. oWndDescr3.ParentIndex = 0
  59. oBounds3.X = 0 : oBounds3.Y = 0
  60. oBounds3.Width = tFieldWidth : oBounds3.Height = tFieldHeight
  61. oWndDescr3.Bounds = oBounds3
  62. oWndDescr3.Parent = oWnd
  63. with com.sun.star.awt.WindowAttribute
  64. oWndDescr3.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  65. end with
  66. oWnd3= toolkit.createWindow(oWndDescr3)
  67. &apos;oWnd2.Text = tFieldText
  68. &apos;printdbgInfo(oWnd3)
  69. setImage(oWnd3)
  70. &apos;oWnd3.Background = 16777215
  71. &apos; oWnd2.SetBackGround(16776960)
  72. oWnd.SetBackGround(16776960)
  73. &apos; oWnd.FontDescriptors(0).Name = &quot;Albany&quot;
  74. &apos; oWnd.FontDescriptors(0).StyleName = &quot;BOLD&quot;
  75. Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
  76. Dim oBounds2 As new com.sun.star.awt.Rectangle
  77. oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
  78. oWndDescr2.WindowServiceName = &quot;fixedtext&quot;
  79. oWndDescr2.ParentIndex = 0
  80. oBounds2.X = tFieldX : oBounds2.Y = tFieldY
  81. oBounds2.Width = tFieldWidth : oBounds2.Height = tFieldHeight
  82. oWndDescr2.Bounds = oBounds2
  83. oWndDescr2.Parent = oWnd3
  84. with com.sun.star.awt.WindowAttribute
  85. oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  86. end with
  87. oWnd2= toolkit.createWindow(oWndDescr2)
  88. oWnd2.Text = tFieldText
  89. oWnd2.Background = 268435455
  90. &apos;printdbgInfo(oWnd2)
  91. &apos;printdbgInfo oWnd.getPosSize()
  92. End Sub
  93. Function GetShowInfoProperties()
  94. stepText = GetStepTitle()
  95. Dim Properties(8) As new com.sun.star.beans.NamedValue
  96. Properties(0).Name = &quot;ShowInfoDialogText&quot;
  97. Properties(0).Value = stepText &amp; &quot;Press [Esc] to abort.&quot;
  98. Properties(1).Name = &quot;WindowX&quot;
  99. Properties(1).Value = 20
  100. Properties(2).Name = &quot;WindowY&quot;
  101. Properties(2).Value = 40
  102. Properties(3).Name = &quot;WindowWidth&quot;
  103. Properties(3).Value = 190
  104. Properties(4).Name = &quot;WindowHeight&quot;
  105. Properties(4).Value = 50
  106. Properties(5).Name = &quot;TFieldX&quot;
  107. Properties(5).Value = 7
  108. Properties(6).Name = &quot;TFieldY&quot;
  109. Properties(6).Value = 8
  110. Properties(7).Name = &quot;TFieldWidth&quot;
  111. Properties(7).Value = 190
  112. Properties(8).Name = &quot;TFieldHeight&quot;
  113. Properties(8).Value = 50
  114. GetShowInfoProperties = Properties()
  115. End Function
  116. Sub setShowInfoText()
  117. stepText = GetStepTitle()
  118. oWnd2.Text = stepText &amp; &quot;Press [Esc] to abort.&quot;
  119. End Sub
  120. Sub ShowON()
  121. setShowInfoText()
  122. oWnd.setVisible(True)
  123. oWnd3.setVisible(True)
  124. oWnd2.setVisible(True)
  125. End Sub
  126. Sub ShowOFF()
  127. &apos;On Local Error Goto NOPROPERTYSETINFO:
  128. oWnd.setVisible(False)
  129. oWnd2.setVisible(False)
  130. oWnd3.setVisible(False)
  131. &apos;oDoc.dispose()
  132. Exit Sub
  133. &apos;NOPROPERTYSETINFO:
  134. End Sub
  135. Sub DisposeIDialog()
  136. &apos;On Local Error Goto NOPROPERTYSETINFO:
  137. oWnd3.dispose
  138. oWnd2.dispose
  139. oWnd.dispose
  140. oDoc.dispose()
  141. Exit Sub
  142. &apos;NOPROPERTYSETINFO:
  143. End Sub
  144. sub setImage(whatever as Object)
  145. templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
  146. Dim bitmapPath As String
  147. iPos = InStr(templatePath,&quot;/&quot;)
  148. if(iPos &gt; 0) Then
  149. bitmapPath = templatePath &amp; &quot;../wizard/bitmap/tutorial_background.gif&quot;
  150. Else
  151. bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\tutorial_background.gif&quot;
  152. End If
  153. dim props(0) as new com.sun.star.beans.PropertyValue
  154. props(0).Name = &quot;Hidden&quot;
  155. props(0).Value = true
  156. oDoc = StarDesktop.loadComponentFromUrl(&quot;private:factory/swriter&quot;,&quot;_blank&quot;,0,props())
  157. oShape = addControlToDefaultForm(&quot;ImageButton&quot;, 1000, 1000, 2000, 1000)
  158. imgControl = oShape.getControl()
  159. &apos;imgControl.ImageUrl=&quot;file:///D:/Program%20Files/src680_m11_qwizards1_49_TEST/share/gallery/tutoItem.gif&quot;
  160. imgControl.ImageUrl = bitmapPath
  161. imgControl.addConsumer(whatever)
  162. imgControl.startProduction()
  163. end sub
  164. Function createControlShape(cKind As String) As Object
  165. Dim oControlShape As Object
  166. Dim oControl As Object
  167. oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
  168. oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
  169. oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.form.control.&quot; &amp; cKind)
  170. oControlShape.setControl(oControl)
  171. createControlShape() = oControlShape
  172. End Function
  173. Function createControlShapeWithDefaultControl(cKind As String) As Object
  174. Dim oControlShape As Object
  175. Dim oControl As Object
  176. oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
  177. oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
  178. oControlShape.setControl(oControl)
  179. createControlShapeWithDefaultControl() = oControlShape
  180. End Function
  181. Function createUNOControlShape(cKind As String, defControl As String) As Object
  182. Dim oControlShape As Object
  183. Dim oControl As Object
  184. oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
  185. oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; &amp; cKind)
  186. oControl.setPropertyValue(&quot;DefaultControl&quot;, &quot;com.sun.star.awt.&quot; &amp; defControl)
  187. oControlShape.setControl(oControl)
  188. createUNOControlShape() = oControlShape
  189. End Function
  190. Function addShape(oShape As Object) As Boolean
  191. Dim vSize As New com.sun.star.awt.Size
  192. Dim oDrawPage As Object
  193. Dim oForms As Object
  194. Dim oForm As Object
  195. oDrawPage = oDoc.getDrawPage()
  196. oForms = oDrawPage.getForms()
  197. if oForms.Count = 0 then
  198. oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
  199. oForms.insertByIndex(0, oForm)
  200. end if
  201. vSize.Height = 2000 : vSize.Width = 2000
  202. oShape.Size = vSize
  203. oDrawPage.add(oShape)
  204. addShape() = true
  205. End Function
  206. sub addControl(cKind as String)
  207. Dim oDrawPage As Object
  208. Dim oForm As Object, oForms As Object
  209. Dim oControl As Object, oControlShape As Object
  210. Dim aSz As Variant
  211. Dim oText As Object
  212. oDrawPage = oDoc.DrawPage
  213. oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
  214. oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
  215. oForm = oDoc.createInstance(&quot;com.sun.star.form.component.Form&quot;)
  216. oforms = oDrawPage.Forms
  217. if oforms.count = 0 then
  218. oforms.insertbyindex(0,oForm)
  219. end if
  220. oControlShape.Control = oControl
  221. oDrawPage.add(oControlShape)
  222. End sub
  223. Function addControlToDefaultForm(cKind as String, x As Integer, y As Integer, width As Integer, height As Integer) As Object
  224. Dim oDrawPage As Object
  225. Dim oControl As Object, oControlShape As Object
  226. Dim pos As New com.sun.star.awt.Point
  227. Dim size As New com.sun.star.awt.Size
  228. pos.X = x
  229. pos.Y = y
  230. size.Width = width
  231. size.Height = height
  232. oDrawPage = oDoc.DrawPage
  233. oControlShape = oDoc.createInstance(&quot;com.sun.star.drawing.ControlShape&quot;)
  234. oControl = oDoc.createInstance(&quot;com.sun.star.form.component.&quot; + cKind)
  235. oControlShape.Control = oControl
  236. oControlShape.Position = pos
  237. oControlShape.Size = size
  238. oDrawPage.add(oControlShape)
  239. addControlToDefaultForm() = oControlShape
  240. End Function
  241. Function addShapeToDrawDoc(oPage as Object, nPosX, nPosY as Integer, oType As String) As Object
  242. Dim aPoint As New com.sun.star.awt.Point
  243. Dim aSize As New com.sun.star.awt.Size
  244. Dim oShape As Object
  245. Dim servNames As Variant
  246. aPoint.x = nPosX
  247. aPoint.y = nPosY
  248. aSize.Width = 2000
  249. aSize.Height = 1000
  250. oShape = oDoc.createInstance(&quot;com.sun.star.drawing.&quot;+oType+&quot;Shape&quot;)
  251. oShape.Size = aSize
  252. oShape.Position = aPoint
  253. if oShape.getPropertySetInfo().hasPropertyByName(&quot;FillColor&quot;) then
  254. oShape.FillColor = RGB(128, 255, 0)
  255. End If
  256. oPage.add(oShape)
  257. addShapeToDrawDoc() = oShape
  258. End Function
  259. </script:module>