home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri Kaikille K-CD 2002 #3 / K-CD_2002-03.iso / OpenOffice / f_0243 / Main.xba < prev   
Extensible Markup Language  |  2001-08-10  |  7KB  |  227 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.  
  16. Sub Main()
  17.     BasicLibraries.LoadLibrary("Tools")
  18.     bSetFonts = False
  19.     bConversionIsRunnig = False
  20.     If bSetFonts Then
  21.         BasicLibraries.LoadLibrary("Translater")
  22.         GetFontNames()
  23.     End If
  24.     sCRLF = CHR(10) & CHR(13)
  25.     oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
  26.     If Not bDebugWizard Then
  27.         On Error Goto RTError
  28.     End If
  29.     SOBitmapPath = GetOfficeSubPath("Template", "wizard/bitmap")
  30.     SOWorkPath = GetPathSettings("Work", False)
  31.     SOTemplatePath = GetPathSettings("Template",False,1)
  32.       bCancelTask = False
  33.       bDoKeepApplValues = False
  34.     CurOffice = 0
  35.     ImportDialogArea = LoadDialog("ImportWizard","ImportDialog")
  36.     ImportDialog = ImportDialogArea.Model
  37.     LoadLanguage()
  38.     FillStep_Welcome()
  39.     RepaintHeaderPreview()
  40.     SetStates()
  41.     ImportDialog.cbGoOn.DefaultButton = True
  42.     ImportDialogArea.Execute()
  43.     ImportDialogArea.Dispose()
  44.     End
  45.     Exit Sub
  46. RTError:
  47. '    Msgbox sRTErrorDesc, 16, sRTErrorHeader
  48. End Sub
  49.  
  50.  
  51. Sub SetStates
  52.     With ImportDialog
  53.         .OptSODocuments.State = 1
  54.         .OptMSDocuments.State = 0
  55.         .TemplateCheckbox.State = 1
  56.         .DocumentPathCheckbox.State = 0
  57.     End With
  58. End Sub
  59.  
  60.  
  61. Sub NextStep
  62. Dim iCurStep as Integer
  63.     If Not bDebugWizard Then
  64.         On Error Goto RTError
  65.     End If
  66.     bConversionIsRunnig = False
  67.     iCurStep = ImportDialog.Step
  68.     Select Case iCurStep
  69.         Case 1
  70.             FillStep_InputPaths(0, True)
  71.         Case 2
  72.             If CheckInputPaths Then
  73.                 SaveStep_InputPath
  74.                 If CurOffice < ApplCount - 1 Then
  75.                     CurOffice = CurOffice + 1
  76.                     TakeOverPathSettings()
  77.                     FillStep_InputPaths(CurOffice, False)
  78.                 Else
  79.                     FillStep_Summary()
  80.                 End If
  81.             End If
  82.         Case 3
  83.             FillStep_Progress()
  84.             Select Case WizardMode
  85.                 Case SBMICROSOFTMODE
  86.                     Call ConvertAllDocuments(MSFilterName())
  87.                 CASE SBXMLMODE
  88.                     Call ConvertAllDocuments(XMLFilterName())
  89.             End Select
  90.         Case 4
  91.             CancelTask(True)
  92.     End Select
  93.     ImportDialog.cbGoOn.DefaultButton = True
  94.     RepaintHeaderPreview()    
  95.     Exit Sub
  96. RTError:
  97.     Msgbox sRTErrorDesc, 16, sRTErrorHeader
  98. End Sub
  99.  
  100.  
  101. Sub PrevStep
  102. Dim iCurStep as Integer
  103.     If Not bDebugWizard Then
  104.         On Error Goto RTError
  105.     End If
  106.     bConversionIsRunnig = False
  107.     iCurStep = ImportDialog.Step
  108.     Select Case iCurStep
  109.         Case 4
  110.             ImportDialog.cbCancel.Label = sCancelButton
  111.             FillStep_Summary()
  112.         Case 3
  113.             FillStep_InputPaths(Applcount-1, False)
  114.         Case 2
  115.             SaveStep_InputPath
  116.             If CurOffice > 0 Then
  117.                 CurOffice = CurOffice - 1
  118.                 FillStep_InputPaths(CurOffice, False)
  119.             Else
  120.                 FillStep_Welcome()
  121.                 bDoKeepApplValues = True
  122.             End If
  123.     End Select
  124.     ImportDialog.cbGoOn.DefaultButton = True
  125.     RepaintHeaderPreview()    
  126.     Exit Sub
  127. RTError:
  128.     Msgbox sRTErrorDesc, 16, sRTErrorHeader
  129. End Sub
  130.  
  131.  
  132. Sub CallCancelTask()
  133.     CancelTask(True)
  134. End Sub
  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.cbCancel.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.     CurStep = ImportDialog.Step
  163.     If CurStep = 2 Then
  164.         sBitmapPath = SOBitmapPath & WizardMode & "-Import_" & CurStep & "-" & Applications(CurOffice,SBAPPLKEY) + 1 & ".bmp"
  165.     Else
  166.         sBitmapPath = SOBitmapPath & "Import_" & CurStep & ".bmp"
  167.     End If
  168.     ImportDialog.ImportPreview.ImageURL = sBitmapPath
  169. End Sub
  170.  
  171.  
  172. Sub ToggleCheckboxes(oEvent as Object)
  173. Dim bMSEnable as Boolean
  174.     bMSEnable = oEvent.Source.Model.Tag = "MS"
  175.     With ImportDialog
  176.         .ChkFirstSOApplication.Enabled = Not bMSEnable
  177.         .ChkSecondSOApplication.Enabled = Not bMSEnable
  178.         .ChkThirdSOApplication.Enabled = Not bMSEnable
  179.         .ChkFourthSOApplication.Enabled = Not bMSEnable
  180.         .ChkFirstMSApplication.Enabled = bMSEnable
  181.         .ChkSecondMSApplication.Enabled = bMSEnable
  182.         .ChkThirdMSApplication.Enabled = bMSEnable
  183.         .WelcomeTextLabel2.Enabled = bMSEnable
  184.     End With
  185.     bDoKeepApplValues = False
  186.     ToggleNextButton()
  187. End Sub
  188.  
  189.  
  190. Sub ToggleNextButton()
  191. Dim iCurStep as Integer
  192. Dim bDoEnable as Boolean
  193. Dim i as Integer
  194.     iCurStep = ImportDialog.Step
  195.     Select Case iCurStep
  196.         Case 1
  197.             With ImportDialog
  198.                 If .OptMSDocuments.State = 1 Then
  199.                       bDoEnable = .ChkFirstMSApplication.State = 1 Or .ChkSecondMSApplication.State = 1 Or .ChkThirdMSApplication.State = 1
  200.                 Else
  201.                       bDoEnable = .ChkFirstSOApplication.State = 1 Or .ChkSecondSOApplication.State = 1 Or .ChkThirdSOApplication.State = 1 Or .ChkFourthSOApplication.State = 1
  202.                 End If
  203.             End With
  204.             bDoKeepApplValues = False
  205.         Case 2
  206.             bDoEnable = CheckControlPath(ImportDialog.TemplateCheckbox, ImportDialog.TemplateImportPath, True)
  207.             bDoEnable = CheckControlPath(ImportDialog.DocumentPathCheckbox, ImportDialog.DocumentImportPath, bDoEnable)
  208.     End Select
  209.     ImportDialog.cbGoOn.Enabled = bDoEnable
  210. End Sub
  211.  
  212.  
  213. Sub TakeOverPathSettings()                    
  214. 'Takes over the Pathsettings from the first selected application to the next applications
  215.     If Applications(CurOffice,SBDOCSOURCE) = "" Then
  216.         Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
  217.         Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
  218.         If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then
  219.             Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
  220.             Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)                                            
  221.         Else
  222.             Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
  223.             Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)                    
  224.         End If
  225.     End If
  226. End Sub
  227. </script:module>