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="Main" script:language="StarBasic">Option Explicit
24REM ***** BASIC *****
25
26Public HeaderPreviews(4) as Object
27Public ImportDialog as Object
28Public ImportDialogArea as Object
29Public oFactoryKey as Object
30Public bShowLogFile as Boolean
31
32&apos; If the ProgressPage ist already on Top The Dialog will be immediately closed when this flag is
33&apos; set to False
34Public bConversionIsRunning as Boolean
35Public RetValue as Integer
36
37Sub Main()
38	Dim NoArgs() as New com.sun.star.beans.PropertyValue
39	bShowLogFile=FALSE
40	If Not bDebugWizard Then
41		On Local Error Goto RTError
42	End If
43	BasicLibraries.LoadLibrary(&quot;Tools&quot;)
44	RetValue = 10
45	bIsFirstLogTable = True
46	bConversionIsRunning = False
47	sCRLF = CHR(13) &amp; CHR(10)
48	oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
49	oFactoryKey = GetRegistryKeyContent(&quot;org.openoffice.Setup/Office/Factories&quot;)
50	If GetImportWizardPaths() = False Then
51		Exit Sub
52	End If
53	bCancelTask = False
54	bDoKeepApplValues = False
55	CurOffice = 0
56	ImportDialogArea = LoadDialog(&quot;ImportWizard&quot;,&quot;ImportDialog&quot;)
57	ImportDialog = ImportDialogArea.Model
58	LoadLanguage()
59	WizardMode = SBXMLMODE
60	MaxApplCount = 4
61	FillStep_Welcome()
62	RepaintHeaderPreview()
63	ImportDialog.ImportPreview.BackGroundColor = RGB(0,60,126)
64	ImportDialog.cmdGoOn.DefaultButton = True
65	ImportDialogArea.GetControl(&quot;optSODocuments&quot;).SetFocus()
66	ToggleCheckboxesWithBoolean(False)
67	RetValue = ImportDialogArea.Execute()
68	If bShowLogFile=TRUE Then
69		OpenDocument(sLogUrl, NoArgs())
70	End if
71	If RetValue = 0 Then
72		CancelTask()
73	End If
74	ImportDialogArea.Dispose()
75	End
76	Exit Sub
77RTError:
78	Msgbox sRTErrorDesc, 16, sRTErrorHeader
79End Sub
80
81
82Sub NextStep()
83Dim iCurStep as Integer
84	If Not bDebugWizard Then
85		On Error Goto RTError
86	End If
87	bConversionIsRunning = False
88	iCurStep = ImportDialog.Step
89	Select Case iCurStep
90		Case 1
91			FillStep_InputPaths(0, True)
92		Case 2
93			If CheckInputPaths Then
94				SaveStep_InputPath
95				If CurOffice &lt; ApplCount - 1 Then
96					CurOffice = CurOffice + 1
97					TakeOverPathSettings()
98					FillStep_InputPaths(CurOffice, False)
99				Else
100					FillStep_Summary()
101				End If
102			End If
103		Case 3
104			FillStep_Progress()
105			Select Case WizardMode
106				Case SBMICROSOFTMODE
107					Call ConvertAllDocuments(MSFilterName())
108				CASE SBXMLMODE
109					Call ConvertAllDocuments(XMLFilterName())
110			End Select
111		Case 4
112			CancelTask(True)
113	End Select
114
115	If ((ImportDialog.chkLogfile.State &lt;&gt; 1) OR (iCurStep &lt;&gt; 3)) Then
116		ImportDialog.cmdGoOn.DefaultButton = True
117	End If
118
119	RepaintHeaderPreview()
120	Exit Sub
121RTError:
122	Msgbox sRTErrorDesc, 16, sRTErrorHeader
123End Sub
124
125
126Sub PrevStep()
127Dim iCurStep as Integer
128	If Not bDebugWizard Then
129		On Error Goto RTError
130	End If
131	bConversionIsRunning = False
132	iCurStep = ImportDialog.Step
133	Select Case iCurStep
134		Case 4
135			ImportDialog.cmdCancel.Label = sCancelButton
136			FillStep_Summary()
137		Case 3
138			FillStep_InputPaths(Applcount-1, False)
139		Case 2
140			SaveStep_InputPath
141			If CurOffice &gt; 0 Then
142				CurOffice = CurOffice - 1
143				FillStep_InputPaths(CurOffice, False)
144			Else
145				FillStep_Welcome()
146				bDoKeepApplValues = True
147			End If
148	End Select
149	ImportDialog.cmdGoOn.DefaultButton = True
150	RepaintHeaderPreview()
151	Exit Sub
152RTError:
153	Msgbox sRTErrorDesc, 16, sRTErrorHeader
154End Sub
155
156
157Sub CancelTask()
158	If bConversionIsRunning Then
159		If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then
160			bCancelTask = True
161			bInterruptSearch = True
162		Else
163			bCancelTask = False
164			ImportDialog.cmdCancel.Enabled = True
165		End If
166	Else
167		ImportDialogArea.EndExecute()
168	End If
169End Sub
170
171
172Sub TemplateDirSearchDialog()
173	CallDirSearchDialog(ImportDialog.TemplateImportPath)
174End Sub
175
176
177Sub RepaintHeaderPreview()
178Dim Bitmap As Object
179Dim CurStep as Integer
180Dim sBitmapPath as String
181Dim LocPrefix as String
182	CurStep = ImportDialog.Step
183	LocPrefix = WizardMode
184	LocPrefix = ReplaceString(LocPrefix,&quot;XML&quot;, &quot;SO&quot;)
185	If CurStep = 2 Then
186		sBitmapPath = SOBitmapPath &amp; LocPrefix &amp; &quot;-Import_&quot; &amp; CurStep &amp; &quot;-&quot; &amp; Applications(CurOffice,SBAPPLKEY) + 1 &amp; &quot;.png&quot;
187	Else
188		sBitmapPath = SOBitmapPath &amp; &quot;Import_&quot; &amp; CurStep &amp; &quot;.png&quot;
189	End If
190	ImportDialog.ImportPreview.ImageURL = sBitmapPath
191End Sub
192
193
194Sub CheckModuleInstallation()
195Dim i as Integer
196	For i = 1 To MaxApplCount
197		ImportDialogArea.GetControl(&quot;chk&quot; &amp; WizardMode &amp; &quot;Application&quot; &amp; i).Model.Enabled = Abs(CheckInstalledModule(i-1))
198	Next i
199End Sub
200
201
202Function CheckInstalledModule(Index as Integer) as Boolean
203Dim ModuleName as String
204Dim NameList() as String
205Dim MaxIndex as Integer
206Dim i as Integer
207	ModuleName = ModuleList(Index)
208	If Instr(1,ModuleName,&quot;/&quot;) &lt;&gt; 0 Then
209		CheckInstalledModule() = False
210		NameList() = ArrayoutOfString(ModuleName,&quot;/&quot;, MaxIndex)
211		For i = 0 To MaxIndex
212			If oFactoryKey.HasByName(NameList(i)) Then
213				CheckInstalledModule() = True
214			End If
215		Next i
216	Else
217		CheckInstalledModule() = oFactoryKey.HasByName(ModuleName)
218	End If
219End Function
220
221
222Sub ToggleCheckboxes(oEvent as Object)
223Dim bMSEnable as Boolean
224	WizardMode = oEvent.Source.Model.Tag
225	bMSEnable = WizardMode = &quot;MS&quot;
226	ToggleCheckBoxesWithBoolean(bMSEnable)
227End Sub
228
229
230Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean)
231	If bMSEnable = True Then
232		WizardMode = SBMICROSOFTMODE
233		MaxApplCount = 3
234	Else
235		WizardMode = SBXMLMODE
236		MaxApplCount = 4
237	End If
238	With ImportDialogArea
239		.GetControl(&quot;chkSOApplication1&quot;).Model.Enabled = Not bMSEnable
240		.GetControl(&quot;chkSOApplication2&quot;).Model.Enabled = Not bMSEnable
241		.GetControl(&quot;chkSOApplication3&quot;).Model.Enabled = Not bMSEnable
242		.GetControl(&quot;chkSOApplication4&quot;).Model.Enabled = Not bMSEnable
243		.GetControl(&quot;chkMSApplication1&quot;).Model.Enabled = bMSEnable
244		.GetControl(&quot;chkMSApplication2&quot;).Model.Enabled = bMSEnable
245		.GetControl(&quot;chkMSApplication3&quot;).Model.Enabled = bMSEnable
246	End With
247	CheckModuleInstallation()
248	ImportDialog.WelcomeTextLabel2.Enabled = bMSEnable
249	bDoKeepApplValues = False
250	ToggleNextButton()
251End Sub
252
253
254Sub ToggleNextButton()
255Dim iCurStep as Integer
256Dim bDoEnable as Boolean
257Dim i as Integer
258	iCurStep = ImportDialog.Step
259	Select Case iCurStep
260		Case 1
261			With ImportDialog
262				If .optMSDocuments.State = 1 Then
263					bDoEnable = .chkMSApplication1.State = 1 Or .chkMSApplication2.State = 1 Or .chkMSApplication3.State = 1
264				Else
265	 				bDoEnable = .chkSOApplication1.State = 1 Or .chkSOApplication2.State = 1 Or .chkSOApplication3.State = 1 Or .chkSOApplication4.State = 1
266				End If
267			End With
268			bDoKeepApplValues = False
269		Case 2
270			bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
271			bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
272	End Select
273	ImportDialog.cmdGoOn.Enabled = bDoEnable
274End Sub
275
276
277Sub TakeOverPathSettings()
278&apos;Takes over the Pathsettings from the first selected application to the next applications
279	If Applications(CurOffice,SBDOCSOURCE) = &quot;&quot; Then
280		Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
281		Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
282		If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then
283			Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
284			Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)
285		Else
286			Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
287			Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)
288		End If
289	End If
290End Sub
291
292
293Function GetImportWizardPaths() as Boolean
294	SOBitmapPath = GetOfficeSubPath(&quot;Template&quot;, &quot;../wizard/bitmap&quot;)
295	If SOBitmapPath &lt;&gt; &quot;&quot; Then
296		SOWorkPath = GetPathSettings(&quot;Work&quot;, False)
297		If SOWorkPath &lt;&gt; &quot;&quot; Then
298			SOTemplatePath = GetPathSettings(&quot;Template_writable&quot;,False,0)
299			If SOTemplatePath &lt;&gt; &quot;&quot; Then
300				GetImportWizardPaths() = True
301				Exit Function
302			End If
303		End If
304	End If
305	GetImportWizardPaths() = False
306End Function
307</script:module>
308