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