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