home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2004 June / VPR0406.ISO / STARSUITE7 / EVALUATION / windows / office7 / f_0080 / Main.xba < prev    next >
Extensible Markup Language  |  2004-01-20  |  8KB  |  278 lines

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