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