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=
"TutorialOpen" script:
language=
"StarBasic">REM ***** BASIC *****
4 Dim myOpenDialog As Object
8 Dim oListener As Object
11 GlobalScope.BasicLibraries.LoadLibrary(
"Tools
")
12 myOpenDialog = LoadDialog(
"Tutorials
",
"TutorialOpenDialog
")
14 myOpenDialog.Execute()
18 On Local Error Goto NOFILE
19 myOpenDialog.Title =
"Tutorials
"
20 oListBox = myOpenDialog.GetControl(
"ListBox
")
21 templatePath = GetPathSettings(
"Template
",false,
0)
22 Dim tutorialPath As String
23 iPos = InStr(templatePath,
"/
")
25 tutorialPath = templatePath
& "/tutorials
"
27 tutorialPath = templatePath
& "\tutorials
"
29 oUcb = createUnoService(
"com.sun.star.ucb.SimpleFileAccess
")
30 files = oUcb.getFolderContents(tutorialPath,true)
31 size = Ubound( files() )
32 Dim tempFiles(size) As String
34 For iCount =
0 To size
35 completPath = files(iCount)
36 oDocInfo = CreateUnoService(
"com.sun.star.document.DocumentProperties
")
37 oDocInfo.Read(completPath)
38 sDocTitle = oDocInfo.Title
39 if(not isNull(sDocTitle) And len(sDocTitle)
> 0) Then
40 oListbox.additem(sDocTitle,
0)
41 tempFiles(tempCount) = completPath
42 tempCount = tempCount +
1
45 'printdbgInfo oListbox
46 size = oListbox.ItemCount -
1
47 Dim tempFiles2(size) As String
48 For iCount =
0 To size
49 tempFiles2(iCount) = tempFiles(iCount)
51 files() = tempFiles2()
54 If Err
<> 0 Then
55 Msgbox
"No file found error!
" & CHR(
13)
& "Path: ...\share\template\...\tutorials\
"
56 myOpenDialog.model.Open.enabled = False
60 Sub ItemSelected(oEvent)
61 On Local Error Goto NOFILE
62 completPath = files(Ubound(files()) - oEvent.Selected)
63 oTextField = myOpenDialog.GetControl(
"Label
")
'TextField
64 oTextField.setText(
"")
65 Dim NoArgs() as new com.sun.star.beans.PropertyValue
66 oDocInfo = CreateUnoService(
"com.sun.star.document.DocumentProperties
")
67 oDocInfo.Read(completPath)
68 sDocDescription = oDocInfo.Description
69 if(not isNull(sDocTitle) And len(sDocDescription)
> 0) Then
70 oTextField.setText(sDocDescription)
72 oTextField.setText(
"Not Description!!!.
")
76 If Err
<> 0 Then
77 Msgbox
"Open file error!
"
81 Sub OpenTutorial(aEvent)
82 completPath = files(Ubound(files()) - oListBox.getSelectedItemPos())
83 Dim Args(
2) as new com.sun.star.beans.PropertyValue
84 Args(
1).Name =
"MacroExecutionMode
"
85 Args(
1).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE
86 Args(
2).Name =
"AsTemplate
"
89 StarDesktop.LoadComponentFromURL(completPath,
"_default
",
0, Args())
90 myOpenDialog.endExecute()
94 myOpenDialog.endExecute()