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'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 = "True" Then 27 Dim localisation(0) As new com.sun.star.beans.NamedValue 28 localisation(0).Name = "Localisation" 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("Tutorials","TutorialsDialog") 39 40 SetTutorialDocumentPosSize() 41 42 documentProps = ThisComponent.getDocumentProperties() 43 myDialog.Title = "Tutorials - " & documentProps.Title 44 oTextField = myDialog.GetControl("myTextField") 45 oTextField.setVisible(False) 46 47 imageStatus = "MIN" 48 setMaxMinImage(imageStatus) 49 50 '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()'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("CommandButton") 76 templatePath = GetPathSettings("Template",false, 0) 77 Dim bitmapPath As String 78 iPos = InStr(templatePath,"/") 79 If(iPos > 0) Then 80 If(param = "MAX") Then 81 bitmapPath = templatePath & "../wizard/bitmap/maximize.bmp" 82 ElseIf(param = "MIN") Then 83 bitmapPath = templatePath & "../wizard/bitmap/minimize.bmp" 84 End If 85 Else 86 If(param = "MAX") Then 87 bitmapPath = templatePath & "..\wizard\bitmap\maximize.bmp" 88 ElseIf(param = "MIN") Then 89 bitmapPath = templatePath & "..\wizard\bitmap\minimize.bmp" 90 End If 91 End If 92 '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 < 550) Then 101 activDesktopWindow.setPosSize(0,0,0,550,8) 102 End If 103 If (activDesktopWindow.posSize.Width < 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("Steps") 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 'myDialog.dispose 131 wait 1000 132 ShowInfoDialog.DisposeIDialog() 133 134 ' HIER WIRD DAS DOCUMENT GESCHLOSSEN!!!!!!!! GPF 135 thisComponent.CurrentController.Frame.close(True) 136 137End Sub 138 139Sub Init 140 GlobalScope.BasicLibraries.LoadLibrary("Tools") 141 myTutorial = createUNOService("com.sun.star.wizards.tutorial.executer.CallTutorialFramework") 142 documentTitle = ThisComponent.getCurrentController.getFrame.Title 143End Sub 144 145Sub InitStep 146 udProps = ThisComponent.DocumentProperties.UserDefinedProperties 147 If udProps.PropertySetInfo.hasPropertyByName("CurrentStep") Then 148 TutorStep = udProps.CurrentStep 149 Else 150 udProps.addProperty("CurrentStep", 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 = "DocumentTYP" 163 property(0).Value = docTYP 164 property(1).Name = "MethodName" 165 property(1).Value = "setDelay" 166 property(2).Name = "Param" 167 property(2).Value = 0 'key insert speed (Millis) 168 property(3).Name = "Param" 169 property(3).Value = 4 'mouse animate speed (Millis) 170 property(4).Name = "Param" 171 property(4).Value = 2000 'after mouse animate sleep (Millis) 172 property(5).Name = "Param" 173 property(5).Value = 10 'mouse scroll speed (Millis) 174 property(6).Name = "Param" 175 property(6).Value = -1 'mouse speed (step) 176 myTutorial.setPropertyValues(property()) 177End Sub 178 179Sub EndDialog 180 oOpenDialogFlag = False 181 If (myDialog.model.done.Label = "Close") 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 <= Ubound(TutorText())) Then 194 TutorStep = StepIndex 195 If TutorStep > 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 = "Done" 201 myDialog.model.show.Label = "Tutorials" 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 '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("ActionItemsLabel") 232 FixedLineVertikal = myDialog.GetControl("FixedLineVertikal") 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 & ". " & gsTitle) 245 oTextField.setVisible(True) 246 ActionItemsTextField.setVisible(False) 247 FixedLineVertikal.setVisible(False) 248 RoadMap.SetVisibleRoadMap(False) 249 End If 250 If(imageStatus = "MAX") Then 251 imageStatus = "MIN" 252 ElseIf(imageStatus = "MIN") Then 253 imageStatus = "MAX" 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 = "Tutorials") 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 = "Done" 282 End If 283End Sub 284 285Sub Show(aEvent) 286 'ShowInfoMain() 287 If( myDialog.model.show.Label = "Tutorials") 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 = "DocumentTYP" 301 mousePosition(0).Value = docTYP 302 mousePosition(1).Name = "MethodName" 303 mousePosition(1).Value = "setMousePosition" 304 mousePosition(2).Name = "Param" 305 mousePosition(2).Value = MyPoints(0) 306 mousePosition(3).Name = "Param" 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("show").AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX 315 position(1) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY 316 MousePoints = position() 317End Function 318 319Function CheckPath(path() As String) 320 'documentTitle = ThisComponent.getCurrentController.getFrame.Title 321 sTitle = path(0) 322 ResultString = Right(sTitle, 3) 323 iPos = InStr(ResultString,"#") 324 ResultString = Right(ResultString, Len(ResultString) - iPos) 325 ResultFrameString = InStr (sTitle, "{D}FRAME#") 326 If ResultFrameString <> 0 Then 327 If Not (sTitle = ("{D}FRAME#" & documentTitle & "#" & ResultString)) Then 328 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString 329 path(0) = "FRAME#" & documentTitle & "#" & ResultString 330 sTitle = path(1) 331 ResultString = Right(sTitle, 3) 332 iPos = InStr(ResultString,"#") 333 ResultString = Right(ResultString, Len(ResultString) - iPos) 334 path(1) = "ROOT_PANE#" & documentTitle & "#" & ResultString 335 Else 336 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString 337 path(0) = "FRAME#" & documentTitle & "#" & 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("com.sun.star.util.URLTransformer") 358 aUrl.Complete = "slot:5621" 359 urlTransformer.parseStrict(aUrl) 360 xController = oDoc.getCurrentController() 361 xDispatcher = xController.queryDispatch(aUrl, "", 0) 362 if NOT isNull(xDispatcher) then 363 xDispatcher.dispatch(aUrl, DimArray()) 364 else 365 msgBox "Error! Cannot close document." 366 End If 367End Sub 368</script:module> 369