summaryrefslogtreecommitdiffstats
path: root/wizards/source/tutorials/Functions.xba
blob: 4b422c80b177bb5be77bab212e2553beb331d74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Functions" script:language="StarBasic">REM  *****  BASIC  *****
Dim DialogVisible As Boolean
Dim TutorStep As Integer
Dim TutorLastStep As Integer
Dim myDialog As Object
Dim myTutorial As Object
Public TutorText() As String
Dim documentTitle As String
Dim exampleUse As Object     
Dim properties() As Object
Dim docTYP  As String
&apos;public myWidth As Long
Dim myHeight As Long
Dim oTextField As Object
Dim stepTitle  As String
Dim oOpenDialogFlag
Dim imageStatus  As String

Sub LoadTutorialDialog(exampleToUse, documentTYP)
	Init()
	exampleUse = exampleToUse
	TutorText() = exampleUse.LoadText()	
	properties() = exampleUse.GetProperties()
	If properties(3).Value = &quot;True&quot; Then
		Dim localisation(0) As new com.sun.star.beans.NamedValue
		localisation(0).Name = &quot;Localisation&quot;
    	localisation(0).Value = properties()
    	myTutorial.execute(localisation())
	Else
		TutorStep = 0
		TutorLastStep = 0
		docTYP = documentTYP
		InitAction()
		ShowInfoMain()	
		DialogVisible = True
		myDialog = LoadDialog(&quot;Tutorials&quot;,&quot;TutorialsDialog&quot;)	
		
		SetTutorialDocumentPosSize()
		
		documentProps =  ThisComponent.getDocumentProperties()
		myDialog.Title = &quot;Tutorials - &quot; &amp; documentProps.Title
		oTextField = myDialog.GetControl(&quot;myTextField&quot;)
		oTextField.setVisible(False)
		
		imageStatus = &quot;MIN&quot;		
		setMaxMinImage(imageStatus)
		
		&apos;myWidth = myDialog.Size.Width
		myHeight = myDialog.Size.Height
		
		CheckForStepShowButtonStatus()
		CheckForStepNextButtonStatus()
		InitRoadMap()		
		SetVisibleTrue()
		myDialog.model.myTextField.Label = stepTitle
		myDialog.model.myText.Label = GetStepText()&apos;TutorText(TutorStep)
				
		
		Do
			wait 1000
		Loop Until DialogVisible = False
		If( oOpenDialogFlag = True) Then
			Destroy()
			TutorialOpen.TutorialOpenMain()		
		Else 
			Destroy()
		End If				
	End If
End Sub

Sub setMaxMinImage(param As String)
	On Local Error Goto NOIMAGE
		oCommandButton = myDialog.GetControl(&quot;CommandButton&quot;)
		templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
		Dim bitmapPath As String
		iPos = InStr(templatePath,&quot;/&quot;)
		If(iPos &gt; 0) Then
			If(param = &quot;MAX&quot;) Then
				bitmapPath = templatePath &amp; &quot;../wizard/bitmap/maximize.png&quot;
			ElseIf(param = &quot;MIN&quot;) Then	
				bitmapPath = templatePath &amp; &quot;../wizard/bitmap/minimize.png&quot;
			End If
		Else
			If(param = &quot;MAX&quot;) Then
				bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\maximize.png&quot;
			ElseIf(param = &quot;MIN&quot;) Then	
				bitmapPath = templatePath &amp; &quot;..\wizard\bitmap\minimize.png&quot;
			End If		
		End If
		&apos;printdbgInfo oCommandButton.Model
		oCommandButton.Model.ImageUrl = bitmapPath
	Exit Sub	
	NOIMAGE:		
End Sub

Sub SetTutorialDocumentPosSize()
	activDesktopWindow = StarDesktop.activeFrame.ContainerWindow
	If(activDesktopWindow.posSize.Height &lt; 550) Then
		activDesktopWindow.setPosSize(0,0,0,550,8)
	End If	
	If	(activDesktopWindow.posSize.Width &lt; 750 ) Then
		activDesktopWindow.setPosSize(0,0,750,0,4)
	EndIf	
End Sub

Sub InitRoadMap()
	RoadMapMain(Functions, myDialog)
	SetControlModelPosSize(0, 0, 85, 176)
	SetControlModelText(&quot;Steps&quot;)
	
	StepSize = Ubound(TutorText())
	Dim ItemsArray(StepSize) as String
	For i = 0 To StepSize		
		stepcontent = TutorText(i)
		iPos = InStr(stepcontent,CHR(13))
		ItemName = Left(stepcontent, iPos)
		ItemsArray(i) = ItemName
	Next i
	InsertItemsLabels( ItemsArray())
	
	For i = 1 To StepSize			
		SetItemEnabled( i, False)			
	Next i
	SetItemEnabled( 0, True)
End Sub

Sub Destroy()
	&apos;myDialog.dispose		
	wait 1000				
    ShowInfoDialog.DisposeIDialog()
    
    &apos; THE DOCUMENT GETS CLOSED HERE!!!!!!!! GPF
    thisComponent.CurrentController.Frame.close(True)    
	
End Sub

Sub Init
	GlobalScope.BasicLibraries.LoadLibrary(&quot;Tools&quot;)	
	myTutorial = createUNOService(&quot;com.sun.star.wizards.tutorial.executer.CallTutorialFramework&quot;)
	documentTitle = ThisComponent.getCurrentController.getFrame.Title	
End Sub

Sub InitStep
    udProps = ThisComponent.DocumentProperties.UserDefinedProperties
    If udProps.PropertySetInfo.hasPropertyByName(&quot;CurrentStep&quot;) Then
        TutorStep = udProps.CurrentStep
    Else
        udProps.addProperty(&quot;CurrentStep&quot;, 0, TutorStep)
    End If
End Sub

Sub setStep
    ThisComponent.DocumentProperties.UserDefinedProperties.CurrentStep = TutorStep
End Sub

Sub InitAction()
	SetStepTitle()
		
	Dim property(6) As new com.sun.star.beans.PropertyValue	
	property(0).Name = &quot;DocumentTYP&quot;
	property(0).Value = docTYP	
	property(1).Name = &quot;MethodName&quot;
	property(1).Value = &quot;setDelay&quot;	
	property(2).Name = &quot;Param&quot;
	property(2).Value = 0	 &apos;key insert speed (Millis)
	property(3).Name = &quot;Param&quot;
	property(3).Value = 4	 &apos;mouse animate speed (Millis)
	property(4).Name = &quot;Param&quot;
	property(4).Value = 2000 &apos;after mouse animate sleep (Millis)
	property(5).Name = &quot;Param&quot;
	property(5).Value = 10	 &apos;mouse scroll speed (Millis)
	property(6).Name = &quot;Param&quot;
	property(6).Value = -1	 &apos;mouse speed (step)
	myTutorial.setPropertyValues(property())
End Sub

Sub EndDialog
	oOpenDialogFlag = False	
	If (myDialog.model.done.Label = &quot;Close&quot;) Then
		TutorialCloseMain()
	Else 
		DialogVisible = False		
	End If
End Sub

Sub NextStep
	GotoStep(TutorStep + 1)	
End Sub

Sub GotoStep(StepIndex)
	If(StepIndex &lt;= Ubound(TutorText())) Then	
		TutorStep = StepIndex
		If TutorStep &gt; TutorLastStep Then
			TutorLastStep = TutorStep
		End If		
		If(TutorStep = Ubound(TutorText())) Then
			myDialog.model.next.enabled = False
			myDialog.model.done.Label = &quot;Done&quot;
			myDialog.model.show.Label = &quot;Tutorials&quot;	
		Else
			myDialog.model.next.enabled = True 	
		End If
		SetStepTitle()
		myDialog.model.myText.Label = GetStepText()
		CheckForStepShowButtonStatus()	
		SetItemEnabled( TutorStep, True)
		&apos;setStep()
	End If
End Sub

Function GetStepText()
	Dim tempText As String
	tempText = TutorText(TutorStep)
	iPos = InStr(tempText,CHR(13))
	ResultString = Right(tempText, Len(tempText) - iPos - 1)
	GetStepText() = ResultString
End Function

Sub ItemChange(CurrentItemID, SelectitemID)
	GotoStep(SelectitemID)
End Sub

Sub SetDisableShowMeButton()
	myDialog.model.show.enabled = False	
	TutorLastStep = TutorLastStep + 1
End Sub

Sub Minimize(aEvent)
	ActionItemsTextField = myDialog.GetControl(&quot;ActionItemsLabel&quot;)
	FixedLineVertikal = myDialog.GetControl(&quot;FixedLineVertikal&quot;)
	
	If myDialog.Size.Height = 35 Then
		myDialog.setPosSize(0,0,0,myHeight,8)
		oTextField.setVisible(False)
		ActionItemsTextField.setVisible(True)
		FixedLineVertikal.setVisible(True)
		RoadMap.SetVisibleRoadMap(True)
	Else
		myDialog.setPosSize(0,0,0,35,8)
		rmSelectedIndex = RoadMap.GetSelectedIndex() + 1
		gsTitle = GetStepTitle()		
		oTextField.setText(rmSelectedIndex &amp; &quot;. &quot; &amp; gsTitle)
		oTextField.setVisible(True)
		ActionItemsTextField.setVisible(False)
		FixedLineVertikal.setVisible(False)
		RoadMap.SetVisibleRoadMap(False)
	End If
	If(imageStatus = &quot;MAX&quot;) Then
		imageStatus = &quot;MIN&quot; 
	ElseIf(imageStatus = &quot;MIN&quot;) Then	
		imageStatus = &quot;MAX&quot;
	End If
	setMaxMinImage(imageStatus)

End Sub

Sub SetStepTitle()
	stepcontent = TutorText(TutorStep)
	iPos = InStr(stepcontent,CHR(13))
	stepTitle = Left(stepcontent, iPos)
	SetStepTitle() = stepTitle
End Sub

Function GetStepTitle()
	GetStepTitle() = stepTitle
End Function

Sub CheckForStepShowButtonStatus()
	If ((exampleUse.ContainsStepAction() = True And TutorStep = TutorLastStep) Or myDialog.model.show.Label = &quot;Tutorials&quot;) Then
		myDialog.model.show.enabled = True			
	Else
		myDialog.model.show.enabled = False
	End If
End Sub

Sub CheckForStepNextButtonStatus()
	If(TutorStep = Ubound(TutorText())) Then
		myDialog.model.next.enabled = False
		myDialog.model.done.Label = &quot;Done&quot;
	End If
End Sub

Sub Show(aEvent)
	&apos;ShowInfoMain()
	If( myDialog.model.show.Label = &quot;Tutorials&quot;) Then
		oOpenDialogFlag = True
		DialogVisible = False
	Else 
		SetMousePosition(aEvent)
		exampleUse.Action() 
	End If	
End Sub

Sub SetMousePosition(aEvent)
	MyPoints() = MousePoints(aEvent)
	
	Dim mousePosition(3) as new com.sun.star.beans.PropertyValue
	mousePosition(0).Name = &quot;DocumentTYP&quot;
	mousePosition(0).Value = docTYP	
	mousePosition(1).Name = &quot;MethodName&quot;
	mousePosition(1).Value = &quot;setMousePosition&quot;           
   	mousePosition(2).Name = &quot;Param&quot;
   	mousePosition(2).Value = MyPoints(0)   	
	mousePosition(3).Name = &quot;Param&quot;
	mousePosition(3).Value = MyPoints(1)
			
	myTutorial.setPropertyValues(mousePosition())	
End Sub

Function MousePoints(aEvent)
	Dim position(1) As Integer
	position(0) = myDialog.getControl(&quot;show&quot;).AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX	
	position(1) = myDialog.getControl(&quot;show&quot;).AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY
	MousePoints = position()	
End Function

Function CheckPath(path() As String)		
	&apos;documentTitle = ThisComponent.getCurrentController.getFrame.Title
	sTitle =  path(0)	
	ResultString = Right(sTitle, 3)
	iPos = InStr(ResultString,&quot;#&quot;)
	ResultString = Right(ResultString, Len(ResultString) - iPos)
	ResultFrameString = InStr (sTitle, &quot;{D}FRAME#&quot;)
	If ResultFrameString &lt;&gt; 0 Then
		If Not (sTitle = (&quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString)) Then
			&apos;path(0) = &quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
			path(0) = &quot;FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
			sTitle =  path(1)	
			ResultString = Right(sTitle, 3)
			iPos = InStr(ResultString,&quot;#&quot;)
			ResultString = Right(ResultString, Len(ResultString) - iPos)
			path(1) = &quot;ROOT_PANE#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString
		Else
			&apos;path(0) = &quot;{D}FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString	
			path(0) = &quot;FRAME#&quot; &amp; documentTitle &amp; &quot;#&quot; &amp; ResultString	
		End If
	End If	
End Function

Sub SetVisibleTutorialsDialog(param)
	myDialog.setVisible(param)
End Sub

Sub SetVisibleTrue()
	myDialog.setVisible(True)
End Sub

Sub SetVisibleFalse()
	myDialog.setVisible(False)
End Sub

Sub ExitTutorial()		
	Dim aUrl As new com.sun.star.util.URL
	oDoc = ThisComponent
    urlTransformer = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
    aUrl.Complete = &quot;slot:5621&quot;
    urlTransformer.parseStrict(aUrl)
    xController = oDoc.getCurrentController()
    xDispatcher = xController.queryDispatch(aUrl, &quot;&quot;, 0)
    if NOT isNull(xDispatcher) then
        xDispatcher.dispatch(aUrl, DimArray())
     else
       msgBox &quot;Error! Cannot close document.&quot;
     End If     
End Sub
</script:module>