1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"TutorialOpen" script:
language=
"StarBasic">REM ***** BASIC *****
21 Dim myOpenDialog As Object
22 Dim oListBox As Object
25 Dim oListener As Object
28 GlobalScope.BasicLibraries.LoadLibrary(
"Tools
")
29 myOpenDialog = LoadDialog(
"Tutorials
",
"TutorialOpenDialog
")
31 myOpenDialog.Execute()
35 On Local Error Goto NOFILE
36 myOpenDialog.Title =
"Tutorials
"
37 oListBox = myOpenDialog.GetControl(
"ListBox
")
38 templatePath = GetPathSettings(
"Template
",false,
0)
39 Dim tutorialPath As String
40 iPos = InStr(templatePath,
"/
")
42 tutorialPath = templatePath
& "/tutorials
"
44 tutorialPath = templatePath
& "\tutorials
"
46 oUcb = createUnoService(
"com.sun.star.ucb.SimpleFileAccess
")
47 files = oUcb.getFolderContents(tutorialPath,true)
48 size = Ubound( files() )
49 Dim tempFiles(size) As String
51 For iCount =
0 To size
52 completPath = files(iCount)
53 oDocInfo = CreateUnoService(
"com.sun.star.document.DocumentProperties
")
54 oDocInfo.Read(completPath)
55 sDocTitle = oDocInfo.Title
56 if(not isNull(sDocTitle) And len(sDocTitle)
> 0) Then
57 oListbox.additem(sDocTitle,
0)
58 tempFiles(tempCount) = completPath
59 tempCount = tempCount +
1
62 'printdbgInfo oListbox
63 size = oListbox.ItemCount -
1
64 Dim tempFiles2(size) As String
65 For iCount =
0 To size
66 tempFiles2(iCount) = tempFiles(iCount)
68 files() = tempFiles2()
71 If Err
<> 0 Then
72 Msgbox
"No file found error!
" & CHR(
13)
& "Path: ...\share\template\...\tutorials\
"
73 myOpenDialog.model.Open.enabled = False
77 Sub ItemSelected(oEvent)
78 On Local Error Goto NOFILE
79 completPath = files(Ubound(files()) - oEvent.Selected)
80 oTextField = myOpenDialog.GetControl(
"Label
")
'TextField
81 oTextField.setText(
"")
82 Dim NoArgs() as new com.sun.star.beans.PropertyValue
83 oDocInfo = CreateUnoService(
"com.sun.star.document.DocumentProperties
")
84 oDocInfo.Read(completPath)
85 sDocDescription = oDocInfo.Description
86 if(not isNull(sDocTitle) And len(sDocDescription)
> 0) Then
87 oTextField.setText(sDocDescription)
89 oTextField.setText(
"Not Description!!!.
")
93 If Err
<> 0 Then
94 Msgbox
"Open file error!
"
98 Sub OpenTutorial(aEvent)
99 completPath = files(Ubound(files()) - oListBox.getSelectedItemPos())
100 Dim Args(
2) as new com.sun.star.beans.PropertyValue
101 Args(
1).Name =
"MacroExecutionMode
"
102 Args(
1).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE
103 Args(
2).Name =
"AsTemplate
"
106 StarDesktop.LoadComponentFromURL(completPath,
"_default
",
0, Args())
107 myOpenDialog.endExecute()
111 myOpenDialog.endExecute()