1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="DialogModul" script:language="StarBasic">Option Explicit
24
25Public Const bDebugWizard = True
26
27Public Const SBFIRSTAPPLCHECKED = 0
28Public Const SBSECONDAPPLCHECKED = 1
29Public Const SBTHIRDAPPLCHECKED = 2
30Public Const SBFOURTHAPPLCHECKED = 3
31Public bFilterTracingAvailable as Boolean
32Public WizardMode as String
33Public Const SBMICROSOFTMODE = &quot;MS&quot;
34Public Const SBXMLMODE = &quot;SO&quot;
35&apos; The absolute maximal Number of possible Applications
36Public Const Twip = 425
37Public Const SBMAXAPPLCOUNT = 4
38Public MaxApplCount as Integer
39Public CurOffice As Integer
40Public SOBitmapPath As String
41Public SOWorkPath As String
42Public SOTemplatePath as String
43Public bCancelTask As Boolean
44Public bDoKeepApplValues as Boolean
45Public iApplSection as Integer
46Public oUcb as Object
47Public PathSeparator as String
48
49Public ApplCount as Integer
50Public sKeyName(SBMAXAPPLCOUNT-1) as String
51Public sValueName(SBMAXAPPLCOUNT-1) as String
52Public sCRLF as String
53Public MSFilterName(5,4) as String
54Public XMLFilterName(7,3) as String &apos;Number of different formats
55Public FilterTracingLogPath(2) as String
56Public bMSApplFilterTracingAvailable(2) as String
57Public bTakeOverTargetName(2) as Boolean
58Public bTakeOverPathName(2) as Boolean
59
60&apos; e.g.:
61&apos; XMLFilterName(x,0) = &quot;sdw&quot; 						&apos; in documents we take the extensions; in SO-templates the appropriate Filtername
62&apos; XMLFilterName(x,1) = &quot;swriter: StarWriter 5.0&quot; 	&apos; the filtername of the target-format
63&apos; XMLFilterName(x,2) = &quot;sxw&quot; 						&apos; the target extension
64
65Public Applications(SBMAXAPPLCOUNT-1,9)
66
67Public Const SBAPPLCONVERT = 0
68Public Const SBDOCCONVERT = 1
69Public Const SBDOCRECURSIVE = 2
70Public Const SBDOCSOURCE = 3
71Public Const SBDOCTARGET = 4
72Public Const SBTEMPLCONVERT = 5
73Public Const SBTEMPLRECURSIVE = 6
74Public Const SBTEMPLSOURCE = 7
75Public Const SBTEMPLTARGET = 8
76Public Const SBAPPLKEY = 9
77Public XMLTemplateList()
78
79&apos; Application-relating Data are stored in this Array
80&apos; according to the following structure:
81&apos; Applications(X,0) = True/False 		(Application is to be converted)
82&apos; Applications(X,1) = True/False 		(Documents are to be converted)
83&apos; Applications(X,2) = True/False		(Including Subdirectories)
84&apos; Applications(X,3) = &quot;File:///...&quot;		(SourceUrl of the documents)
85&apos; Applications(X,4) = &quot;File///:...&quot;		(TargetUrl of the documents)
86&apos; Applications(X,5) = True/False		(Templates are to be converted)
87&apos; Applications(X,6) = True/False 		(Including Subdirectories)
88&apos; Applications(X,7) = &quot;File:///...&quot;		(SourceUrl of the templates)
89&apos; Applications(X,8) = &quot;File:///...&quot; 	(TargetUrl of the templates)
90&apos; Applications(X,9) = 0				    (Key to the original Index of the Applications)
91
92Public Const SBMAXEXTENSIONLENGTH = 17
93
94
95Sub FillStep_Welcome()
96Dim i as Integer
97&apos;	bDoKeepApplValues = False
98	ImportDialogArea.Title = sTitle
99	With ImportDialog
100		.cmdHelp.Label = sHelpButton
101		.cmdCancel.Label = sCancelButton
102		.cmdBack.Label = sBackButton
103		.cmdGoOn.Label = sNextButton
104		.WelcomeTextLabel.Label = sWelcomeTextLabel1
105		.WelcomeTextLabel2.Label = sWelcomeTextLabel2
106		.WelcomeTextLabel3.Label = sWelcomeTextLabel3
107
108		.optMSDocuments.Label = sContainerName(0)
109		.chkMSApplication1.Label = sMsDocumentCheckbox(0)
110		.chkMSApplication2.Label = sMsDocumentCheckbox(1)
111		.chkMSApplication3.Label = sMsDocumentCheckbox(2)
112
113		.optSODocuments.Label = sContainerName(1)
114		.chkSOApplication1.Label = sSODocumentCheckbox(0)
115		.chkSOApplication2.Label = sSODocumentCheckbox(1)
116		.chkSOApplication3.Label = sSODocumentCheckbox(2)
117		.chkSOApplication4.Label = sSODocumentCheckbox(3)
118		.cmdBack.Enabled = False
119		.Step = 1
120
121		If Not oFactoryKey.hasbyName(&quot;com.sun.star.text.TextDocument&quot;) Then
122			.chkLogfile.State = 0
123			.chkLogfile.Enabled = False
124		End If
125	End With
126	CheckModuleInstallation()
127	ToggleNextButton()
128End Sub
129
130
131Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean)
132Dim Index as Integer
133Dim oNullObject as Object
134	If bStartup And Not bDoKeepApplValues Then
135	    If ImportDialog.optMSDocuments.State = 1 Then
136			SetupMSConfiguration()
137		Else
138			SetupXMLConfiguration()
139		End If
140		FillUpApplicationList()
141	End If
142	CurOffice = OfficeIndex
143	Index = Applications(CurOffice,SBAPPLKEY)
144	InitializePathsforCurrentApplication(Index)
145	With ImportDialog
146		.chkTemplatePath.Label = sTemplateCheckbox(Index)
147    	.chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT))
148 	  	.chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE))
149		.txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE))
150		.txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET))
151		.hlnDocuments.Label = sProgressMoreDocs
152		If WizardMode = SBXMLMODE Then
153			ImportDialogArea.Title = sTitle &amp; &quot; - &quot; &amp; sSODocumentCheckBox(Index)
154		Else
155			ImportDialogArea.Title = sTitle &amp; &quot; - &quot; &amp; sMSDocumentCheckBox(Index)
156		End If
157		If WizardMode = SBXMLMODE AND Index = 3 Then
158			&apos; Note: SO-Helper Applications are partly treated like templates although they only have documents
159			.hlnTemplates.Label = sProgressMoreDocs
160			.chkTemplatePath.Label = sSOHelperDocuments(0,0)
161			.chkTemplatePath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(0,1))
162			.chkDocumentPath.Label = sSOHelperDocuments(1,0)
163			.chkDocumentPath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(1,1))
164		Else
165			.chkTemplatePath.Enabled = True
166			.chkDocumentPath.Enabled = True
167			.chkTemplatePath.Label = sTemplateCheckbox(Index)
168			.chkDocumentPath.Label = sDocumentCheckbox(Index)
169			.hlnTemplates.Label = sProgressMoreTemplates
170		End If
171		.chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT))
172		ToggleInputPaths(oNullObject,&quot;Template&quot;)
173		ToggleInputPaths(oNullObject,&quot;Document&quot;)
174		.chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE))
175		.txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE))
176		.txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET))
177		.cmdGoOn.Label = sNextButton
178		.cmdBack.Enabled = True
179		ImportDialog.Step = 2
180	End With
181	ImportDialogArea.GetControl(&quot;chkTemplatePath&quot;).SetFocus()
182	ToggleNextButton()
183End Sub
184
185
186Sub FillUpApplicationList()
187Dim i as Integer
188Dim a as Integer
189Dim BoolValue as Boolean
190	If Not bDoKeepApplValues Then
191		a = 0
192		For i = 1 To ApplCount
193		    If ImportDialog.optMSDocuments.State = 1 Then
194				BoolValue = ImportDialogArea.GetControl(&quot;chkMSApplication&quot; &amp; i).Model.State = 1
195			Else
196				BoolValue = ImportDialogArea.GetControl(&quot;chkSOApplication&quot; &amp; i).Model.State = 1
197			End If
198			Applications(a,SBAPPLCONVERT) = BoolValue
199			Applications(a,SBDOCCONVERT) = BoolValue
200			Applications(a,SBDOCRECURSIVE) = BoolValue
201			Applications(a,SBDOCSOURCE) = &quot;&quot;			&apos; GetDefaultPath(i)
202			Applications(a,SBDOCTARGET) = &quot;&quot;			&apos; SOWorkPath
203			Applications(a,SBTEMPLCONVERT) = BoolValue
204			Applications(a,SBTEMPLRECURSIVE) = BoolValue
205			Applications(a,SBTEMPLSOURCE) = &quot;&quot; 			&apos; GetTemplateDefaultPath(i)
206			Applications(a,SBTEMPLTARGET) = &quot;&quot; 			&apos; GetTargetTemplatePath(i)
207			Applications(a,SBAPPLKEY) = i-1
208			If BoolValue Then
209				a = a + 1
210			End If
211		Next i
212		ApplCount = a
213	End If
214End Sub
215
216
217Sub InitializePathsforCurrentApplication(i as Integer)
218	AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i))
219	AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath)
220	AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i))
221	AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i))
222End Sub
223
224
225Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String)
226	If Applications(CurOffice,Index) = &quot;&quot; Then
227		If CurOffice &gt; 0 Then
228			Applications(CurOffice,Index) = Applications(CurOffice-1,Index)
229		Else
230			Applications(CurOffice,Index) = NewPath
231		End If
232	End If
233End Sub
234
235
236Sub SaveStep_InputPath()
237	Applications(CurOffice,SBDOCCONVERT)  = ImportDialog.chkDocumentPath.State = 1
238	Applications(CurOffice,SBDOCRECURSIVE)  = ImportDialog.chkDocumentSearchSubDir.State = 1
239	Applications(CurOffice,SBDOCSOURCE)  = ConvertToURL(ImportDialog.txtDocumentImportPath.Text)
240	Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text)
241    Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State = 1
242    Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State = 1
243	Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text)
244	Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text)
245End Sub
246
247
248Sub ToggleInputPaths(aEvent as Object, Optional sDocType)
249Dim bDoEnable as Boolean
250Dim sLocDocType as String
251Dim oCheckBox as Object
252	If Not IsNull(aEvent) Then
253		sLocDocType = aEvent.Source.Model.Tag
254	Else
255		sLocDocType = sDocType
256	End If
257	With ImportDialogArea
258		oCheckBox = .GetControl(&quot;chk&quot; &amp; sLocDocType &amp; &quot;Path&quot;).Model
259    	bDoEnable = oCheckBox.State = 1 And oCheckBox.Enabled
260		.GetControl(&quot;lbl&quot; &amp; sLocDocType &amp; &quot;Import&quot;).Model.Enabled = bDoEnable
261		.GetControl(&quot;lbl&quot; &amp; sLocDocType &amp; &quot;Export&quot;).Model.Enabled = bDoEnable
262		.GetControl(&quot;txt&quot; &amp; sLocDocType &amp; &quot;ImportPath&quot;).Model.Enabled = bDoEnable
263		.GetControl(&quot;txt&quot; &amp; sLocDocType &amp; &quot;ExportPath&quot;).Model.Enabled = bDoEnable
264		.GetControl(&quot;chk&quot; &amp; sLocDocType &amp; &quot;SearchSubDir&quot;).Model.Enabled = bDoEnable
265		.GetControl(&quot;cmd&quot; &amp; sLocDocType &amp; &quot;Import&quot;).Model.Enabled = bDoEnable
266		.GetControl(&quot;cmd&quot; &amp; sLocDocType &amp; &quot;Export&quot;).Model.Enabled = bDoEnable
267	End With
268	ToggleNextButton()
269End Sub
270
271
272Function MakeSummaryString()
273Dim sTmpText As String
274Dim i as Integer
275Dim Index as Integer
276Dim sAddText as String
277	For i = 0 To ApplCount -1
278		Index = Applications(i,SBAPPLKEY)
279		GetFilterTracingLogPath(i, Index)
280		If 	Applications(i,SBTEMPLCONVERT) Then
281			&apos; Templates are to be converted
282			sAddText = &quot;&quot;
283			If WizardMode = SBMICROSOFTMODE Then
284				sAddText = sSumMSTemplates(Index) &amp; sCRLF
285			Else
286				sAddText = sSumSOTemplates(Index) &amp; sCRLF
287			End If
288			sTmpText = sTmpText &amp; sAddText &amp;  ConvertFromUrl(Applications(i,SBTEMPLSOURCE)) &amp; sCRLF
289			If Applications(i,SBTEMPLRECURSIVE) Then
290				&apos; Including Subdirectories
291				sTmpText = sTmpText &amp; sSumInclusiveSubDir &amp; sCRLF
292			End If
293			sTmpText = sTmpText &amp; sSumSaveDocuments &amp; sCRLF
294			sTmpText = sTmpText &amp; ConvertFromUrl(Applications(i,SBTEMPLTARGET)) &amp; sCRLF
295			sTmpText = sTmpText &amp; sCRLF
296		End If
297
298		If Applications(i,SBDOCCONVERT) Then
299			&apos; Documents are to be converted
300			If WizardMode = SBMICROSOFTMODE Then
301				sAddText = sSumMSDocuments(Index) &amp; sCRLF
302			Else
303				sAddText = sSumSODocuments(Index) &amp; sCRLF
304			End If
305			sTmpText = sTmpText &amp; sAddText &amp; ConvertFromUrl(Applications(i,SBDOCSOURCE)) &amp; sCRLF
306
307			If Applications(i,SBDOCRECURSIVE) Then
308				&apos; Including Subdirectories
309				sTmpText = sTmpText &amp; sSumInclusiveSubDir &amp; sCRLF
310			End If
311
312			sTmpText = sTmpText &amp; sSumSaveDocuments &amp; sCRLF
313			sTmpText = sTmpText &amp; ConvertFromUrl(Applications(i,SBDOCTARGET)) &amp; sCRLF
314			sTmpText = sTmpText &amp; sCRLF
315		End If
316	Next i
317	MakeSummaryString = sTmpText
318End Function
319
320
321Sub FillStep_Summary()
322	ImportDialogArea.Title = sTitle
323	With ImportDialog
324		.SummaryTextbox.Text = MakeSummaryString()
325		.cmdGoOn.Enabled = .SummaryTextbox.Text &lt;&gt; &quot;&quot;
326		.cmdGoOn.Label = sBeginButton
327		.SummaryHeaderLabel.Label = sSummaryHeader
328		.Step = 3
329	End With
330	ImportDialogArea.GetControl(&quot;SummaryHeaderLabel&quot;).SetFocus()
331End Sub
332
333
334Sub FillStep_Progress()
335	With ImportDialog
336		.cmdBack.Enabled = False
337		.cmdGoOn.Enabled = False
338	    .hlnProgress.Label = sProgressPage_1
339	    .LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
340   	 	.LabelRetrieval.Label = sProgressPage_2
341   	 	.LabelCurProgress.Label = sProgressPage_3
342   	 	.LabelCurDocumentRetrieval.Label = &quot;&quot;
343   	 	.LabelCurTemplateRetrieval.Label = &quot;&quot;
344   		.LabelCurDocument.Label = &quot;&quot;
345		.Step = 4
346	End With
347	ImportDialogArea.GetControl(&quot;LabelRetrieval&quot;).SetFocus()
348	If ImportDialog.chkLogfile.State = 1 Then
349		ImportDialog.cmdShowLogFile.DefaultButton = True
350	End If
351End Sub
352
353
354Sub GetFilterTracingLogPath(i as Integer, Index as Integer)
355Dim aNodePath(0) as new com.sun.star.beans.PropertyValue
356Dim oMasterKey
357Dim oImportKey
358Dim oWordKey
359Dim oExcelkey
360Dim oPowerpointKey
361Dim oFilterService
362	aNodePath(0).Name = &quot;nodepath&quot;
363	aNodePath(0).Value = &quot;org.openoffice.Office.Tracing&quot;
364	oFilterService = createUnoService(&quot;com.sun.star.util.FilterTracer&quot;)
365	bFilterTracingAvailable = Not IsNull(oFilterService)
366	If bFilterTracingAvailable Then
367		oMasterkey = GetRegistryKeyContent(&quot;org.openoffice.Office.Tracing/&quot;)
368		If oMasterKey.hasbyName(&quot;Import&quot;) Then
369			oImportKey = GetRegistryKeyContent(&quot;org.openoffice.Office.Tracing/Import&quot;)
370			bMSApplFilterTracingAvailable(i) = CheckMSImportAvailability(oImportkey, MSFiltername(Index, 4), FilterTracingLogPath(i), bTakeOverTargetName(i), bTakeOverPathName(i))
371		End If
372	End If
373End Sub
374
375
376Function CheckMSImportAvailability(oImportkey, MSApplName as String, MSLogPath as String, bTakeOverTargetname as String, bTakeOverpathName as String) as Boolean
377Dim bApplIsAvailable as Boolean
378Dim oApplKey
379Dim LocApplName as String
380Dim LocApplPath as String
381	bApplIsAvailable = oImportKey.hasbyName(MSApplName)
382	If bApplIsAvailable Then
383		oApplKey = oImportKey.getByName(MSApplName)
384		bApplIsAvailable = oApplKey.On
385		LocApplName = oApplKey.Name
386		LocApplPath = oApplKey.Path
387		bTakeOverTargetName = (LocApplName = &quot;&quot;)
388		bTakeOverPathName = (LocApplPath = &quot;&quot;)
389		MSLogPath = LocApplPath &amp; &quot;/&quot; &amp; LocApplName &amp; &quot;.log&quot;
390	End If
391	CheckMSImportAvailability() = bApplIsAvailable
392End Function
393
394
395
396Sub	SetupMSConfiguration()
397	iApplSection = 0
398	Wizardmode = SBMICROSOFTMODE
399	MaxApplCount = 3
400	ApplCount = 3
401	&apos; chkTemplatePath-Captions
402	GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
403	&apos; DocumentCheckbox- Captions
404	GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
405
406	sKeyName(0) = &quot;Software\Microsoft\Office\8.0\Word\Options&quot;
407	sKeyName(1) = &quot;Software\Microsoft\Office\8.0\Excel\Microsoft Excel&quot;
408	sKeyName(2) = &quot;Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default&quot;
409
410	sValueName(0) = &quot;DOC-PATH&quot;
411	sValueName(1) = &quot;DefaultPath&quot;
412	sValueName(2) = &quot;&quot;
413
414&apos; See definition of Filtername-Array about meaning of fields
415	MSFilterName(0,0) = &quot;doc|docx|docm&quot;
416	MSFilterName(0,1) = &quot;writer8|writer8|writer8&quot;
417	MSFilterName(0,2) = &quot;odt|odt|odt&quot;
418	MSFilterName(0,3) = sMSDocumentCheckBox(0)
419	MSFilterName(0,4) = &quot;Word&quot;
420
421
422	MSFilterName(1,0) = &quot;xls|xlsx|xlsm&quot;
423	MSFilterName(1,1) = &quot;calc8|calc8|calc8&quot;
424	MSFilterName(1,2) = &quot;ods|ods|ods&quot;
425	MSFilterName(1,3) = sMSDocumentCheckBox(1)
426	MSFilterName(1,4) = &quot;Excel&quot;
427
428	MSFilterName(2,0) = &quot;ppt|pps|pptx|pptm&quot;
429	MSFilterName(2,1) = &quot;impress8|impress8|impress8|impress8&quot;
430	MSFilterName(2,2) = &quot;odp|odp|odp|odp&quot;
431	MSFilterName(2,3) = sMSDocumentCheckBox(2)
432	MSFilterName(2,4) = &quot;PowerPoint&quot;
433
434	MSFilterName(3,0) = &quot;dot|dotx|dotm&quot;
435	MSFilterName(3,1) = &quot;writer8_template|writer8_template|writer8_template&quot;
436	MSFilterName(3,2) = &quot;ott|ott|ott&quot;
437	MSFilterName(3,3) = sMSTemplateCheckBox(0)
438	MSFilterName(3,4) = &quot;Word&quot;
439
440	MSFilterName(4,0) = &quot;xlt|xltx|xltm&quot;
441	MSFilterName(4,1) = &quot;calc8_template|calc8_template|calc8_template&quot;
442	MSFilterName(4,2) = &quot;ots|ots|ots&quot;
443	MSFilterName(4,3) = sMSTemplateCheckBox(1)
444	MSFilterName(4,4) = &quot;Excel&quot;
445
446	MSFilterName(5,0) = &quot;pot|potx|potm&quot;
447	MSFilterName(5,1) = &quot;impress8_template|impress8_template|impress8_template&quot;
448	MSFilterName(5,2) = &quot;otp|otp|otp&quot;
449	MSFilterName(5,3) = sMSTemplateCheckBox(2)
450	MSFilterName(5,4) = &quot;PowerPoint&quot;
451End Sub
452
453
454
455&apos; This is an extract from &quot;http://util.openoffice.org/source/browse/util/sot/source/base/exchange.cxx?rev=1.25&amp;content-type=text/x-cvsweb-markup&quot;
456&apos; about the listed defined mimetypes that are required to define binary StarOffice templates that have for all applications the same extension &quot;.vor&quot;
457
458&apos; 26 SOT_FORMATSTR_ID_STARWRITER_30*/			{ &quot;application/x-openoffice-starwriter-30;windows_formatname=\&quot;StarWriter 3.0\&quot;&quot;, &quot;StarWriter 3.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
459&apos; 27 SOT_FORMATSTR_ID_STARWRITER_40*/			{ &quot;application/x-openoffice-starwriter-40;windows_formatname=\&quot;StarWriter 4.0\&quot;&quot;, &quot;StarWriter 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
460&apos; 28 SOT_FORMATSTR_ID_STARWRITER_50*/			{ &quot;application/x-openoffice-starwriter-50;windows_formatname=\&quot;StarWriter 5.0\&quot;&quot;, &quot;StarWriter 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
461
462&apos; 29 SOT_FORMATSTR_ID_STARWRITERWEB_40*/		{ &quot;application/x-openoffice-starwriterweb-40;windows_formatname=\&quot;StarWriter/Web 4.0\&quot;&quot;, &quot;StarWriter/Web 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
463&apos; 30 SOT_FORMATSTR_ID_STARWRITERWEB_50*/		{ &quot;application/x-openoffice-starwriterweb-50;windows_formatname=\&quot;StarWriter/Web 5.0\&quot;&quot;, &quot;StarWriter/Web 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
464
465&apos; 31 SOT_FORMATSTR_ID_STARWRITERGLOB_40*/		{ &quot;application/x-openoffice-starwriterglob-40;windows_formatname=\&quot;StarWriter/Global 4.0\&quot;&quot;, &quot;StarWriter/Global 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
466&apos; 32 SOT_FORMATSTR_ID_STARWRITERGLOB_50*/		{ &quot;application/x-openoffice-starwriterglob-50;windows_formatname=\&quot;StarWriter/Global 5.0\&quot;&quot;, &quot;StarWriter/Global 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
467
468&apos; 33 SOT_FORMATSTR_ID_STARDRAW*/				{ &quot;application/x-openoffice-stardraw;windows_formatname=\&quot;StarDrawDocument\&quot;&quot;, &quot;StarDrawDocument&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
469&apos; 34 SOT_FORMATSTR_ID_STARDRAW_40*/				{ &quot;application/x-openoffice-stardraw-40;windows_formatname=\&quot;StarDrawDocument 4.0\&quot;&quot;, &quot;StarDrawDocument 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
470&apos; 36 SOT_FORMATSTR_ID_STARDRAW_50*/				{ &quot;application/x-openoffice-stardraw-50;windows_formatname=\&quot;StarDraw 5.0\&quot;&quot;, &quot;StarDraw 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
471
472&apos; 35 SOT_FORMATSTR_ID_STARIMPRESS_50*/			{ &quot;application/x-openoffice-starimpress-50;windows_formatname=\&quot;StarImpress 5.0\&quot;&quot;, &quot;StarImpress 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
473
474&apos; 37 SOT_FORMATSTR_ID_STARCALC*/				{ &quot;application/x-openoffice-starcalc;windows_formatname=\&quot;StarCalcDocument\&quot;&quot;, &quot;StarCalcDocument&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
475&apos; 38 SOT_FORMATSTR_ID_STARCALC_40*/				{ &quot;application/x-openoffice-starcalc-40;windows_formatname=\&quot;StarCalc 4.0\&quot;&quot;, &quot;StarCalc 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
476&apos; 39 SOT_FORMATSTR_ID_STARCALC_50*/				{ &quot;application/x-openoffice-starcalc-50;windows_formatname=\&quot;StarCalc 5.0\&quot;&quot;, &quot;StarCalc 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
477
478&apos; 40 SOT_FORMATSTR_ID_STARCHART*/				{ &quot;application/x-openoffice-starchart;windows_formatname=\&quot;StarChartDocument\&quot;&quot;, &quot;StarChartDocument&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
479&apos; 41 SOT_FORMATSTR_ID_STARCHART_40*/			{ &quot;application/x-openoffice-starchart-40;windows_formatname=\&quot;StarChartDocument 4.0\&quot;&quot;, &quot;StarChartDocument 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
480&apos; 42 SOT_FORMATSTR_ID_STARCHART_50*/			{ &quot;application/x-openoffice-starchart-50;windows_formatname=\&quot;StarChart 5.0\&quot;&quot;, &quot;StarChart 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
481
482&apos; 46 SOT_FORMATSTR_ID_STARMATH*/				{ &quot;application/x-openoffice-starmath;windows_formatname=\&quot;StarMath\&quot;&quot;, &quot;StarMath&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
483&apos; 47 SOT_FORMATSTR_ID_STARMATH_40*/				{ &quot;application/x-openoffice-starmath-40;windows_formatname=\&quot;StarMathDocument 4.0\&quot;&quot;, &quot;StarMathDocument 4.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
484&apos; 48 SOT_FORMATSTR_ID_STARMATH_50*/				{ &quot;application/x-openoffice-starmath-50;windows_formatname=\&quot;StarMath 5.0\&quot;&quot;, &quot;StarMath 5.0&quot;, &amp;::getCppuType( (const Sequence&lt; sal_Int8 &gt;*) 0 ) },
485
486
487Sub SetupXMLConfiguration()
488	iApplSection = 1000
489	Wizardmode = SBXMLMODE
490	ApplCount = 4
491	MaxApplCount = 4
492	XMLTemplateList = Array(&quot;vor&quot;, &quot;sti&quot;, &quot;stw&quot; , &quot;stc&quot; , &quot;std&quot;)
493	&apos; chkTemplatePath-Captions
494	GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
495	&apos; DocumentCheckbox- Captions
496	GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
497
498	XMLFilterName(0,0) = &quot;sdw|sxw&quot;
499	XMLFilterName(0,1) = &quot;writer8|writer8&quot;
500	XMLFilterName(0,2) = &quot;odt|odt&quot;
501	XMLFilterName(0,3) = sDocumentCheckBox(0)
502
503	XMLFilterName(1,0) = &quot;sdc|sxc&quot;
504	XMLFilterName(1,1) = &quot;calc8|calc8&quot;
505	XMLFilterName(1,2) = &quot;ods|ods&quot;
506	XMLFilterName(1,3) = sDocumentCheckBox(1)
507
508	If oFactoryKey.HasByName(&quot;com.sun.star.drawing.DrawingDocument&quot;) and oFactoryKey.HasByName(&quot;com.sun.star.presentation.PresentationDocument&quot;) Then
509		XMLFilterName(2,0) = &quot;sdd|sda|sxi|sxd&quot;
510		XMLFilterName(2,1) = &quot;impress8|draw8|impress8|draw8&quot;
511		XMLFilterName(2,2) = &quot;odp|odg|odp|odg&quot;
512	Elseif oFactoryKey.HasByName(&quot;com.sun.star.drawing.DrawingDocument&quot;) Then
513		XMLFilterName(2,0) = &quot;sda|sxd&quot;
514		XMLFilterName(2,1) = &quot;draw8|draw8&quot;
515		XMLFilterName(2,2) = &quot;odg|odg&quot;
516	Elseif oFactoryKey.HasByName(&quot;com.sun.star.presentation.PresentationDocument&quot;) Then
517		XMLFilterName(2,0) = &quot;sdd|sxi&quot;
518		XMLFilterName(2,1) = &quot;impress8|impress8&quot;
519		XMLFilterName(2,2) = &quot;odp|odp&quot;
520	End If
521	XMLFilterName(2,3) = sDocumentCheckBox(2)
522
523
524	XMLFilterName(3,0) = &quot;smf|sxm&quot;
525	XMLFilterName(3,1) = &quot;math8|math8&quot;
526	XMLFilterName(3,2) = &quot;odf|odf&quot;
527	XMLFilterName(3,3) = sDocumentCheckBox(3)
528
529	XMLFilterName(4,0) = &quot;application/x-openoffice-starwriter|application/vnd.stardivision.writer/web|application/vnd.sun.xml.writer|application/vnd.sun.xml.writerweb&quot;
530	XMLFilterName(4,1) = &quot;writer8_template|writerweb8_writer_template|writer8_template|writerweb8_writer_template&quot;
531	XMLFilterName(4,2) = &quot;ott|oth|ott|oth&quot;
532	XMLFilterName(4,3) = sTemplateCheckBox(0)
533
534
535	XMLFilterName(5,0) = &quot;application/x-openoffice-starcalc|application/vnd.sun.xml.calc&quot;
536	XMLFilterName(5,1) = &quot;calc8_template|calc8_template&quot;
537	XMLFilterName(5,2) = &quot;ots|ots&quot;
538	XMLFilterName(5,3) = sTemplateCheckBox(1)
539
540	&apos; due to bug #108942# impress templates of the version 4.0 have to be handled in a special way because their mimetype
541	&apos; falsely points to the draw application.
542	If oFactoryKey.HasByName(&quot;com.sun.star.drawing.DrawingDocument&quot;) and  oFactoryKey.HasByName(&quot;com.sun.star.presentation.PresentationDocument&quot;) Then
543		XMLFilterName(6,0) = &quot;application/x-openoffice-starimpress|application/x-openoffice-stardraw-40|application/x-openoffice-stardraw|application/vnd.sun.xml.impress|application/vnd.sun.xml.draw&quot;
544		XMLFilterName(6,1) = &quot;impress8_template|impress8_template|draw8_template|impress8_template|draw8_template&quot;
545		XMLFilterName(6,2) = &quot;otp|otp|otg|otp|otg&quot;
546	Elseif oFactoryKey.HasByName(&quot;com.sun.star.drawing.DrawingDocument&quot;) Then
547		XMLFilterName(6,0) = &quot;application/x-openoffice-stardraw|application/vnd.sun.xml.draw&quot;
548		XMLFilterName(6,1) = &quot;draw8_template|draw8_template&quot;
549		XMLFilterName(6,2) = &quot;otg|otg&quot;
550	Elseif oFactoryKey.HasByName(&quot;com.sun.star.presentation.PresentationDocument&quot;) Then
551		XMLFilterName(6,0) = &quot;application/x-openoffice-starimpress|application/x-openoffice-stardraw-40|application/vnd.sun.xml.impress&quot;
552		XMLFilterName(6,1) = &quot;impress8_template|impress8_template|impress8_template&quot;
553		XMLFilterName(6,2) = &quot;otp|otp|otp&quot;
554	End If
555	XMLFilterName(6,3) = sTemplateCheckBox(2)
556
557	If oFactoryKey.HasByName(&quot;com.sun.star.text.GlobalDocument&quot;) Then
558		XMLFilterName(7,0) = &quot;sgl|sxg&quot;
559		XMLFilterName(7,1) = &quot;writerglobal8|writerglobal8&quot;
560		XMLFilterName(7,2) = &quot;odm|odm&quot;
561		XMLFilterName(7,3) = sTemplateCheckBox(3)
562	End If
563End Sub
564
565
566Function CheckControlPath(oCheckbox as Object, oTextBox as Object, ByVal bDoEnable as Boolean)
567Dim sPath as String
568	If Not bDoEnable Then
569		CheckControlPath = False
570	ElseIf oCheckbox.State = 0 Then
571		CheckControlPath = True
572	Else
573		sPath = ConvertToUrl(Trim(oTextBox.Text)
574		CheckControlPath = oUcb.Exists(sPath)
575	End If
576End Function
577
578
579Function CheckInputPaths() as Boolean
580Dim bChangePage as Boolean
581	bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateImportPath, True, False, sTitle, False)
582	bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateExportPath, bChangePage, True, sTitle, False)
583	bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentImportPath, bChangePage, False, sTitle, False)
584	bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentExportPath, bChangePage, True, sTitle, False)
585	CheckInputPaths = bChangePage
586End Function
587
588
589Function CheckTextBoxPath(oTextBox as Object, ByVal bCheck as Boolean, bCreateNew as Boolean, sTitle as String, bgetResources as Boolean) as Boolean
590Dim iCreate as Integer
591Dim sQueryMessage as String
592Dim sUrlPath as String
593Dim sMessageNoDir as String
594Dim sShowPath as String
595Dim oLocUcb as Object
596	oLocUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
597	If bGetResources Then
598		If InitResources(&quot;ImportWizard&quot;,&quot;imp&quot;) then
599 			sNoDirCreation = GetResText(1050)
600			sMsgDirNotThere = GetResText(1051)
601			sQueryForNewCreation = GetResText(1052)
602		Else
603			CheckTextBoxPath() = False
604			Exit Function
605		End If
606	End If
607	If oTextBox.Enabled Then
608		If bCheck Then
609			sShowPath = oTextBox.Text
610			sUrlPath = ConvertToUrl(sShowPath)
611			If Not oLocUcb.Exists(sUrlPath) Then
612				If Not bCreateNew Then
613					&apos; Sourcedirectories must be existing, Targetdirectories may be created new
614					sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,&quot;%1&quot;)
615					Msgbox(sQueryMessage,16,sTitle)
616					CheckTextBoxPath() = False
617					Exit Function
618				Else
619					sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,&quot;%1&quot;)
620					sQueryMessage = sQueryMessage &amp; Chr(13) &amp; sQueryForNewCreation
621					iCreate = Msgbox (sQueryMessage, 36, sTitle)
622					If iCreate = 6 Then
623						On Local Error Goto NOVALIDPATH
624						CreateFolder(sUrlPath)
625						If Not oLocUcb.Exists(sUrlPath) Then
626							Goto NOVALIDPATH
627						End If
628					Else
629						CheckTextBoxPath() = False
630						Exit Function
631					End If
632				End If
633			End If
634			CheckTextBoxPath() = True
635		Else
636			CheckTextBoxPath() = False
637		End If
638	Else
639		CheckTextBoxPath() = True
640	End If
641	Exit Function
642NOVALIDPATH:
643	sMessageNoDir = ReplaceString(sNoDirCreation, sShowPath, &quot;%1&quot;)
644	Msgbox(sMessageNoDir, 16, sTitle)
645	CheckTextBoxPath() = False
646End Function
647
648
649Sub InitializeProgressPage(oDialog as Object)
650  oDialog.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL
651  oDialog.LabelCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD
652End Sub
653
654
655Sub	SetProgressDisplay(AbsFound as Integer)
656	ImportDialog.LabelRetrieval.Label = sProgressPage_2 &amp;  &quot;  &quot; &amp; ReplaceString(sProgressPage_5, Str(AbsFound) &amp; &quot; &quot;, &quot;%1&quot;)
657	ImportDialog.LabelCurDocumentRetrieval.Label =  sProgressFound &amp; &quot; &quot; &amp; CStr(AbsDocuFound) &amp;  &quot; &quot; &amp; sProgressMoreDocs
658	ImportDialog.LabelCurTemplateRetrieval.Label = sProgressFound &amp; &quot; &quot; &amp; CStr(AbsTemplateFound) &amp; &quot; &quot; &amp; sProgressMoreTemplates
659End Sub
660
661Sub TakoverFolderName(aEvent as Object)
662Dim RefControlName as String
663Dim oRefControl
664	RefControlName = aEvent.Source.Model.Tag
665	oRefControl = ImportDialogArea.GetControl(RefControlName)
666	GetFolderName(oRefControl.Model)
667	ToggleNextButton()
668End Sub
669
670
671Sub FinalizeDialogButtons()
672	ImportDialog.cmdShowLogFile.Enabled = ((Isnull(oLogDocument) = False) And (ImportDialog.chkLogfile.State = 1))
673	ImportDialog.cmdCancel.Enabled = False
674	ImportDialog.cmdGoOn.Label = sCloseButton
675	ImportDialog.cmdGoOn.Enabled = True
676End Sub
677</script:module>
678