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