ShowInfoDialog.xba 11 KB

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