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
24
25&apos;  *****  BASIC  *****
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
82
83Sub NextStep()
84Dim iCurStep as Integer
85	If Not bDebugWizard Then
86		On Error Goto RTError
87	End If
88	bConversionIsRunning = False
89	iCurStep = ImportDialog.Step
90	Select Case iCurStep
91		Case 1
92			FillStep_InputPaths(0, True)
93		Case 2
94			If CheckInputPaths Then
95				SaveStep_InputPath
96				If CurOffice &lt; ApplCount - 1 Then
97					CurOffice = CurOffice + 1
98					TakeOverPathSettings()
99					FillStep_InputPaths(CurOffice, False)
100				Else
101					FillStep_Summary()
102				End If
103			End If
104		Case 3
105			FillStep_Progress()
106			Select Case WizardMode
107				Case SBMICROSOFTMODE
108					Call ConvertAllDocuments(MSFilterName())
109				CASE SBXMLMODE
110					Call ConvertAllDocuments(XMLFilterName())
111			End Select
112		Case 4
113			CancelTask(True)
114	End Select
115
116	If ((ImportDialog.chkLogfile.State &lt;&gt; 1) OR (iCurStep &lt;&gt; 3)) Then
117		ImportDialog.cmdGoOn.DefaultButton = True
118	End If
119
120	RepaintHeaderPreview()
121	Exit Sub
122RTError:
123	Msgbox sRTErrorDesc, 16, sRTErrorHeader
124End Sub
125
126
127
128Sub PrevStep()
129Dim iCurStep as Integer
130	If Not bDebugWizard Then
131		On Error Goto RTError
132	End If
133	bConversionIsRunning = False
134	iCurStep = ImportDialog.Step
135	Select Case iCurStep
136		Case 4
137			ImportDialog.cmdCancel.Label = sCancelButton
138			FillStep_Summary()
139		Case 3
140			FillStep_InputPaths(Applcount-1, False)
141		Case 2
142			SaveStep_InputPath
143			If CurOffice &gt; 0 Then
144				CurOffice = CurOffice - 1
145				FillStep_InputPaths(CurOffice, False)
146			Else
147				FillStep_Welcome()
148				bDoKeepApplValues = True
149			End If
150	End Select
151	ImportDialog.cmdGoOn.DefaultButton = True
152	RepaintHeaderPreview()
153	Exit Sub
154RTError:
155	Msgbox sRTErrorDesc, 16, sRTErrorHeader
156End Sub
157
158
159
160Sub CancelTask()
161	If bConversionIsRunning Then
162		If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then
163			bCancelTask = True
164			bInterruptSearch = True
165		Else
166			bCancelTask = False
167			ImportDialog.cmdCancel.Enabled = True
168		End If
169	Else
170		ImportDialogArea.EndExecute()
171	End If
172End Sub
173
174
175Sub TemplateDirSearchDialog()
176	CallDirSearchDialog(ImportDialog.TemplateImportPath)
177End Sub
178
179
180Sub RepaintHeaderPreview()
181Dim Bitmap As Object
182Dim CurStep as Integer
183Dim sBitmapPath as String
184Dim LocPrefix as String
185	CurStep = ImportDialog.Step
186	LocPrefix = WizardMode
187	LocPrefix = ReplaceString(LocPrefix,&quot;XML&quot;, &quot;SO&quot;)
188	If CurStep = 2 Then
189		sBitmapPath = SOBitmapPath &amp; LocPrefix &amp; &quot;-Import_&quot; &amp; CurStep &amp; &quot;-&quot; &amp; Applications(CurOffice,SBAPPLKEY) + 1 &amp; &quot;.bmp&quot;
190	Else
191		sBitmapPath = SOBitmapPath &amp; &quot;Import_&quot; &amp; CurStep &amp; &quot;.bmp&quot;
192	End If
193	ImportDialog.ImportPreview.ImageURL = sBitmapPath
194End Sub
195
196
197Sub CheckModuleInstallation()
198Dim i as Integer
199	For i = 1 To MaxApplCount
200		ImportDialogArea.GetControl(&quot;chk&quot; &amp; WizardMode &amp; &quot;Application&quot; &amp; i).Model.Enabled = Abs(CheckInstalledModule(i-1))
201	Next i
202End Sub
203
204
205Function CheckInstalledModule(Index as Integer) as Boolean
206Dim ModuleName as String
207Dim NameList() as String
208Dim MaxIndex as Integer
209Dim i as Integer
210	ModuleName = ModuleList(Index)
211	If Instr(1,ModuleName,&quot;/&quot;) &lt;&gt; 0 Then
212		CheckInstalledModule() = False
213		NameList() = ArrayoutOfString(ModuleName,&quot;/&quot;, MaxIndex)
214		For i = 0 To MaxIndex
215			If oFactoryKey.HasByName(NameList(i)) Then
216				CheckInstalledModule() = True
217			End If
218		Next i
219	Else
220		CheckInstalledModule() = oFactoryKey.HasByName(ModuleName)
221	End If
222End Function
223
224
225Sub ToggleCheckboxes(oEvent as Object)
226Dim bMSEnable as Boolean
227	WizardMode = oEvent.Source.Model.Tag
228	bMSEnable = WizardMode = &quot;MS&quot;
229	ToggleCheckBoxesWithBoolean(bMSEnable)
230End Sub
231
232
233Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean)
234	If bMSEnable = True Then
235		WizardMode = SBMICROSOFTMODE
236		MaxApplCount = 3
237	Else
238		WizardMode = SBXMLMODE
239		MaxApplCount = 4
240	End If
241	With ImportDialogArea
242		.GetControl(&quot;chkSOApplication1&quot;).Model.Enabled = Not bMSEnable
243		.GetControl(&quot;chkSOApplication2&quot;).Model.Enabled = Not bMSEnable
244		.GetControl(&quot;chkSOApplication3&quot;).Model.Enabled = Not bMSEnable
245		.GetControl(&quot;chkSOApplication4&quot;).Model.Enabled = Not bMSEnable
246		.GetControl(&quot;chkMSApplication1&quot;).Model.Enabled = bMSEnable
247		.GetControl(&quot;chkMSApplication2&quot;).Model.Enabled = bMSEnable
248		.GetControl(&quot;chkMSApplication3&quot;).Model.Enabled = bMSEnable
249	End With
250	CheckModuleInstallation()
251	ImportDialog.WelcomeTextLabel2.Enabled = bMSEnable
252	bDoKeepApplValues = False
253	ToggleNextButton()
254End Sub
255
256
257Sub ToggleNextButton()
258Dim iCurStep as Integer
259Dim bDoEnable as Boolean
260Dim i as Integer
261	iCurStep = ImportDialog.Step
262	Select Case iCurStep
263		Case 1
264			With ImportDialog
265				If .optMSDocuments.State = 1 Then
266          			bDoEnable = .chkMSApplication1.State = 1 Or .chkMSApplication2.State = 1 Or .chkMSApplication3.State = 1
267				Else
268          			bDoEnable = .chkSOApplication1.State = 1 Or .chkSOApplication2.State = 1 Or .chkSOApplication3.State = 1 Or .chkSOApplication4.State = 1
269				End If
270			End With
271			bDoKeepApplValues = False
272		Case 2
273			bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
274			bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
275	End Select
276	ImportDialog.cmdGoOn.Enabled = bDoEnable
277End Sub
278
279
280Sub TakeOverPathSettings()
281&apos;Takes over the Pathsettings from the first selected application to the next applications
282	If Applications(CurOffice,SBDOCSOURCE) = &quot;&quot; Then
283		Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
284		Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
285		If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then
286			Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
287			Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)
288		Else
289			Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
290			Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)
291		End If
292	End If
293End Sub
294
295
296Function GetImportWizardPaths() as Boolean
297	SOBitmapPath = GetOfficeSubPath(&quot;Template&quot;, &quot;../wizard/bitmap&quot;)
298	If SOBitmapPath &lt;&gt; &quot;&quot; Then
299		SOWorkPath = GetPathSettings(&quot;Work&quot;, False)
300		If SOWorkPath &lt;&gt; &quot;&quot; Then
301			SOTemplatePath = GetPathSettings(&quot;Template_writable&quot;,False,0)
302			If SOTemplatePath &lt;&gt; &quot;&quot; Then
303				GetImportWizardPaths() = True
304				Exit Function
305			End If
306		End If
307	End  If
308	GetImportWizardPaths() = False
309End Function
310</script:module>
311