1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"Main" script:
language=
"StarBasic">Option Explicit
22 ' ***** BASIC *****
23 Public HeaderPreviews(
4) as Object
24 Public ImportDialog as Object
25 Public ImportDialogArea as Object
26 Public oFactoryKey as Object
27 Public bShowLogFile as Boolean
28 Public oBinFilterComp as Object
30 ' If the ProgressPage ist already on Top The Dialog will be immediately closed when this flag is
32 Public bConversionIsRunning as Boolean
33 Public RetValue as Integer
36 Dim NoArgs() as New com.sun.star.beans.PropertyValue
38 If Not bDebugWizard Then
39 On Local Error Goto RTError
41 BasicLibraries.LoadLibrary(
"Tools
")
43 bIsFirstLogTable = True
44 bConversionIsRunning = False
45 sCRLF = CHR(
13)
& CHR(
10)
46 oUcb = createUnoService(
"com.sun.star.ucb.SimpleFileAccess
")
47 oFactoryKey = GetRegistryKeyContent(
"org.openoffice.Setup/Office/Factories
")
48 If GetImportWizardPaths() = False Then
52 bDoKeepApplValues = False
54 ImportDialogArea = LoadDialog(
"ImportWizard
",
"ImportDialog
")
55 ImportDialog = ImportDialogArea.Model
57 WizardMode = SBXMLMODE
60 RepaintHeaderPreview()
61 ImportDialog.ImportPreview.BackGroundColor = RGB(
0,
60,
126)
62 ImportDialog.cmdGoOn.DefaultButton = True
63 ImportDialogArea.GetControl(
"optMSDocuments
").SetFocus()
64 oBinFilterComp = createBF_MigrateFilterIfPossible()
65 ToggleCheckboxesWithBoolean(True)
67 RetValue = ImportDialogArea.Execute()
68 If bShowLogFile=TRUE Then
69 OpenDocument(sLogUrl, NoArgs())
74 ImportDialogArea.Dispose()
78 Msgbox sRTErrorDesc,
16, sRTErrorHeader
84 Dim iCurStep as Integer
85 If Not bDebugWizard Then
88 bConversionIsRunning = False
89 iCurStep = ImportDialog.Step
92 FillStep_InputPaths(
0, True)
94 If CheckInputPaths Then
96 If CurOffice
< ApplCount -
1 Then
97 CurOffice = CurOffice +
1
98 TakeOverPathSettings()
99 FillStep_InputPaths(CurOffice, False)
106 Select Case WizardMode
108 Call ConvertAllDocuments(MSFilterName())
110 Call ConvertAllDocuments(XMLFilterName())
116 If ((ImportDialog.chkLogfile.State
<> 1) OR (iCurStep
<> 3)) Then
117 ImportDialog.cmdGoOn.DefaultButton = True
120 RepaintHeaderPreview()
123 Msgbox sRTErrorDesc,
16, sRTErrorHeader
129 Dim iCurStep as Integer
130 If Not bDebugWizard Then
131 On Error Goto RTError
133 bConversionIsRunning = False
134 iCurStep = ImportDialog.Step
137 ImportDialog.cmdCancel.Label = sCancelButton
140 FillStep_InputPaths(Applcount-
1, False)
143 If CurOffice
> 0 Then
144 CurOffice = CurOffice -
1
145 FillStep_InputPaths(CurOffice, False)
148 ToggleCheckboxesWithBoolean(True)
149 bDoKeepApplValues = True
152 ImportDialog.cmdGoOn.DefaultButton = True
153 RepaintHeaderPreview()
156 Msgbox sRTErrorDesc,
16, sRTErrorHeader
162 If bConversionIsRunning Then
163 If Msgbox(sConvertError1,
36, sConvertError2) =
6 Then
165 bInterruptSearch = True
168 ImportDialog.cmdCancel.Enabled = True
171 ImportDialogArea.EndExecute()
176 Sub TemplateDirSearchDialog()
177 CallDirSearchDialog(ImportDialog.TemplateImportPath)
181 Sub RepaintHeaderPreview()
183 Dim CurStep as Integer
184 Dim sBitmapPath as String
185 Dim LocPrefix as String
186 CurStep = ImportDialog.Step
187 LocPrefix = WizardMode
188 LocPrefix = ReplaceString(LocPrefix,
"XML
",
"SO
")
190 sBitmapPath = SOBitmapPath
& LocPrefix
& "-Import_
" & CurStep
& "-
" & Applications(CurOffice,SBAPPLKEY) +
1 & ".bmp
"
192 sBitmapPath = SOBitmapPath
& "Import_
" & CurStep
& ".bmp
"
194 ImportDialog.ImportPreview.ImageURL = sBitmapPath
198 Sub CheckModuleInstallation()
200 For i =
1 To MaxApplCount
201 ImportDialogArea.GetControl(
"chk
" & WizardMode
& "Application
" & i).Model.Enabled = Abs(CheckInstalledModule(i-
1))
206 Function createBF_MigrateFilterIfPossible()
208 On Error Goto RTError
209 oService = createUnoService(
"com.sun.star.comp.office.BF_MigrateFilter
")
210 getBinFilterCompIfItExists = oService
213 createBF_MigrateFilterIfPossible = Nothing
217 Function CheckInstalledModule(Index as Integer) as Boolean
218 Dim ModuleName as String
219 Dim NameList() as String
220 Dim MaxIndex as Integer
222 ModuleName = ModuleList(Index)
223 If Instr(
1,ModuleName,
"/
")
<> 0 Then
224 CheckInstalledModule() = False
225 NameList() = ArrayoutOfString(ModuleName,
"/
", MaxIndex)
226 For i =
0 To MaxIndex
227 If oFactoryKey.HasByName(NameList(i)) Then
228 CheckInstalledModule() = True
232 CheckInstalledModule() = oFactoryKey.HasByName(ModuleName)
237 Sub ToggleCheckboxes(oEvent as Object)
238 Dim bMSEnable as Boolean
239 WizardMode = oEvent.Source.Model.Tag
240 bMSEnable = WizardMode =
"MS
"
241 ToggleCheckboxesWithBoolean(bMSEnable)
245 Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean)
246 If bMSEnable = True Then
247 WizardMode = SBMICROSOFTMODE
250 WizardMode = SBXMLMODE
253 With ImportDialogArea
254 If (isNull(oBinFilterComp)) Then
255 .GetControl(
"optSODocuments
").Visible = False
256 .GetControl(
"chkSOApplication1
").Visible = False
257 .GetControl(
"chkSOApplication2
").Visible = False
258 .GetControl(
"chkSOApplication3
").Visible = False
259 .GetControl(
"chkSOApplication4
").Visible = False
261 .GetControl(
"chkSOApplication1
").Model.Enabled = Not bMSEnable
262 .GetControl(
"chkSOApplication2
").Model.Enabled = Not bMSEnable
263 .GetControl(
"chkSOApplication3
").Model.Enabled = Not bMSEnable
264 .GetControl(
"chkSOApplication4
").Model.Enabled = Not bMSEnable
266 .GetControl(
"chkMSApplication1
").Model.Enabled = bMSEnable
267 .GetControl(
"chkMSApplication2
").Model.Enabled = bMSEnable
268 .GetControl(
"chkMSApplication3
").Model.Enabled = bMSEnable
270 CheckModuleInstallation()
271 bDoKeepApplValues = False
276 Sub ToggleNextButton()
277 Dim iCurStep as Integer
278 Dim bDoEnable as Boolean
280 iCurStep = ImportDialog.Step
284 If .optMSDocuments.State =
1 Then
285 bDoEnable = .chkMSApplication1.State =
1 Or .chkMSApplication2.State =
1 Or .chkMSApplication3.State =
1
287 bDoEnable = .chkSOApplication1.State =
1 Or .chkSOApplication2.State =
1 Or .chkSOApplication3.State =
1 Or .chkSOApplication4.State =
1
290 bDoKeepApplValues = False
292 bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
293 bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
295 ImportDialog.cmdGoOn.Enabled = bDoEnable
299 Sub TakeOverPathSettings()
300 'Takes over the Pathsettings from the first selected application to the next applications
301 If Applications(CurOffice,SBDOCSOURCE) =
"" Then
302 Applications(CurOffice,SBDOCSOURCE) = Applications(
0,SBDOCSOURCE)
303 Applications(CurOffice,SBDOCTARGET) = Applications(
0,SBDOCTARGET)
304 If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) =
3 Then
305 Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
306 Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)
308 Applications(CurOffice,SBTEMPLSOURCE) = Applications(
0,SBTEMPLSOURCE)
309 Applications(CurOffice,SBTEMPLTARGET) = Applications(
0,SBTEMPLTARGET)
315 Function GetImportWizardPaths() as Boolean
316 SOBitmapPath = GetOfficeSubPath(
"Template
",
"../wizard/bitmap
")
317 If SOBitmapPath
<> "" Then
318 SOWorkPath = GetPathSettings(
"Work
", False)
319 If SOWorkPath
<> "" Then
320 SOTemplatePath = GetPathSettings(
"Template_writable
",False,
0)
321 If SOTemplatePath
<> "" Then
322 GetImportWizardPaths() = True
327 GetImportWizardPaths() = False