diff options
Diffstat (limited to 'wizards/source/tutorials/Functions.xba')
-rw-r--r-- | wizards/source/tutorials/Functions.xba | 385 |
1 files changed, 385 insertions, 0 deletions
diff --git a/wizards/source/tutorials/Functions.xba b/wizards/source/tutorials/Functions.xba new file mode 100644 index 000000000..4b422c80b --- /dev/null +++ b/wizards/source/tutorials/Functions.xba @@ -0,0 +1,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 +'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> |