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