Functions.xba 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="Functions" script:language="StarBasic">REM ***** BASIC *****
  24. Dim DialogVisible As Boolean
  25. Dim TutorStep As Integer
  26. Dim TutorLastStep As Integer
  27. Dim myDialog As Object
  28. Dim myTutorial As Object
  29. Public TutorText() As String
  30. Dim documentTitle As String
  31. Dim exampleUse As Object
  32. Dim properties() As Object
  33. Dim docTYP As String
  34. &apos;public myWidth As Long
  35. Dim myHeight As Long
  36. Dim oTextField As Object
  37. Dim stepTitle As String
  38. Dim oOpenDialogFlag
  39. Dim imageStatus As String
  40. Sub LoadTutorialDialog(exampleToUse, documentTYP)
  41. Init()
  42. exampleUse = exampleToUse
  43. TutorText() = exampleUse.LoadText()
  44. properties() = exampleUse.GetProperties()
  45. If properties(3).Value = &quot;True&quot; Then
  46. Dim localisation(0) As new com.sun.star.beans.NamedValue
  47. localisation(0).Name = &quot;Localisation&quot;
  48. localisation(0).Value = properties()
  49. myTutorial.execute(localisation())
  50. Else
  51. TutorStep = 0
  52. TutorLastStep = 0
  53. docTYP = documentTYP
  54. InitAction()
  55. ShowInfoMain()
  56. DialogVisible = True
  57. myDialog = LoadDialog(&quot;Tutorials&quot;,&quot;TutorialsDialog&quot;)
  58. SetTutorialDocumentPosSize()
  59. documentProps = ThisComponent.getDocumentProperties()
  60. myDialog.Title = &quot;Tutorials - &quot; &amp; documentProps.Title
  61. oTextField = myDialog.GetControl(&quot;myTextField&quot;)
  62. oTextField.setVisible(False)
  63. imageStatus = &quot;MIN&quot;
  64. setMaxMinImage(imageStatus)
  65. &apos;myWidth = myDialog.Size.Width
  66. myHeight = myDialog.Size.Height
  67. CheckForStepShowButtonStatus()
  68. CheckForStepNextButtonStatus()
  69. InitRoadMap()
  70. SetVisibleTrue()
  71. myDialog.model.myTextField.Label = stepTitle
  72. myDialog.model.myText.Label = GetStepText()&apos;TutorText(TutorStep)
  73. Do
  74. wait 1000
  75. Loop Until DialogVisible = False
  76. If( oOpenDialogFlag = True) Then
  77. Destroy()
  78. TutorialOpen.TutorialOpenMain()
  79. Else
  80. Destroy()
  81. End If
  82. End If
  83. End Sub
  84. Sub setMaxMinImage(param As String)
  85. On Local Error Goto NOIMAGE
  86. oCommandButton = myDialog.GetControl(&quot;CommandButton&quot;)
  87. templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
  88. Dim bitmapPath As String
  89. iPos = InStr(templatePath,&quot;/&quot;)
  90. If(iPos &gt; 0) Then
  91. If(param = &quot;MAX&quot;) Then
  92. bitmapPath = templatePath &amp; &quot;../wizard/bitmap/maximize.bmp&quot;
  93. ElseIf(param = &quot;MIN&quot;) Then
  94. bitmapPath = templatePath &amp; &quot;../wizard/bitmap/minimize.bmp&quot;
  95. End If
  96. Else
  97. If(param = &quot;MAX&quot;) Then
  98. bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\maximize.bmp&quot;
  99. ElseIf(param = &quot;MIN&quot;) Then
  100. bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\minimize.bmp&quot;
  101. End If
  102. End If
  103. &apos;printdbgInfo oCommandButton.Model
  104. oCommandButton.Model.ImageUrl = bitmapPath
  105. Exit Sub
  106. NOIMAGE:
  107. End Sub
  108. Sub SetTutorialDocumentPosSize()
  109. activDesktopWindow = StarDesktop.activeFrame.ContainerWindow
  110. If(activDesktopWindow.posSize.Height &lt; 550) Then
  111. activDesktopWindow.setPosSize(0,0,0,550,8)
  112. End If
  113. If (activDesktopWindow.posSize.Width &lt; 750 ) Then
  114. activDesktopWindow.setPosSize(0,0,750,0,4)
  115. EndIf
  116. End Sub
  117. Sub InitRoadMap()
  118. RoadMapMain(Functions, myDialog)
  119. SetControlModelPosSize(0, 0, 85, 176)
  120. SetControlModelText(&quot;Steps&quot;)
  121. StepSize = Ubound(TutorText())
  122. Dim ItemsArray(StepSize) as String
  123. For i = 0 To StepSize
  124. stepcontent = TutorText(i)
  125. iPos = InStr(stepcontent,CHR(13))
  126. ItemName = Left(stepcontent, iPos)
  127. ItemsArray(i) = ItemName
  128. Next i
  129. InsertItemsLabels( ItemsArray())
  130. For i = 1 To StepSize
  131. SetItemEnabled( i, False)
  132. Next i
  133. SetItemEnabled( 0, True)
  134. End Sub
  135. Sub Destroy()
  136. &apos;myDialog.dispose
  137. wait 1000
  138. ShowInfoDialog.DisposeIDialog()
  139. &apos; HIER WIRD DAS DOCUMENT GESCHLOSSEN!!!!!!!! GPF
  140. thisComponent.CurrentController.Frame.close(True)
  141. End Sub
  142. Sub Init
  143. GlobalScope.BasicLibraries.LoadLibrary(&quot;Tools&quot;)
  144. myTutorial = createUNOService(&quot;com.sun.star.wizards.tutorial.executer.CallTutorialFramework&quot;)
  145. documentTitle = ThisComponent.getCurrentController.getFrame.Title
  146. End Sub
  147. Sub InitStep
  148. udProps = ThisComponent.DocumentProperties.UserDefinedProperties
  149. If udProps.PropertySetInfo.hasPropertyByName(&quot;CurrentStep&quot;) Then
  150. TutorStep = udProps.CurrentStep
  151. Else
  152. udProps.addProperty(&quot;CurrentStep&quot;, 0, TutorStep)
  153. End If
  154. End Sub
  155. Sub setStep
  156. ThisComponent.DocumentProperties.UserDefinedProperties.CurrentStep = TutorStep
  157. End Sub
  158. Sub InitAction()
  159. SetStepTitle()
  160. Dim property(6) As new com.sun.star.beans.PropertyValue
  161. property(0).Name = &quot;DocumentTYP&quot;
  162. property(0).Value = docTYP
  163. property(1).Name = &quot;MethodName&quot;
  164. property(1).Value = &quot;setDelay&quot;
  165. property(2).Name = &quot;Param&quot;
  166. property(2).Value = 0 &apos;key insert speed (Millis)
  167. property(3).Name = &quot;Param&quot;
  168. property(3).Value = 4 &apos;mouse animate speed (Millis)
  169. property(4).Name = &quot;Param&quot;
  170. property(4).Value = 2000 &apos;after mouse animate sleep (Millis)
  171. property(5).Name = &quot;Param&quot;
  172. property(5).Value = 10 &apos;mouse scroll speed (Millis)
  173. property(6).Name = &quot;Param&quot;
  174. property(6).Value = -1 &apos;mouse speed (step)
  175. myTutorial.setPropertyValues(property())
  176. End Sub
  177. Sub EndDialog
  178. oOpenDialogFlag = False
  179. If (myDialog.model.done.Label = &quot;Close&quot;) Then
  180. TutorialCloseMain()
  181. Else
  182. DialogVisible = False
  183. End If
  184. End Sub
  185. Sub NextStep
  186. GotoStep(TutorStep + 1)
  187. End Sub
  188. Sub GotoStep(StepIndex)
  189. If(StepIndex &lt;= Ubound(TutorText())) Then
  190. TutorStep = StepIndex
  191. If TutorStep &gt; TutorLastStep Then
  192. TutorLastStep = TutorStep
  193. End If
  194. If(TutorStep = Ubound(TutorText())) Then
  195. myDialog.model.next.enabled = False
  196. myDialog.model.done.Label = &quot;Done&quot;
  197. myDialog.model.show.Label = &quot;Tutorials&quot;
  198. Else
  199. myDialog.model.next.enabled = True
  200. End If
  201. SetStepTitle()
  202. myDialog.model.myText.Label = GetStepText()
  203. CheckForStepShowButtonStatus()
  204. SetItemEnabled( TutorStep, True)
  205. &apos;setStep()
  206. End If
  207. End Sub
  208. Function GetStepText()
  209. Dim tempText As String
  210. tempText = TutorText(TutorStep)
  211. iPos = InStr(tempText,CHR(13))
  212. ResultString = Right(tempText, Len(tempText) - iPos - 1)
  213. GetStepText() = ResultString
  214. End Function
  215. Sub ItemChange(CurrentItemID, SelectitemID)
  216. GotoStep(SelectitemID)
  217. End Sub
  218. Sub SetDisableShowMeButton()
  219. myDialog.model.show.enabled = False
  220. TutorLastStep = TutorLastStep + 1
  221. End Sub
  222. Sub Minimize(aEvent)
  223. ActionItemsTextField = myDialog.GetControl(&quot;ActionItemsLabel&quot;)
  224. FixedLineVertikal = myDialog.GetControl(&quot;FixedLineVertikal&quot;)
  225. If myDialog.Size.Height = 35 Then
  226. myDialog.setPosSize(0,0,0,myHeight,8)
  227. oTextField.setVisible(False)
  228. ActionItemsTextField.setVisible(True)
  229. FixedLineVertikal.setVisible(True)
  230. RoadMap.SetVisibleRoadMap(True)
  231. Else
  232. myDialog.setPosSize(0,0,0,35,8)
  233. rmSelectedIndex = RoadMap.GetSelectedIndex() + 1
  234. gsTitle = GetStepTitle()
  235. oTextField.setText(rmSelectedIndex &amp; &quot;. &quot; &amp; gsTitle)
  236. oTextField.setVisible(True)
  237. ActionItemsTextField.setVisible(False)
  238. FixedLineVertikal.setVisible(False)
  239. RoadMap.SetVisibleRoadMap(False)
  240. End If
  241. If(imageStatus = &quot;MAX&quot;) Then
  242. imageStatus = &quot;MIN&quot;
  243. ElseIf(imageStatus = &quot;MIN&quot;) Then
  244. imageStatus = &quot;MAX&quot;
  245. End If
  246. setMaxMinImage(imageStatus)
  247. End Sub
  248. Sub SetStepTitle()
  249. stepcontent = TutorText(TutorStep)
  250. iPos = InStr(stepcontent,CHR(13))
  251. stepTitle = Left(stepcontent, iPos)
  252. SetStepTitle() = stepTitle
  253. End Sub
  254. Function GetStepTitle()
  255. GetStepTitle() = stepTitle
  256. End Function
  257. Sub CheckForStepShowButtonStatus()
  258. If ((exampleUse.ContainsStepAction() = True And TutorStep = TutorLastStep) Or myDialog.model.show.Label = &quot;Tutorials&quot;) Then
  259. myDialog.model.show.enabled = True
  260. Else
  261. myDialog.model.show.enabled = False
  262. End If
  263. End Sub
  264. Sub CheckForStepNextButtonStatus()
  265. If(TutorStep = Ubound(TutorText())) Then
  266. myDialog.model.next.enabled = False
  267. myDialog.model.done.Label = &quot;Done&quot;
  268. End If
  269. End Sub
  270. Sub Show(aEvent)
  271. &apos;ShowInfoMain()
  272. If( myDialog.model.show.Label = &quot;Tutorials&quot;) Then
  273. oOpenDialogFlag = True
  274. DialogVisible = False
  275. Else
  276. SetMousePosition(aEvent)
  277. exampleUse.Action()
  278. End If
  279. End Sub
  280. Sub SetMousePosition(aEvent)
  281. MyPoints() = MousePoints(aEvent)
  282. Dim mousePosition(3) as new com.sun.star.beans.PropertyValue
  283. mousePosition(0).Name = &quot;DocumentTYP&quot;
  284. mousePosition(0).Value = docTYP
  285. mousePosition(1).Name = &quot;MethodName&quot;
  286. mousePosition(1).Value = &quot;setMousePosition&quot;
  287. mousePosition(2).Name = &quot;Param&quot;
  288. mousePosition(2).Value = MyPoints(0)
  289. mousePosition(3).Name = &quot;Param&quot;
  290. mousePosition(3).Value = MyPoints(1)
  291. myTutorial.setPropertyValues(mousePosition())
  292. End Sub
  293. Function MousePoints(aEvent)
  294. Dim position(1) As Integer
  295. position(0) = myDialog.getControl(&quot;show&quot;).AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX
  296. position(1) = myDialog.getControl(&quot;show&quot;).AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY
  297. MousePoints = position()
  298. End Function
  299. Function CheckPath(path() As String)
  300. &apos;documentTitle = ThisComponent.getCurrentController.getFrame.Title
  301. sTitle = path(0)
  302. ResultString = Right(sTitle, 3)
  303. iPos = InStr(ResultString,&quot;#&quot;)
  304. ResultString = Right(ResultString, Len(ResultString) - iPos)
  305. ResultFrameString = InStr (sTitle, &quot;{D}FRAME#&quot;)
  306. If ResultFrameString &lt;&gt; 0 Then
  307. If Not (sTitle = (&quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString)) Then
  308. &apos;path(0) = &quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
  309. path(0) = &quot;FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
  310. sTitle = path(1)
  311. ResultString = Right(sTitle, 3)
  312. iPos = InStr(ResultString,&quot;#&quot;)
  313. ResultString = Right(ResultString, Len(ResultString) - iPos)
  314. path(1) = &quot;ROOT_PANE#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
  315. Else
  316. &apos;path(0) = &quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
  317. path(0) = &quot;FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
  318. End If
  319. End If
  320. End Function
  321. Sub SetVisibleTutorialsDialog(param)
  322. myDialog.setVisible(param)
  323. End Sub
  324. Sub SetVisibleTrue()
  325. myDialog.setVisible(True)
  326. End Sub
  327. Sub SetVisibleFalse()
  328. myDialog.setVisible(False)
  329. End Sub
  330. Sub ExitTutorial()
  331. Dim aUrl As new com.sun.star.util.URL
  332. oDoc = ThisComponent
  333. urlTransformer = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
  334. aUrl.Complete = &quot;slot:5621&quot;
  335. urlTransformer.parseStrict(aUrl)
  336. xController = oDoc.getCurrentController()
  337. xDispatcher = xController.queryDispatch(aUrl, &quot;&quot;, 0)
  338. if NOT isNull(xDispatcher) then
  339. xDispatcher.dispatch(aUrl, DimArray())
  340. else
  341. msgBox &quot;Error! Cannot close document.&quot;
  342. End If
  343. End Sub
  344. </script:module>