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