home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2003 July & August
/
PCWorld_2003-07-08_cd.bin
/
Software
/
Komercni
/
Openoffice
/
f_0272
/
Main.xba
< prev
next >
Wrap
Extensible Markup Language
|
2002-02-19
|
8KB
|
265 lines
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Main" script:language="StarBasic">Option Explicit
' ***** BASIC *****
' Todo: Problematik der VBA-Makros, die angeblich nicht mit abgespeichert werden koennen.
' Evt. Erkennen der Arbeitsverzeichnisse von MS Office
Public HeaderPreviews(4) as Object
Public ImportDialog as Object
Public ImportDialogArea as Object
Public bSetFonts as Boolean
' If the ProgressPage ist already on Top The Dialog will be immediately closed when this flag is
' set to False
Public bConversionIsRunnig as Boolean
Public oFactoriesAccess as Object
Public RetValue as Integer
Sub Main()
If Not bDebugWizard Then
On Local Error Goto RTError
End If
BasicLibraries.LoadLibrary("Tools")
RetValue = 10
bSetFonts = False
bConversionIsRunnig = False
If bSetFonts Then
BasicLibraries.LoadLibrary("Translater")
GetFontNames()
End If
sCRLF = CHR(10) & CHR(13)
oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oFactoriesAccess = GetRegistryKeyContent("org.openoffice.Setup/Office/Factories")
SOBitmapPath = GetOfficeSubPath("Template", "wizard/bitmap")
SOWorkPath = GetPathSettings("Work", False)
SOTemplatePath = GetPathSettings("Template",False,1)
bCancelTask = False
bDoKeepApplValues = False
CurOffice = 0
ImportDialogArea = LoadDialog("ImportWizard","ImportDialog")
ImportDialog = ImportDialogArea.Model
LoadLanguage()
WizardMode = SBXMLMODE
MaxApplCount = 4
FillStep_Welcome()
RepaintHeaderPreview()
ImportDialog.cmdGoOn.DefaultButton = True
ImportDialogArea.GetControl("optSODocuments").SetFocus()
RetValue = ImportDialogArea.Execute()
If RetValue = 0 Then
CallCancelTask()
End If
ImportDialogArea.Dispose()
End
Exit Sub
RTError:
Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub
Sub NextStep
Dim iCurStep as Integer
If Not bDebugWizard Then
On Error Goto RTError
End If
bConversionIsRunnig = False
iCurStep = ImportDialog.Step
Select Case iCurStep
Case 1
FillStep_InputPaths(0, True)
Case 2
If CheckInputPaths Then
SaveStep_InputPath
If CurOffice < ApplCount - 1 Then
CurOffice = CurOffice + 1
TakeOverPathSettings()
FillStep_InputPaths(CurOffice, False)
Else
FillStep_Summary()
End If
End If
Case 3
FillStep_Progress()
Select Case WizardMode
Case SBMICROSOFTMODE
Call ConvertAllDocuments(MSFilterName())
CASE SBXMLMODE
Call ConvertAllDocuments(XMLFilterName())
End Select
Case 4
CancelTask(True)
End Select
ImportDialog.cmdGoOn.DefaultButton = True
RepaintHeaderPreview()
Exit Sub
RTError:
Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub
Sub PrevStep()
Dim iCurStep as Integer
If Not bDebugWizard Then
On Error Goto RTError
End If
bConversionIsRunnig = False
iCurStep = ImportDialog.Step
Select Case iCurStep
Case 4
ImportDialog.cmdCancel.Label = sCancelButton
FillStep_Summary()
Case 3
FillStep_InputPaths(Applcount-1, False)
Case 2
SaveStep_InputPath
If CurOffice > 0 Then
CurOffice = CurOffice - 1
FillStep_InputPaths(CurOffice, False)
Else
FillStep_Welcome()
bDoKeepApplValues = True
End If
End Select
ImportDialog.cmdGoOn.DefaultButton = True
RepaintHeaderPreview()
Exit Sub
RTError:
Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub
Sub CallCancelTask()
CancelTask(True)
End Sub
Sub CancelTask(bCloseDialog as Boolean)
If bConversionIsRunnig Then
If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then
If bCloseDialog Then
ImportDialogArea.EndExecute
End If
bCancelTask = True
Else
bCancelTask = False
ImportDialog.cmdCancel.Enabled = True
End If
Else
ImportDialogArea.EndExecute()
End If
End Sub
Sub TemplateDirSearchDialog()
CallDirSearchDialog(ImportDialog.TemplateImportPath)
End Sub
Sub RepaintHeaderPreview()
Dim Bitmap As Object
Dim CurStep as Integer
Dim sBitmapPath as String
Dim LocPrefix as String
CurStep = ImportDialog.Step
LocPrefix = WizardMode
LocPrefix = ReplaceString(LocPrefix,"XML", "SO")
If CurStep = 2 Then
sBitmapPath = SOBitmapPath & LocPrefix & "-Import_" & CurStep & "-" & Applications(CurOffice,SBAPPLKEY) + 1 & ".bmp"
Else
sBitmapPath = SOBitmapPath & "Import_" & CurStep & ".bmp"
End If
ImportDialog.ImportPreview.ImageURL = sBitmapPath
End Sub
Sub CheckModuleInstallation()
Dim i as Integer
For i = 1 To MaxApplCount
ImportDialogArea.GetControl("chk" & WizardMode & "Application" & i).Model.Enabled = Abs(CheckInstalledModule(i-1))
Next i
End Sub
Function CheckInstalledModule(Index as Integer) as Boolean
Dim ModuleName as String
Dim NameList() as String
Dim MaxIndex as Integer
Dim i as Integer
ModuleName = ModuleList(Index)
If Instr(1,ModuleName,"/") <> 0 Then
NameList() = ArrayoutOfString(ModuleName,"/", MaxIndex)
For i = 0 To MaxIndex
If Not oFactoriesAccess.HasByName(NameList(i)) Then
CheckInstalledModule() = False
Exit Function
End If
Next i
CheckInstalledModule() = True
Else
CheckInstalledModule() = oFactoriesAccess.HasByName(ModuleName)
End If
End Function
Sub ToggleCheckboxes(oEvent as Object)
Dim bMSEnable as Boolean
WizardMode = oEvent.Source.Model.Tag
bMSEnable = WizardMode = "MS"
If WizardMode = "MS" Then
MaxApplCount = 3
Else
MaxApplCount = 4
End If
With ImportDialogArea
.GetControl("chkSOApplication1").Model.Enabled = Not bMSEnable
.GetControl("chkSOApplication2").Model.Enabled = Not bMSEnable
.GetControl("chkSOApplication3").Model.Enabled = Not bMSEnable
.GetControl("chkSOApplication4").Model.Enabled = Not bMSEnable
.GetControl("chkMSApplication1").Model.Enabled = bMSEnable
.GetControl("chkMSApplication2").Model.Enabled = bMSEnable
.GetControl("chkMSApplication3").Model.Enabled = bMSEnable
End With
CheckModuleInstallation()
ImportDialog.WelcomeTextLabel2.Enabled = bMSEnable
bDoKeepApplValues = False
ToggleNextButton()
End Sub
Sub ToggleNextButton()
Dim iCurStep as Integer
Dim bDoEnable as Boolean
Dim i as Integer
iCurStep = ImportDialog.Step
Select Case iCurStep
Case 1
With ImportDialog
If .optMSDocuments.State = 1 Then
bDoEnable = .chkMSApplication1.State = 1 Or .chkMSApplication2.State = 1 Or .chkMSApplication3.State = 1
Else
bDoEnable = .chkSOApplication1.State = 1 Or .chkSOApplication2.State = 1 Or .chkSOApplication3.State = 1 Or .chkSOApplication4.State = 1
End If
End With
bDoKeepApplValues = False
Case 2
bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
End Select
ImportDialog.cmdGoOn.Enabled = bDoEnable
End Sub
Sub TakeOverPathSettings()
'Takes over the Pathsettings from the first selected application to the next applications
If Applications(CurOffice,SBDOCSOURCE) = "" Then
Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then
Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)
Else
Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)
End If
End If
End Sub</script:module>