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