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
29 ' If the ProgressPage ist 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
82 Dim iCurStep as Integer
83 If Not bDebugWizard Then
86 bConversionIsRunning = False
87 iCurStep = ImportDialog.Step
90 FillStep_InputPaths(
0, True)
92 If CheckInputPaths Then
94 If CurOffice
< ApplCount -
1 Then
95 CurOffice = CurOffice +
1
96 TakeOverPathSettings()
97 FillStep_InputPaths(CurOffice, False)
104 Select Case WizardMode
106 Call ConvertAllDocuments(MSFilterName())
112 If ((ImportDialog.chkLogfile.State
<> 1) OR (iCurStep
<> 3)) Then
113 ImportDialog.cmdGoOn.DefaultButton = True
116 RepaintHeaderPreview()
119 Msgbox sRTErrorDesc,
16, sRTErrorHeader
125 Dim iCurStep as Integer
126 If Not bDebugWizard Then
127 On Error Goto RTError
129 bConversionIsRunning = False
130 iCurStep = ImportDialog.Step
133 ImportDialog.cmdCancel.Label = sCancelButton
136 FillStep_InputPaths(Applcount-
1, False)
139 If CurOffice
> 0 Then
140 CurOffice = CurOffice -
1
141 FillStep_InputPaths(CurOffice, False)
144 ToggleCheckboxesWithBoolean(True)
145 bDoKeepApplValues = True
148 ImportDialog.cmdGoOn.DefaultButton = True
149 RepaintHeaderPreview()
152 Msgbox sRTErrorDesc,
16, sRTErrorHeader
158 If bConversionIsRunning Then
159 If Msgbox(sConvertError1,
36, sConvertError2) =
6 Then
161 bInterruptSearch = True
164 ImportDialog.cmdCancel.Enabled = True
167 ImportDialogArea.EndExecute()
172 Sub TemplateDirSearchDialog()
173 CallDirSearchDialog(ImportDialog.TemplateImportPath)
177 Sub RepaintHeaderPreview()
179 Dim CurStep as Integer
180 Dim sBitmapPath as String
181 Dim LocPrefix as String
182 CurStep = ImportDialog.Step
183 LocPrefix = WizardMode
184 LocPrefix = ReplaceString(LocPrefix,
"XML
",
"SO
")
186 sBitmapPath = SOBitmapPath
& LocPrefix
& "-Import_
" & CurStep
& "-
" & Applications(CurOffice,SBAPPLKEY) +
1 & ".bmp
"
188 sBitmapPath = SOBitmapPath
& "Import_
" & CurStep
& ".bmp
"
190 ImportDialog.ImportPreview.ImageURL = sBitmapPath
194 Sub CheckModuleInstallation()
196 For i =
1 To MaxApplCount
197 ImportDialogArea.GetControl(
"chk
" & WizardMode
& "Application
" & i).Model.Enabled = Abs(CheckInstalledModule(i-
1))
202 Function CheckInstalledModule(Index as Integer) as Boolean
203 Dim ModuleName as String
204 Dim NameList() as String
205 Dim MaxIndex as Integer
207 ModuleName = ModuleList(Index)
208 If Instr(
1,ModuleName,
"/
")
<> 0 Then
209 CheckInstalledModule() = False
210 NameList() = ArrayoutOfString(ModuleName,
"/
", MaxIndex)
211 For i =
0 To MaxIndex
212 If oFactoryKey.HasByName(NameList(i)) Then
213 CheckInstalledModule() = True
217 CheckInstalledModule() = oFactoryKey.HasByName(ModuleName)
222 Sub ToggleCheckboxes(oEvent as Object)
223 Dim bMSEnable as Boolean
224 WizardMode = oEvent.Source.Model.Tag
225 bMSEnable = WizardMode =
"MS
"
226 ToggleCheckboxesWithBoolean(bMSEnable)
230 Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean)
231 If bMSEnable = True Then
232 WizardMode = SBMICROSOFTMODE
235 'Not supposed to happen - is there an assert in BASIC...
237 With ImportDialogArea
238 .GetControl(
"chkMSApplication1
").Model.Enabled = bMSEnable
239 .GetControl(
"chkMSApplication2
").Model.Enabled = bMSEnable
240 .GetControl(
"chkMSApplication3
").Model.Enabled = bMSEnable
242 CheckModuleInstallation()
243 bDoKeepApplValues = False
248 Sub ToggleNextButton()
249 Dim iCurStep as Integer
250 Dim bDoEnable as Boolean
252 iCurStep = ImportDialog.Step
256 If .optMSDocuments.State =
1 Then
257 bDoEnable = .chkMSApplication1.State =
1 Or .chkMSApplication2.State =
1 Or .chkMSApplication3.State =
1
260 bDoKeepApplValues = False
262 bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
263 bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
265 ImportDialog.cmdGoOn.Enabled = bDoEnable
269 Sub TakeOverPathSettings()
270 'Takes over the Pathsettings from the first selected application to the next applications
271 If Applications(CurOffice,SBDOCSOURCE) =
"" Then
272 Applications(CurOffice,SBDOCSOURCE) = Applications(
0,SBDOCSOURCE)
273 Applications(CurOffice,SBDOCTARGET) = Applications(
0,SBDOCTARGET)
274 Applications(CurOffice,SBTEMPLSOURCE) = Applications(
0,SBTEMPLSOURCE)
275 Applications(CurOffice,SBTEMPLTARGET) = Applications(
0,SBTEMPLTARGET)
280 Function GetImportWizardPaths() as Boolean
281 SOBitmapPath = GetOfficeSubPath(
"Template
",
"../wizard/bitmap
")
282 If SOBitmapPath
<> "" Then
283 SOWorkPath = GetPathSettings(
"Work
", False)
284 If SOWorkPath
<> "" Then
285 SOTemplatePath = GetPathSettings(
"Template_writable
",False,
0)
286 If SOTemplatePath
<> "" Then
287 GetImportWizardPaths() = True
292 GetImportWizardPaths() = False