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
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
29 ' If the ProgressPage is already on Top The Dialog will be immediately closed when this flag is
31 Public bConversionIsRunning as Boolean
32 Public RetValue as Integer
35 Dim NoArgs() as New com.sun.star.beans.PropertyValue
37 If Not bDebugWizard Then
38 On Local Error Goto RTError
40 BasicLibraries.LoadLibrary(
"Tools
")
42 bIsFirstLogTable = True
43 bConversionIsRunning = False
44 sCRLF = CHR(
13)
& CHR(
10)
45 oUcb = createUnoService(
"com.sun.star.ucb.SimpleFileAccess
")
46 oFactoryKey = GetRegistryKeyContent(
"org.openoffice.Setup/Office/Factories
")
47 If GetImportWizardPaths() = False Then
51 bDoKeepApplValues = False
53 ImportDialogArea = LoadDialog(
"ImportWizard
",
"ImportDialog
")
54 ImportDialog = ImportDialogArea.Model
56 WizardMode = SBMICROSOFTMODE
59 RepaintHeaderPreview()
60 ImportDialog.ImportPreview.BackGroundColor = RGB(
0,
60,
126)
61 ImportDialog.cmdGoOn.DefaultButton = True
62 ImportDialogArea.GetControl(
"optMSDocuments
").SetFocus()
63 ToggleCheckboxesWithBoolean(True)
65 RetValue = ImportDialogArea.Execute()
66 If bShowLogFile=TRUE Then
67 OpenDocument(sLogUrl, NoArgs())
72 ImportDialogArea.Dispose()
76 Msgbox sRTErrorDesc,
16, sRTErrorHeader
81 Dim iCurStep as Integer
82 If Not bDebugWizard Then
85 bConversionIsRunning = False
86 iCurStep = ImportDialog.Step
89 FillStep_InputPaths(
0, True)
91 If CheckInputPaths Then
93 If CurOffice
< ApplCount -
1 Then
94 CurOffice = CurOffice +
1
95 TakeOverPathSettings()
96 FillStep_InputPaths(CurOffice, False)
103 Select Case WizardMode
105 Call ConvertAllDocuments(MSFilterName())
111 If ((ImportDialog.chkLogfile.State
<> 1) OR (iCurStep
<> 3)) Then
112 ImportDialog.cmdGoOn.DefaultButton = True
115 RepaintHeaderPreview()
118 Msgbox sRTErrorDesc,
16, sRTErrorHeader
123 Dim iCurStep as Integer
124 If Not bDebugWizard Then
125 On Error Goto RTError
127 bConversionIsRunning = False
128 iCurStep = ImportDialog.Step
131 ImportDialog.cmdCancel.Label = sCancelButton
134 FillStep_InputPaths(Applcount-
1, False)
137 If CurOffice
> 0 Then
138 CurOffice = CurOffice -
1
139 FillStep_InputPaths(CurOffice, False)
142 ToggleCheckboxesWithBoolean(True)
143 bDoKeepApplValues = True
146 ImportDialog.cmdGoOn.DefaultButton = True
147 RepaintHeaderPreview()
150 Msgbox sRTErrorDesc,
16, sRTErrorHeader
155 If bConversionIsRunning Then
156 If Msgbox(sConvertError1,
36, sConvertError2) =
6 Then
158 bInterruptSearch = True
161 ImportDialog.cmdCancel.Enabled = True
164 ImportDialogArea.EndExecute()
169 Sub TemplateDirSearchDialog()
170 CallDirSearchDialog(ImportDialog.TemplateImportPath)
174 Sub RepaintHeaderPreview()
176 Dim CurStep as Integer
177 Dim sBitmapPath as String
178 Dim LocPrefix as String
179 CurStep = ImportDialog.Step
180 LocPrefix = WizardMode
181 LocPrefix = ReplaceString(LocPrefix,
"XML
",
"SO
")
183 sBitmapPath = SOBitmapPath
& LocPrefix
& "-Import_
" & CurStep
& "-
" & Applications(CurOffice,SBAPPLKEY) +
1 & ".png
"
185 sBitmapPath = SOBitmapPath
& "Import_
" & CurStep
& ".png
"
187 ImportDialog.ImportPreview.ImageURL = sBitmapPath
191 Sub CheckModuleInstallation()
193 For i =
1 To MaxApplCount
194 ImportDialogArea.GetControl(
"chk
" & WizardMode
& "Application
" & i).Model.Enabled = Abs(CheckInstalledModule(i-
1))
199 Function CheckInstalledModule(Index as Integer) as Boolean
200 Dim ModuleName as String
201 Dim NameList() as String
202 Dim MaxIndex as Integer
204 ModuleName = ModuleList(Index)
205 If Instr(
1,ModuleName,
"/
")
<> 0 Then
206 CheckInstalledModule() = False
207 NameList() = ArrayoutOfString(ModuleName,
"/
", MaxIndex)
208 For i =
0 To MaxIndex
209 If oFactoryKey.HasByName(NameList(i)) Then
210 CheckInstalledModule() = True
214 CheckInstalledModule() = oFactoryKey.HasByName(ModuleName)
219 Sub ToggleCheckboxes(oEvent as Object)
220 Dim bMSEnable as Boolean
221 WizardMode = oEvent.Source.Model.Tag
222 bMSEnable = WizardMode =
"MS
"
223 ToggleCheckboxesWithBoolean(bMSEnable)
227 Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean)
228 If bMSEnable = True Then
229 WizardMode = SBMICROSOFTMODE
232 'Not supposed to happen - is there an assert in BASIC...
234 With ImportDialogArea
235 .GetControl(
"chkMSApplication1
").Model.Enabled = bMSEnable
236 .GetControl(
"chkMSApplication2
").Model.Enabled = bMSEnable
237 .GetControl(
"chkMSApplication3
").Model.Enabled = bMSEnable
239 CheckModuleInstallation()
240 bDoKeepApplValues = False
245 Sub ToggleNextButton()
246 Dim iCurStep as Integer
247 Dim bDoEnable as Boolean
249 iCurStep = ImportDialog.Step
253 If .optMSDocuments.State =
1 Then
254 bDoEnable = .chkMSApplication1.State =
1 Or .chkMSApplication2.State =
1 Or .chkMSApplication3.State =
1
257 bDoKeepApplValues = False
259 bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
260 bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
262 ImportDialog.cmdGoOn.Enabled = bDoEnable
266 Sub TakeOverPathSettings()
267 'Takes over the Pathsettings from the first selected application to the next applications
268 If Applications(CurOffice,SBDOCSOURCE) =
"" Then
269 Applications(CurOffice,SBDOCSOURCE) = Applications(
0,SBDOCSOURCE)
270 Applications(CurOffice,SBDOCTARGET) = Applications(
0,SBDOCTARGET)
271 Applications(CurOffice,SBTEMPLSOURCE) = Applications(
0,SBTEMPLSOURCE)
272 Applications(CurOffice,SBTEMPLTARGET) = Applications(
0,SBTEMPLTARGET)
277 Function GetImportWizardPaths() as Boolean
278 SOBitmapPath = GetOfficeSubPath(
"Template
",
"../wizard/bitmap
")
279 If SOBitmapPath
<> "" Then
280 SOWorkPath = GetPathSettings(
"Work
", False)
281 If SOWorkPath
<> "" Then
282 SOTemplatePath = GetPathSettings(
"Template_writable
",False,
0)
283 If SOTemplatePath
<> "" Then
284 GetImportWizardPaths() = True
289 GetImportWizardPaths() = False