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