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