123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <?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
- '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 = "True" Then
- Dim localisation(0) As new com.sun.star.beans.NamedValue
- localisation(0).Name = "Localisation"
- localisation(0).Value = properties()
- myTutorial.execute(localisation())
- Else
- TutorStep = 0
- TutorLastStep = 0
- docTYP = documentTYP
- InitAction()
- ShowInfoMain()
- DialogVisible = True
- myDialog = LoadDialog("Tutorials","TutorialsDialog")
-
- SetTutorialDocumentPosSize()
-
- documentProps = ThisComponent.getDocumentProperties()
- myDialog.Title = "Tutorials - " & documentProps.Title
- oTextField = myDialog.GetControl("myTextField")
- oTextField.setVisible(False)
-
- imageStatus = "MIN"
- setMaxMinImage(imageStatus)
-
- 'myWidth = myDialog.Size.Width
- myHeight = myDialog.Size.Height
-
- CheckForStepShowButtonStatus()
- CheckForStepNextButtonStatus()
- InitRoadMap()
- SetVisibleTrue()
- myDialog.model.myTextField.Label = stepTitle
- myDialog.model.myText.Label = GetStepText()'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("CommandButton")
- templatePath = GetPathSettings("Template",false, 0)
- Dim bitmapPath As String
- iPos = InStr(templatePath,"/")
- If(iPos > 0) Then
- If(param = "MAX") Then
- bitmapPath = templatePath & "../wizard/bitmap/maximize.png"
- ElseIf(param = "MIN") Then
- bitmapPath = templatePath & "../wizard/bitmap/minimize.png"
- End If
- Else
- If(param = "MAX") Then
- bitmapPath = templatePath & "..\wizard\bitmap\maximize.png"
- ElseIf(param = "MIN") Then
- bitmapPath = templatePath & "..\wizard\bitmap\minimize.png"
- End If
- End If
- 'printdbgInfo oCommandButton.Model
- oCommandButton.Model.ImageUrl = bitmapPath
- Exit Sub
- NOIMAGE:
- End Sub
- Sub SetTutorialDocumentPosSize()
- activDesktopWindow = StarDesktop.activeFrame.ContainerWindow
- If(activDesktopWindow.posSize.Height < 550) Then
- activDesktopWindow.setPosSize(0,0,0,550,8)
- End If
- If (activDesktopWindow.posSize.Width < 750 ) Then
- activDesktopWindow.setPosSize(0,0,750,0,4)
- EndIf
- End Sub
- Sub InitRoadMap()
- RoadMapMain(Functions, myDialog)
- SetControlModelPosSize(0, 0, 85, 176)
- SetControlModelText("Steps")
-
- 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()
- 'myDialog.dispose
- wait 1000
- ShowInfoDialog.DisposeIDialog()
-
- ' THE DOCUMENT GETS CLOSED HERE!!!!!!!! GPF
- thisComponent.CurrentController.Frame.close(True)
-
- End Sub
- Sub Init
- GlobalScope.BasicLibraries.LoadLibrary("Tools")
- myTutorial = createUNOService("com.sun.star.wizards.tutorial.executer.CallTutorialFramework")
- documentTitle = ThisComponent.getCurrentController.getFrame.Title
- End Sub
- Sub InitStep
- udProps = ThisComponent.DocumentProperties.UserDefinedProperties
- If udProps.PropertySetInfo.hasPropertyByName("CurrentStep") Then
- TutorStep = udProps.CurrentStep
- Else
- udProps.addProperty("CurrentStep", 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 = "DocumentTYP"
- property(0).Value = docTYP
- property(1).Name = "MethodName"
- property(1).Value = "setDelay"
- property(2).Name = "Param"
- property(2).Value = 0 'key insert speed (Millis)
- property(3).Name = "Param"
- property(3).Value = 4 'mouse animate speed (Millis)
- property(4).Name = "Param"
- property(4).Value = 2000 'after mouse animate sleep (Millis)
- property(5).Name = "Param"
- property(5).Value = 10 'mouse scroll speed (Millis)
- property(6).Name = "Param"
- property(6).Value = -1 'mouse speed (step)
- myTutorial.setPropertyValues(property())
- End Sub
- Sub EndDialog
- oOpenDialogFlag = False
- If (myDialog.model.done.Label = "Close") Then
- TutorialCloseMain()
- Else
- DialogVisible = False
- End If
- End Sub
- Sub NextStep
- GotoStep(TutorStep + 1)
- End Sub
- Sub GotoStep(StepIndex)
- If(StepIndex <= Ubound(TutorText())) Then
- TutorStep = StepIndex
- If TutorStep > TutorLastStep Then
- TutorLastStep = TutorStep
- End If
- If(TutorStep = Ubound(TutorText())) Then
- myDialog.model.next.enabled = False
- myDialog.model.done.Label = "Done"
- myDialog.model.show.Label = "Tutorials"
- Else
- myDialog.model.next.enabled = True
- End If
- SetStepTitle()
- myDialog.model.myText.Label = GetStepText()
- CheckForStepShowButtonStatus()
- SetItemEnabled( TutorStep, True)
- '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("ActionItemsLabel")
- FixedLineVertikal = myDialog.GetControl("FixedLineVertikal")
-
- 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 & ". " & gsTitle)
- oTextField.setVisible(True)
- ActionItemsTextField.setVisible(False)
- FixedLineVertikal.setVisible(False)
- RoadMap.SetVisibleRoadMap(False)
- End If
- If(imageStatus = "MAX") Then
- imageStatus = "MIN"
- ElseIf(imageStatus = "MIN") Then
- imageStatus = "MAX"
- 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 = "Tutorials") 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 = "Done"
- End If
- End Sub
- Sub Show(aEvent)
- 'ShowInfoMain()
- If( myDialog.model.show.Label = "Tutorials") 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 = "DocumentTYP"
- mousePosition(0).Value = docTYP
- mousePosition(1).Name = "MethodName"
- mousePosition(1).Value = "setMousePosition"
- mousePosition(2).Name = "Param"
- mousePosition(2).Value = MyPoints(0)
- mousePosition(3).Name = "Param"
- mousePosition(3).Value = MyPoints(1)
-
- myTutorial.setPropertyValues(mousePosition())
- End Sub
- Function MousePoints(aEvent)
- Dim position(1) As Integer
- position(0) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX
- position(1) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY
- MousePoints = position()
- End Function
- Function CheckPath(path() As String)
- 'documentTitle = ThisComponent.getCurrentController.getFrame.Title
- sTitle = path(0)
- ResultString = Right(sTitle, 3)
- iPos = InStr(ResultString,"#")
- ResultString = Right(ResultString, Len(ResultString) - iPos)
- ResultFrameString = InStr (sTitle, "{D}FRAME#")
- If ResultFrameString <> 0 Then
- If Not (sTitle = ("{D}FRAME#" & documentTitle & "#" & ResultString)) Then
- 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString
- path(0) = "FRAME#" & documentTitle & "#" & ResultString
- sTitle = path(1)
- ResultString = Right(sTitle, 3)
- iPos = InStr(ResultString,"#")
- ResultString = Right(ResultString, Len(ResultString) - iPos)
- path(1) = "ROOT_PANE#" & documentTitle & "#" & ResultString
- Else
- 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString
- path(0) = "FRAME#" & documentTitle & "#" & 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("com.sun.star.util.URLTransformer")
- aUrl.Complete = "slot:5621"
- urlTransformer.parseStrict(aUrl)
- xController = oDoc.getCurrentController()
- xDispatcher = xController.queryDispatch(aUrl, "", 0)
- if NOT isNull(xDispatcher) then
- xDispatcher.dispatch(aUrl, DimArray())
- else
- msgBox "Error! Cannot close document."
- End If
- End Sub
- </script:module>
|