xref: /AOO42X/main/wizards/source/euro/AutoPilotRun.xba (revision 283d1c44daea08365db7c80e04834e4b25002b26)
1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="AutoPilotRun" script:language="StarBasic">Option Explicit
4cdf0e10cSrcweir
5cdf0e10cSrcweirPublic SourceDir as String
6cdf0e10cSrcweirPublic TargetDir as String
7cdf0e10cSrcweirPublic TargetStemDir as String
8cdf0e10cSrcweirPublic SourceFile as String
9cdf0e10cSrcweirPublic TargetFile as String
10cdf0e10cSrcweirPublic Source as String
11cdf0e10cSrcweirPublic SubstFile as String
12cdf0e10cSrcweirPublic SubstDir as String
13cdf0e10cSrcweirPublic NoArgs()
14*283d1c44SPedro GiffuniPublic TypeList(14) as String
15cdf0e10cSrcweirPublic GoOn as Boolean
16cdf0e10cSrcweirPublic DoUnprotect as Integer
17cdf0e10cSrcweirPublic Password as String
18cdf0e10cSrcweirPublic DocIndex as Integer
19cdf0e10cSrcweirPublic oPathSettings as Object
20cdf0e10cSrcweirPublic oUcb as Object
21cdf0e10cSrcweirPublic TotDocCount as Integer
22cdf0e10cSrcweirPublic sTotDocCount as String
23cdf0e10cSrcweirPublic OpenProperties(1) as New com.sun.star.beans.PropertyValue
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweirSub StartAutoPilot()
27cdf0e10cSrcweirDim i As Integer
28cdf0e10cSrcweirDim oFactoryKey as Object
29cdf0e10cSrcweir    BasicLibraries.LoadLibrary(&quot;Tools&quot;)
30cdf0e10cSrcweir    BasicLibraries.LoadLibrary(&quot;ImportWizard&quot;)
31cdf0e10cSrcweir    If InitResources(&quot;Euro Converter&quot;, &quot;eur&quot;) Then
32cdf0e10cSrcweir        oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
33cdf0e10cSrcweir        oLocale = GetStarOfficeLocale()
34cdf0e10cSrcweir        InitializeConverter(oLocale, 2)
35cdf0e10cSrcweir        ToggleGoOnButton()
36cdf0e10cSrcweir        oFactoryKey = GetRegistryKeyContent(&quot;org.openoffice.Setup/Office/Factories&quot;)
37cdf0e10cSrcweir        DialogModel.chkTextDocuments.Enabled =  oFactoryKey.hasbyName(&quot;com.sun.star.text.TextDocument&quot;)
38cdf0e10cSrcweir        DialogModel.cmdGoOn.DefaultButton = True
39cdf0e10cSrcweir        DialogModel.lstCurrencies.TabIndex = 12
40cdf0e10cSrcweir        DialogConvert.GetControl(&quot;optWholeDir&quot;).SetFocus()
41cdf0e10cSrcweir        DialogConvert.Execute()
42cdf0e10cSrcweir        DialogConvert.Dispose()
43cdf0e10cSrcweir    End If
44cdf0e10cSrcweirEnd Sub
45cdf0e10cSrcweir
46cdf0e10cSrcweir
47cdf0e10cSrcweirSub ConvertDocuments()
48cdf0e10cSrcweirDim FilesList()
49cdf0e10cSrcweirDim bDisposable as Boolean
50cdf0e10cSrcweir
51cdf0e10cSrcweir    If Source &lt;&gt; &quot;&quot; And TargetDir &lt;&gt; &quot;&quot; Then
52cdf0e10cSrcweir        If DialogModel.optSingleFile.State = 1 Then
53cdf0e10cSrcweir            SourceFile = Source
54cdf0e10cSrcweir            TotDocCount = 1
55cdf0e10cSrcweir        Else
56cdf0e10cSrcweir            SourceDir = Source
57cdf0e10cSrcweir            TargetStemDir = TargetDir
58*283d1c44SPedro Giffuni            TypeList(0) = &quot;calc8&quot;
59*283d1c44SPedro Giffuni            TypeList(1) = &quot;calc_StarOffice_XML_Calc&quot;
60*283d1c44SPedro Giffuni            TypeList(2) = &quot;calc_StarCalc_30&quot;
61*283d1c44SPedro Giffuni            TypeList(3) = &quot;calc_StarCalc_40&quot;
62*283d1c44SPedro Giffuni            TypeList(4) = &quot;calc_StarCalc_50&quot;
63cdf0e10cSrcweir            If DialogModel.chkTextDocuments.State = 1 Then
64*283d1c44SPedro Giffuni                ReDim Preserve TypeList(13) as String
65cdf0e10cSrcweir
66*283d1c44SPedro Giffuni                TypeList(5) = &quot;writer8&quot;
67*283d1c44SPedro Giffuni                TypeList(6) = &quot;writerglobal8&quot;
68*283d1c44SPedro Giffuni                TypeList(7) = &quot;writer_StarOffice_XML_Writer&quot;
69*283d1c44SPedro Giffuni                TypeList(8) = &quot;writer_globaldocument_StarOffice_XML_Writer_GlobalDocument&quot;
70*283d1c44SPedro Giffuni                TypeList(9) = &quot;writer_StarWriter_30&quot;
71*283d1c44SPedro Giffuni                TypeList(10) = &quot;writer_StarWriter_40&quot;
72*283d1c44SPedro Giffuni                TypeList(11) = &quot;writer_globaldocument_StarWriter_40GlobalDocument&quot;
73*283d1c44SPedro Giffuni                TypeList(12) = &quot;writer_StarWriter_50&quot;
74*283d1c44SPedro Giffuni                TypeList(13) = &quot;writer_globaldocument_StarWriter_50GlobalDocument&quot;
75cdf0e10cSrcweir            End If
76*283d1c44SPedro Giffuni            FilesList() = ReadDirectories(SourceDir, bRecursive, True, False, TypeList())
77cdf0e10cSrcweir            TotDocCount = Ubound(FilesList(),1) + 1
78cdf0e10cSrcweir        End If
79cdf0e10cSrcweir        InitializeProgressPage(DialogModel)
80cdf0e10cSrcweir&apos;      ChangeToNextProgressStep()
81cdf0e10cSrcweir        sTotDocCount = CStr(TotDocCount)
82cdf0e10cSrcweir        OpenProperties(0).Name = &quot;Hidden&quot;
83cdf0e10cSrcweir        OpenProperties(0).Value = True
84cdf0e10cSrcweir        OpenProperties(1).Name = &quot;AsTemplate&quot;
85cdf0e10cSrcweir        OpenProperties(1).Value = False
86cdf0e10cSrcweir        For DocIndex = 0 To TotDocCount - 1
87cdf0e10cSrcweir            If InitializeDocument(FilesList(), bDisposable) Then
88cdf0e10cSrcweir                If StoreDocument() Then
89cdf0e10cSrcweir                    ConvertDocument()
90cdf0e10cSrcweir                    oDocument.Store
91cdf0e10cSrcweir                End If
92cdf0e10cSrcweir                If bDisposable Then
93cdf0e10cSrcweir                    oDocument.Dispose()
94cdf0e10cSrcweir                End If
95cdf0e10cSrcweir            End If
96cdf0e10cSrcweir        Next DocIndex
97cdf0e10cSrcweir        DialogModel.cmdBack.Enabled = True
98cdf0e10cSrcweir        DialogModel.cmdGoOn.Enabled = True
99cdf0e10cSrcweir        DialogModel.cmdGoOn.Label = sReady
100cdf0e10cSrcweir        DialogModel.cmdCancel.Label = sEnd
101cdf0e10cSrcweir    End If
102cdf0e10cSrcweirEnd Sub
103cdf0e10cSrcweir
104cdf0e10cSrcweir
105cdf0e10cSrcweirFunction InitializeDocument(FilesList(), bDisposable as Boolean) as Boolean
106cdf0e10cSrcweir&apos; The Autopilot is started from step No. 2
107cdf0e10cSrcweirDim sViewPath as String
108cdf0e10cSrcweirDim bIsReadOnly as Boolean
109cdf0e10cSrcweirDim sExtension as String
110cdf0e10cSrcweir    On Local Error Goto NEXTFILE
111cdf0e10cSrcweir    If Not bCancelTask Then
112cdf0e10cSrcweir        If DialogModel.optWholeDir.State = 1 Then
113cdf0e10cSrcweir            SourceFile = FilesList(DocIndex,0)
114cdf0e10cSrcweir            TargetFile = ReplaceString(SourceFile,TargetStemDir,SourceDir)
115cdf0e10cSrcweir            TargetDir = DirectorynameoutofPath(TargetFile, &quot;/&quot;)
116cdf0e10cSrcweir        Else
117cdf0e10cSrcweir            SourceFile = Source
118cdf0e10cSrcweir            TargetFile = TargetDir &amp; &quot;/&quot; &amp; FileNameoutofPath(SourceFile, &quot;/&quot;)
119cdf0e10cSrcweir        End If
120cdf0e10cSrcweir        If CreateFolder(TargetDir) Then
121cdf0e10cSrcweir            sExtension = GetFileNameExtension(SourceFile, &quot;/&quot;)
122cdf0e10cSrcweir            oDocument = OpenDocument(SourceFile, OpenProperties(), bDisposable)
123cdf0e10cSrcweir            If (oDocument.IsReadOnly) AND (UCase(SourceFile) = UCase(TargetFile)) Then
124cdf0e10cSrcweir                bIsReadOnly = True
125cdf0e10cSrcweir                Msgbox(sMsgDOCISREADONLY, 16, GetProductName())
126cdf0e10cSrcweir            Else
127cdf0e10cSrcweir                bIsReadOnly = False
128cdf0e10cSrcweir                RetrieveDocumentObjects()
129cdf0e10cSrcweir                sViewPath = CutPathView(SourceFile, 60)
130cdf0e10cSrcweir                DialogModel.lblCurDocument.Label = Str(DocIndex+1) &amp; &quot;/&quot; &amp; sTotDocCount &amp; &quot;  (&quot; &amp; sViewPath &amp; &quot;)&quot;
131cdf0e10cSrcweir            End If
132cdf0e10cSrcweir            InitializeDocument() = Not bIsReadOnly
133cdf0e10cSrcweir        Else
134cdf0e10cSrcweir            InitializeDocument() = False
135cdf0e10cSrcweir        End If
136cdf0e10cSrcweir    Else
137cdf0e10cSrcweir        InitializeDocument() = False
138cdf0e10cSrcweir    End If
139cdf0e10cSrcweirNEXTFILE:
140cdf0e10cSrcweir    If Err &lt;&gt; 0 Then
141cdf0e10cSrcweir        InitializeDocument() = False
142cdf0e10cSrcweir        Resume LETSGO
143cdf0e10cSrcweirLETSGO:
144cdf0e10cSrcweir    End If
145cdf0e10cSrcweirEnd Function
146cdf0e10cSrcweir
147cdf0e10cSrcweir
148cdf0e10cSrcweirSub ChangeToNextProgressStep()
149cdf0e10cSrcweir    DialogModel.lblCurProgress.FontWeight = com.sun.star.awt.FontWeight.NORMAL
150cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblCurProgress&quot;).Visible = True
151cdf0e10cSrcweirEnd Sub
152cdf0e10cSrcweir
153cdf0e10cSrcweir
154cdf0e10cSrcweirFunction StoreDocument() as Boolean
155cdf0e10cSrcweirDim sCurFileExists as String
156cdf0e10cSrcweirDim iOverWrite as Integer
157cdf0e10cSrcweir    If (TargetFile &lt;&gt; &quot;&quot;) And (Not bCancelTask) Then
158cdf0e10cSrcweir        On Local Error Goto NOSAVING
159cdf0e10cSrcweir        If oUcb.Exists(TargetFile) Then
160cdf0e10cSrcweir            sCurFileExists = ReplaceString(sMsgFileExists, ConvertFromUrl(TargetFile), &quot;&lt;1&gt;&quot;)
161cdf0e10cSrcweir            sCurFileExists = ReplaceString(sCurFileExists, chr(13), &quot;&lt;CR&gt;&quot;)
162cdf0e10cSrcweir            iOverWrite = Msgbox (sCurFileExists, 32 + 3, sMsgDLGTITLE)
163cdf0e10cSrcweir            Select Case iOverWrite
164cdf0e10cSrcweir                Case 1  &apos; OK
165cdf0e10cSrcweir                Case 2  &apos; Abort
166cdf0e10cSrcweir                    bCancelTask = True
167cdf0e10cSrcweir                    StoreDocument() = False
168cdf0e10cSrcweir                    Exit Function
169cdf0e10cSrcweir                Case 7  &apos; No
170cdf0e10cSrcweir                    StoreDocument() = False
171cdf0e10cSrcweir                    Exit Function
172cdf0e10cSrcweir            End Select
173cdf0e10cSrcweir        End If
174cdf0e10cSrcweir        If TargetFile &lt;&gt; SourceFile Then
175cdf0e10cSrcweir            oDocument.StoreAsUrl(TargetFile,NoArgs)
176cdf0e10cSrcweir        Else
177cdf0e10cSrcweir            oDocument.Store
178cdf0e10cSrcweir        End If
179cdf0e10cSrcweir        StoreDocument() = True
180cdf0e10cSrcweir        NOSAVING:
181cdf0e10cSrcweir        If Err &lt;&gt; 0 Then
182cdf0e10cSrcweir            StoreDocument() = False
183cdf0e10cSrcweir            Resume CLERROR
184cdf0e10cSrcweir        End If
185cdf0e10cSrcweir        CLERROR:
186cdf0e10cSrcweir    End If
187cdf0e10cSrcweirEnd Function
188cdf0e10cSrcweir
189cdf0e10cSrcweir
190cdf0e10cSrcweirSub SwapExtent()
191cdf0e10cSrcweir    DialogModel.chkRecursive.Enabled = DialogModel.optWholeDir.State = 1
192cdf0e10cSrcweir    If DialogModel.optWholeDir.State = 1 Then
193cdf0e10cSrcweir        DialogModel.lblSource.Label = sSOURCEDIR
194cdf0e10cSrcweir        If Not IsNull(SubstFile) Then
195cdf0e10cSrcweir            SubstFile = DialogModel.txtSource.Text
196cdf0e10cSrcweir            DialogModel.txtSource.Text = SubstDir
197cdf0e10cSrcweir        End If
198cdf0e10cSrcweir    Else
199cdf0e10cSrcweir        DialogModel.LblSource.Label = sSOURCEFILE
200cdf0e10cSrcweir        If Not IsNull(SubstDir) Then
201cdf0e10cSrcweir            SubstDir = DialogModel.txtSource.Text
202cdf0e10cSrcweir            DialogModel.txtSource.Text = SubstFile
203cdf0e10cSrcweir        End If
204cdf0e10cSrcweir    End If
205cdf0e10cSrcweir    ToggleGoOnButton()
206cdf0e10cSrcweirEnd Sub
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweirFunction InitializeThirdStep() as Boolean
210cdf0e10cSrcweirDim TextBoxText as String
211cdf0e10cSrcweir    Source = AssignFileName(DialogModel.txtSource.Text, DialogModel.lblSource.Label, True)
212cdf0e10cSrcweir    If CheckTextBoxPath(DialogModel.txtTarget, True, True, sMsgDLGTITLE, True) Then
213cdf0e10cSrcweir        TargetDir = AssignFileName(DialogModel.txtTarget.Text, DialogModel.lblTarget.Label, False)
214cdf0e10cSrcweir    Else
215cdf0e10cSrcweir        TargetDir = &quot;&quot;
216cdf0e10cSrcweir    End If
217cdf0e10cSrcweir    If Source &lt;&gt; &quot;&quot; And TargetDir &lt;&gt; &quot;&quot; Then
218cdf0e10cSrcweir        bRecursive = DialogModel.chkRecursive.State = 1
219cdf0e10cSrcweir        bDoUnprotect = DialogModel.chkProtect.State = 1
220cdf0e10cSrcweir        DialogModel.lblRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
221cdf0e10cSrcweir        DialogModel.lblRetrieval.Label = sPrgsRETRIEVAL
222cdf0e10cSrcweir        DialogModel.lblCurProgress.Label = sPrgsCONVERTING
223cdf0e10cSrcweir        If DialogModel.optWholeDir.State = 1 Then
224cdf0e10cSrcweir            TextBoxText = sSOURCEDIR &amp; &quot; &quot; &amp; ConvertFromUrl(Source) &amp; chr(13)
225cdf0e10cSrcweir            If DialogModel.chkRecursive.State = 1 Then
226cdf0e10cSrcweir                TextBoxText = TextBoxText &amp; DeleteStr(sInclusiveSubDir,&quot;~&quot;) &amp; chr(13)
227cdf0e10cSrcweir            End If
228cdf0e10cSrcweir        Else
229cdf0e10cSrcweir            TextBoxText = sSOURCEFILE &amp; &quot; &quot; &amp; ConvertFromUrl(Source) &amp; chr(13)
230cdf0e10cSrcweir        End If
231cdf0e10cSrcweir        TextBoxText = TextBoxText &amp; sTARGETDIR &amp; &quot; &quot; &amp; ConvertFromUrl(TargetDir) &amp; chr(13)
232cdf0e10cSrcweir        If DialogModel.chkProtect.State = 1 Then
233cdf0e10cSrcweir            TextBoxText = TextboxText &amp; sPrgsUNPROTECT
234cdf0e10cSrcweir        End If
235cdf0e10cSrcweir        DialogModel.txtConfig.Text = TextBoxText
236cdf0e10cSrcweir        ToggleProgressStep()
237cdf0e10cSrcweir        DialogModel.cmdGoOn.Enabled = False
238cdf0e10cSrcweir        InitializeThirdStep() = True
239cdf0e10cSrcweir    Else
240cdf0e10cSrcweir        InitializeThirdStep() = False
241cdf0e10cSrcweir    End If
242cdf0e10cSrcweirEnd Function
243cdf0e10cSrcweir
244cdf0e10cSrcweir
245cdf0e10cSrcweirSub ToggleProgressStep(Optional aEvent as Object)
246cdf0e10cSrcweirDim bMakeVisible as Boolean
247cdf0e10cSrcweirDim LocStep as Integer
248cdf0e10cSrcweir    &apos; If the Sub is call by the &apos;cmdBack&apos; Button then set the &apos;bMakeVisible&apos; variable accordingly
249cdf0e10cSrcweir    bMakeVisible = IsMissing(aEvent)
250cdf0e10cSrcweir    If bMakeVisible Then
251cdf0e10cSrcweir        DialogModel.Step = 3
252cdf0e10cSrcweir    Else
253cdf0e10cSrcweir        DialogModel.Step = 2
254cdf0e10cSrcweir    End If
255cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblCurrencies&quot;).Visible = Not bMakeVisible
256cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lstCurrencies&quot;).Visible = Not bMakeVisible
257cdf0e10cSrcweir    DialogConvert.GetControl(&quot;cmdBack&quot;).Visible = bMakeVisible
258cdf0e10cSrcweir    DialogConvert.GetControl(&quot;cmdGoOn&quot;).Visible = bMakeVisible
259cdf0e10cSrcweir    DialogModel.imgPreview.ImageUrl = BitmapDir &amp; &quot;euro_&quot; &amp; DialogModel.Step &amp; &quot;.bmp&quot;
260cdf0e10cSrcweirEnd Sub
261cdf0e10cSrcweir
262cdf0e10cSrcweir
263cdf0e10cSrcweirSub EnableStep2DialogControls(OnValue as Boolean)
264cdf0e10cSrcweir    With DialogModel
265cdf0e10cSrcweir        .hlnExtent.Enabled = OnValue
266cdf0e10cSrcweir        .optWholeDir.Enabled = OnValue
267cdf0e10cSrcweir        .optSingleFile.Enabled = OnValue
268cdf0e10cSrcweir        .chkProtect.Enabled = OnValue
269cdf0e10cSrcweir        .cmdCallSourceDialog.Enabled = OnValue
270cdf0e10cSrcweir        .cmdCallTargetDialog.Enabled = OnValue
271cdf0e10cSrcweir        .lblSource.Enabled = OnValue
272cdf0e10cSrcweir        .lblTarget.Enabled = OnValue
273cdf0e10cSrcweir        .txtSource.Enabled = OnValue
274cdf0e10cSrcweir        .txtTarget.Enabled = OnValue
275cdf0e10cSrcweir        .imgPreview.Enabled = OnValue
276cdf0e10cSrcweir        .lstCurrencies.Enabled = OnValue
277cdf0e10cSrcweir        .lblCurrencies.Enabled = OnValue
278cdf0e10cSrcweir        If OnValue Then
279cdf0e10cSrcweir            ToggleGoOnButton()
280cdf0e10cSrcweir            .chkRecursive.Enabled = .optWholeDir.State = 1
281cdf0e10cSrcweir        Else
282cdf0e10cSrcweir            .cmdGoOn.Enabled = False
283cdf0e10cSrcweir            .chkRecursive.Enabled = False
284cdf0e10cSrcweir        End If
285cdf0e10cSrcweir    End With
286cdf0e10cSrcweirEnd Sub
287cdf0e10cSrcweir
288cdf0e10cSrcweir
289cdf0e10cSrcweirSub InitializeProgressPage()
290cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblRetrieval&quot;).Visible = False
291cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblCurProgress&quot;).Visible = False
292cdf0e10cSrcweir    DialogModel.lblRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL
293cdf0e10cSrcweir    DialogModel.lblCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD
294cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblRetrieval&quot;).Visible = True
295cdf0e10cSrcweir    DialogConvert.GetControl(&quot;lblCurProgress&quot;).Visible = True
296cdf0e10cSrcweirEnd Sub
297cdf0e10cSrcweir
298cdf0e10cSrcweir
299cdf0e10cSrcweirFunction AssignFileName(sPath as String, ByVal HeaderString, bCheckFileType as Boolean) as String
300cdf0e10cSrcweirDim bIsValid as Boolean
301cdf0e10cSrcweirDim sLocMimeType as String
302cdf0e10cSrcweirDim sNoDirMessage as String
303cdf0e10cSrcweir    HeaderString = DeleteStr(HeaderString, &quot;:&quot;)
304cdf0e10cSrcweir    sPath = ConvertToUrl(Trim(sPath))
305cdf0e10cSrcweir    bIsValid = oUcb.Exists(sPath)
306cdf0e10cSrcweir    If bIsValid Then
307cdf0e10cSrcweir        If DialogModel.optSingleFile.State = 1 Then
308cdf0e10cSrcweir            If bCheckFileType Then
309cdf0e10cSrcweir                sLocMimeType = GetRealFileContent(sPath)
310cdf0e10cSrcweir                If DialogModel.chkTextDocuments.State = 1 Then
311cdf0e10cSrcweir                    If (Instr(1, sLocMimeType, &quot;text&quot;) = 0) And (Instr(1, sLocMimeType, &quot;calc&quot;) = 0) Then
312cdf0e10cSrcweir                        Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE)
313cdf0e10cSrcweir                        bIsValid = False
314cdf0e10cSrcweir                    End If
315cdf0e10cSrcweir                Else
316cdf0e10cSrcweir                    If (Instr(1, sLocMimeType, &quot;spreadsheet&quot;) = 0) And (Instr(1, sLocMimeType, &quot;calc&quot;)) = 0 Then
317cdf0e10cSrcweir                        Msgbox(sMsgFileInvalid, 48, sMsgDLGTITLE)
318cdf0e10cSrcweir                        bIsValid = False
319cdf0e10cSrcweir                    End If
320cdf0e10cSrcweir                End If
321cdf0e10cSrcweir            End If
322cdf0e10cSrcweir        Else
323cdf0e10cSrcweir            If Not oUcb.IsFolder(sPath) Then
324cdf0e10cSrcweir                sNoDirMessage = ReplaceString(sMsgNODIRECTORY,sPath,&quot;&lt;1&gt;&quot;)
325cdf0e10cSrcweir                Msgbox(sNoDirMessage,48, sMsgDLGTITLE)
326cdf0e10cSrcweir                bIsValid = False
327cdf0e10cSrcweir            Else
328cdf0e10cSrcweir                sPath = RTrimStr(sPath,&quot;/&quot;)
329cdf0e10cSrcweir                sPath = sPath &amp; &quot;/&quot;
330cdf0e10cSrcweir            End If
331cdf0e10cSrcweir        End if
332cdf0e10cSrcweir    Else
333cdf0e10cSrcweir        Msgbox(HeaderString &amp; &quot; &apos;&quot; &amp; ConvertFromUrl(sPath) &amp; &quot;&apos; &quot; &amp;  sMsgNOTTHERE,48, sMsgDLGTITLE)
334cdf0e10cSrcweir    End If
335cdf0e10cSrcweir    If bIsValid Then
336cdf0e10cSrcweir        AssignFileName() = sPath
337cdf0e10cSrcweir    Else
338cdf0e10cSrcweir        AssignFilename() = &quot;&quot;
339cdf0e10cSrcweir    End If
340cdf0e10cSrcweirEnd Function
341cdf0e10cSrcweir
342cdf0e10cSrcweir
343cdf0e10cSrcweirSub ToggleGoOnButton()
344cdf0e10cSrcweirDim bDoEnable as Boolean
345cdf0e10cSrcweirDim sLocMimeType as String
346cdf0e10cSrcweirDim sPath as String
347cdf0e10cSrcweir    bDoEnable = Ubound(DialogModel.lstCurrencies.SelectedItems()) &gt; -1
348cdf0e10cSrcweir    If bDoEnable Then
349cdf0e10cSrcweir        &apos; Check if Source is set correctly
350cdf0e10cSrcweir        sPath = ConvertToUrl(Trim(DialogModel.txtSource.Text))
351cdf0e10cSrcweir        bDoEnable = oUcb.Exists(sPath)
352cdf0e10cSrcweir    End If
353cdf0e10cSrcweir    DialogModel.cmdGoOn.Enabled = bDoEnable
354cdf0e10cSrcweirEnd Sub
355cdf0e10cSrcweir
356cdf0e10cSrcweir
357cdf0e10cSrcweirSub CallFolderPicker()
358cdf0e10cSrcweir    GetFolderName(DialogModel.txtTarget)
359cdf0e10cSrcweir    ToggleGoOnButton()
360cdf0e10cSrcweirEnd Sub
361cdf0e10cSrcweir
362cdf0e10cSrcweir
363cdf0e10cSrcweirSub CallFilePicker()
364cdf0e10cSrcweir    If DialogModel.optSingleFile.State = 1 Then
365cdf0e10cSrcweir        Dim oMasterKey as Object
366cdf0e10cSrcweir        Dim oTypes() as Object
367cdf0e10cSrcweir        Dim oUIKey() as Object
368cdf0e10cSrcweir
369cdf0e10cSrcweir        oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types&quot;)
370cdf0e10cSrcweir        oTypes() = oMasterKey.Types
371cdf0e10cSrcweir        oUIKey = GetRegistryKeyContent(&quot;org.openoffice.Office.UI/FilterClassification/LocalFilters&quot;)
372cdf0e10cSrcweir        If DialogModel.chkTextDocuments.State = 1 Then
373cdf0e10cSrcweir            Dim FilterNames(11,1) as String
374cdf0e10cSrcweir            FilterNames(6,0) = oTypes.GetByName(&quot;writer_StarOffice_XML_Writer&quot;).UIName
375cdf0e10cSrcweir            FilterNames(6,1) = &quot;*.sxw&quot;
376cdf0e10cSrcweir            FilterNames(7,0) = oTypes.GetByName(&quot;writer_StarOffice_XML_Writer_Template&quot;).UIName
377cdf0e10cSrcweir            FilterNames(7,1) = &quot;*.stw&quot;
378cdf0e10cSrcweir            FilterNames(8,0) = oUIKey.Classes.GetByName(&quot;sw3to5&quot;).DisplayName
379cdf0e10cSrcweir            FilterNames(8,1) = &quot;*.sdw&quot;
380cdf0e10cSrcweir            FilterNames(9,0) = oUIKey.Classes.GetByName(&quot;sw3to5templ&quot;).DisplayName
381cdf0e10cSrcweir            Filternames(9,1) = &quot;*.vor&quot;
382cdf0e10cSrcweir            FilterNames(10,0) = oTypes.GetByName(&quot;writer8&quot;).UIName
383cdf0e10cSrcweir            FilterNames(10,1) = &quot;*.odt&quot;
384cdf0e10cSrcweir            FilterNames(11,0) = oTypes.GetByName(&quot;writer8_template&quot;).UIName
385cdf0e10cSrcweir            FilterNames(11,1) = &quot;*.ott&quot;
386cdf0e10cSrcweir        Else
387cdf0e10cSrcweir            ReDim FilterNames(5,1) as String
388cdf0e10cSrcweir        End If
389cdf0e10cSrcweir        FilterNames(0,0) = oTypes.GetByName(&quot;calc_StarOffice_XML_Calc&quot;).UIName
390cdf0e10cSrcweir        Filternames(0,1) = &quot;*.sxc&quot;
391cdf0e10cSrcweir        FilterNames(1,0) = oTypes.GetByName(&quot;calc_StarOffice_XML_Calc_Template&quot;).UIName
392cdf0e10cSrcweir        Filternames(1,1) = &quot;*.stc&quot;
393cdf0e10cSrcweir        FilterNames(2,0) = oUIKey.Classes.GetByName(&quot;sc345&quot;).DisplayName
394cdf0e10cSrcweir        FilterNames(2,1) = &quot;*.sdc&quot;
395cdf0e10cSrcweir        FilterNames(3,0) = oUIKey.Classes.GetByName(&quot;sc345templ&quot;).DisplayName
396cdf0e10cSrcweir        Filternames(3,1) = &quot;*.vor&quot;
397cdf0e10cSrcweir        FilterNames(4,0) = oTypes.GetByName(&quot;calc8&quot;).UIName
398cdf0e10cSrcweir        Filternames(4,1) = &quot;*.ods&quot;
399cdf0e10cSrcweir        FilterNames(5,0) = oTypes.GetByName(&quot;calc8_template&quot;).UIName
400cdf0e10cSrcweir        Filternames(5,1) = &quot;*.ots&quot;
401cdf0e10cSrcweir        GetFileName(DialogModel.txtSource, Filternames())
402cdf0e10cSrcweir    Else
403cdf0e10cSrcweir        GetFolderName(DialogModel.txtSource)
404cdf0e10cSrcweir    End If
405cdf0e10cSrcweir    ToggleGoOnButton()
406cdf0e10cSrcweirEnd Sub
407cdf0e10cSrcweir
408cdf0e10cSrcweir
409cdf0e10cSrcweirSub PreviousStep()
410cdf0e10cSrcweir    DialogModel.Step = 2
411cdf0e10cSrcweir    DialogModel.cmdGoOn.Label =  sGOON
412cdf0e10cSrcweir    DialogModel.cmdCancel.Label = sCANCEL
413cdf0e10cSrcweirEnd Sub
414cdf0e10cSrcweir</script:module>
415