xref: /AOO41X/main/wizards/source/tutorials/Functions.xba (revision 3e9d7d56104abce564d08b4855d60c905ce880b7)
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  *****
4Dim DialogVisible As Boolean
5Dim TutorStep As Integer
6Dim TutorLastStep As Integer
7Dim myDialog As Object
8Dim myTutorial As Object
9Public TutorText() As String
10Dim documentTitle As String
11Dim exampleUse As Object
12Dim properties() As Object
13Dim docTYP  As String
14&apos;public myWidth As Long
15Dim myHeight As Long
16Dim oTextField As Object
17Dim stepTitle  As String
18Dim oOpenDialogFlag
19Dim imageStatus  As String
20
21Sub 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;)
39
40		SetTutorialDocumentPosSize()
41
42		documentProps =  ThisComponent.getDocumentProperties()
43		myDialog.Title = &quot;Tutorials - &quot; &amp; documentProps.Title
44		oTextField = myDialog.GetControl(&quot;myTextField&quot;)
45		oTextField.setVisible(False)
46
47		imageStatus = &quot;MIN&quot;
48		setMaxMinImage(imageStatus)
49
50		&apos;myWidth = myDialog.Size.Width
51		myHeight = myDialog.Size.Height
52
53		CheckForStepShowButtonStatus()
54		CheckForStepNextButtonStatus()
55		InitRoadMap()
56		SetVisibleTrue()
57		myDialog.model.myTextField.Label = stepTitle
58		myDialog.model.myText.Label = GetStepText()&apos;TutorText(TutorStep)
59
60
61		Do
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
71End Sub
72
73Sub 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:
96End Sub
97
98Sub 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
106End Sub
107
108Sub InitRoadMap()
109	RoadMapMain(Functions, myDialog)
110	SetControlModelPosSize(0, 0, 85, 176)
111	SetControlModelText(&quot;Steps&quot;)
112
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())
122
123	For i = 1 To StepSize
124		SetItemEnabled( i, False)
125	Next i
126	SetItemEnabled( 0, True)
127End Sub
128
129Sub Destroy()
130	&apos;myDialog.dispose
131	wait 1000
132    ShowInfoDialog.DisposeIDialog()
133
134    &apos; HIER WIRD DAS DOCUMENT GESCHLOSSEN!!!!!!!! GPF
135    thisComponent.CurrentController.Frame.close(True)
136
137End Sub
138
139Sub 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
143End Sub
144
145Sub 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
152End Sub
153
154Sub setStep
155    ThisComponent.DocumentProperties.UserDefinedProperties.CurrentStep = TutorStep
156End Sub
157
158Sub InitAction()
159	SetStepTitle()
160
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())
177End Sub
178
179Sub EndDialog
180	oOpenDialogFlag = False
181	If (myDialog.model.done.Label = &quot;Close&quot;) Then
182		TutorialCloseMain()
183	Else
184		DialogVisible = False
185	End If
186End Sub
187
188Sub NextStep
189	GotoStep(TutorStep + 1)
190End Sub
191
192Sub 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
211End Sub
212
213Function 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
219End Function
220
221Sub ItemChange(CurrentItemID, SelectitemID)
222	GotoStep(SelectitemID)
223End Sub
224
225Sub SetDisableShowMeButton()
226	myDialog.model.show.enabled = False
227	TutorLastStep = TutorLastStep + 1
228End Sub
229
230Sub Minimize(aEvent)
231	ActionItemsTextField = myDialog.GetControl(&quot;ActionItemsLabel&quot;)
232	FixedLineVertikal = myDialog.GetControl(&quot;FixedLineVertikal&quot;)
233
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)
256
257End Sub
258
259Sub SetStepTitle()
260	stepcontent = TutorText(TutorStep)
261	iPos = InStr(stepcontent,CHR(13))
262	stepTitle = Left(stepcontent, iPos)
263	SetStepTitle() = stepTitle
264End Sub
265
266Function GetStepTitle()
267	GetStepTitle() = stepTitle
268End Function
269
270Sub 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
276End Sub
277
278Sub CheckForStepNextButtonStatus()
279	If(TutorStep = Ubound(TutorText())) Then
280		myDialog.model.next.enabled = False
281		myDialog.model.done.Label = &quot;Done&quot;
282	End If
283End Sub
284
285Sub 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
294End Sub
295
296Sub SetMousePosition(aEvent)
297	MyPoints() = MousePoints(aEvent)
298
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)
308
309	myTutorial.setPropertyValues(mousePosition())
310End Sub
311
312Function 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()
317End Function
318
319Function 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
340End Function
341
342Sub SetVisibleTutorialsDialog(param)
343	myDialog.setVisible(param)
344End Sub
345
346Sub SetVisibleTrue()
347	myDialog.setVisible(True)
348End Sub
349
350Sub SetVisibleFalse()
351	myDialog.setVisible(False)
352End Sub
353
354Sub 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
367End Sub
368</script:module>
369