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