Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / wizards / source / tutorials / TutorialOpen.xba
blob5b6001c6ca134e5d93aa50bf8305235d22d39125
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <!--
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 .
19 -->
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
23 Dim files As Object
24 Dim oUcb As Object
25 Dim oListener As Object
27 Sub TutorialOpenMain
28 GlobalScope.BasicLibraries.LoadLibrary(&quot;Tools&quot;)
29 myOpenDialog = LoadDialog(&quot;Tutorials&quot;,&quot;TutorialOpenDialog&quot;)
30 init()
31 myOpenDialog.Execute()
32 End Sub
34 Sub Init
35 On Local Error Goto NOFILE
36 myOpenDialog.Title = &quot;Tutorials&quot;
37 oListBox = myOpenDialog.GetControl(&quot;ListBox&quot;)
38 templatePath = GetPathSettings(&quot;Template&quot;,false, 0)
39 Dim tutorialPath As String
40 iPos = InStr(templatePath,&quot;/&quot;)
41 if(iPos &gt; 0) Then
42 tutorialPath = templatePath &amp; &quot;/tutorials&quot;
43 Else
44 tutorialPath = templatePath &amp; &quot;\tutorials&quot;
45 End If
46 oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
47 files = oUcb.getFolderContents(tutorialPath,true)
48 size = Ubound( files() )
49 Dim tempFiles(size) As String
50 tempCount = 0
51 For iCount = 0 To size
52 completPath = files(iCount)
53 oDocInfo = CreateUnoService(&quot;com.sun.star.document.DocumentProperties&quot;)
54 oDocInfo.Read(completPath)
55 sDocTitle = oDocInfo.Title
56 if(not isNull(sDocTitle) And len(sDocTitle) &gt; 0) Then
57 oListbox.addItem(sDocTitle,0)
58 tempFiles(tempCount) = completPath
59 tempCount = tempCount + 1
60 End If
61 Next iCount
62 &apos;printdbgInfo oListbox
63 size = oListbox.ItemCount - 1
64 Dim tempFiles2(size) As String
65 For iCount = 0 To size
66 tempFiles2(iCount) = tempFiles(iCount)
67 Next iCount
68 files() = tempFiles2()
69 Exit Sub
70 NOFILE:
71 If Err &lt;&gt; 0 Then
72 Msgbox &quot;No file found error!&quot; &amp; CHR(13) &amp; &quot;Path: ...\share\template\...\tutorials\&quot;
73 myOpenDialog.model.Open.enabled = False
74 End If
75 End Sub
77 Sub ItemSelected(oEvent)
78 On Local Error Goto NOFILE
79 completPath = files(Ubound(files()) - oEvent.Selected)
80 oTextField = myOpenDialog.GetControl(&quot;Label&quot;) &apos;TextField
81 oTextField.setText(&quot;&quot;)
82 Dim NoArgs() as new com.sun.star.beans.PropertyValue
83 oDocInfo = CreateUnoService(&quot;com.sun.star.document.DocumentProperties&quot;)
84 oDocInfo.Read(completPath)
85 sDocDescription = oDocInfo.Description
86 if(not isNull(sDocTitle) And len(sDocDescription) &gt; 0) Then
87 oTextField.setText(sDocDescription)
88 Else
89 oTextField.setText(&quot;Not Description!!!.&quot;)
90 End If
91 Exit Sub
92 NOFILE:
93 If Err &lt;&gt; 0 Then
94 Msgbox &quot;Open file error!&quot;
95 End If
96 End Sub
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 = &quot;MacroExecutionMode&quot;
102 Args(1).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE
103 Args(2).Name = &quot;AsTemplate&quot;
104 Args(2).Value = true
106 StarDesktop.LoadComponentFromURL(completPath,&quot;_default&quot;,0, Args())
107 myOpenDialog.endExecute()
108 End Sub
110 Sub Cancel(aEvent)
111 myOpenDialog.endExecute()
112 End Sub
113 </script:module>