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'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 = "True" Then 47 Dim localisation(0) As new com.sun.star.beans.NamedValue 48 localisation(0).Name = "Localisation" 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("Tutorials","TutorialsDialog") 59 60 SetTutorialDocumentPosSize() 61 62 documentProps = ThisComponent.getDocumentProperties() 63 myDialog.Title = "Tutorials - " & documentProps.Title 64 oTextField = myDialog.GetControl("myTextField") 65 oTextField.setVisible(False) 66 67 imageStatus = "MIN" 68 setMaxMinImage(imageStatus) 69 70 '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()'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("CommandButton") 96 templatePath = GetPathSettings("Template",false, 0) 97 Dim bitmapPath As String 98 iPos = InStr(templatePath,"/") 99 If(iPos > 0) Then 100 If(param = "MAX") Then 101 bitmapPath = templatePath & "../wizard/bitmap/maximize.bmp" 102 ElseIf(param = "MIN") Then 103 bitmapPath = templatePath & "../wizard/bitmap/minimize.bmp" 104 End If 105 Else 106 If(param = "MAX") Then 107 bitmapPath = templatePath & "..\wizard\bitmap\maximize.bmp" 108 ElseIf(param = "MIN") Then 109 bitmapPath = templatePath & "..\wizard\bitmap\minimize.bmp" 110 End If 111 End If 112 '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 < 550) Then 121 activDesktopWindow.setPosSize(0,0,0,550,8) 122 End If 123 If (activDesktopWindow.posSize.Width < 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("Steps") 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 'myDialog.dispose 151 wait 1000 152 ShowInfoDialog.DisposeIDialog() 153 154 ' HIER WIRD DAS DOCUMENT GESCHLOSSEN!!!!!!!! GPF 155 thisComponent.CurrentController.Frame.close(True) 156 157End Sub 158 159Sub Init 160 GlobalScope.BasicLibraries.LoadLibrary("Tools") 161 myTutorial = createUNOService("com.sun.star.wizards.tutorial.executer.CallTutorialFramework") 162 documentTitle = ThisComponent.getCurrentController.getFrame.Title 163End Sub 164 165Sub InitStep 166 udProps = ThisComponent.DocumentProperties.UserDefinedProperties 167 If udProps.PropertySetInfo.hasPropertyByName("CurrentStep") Then 168 TutorStep = udProps.CurrentStep 169 Else 170 udProps.addProperty("CurrentStep", 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 = "DocumentTYP" 183 property(0).Value = docTYP 184 property(1).Name = "MethodName" 185 property(1).Value = "setDelay" 186 property(2).Name = "Param" 187 property(2).Value = 0 'key insert speed (Millis) 188 property(3).Name = "Param" 189 property(3).Value = 4 'mouse animate speed (Millis) 190 property(4).Name = "Param" 191 property(4).Value = 2000 'after mouse animate sleep (Millis) 192 property(5).Name = "Param" 193 property(5).Value = 10 'mouse scroll speed (Millis) 194 property(6).Name = "Param" 195 property(6).Value = -1 'mouse speed (step) 196 myTutorial.setPropertyValues(property()) 197End Sub 198 199Sub EndDialog 200 oOpenDialogFlag = False 201 If (myDialog.model.done.Label = "Close") 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 <= Ubound(TutorText())) Then 214 TutorStep = StepIndex 215 If TutorStep > 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 = "Done" 221 myDialog.model.show.Label = "Tutorials" 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 '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("ActionItemsLabel") 252 FixedLineVertikal = myDialog.GetControl("FixedLineVertikal") 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 & ". " & gsTitle) 265 oTextField.setVisible(True) 266 ActionItemsTextField.setVisible(False) 267 FixedLineVertikal.setVisible(False) 268 RoadMap.SetVisibleRoadMap(False) 269 End If 270 If(imageStatus = "MAX") Then 271 imageStatus = "MIN" 272 ElseIf(imageStatus = "MIN") Then 273 imageStatus = "MAX" 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 = "Tutorials") 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 = "Done" 302 End If 303End Sub 304 305Sub Show(aEvent) 306 'ShowInfoMain() 307 If( myDialog.model.show.Label = "Tutorials") 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 = "DocumentTYP" 321 mousePosition(0).Value = docTYP 322 mousePosition(1).Name = "MethodName" 323 mousePosition(1).Value = "setMousePosition" 324 mousePosition(2).Name = "Param" 325 mousePosition(2).Value = MyPoints(0) 326 mousePosition(3).Name = "Param" 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("show").AccessibleContext.LocationOnScreen.X + aEvent.Source.Model.PositionX 335 position(1) = myDialog.getControl("show").AccessibleContext.LocationOnScreen.Y + aEvent.Source.Model.PositionY 336 MousePoints = position() 337End Function 338 339Function CheckPath(path() As String) 340 'documentTitle = ThisComponent.getCurrentController.getFrame.Title 341 sTitle = path(0) 342 ResultString = Right(sTitle, 3) 343 iPos = InStr(ResultString,"#") 344 ResultString = Right(ResultString, Len(ResultString) - iPos) 345 ResultFrameString = InStr (sTitle, "{D}FRAME#") 346 If ResultFrameString <> 0 Then 347 If Not (sTitle = ("{D}FRAME#" & documentTitle & "#" & ResultString)) Then 348 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString 349 path(0) = "FRAME#" & documentTitle & "#" & ResultString 350 sTitle = path(1) 351 ResultString = Right(sTitle, 3) 352 iPos = InStr(ResultString,"#") 353 ResultString = Right(ResultString, Len(ResultString) - iPos) 354 path(1) = "ROOT_PANE#" & documentTitle & "#" & ResultString 355 Else 356 'path(0) = "{D}FRAME#" & documentTitle & "#" & ResultString 357 path(0) = "FRAME#" & documentTitle & "#" & 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("com.sun.star.util.URLTransformer") 378 aUrl.Complete = "slot:5621" 379 urlTransformer.parseStrict(aUrl) 380 xController = oDoc.getCurrentController() 381 xDispatcher = xController.queryDispatch(aUrl, "", 0) 382 if NOT isNull(xDispatcher) then 383 xDispatcher.dispatch(aUrl, DimArray()) 384 else 385 msgBox "Error! Cannot close document." 386 End If 387End Sub 388</script:module> 389