home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2003 March
/
PCWorld_2003-03_cd.bin
/
Software
/
Vyzkuste
/
openoffice
/
f_0263
/
DialogModul.xba
< prev
next >
Wrap
Extensible Markup Language
|
2002-02-19
|
19KB
|
501 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="DialogModul" script:language="StarBasic">Option Explicit
Public Const bDebugWizard = False
Public Const SBFIRSTAPPLCHECKED = 0
Public Const SBSECONDAPPLCHECKED = 1
Public Const SBTHIRDAPPLCHECKED = 2
Public Const SBFOURTHAPPLCHECKED = 3
Public WizardMode as String
Public Const SBMICROSOFTMODE = "MS"
Public Const SBXMLMODE = "SO"
' The absolute maximal Number of possible Applications
Public Const Twip = 425
Public Const SBMAXAPPLCOUNT = 4
Public MaxApplCount as Integer
Public CurOffice As Integer
Public SOBitmapPath As String
Public SOWorkPath As String
Public SOTemplatePath as String
Public bCancelTask As Boolean
Public bDoKeepApplValues as Boolean
Public iApplSection as Integer
Public oUcb as Object
Public PathSeparator as String
Public ApplCount as Integer
Public sKeyName(SBMAXAPPLCOUNT-1) as String
Public sValueName(SBMAXAPPLCOUNT-1) as String
Public sCRLF as String
Public MSFilterName(5,2) as String
Public XMLFilterName(7,2)
' e.g.:
' XMLFilterName(x,0) = "sdw" ' in documents we take the extensions; in SO-templates the appropriate Filtername
' XMLFilterName(x,1) = "swriter: StarWriter 5.0" ' the filtername of the target-format
' XMLFilterName(x,2) = "sxw" ' the target extension
Public Applications(SBMAXAPPLCOUNT-1,9)
Public Const SBAPPLCONVERT = 0
Public Const SBDOCCONVERT = 1
Public Const SBDOCRECURSIVE = 2
Public Const SBDOCSOURCE = 3
Public Const SBDOCTARGET = 4
Public Const SBTEMPLCONVERT = 5
Public Const SBTEMPLRECURSIVE = 6
Public Const SBTEMPLSOURCE = 7
Public Const SBTEMPLTARGET = 8
Public Const SBAPPLKEY = 9
' Application-relating Data are stored in this Array
' according to the following structure:
' Applications(X,0) = True/False (Application is to be converted)
' Applications(X,1) = True/False (Documents are to be converted)
' Applications(X,2) = True/False (Including Subdirectories)
' Applications(X,3) = "File:///..." (SourceUrl of the documents)
' Applications(X,4) = "File///:..." (TargetUrl of the documents)
' Applications(X,5) = True/False (Templates are to be converted)
' Applications(X,6) = True/False (Including Subdirectories)
' Applications(X,7) = "File:///..." (SourceUrl of the templates)
' Applications(X,8) = "File:///..." (TargetUrl of the templates)
' Applications(X,9) = 0 (Key to the original Index of the Applications)
Sub FillStep_Welcome()
Dim i as Integer
' bDoKeepApplValues = False
ImportDialogArea.Title = sTitle
With ImportDialog
.cmdHelp.Label = sHelpButton
.cmdCancel.Label = sCancelButton
.cmdBack.Label = sBackButton
.cmdGoOn.Label = sNextButton
.WelcomeTextLabel.Label = sWelcomeTextLabel1
.WelcomeTextLabel2.Label = sWelcomeTextLabel2
.WelcomeTextLabel3.Label = sWelcomeTextLabel3
.optMSDocuments.Label = sContainerName(0)
.chkMSApplication1.Label = sMsDocumentCheckbox(0)
.chkMSApplication2.Label = sMsDocumentCheckbox(1)
.chkMSApplication3.Label = sMsDocumentCheckbox(2)
.optSODocuments.Label = sContainerName(1)
.chkSOApplication1.Label = sSODocumentCheckbox(0)
.chkSOApplication2.Label = sSODocumentCheckbox(1)
.chkSOApplication3.Label = sSODocumentCheckbox(2)
.chkSOApplication4.Label = sSODocumentCheckbox(3)
.cmdBack.Enabled = False
.Step = 1
End With
CheckModuleInstallation()
ToggleNextButton()
End Sub
Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean)
Dim Index as Integer
Dim oNullObject as Object
If bStartup And Not bDoKeepApplValues Then
If ImportDialog.optMSDocuments.State = 1 Then
SetupMSConfiguration()
Else
SetupXMLConfiguration()
End If
' chkTemplatePath-Captions
GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
' DocumentCheckbox- Captions
GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
FillUpApplicationList()
End If
CurOffice = OfficeIndex
Index = Applications(CurOffice,SBAPPLKEY)
InitializePathsforCurrentApplication(Index)
With ImportDialog
.chkTemplatePath.Label = sTemplateCheckbox(Index)
.chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT))
.chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE))
.txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE))
.txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET))
.hlnDocuments.Label = sProgressMoreDocs
If WizardMode = SBXMLMODE Then
ImportDialogArea.Title = sTitle & " - " & sSODocumentCheckBox(Index)
Else
ImportDialogArea.Title = sTitle & " - " & sMSDocumentCheckBox(Index)
End If
If WizardMode = SBXMLMODE AND Index = 3 Then
' Note: SO-Helper Applications are partly treated like templates although they only have documents
.hlnTemplates.Label = sProgressMoreDocs
.chkTemplatePath.Label = sSOHelperDocuments(0,0)
.chkTemplatePath.Enabled = oFactoriesAccess.HasByName(sSOHelperDocuments(0,1))
.chkDocumentPath.Label = sSOHelperDocuments(1,0)
.chkDocumentPath.Enabled = oFactoriesAccess.HasByName(sSOHelperDocuments(1,1))
Else
.chkTemplatePath.Enabled = True
.chkDocumentPath.Enabled = True
.chkTemplatePath.Label = sTemplateCheckbox(Index)
.chkDocumentPath.Label = sDocumentCheckbox(Index)
.hlnTemplates.Label = sProgressMoreTemplates
End If
.chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT))
ToggleInputPaths(oNullObject,"Template")
ToggleInputPaths(oNullObject,"Document")
.chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE))
.txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE))
.txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET))
.cmdGoOn.Label = sNextButton
.cmdBack.Enabled = True
ImportDialog.Step = 2
End With
ImportDialogArea.GetControl("chkTemplatePath").SetFocus()
ToggleNextButton()
End Sub
Sub FillUpApplicationList()
Dim i as Integer
Dim a as Integer
Dim BoolValue as Boolean
If Not bDoKeepApplValues Then
a = 0
For i = 1 To ApplCount
If ImportDialog.optMSDocuments.State = 1 Then
BoolValue = ImportDialogArea.GetControl("chkMSApplication" & i).Model.State = 1
Else
BoolValue = ImportDialogArea.GetControl("chkSOApplication" & i).Model.State = 1
End If
Applications(a,SBAPPLCONVERT) = BoolValue
Applications(a,SBDOCCONVERT) = BoolValue
Applications(a,SBDOCRECURSIVE) = BoolValue
Applications(a,SBDOCSOURCE) = "" ' GetDefaultPath(i)
Applications(a,SBDOCTARGET) = "" ' SOWorkPath
Applications(a,SBTEMPLCONVERT) = BoolValue
Applications(a,SBTEMPLRECURSIVE) = BoolValue
Applications(a,SBTEMPLSOURCE) = "" ' GetTemplateDefaultPath(i)
Applications(a,SBTEMPLTARGET) = "" ' GetTargetTemplatePath(i)
Applications(a,SBAPPLKEY) = i-1
If BoolValue Then
a = a + 1
End If
Next i
ApplCount = a
End If
End Sub
Sub InitializePathsforCurrentApplication(i as Integer)
AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i))
AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath)
AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i))
AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i))
End Sub
Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String)
If Applications(CurOffice,Index) = "" Then
If CurOffice > 0 Then
Applications(CurOffice,Index) = Applications(CurOffice-1,Index)
Else
Applications(CurOffice,Index) = NewPath
End If
End If
End Sub
Sub SaveStep_InputPath()
Applications(CurOffice,SBDOCCONVERT) = ImportDialog.chkDocumentPath.State = 1
Applications(CurOffice,SBDOCRECURSIVE) = ImportDialog.chkDocumentSearchSubDir.State = 1
Applications(CurOffice,SBDOCSOURCE) = ConvertToURL(ImportDialog.txtDocumentImportPath.Text)
Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text)
Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State = 1
Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State = 1
Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text)
Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text)
End Sub
Sub ToggleInputPaths(aEvent as Object, Optional sDocType)
Dim bDoEnable as Boolean
Dim sLocDocType as String
Dim oCheckBox as Object
If Not IsNull(aEvent) Then
sLocDocType = aEvent.Source.Model.Tag
Else
sLocDocType = sDocType
End If
With ImportDialogArea
oCheckBox = .GetControl("chk" & sLocDocType & "Path").Model
bDoEnable = oCheckBox.State = 1 And oCheckBox.Enabled
.GetControl("lbl" & sLocDocType & "Import").Model.Enabled = bDoEnable
.GetControl("lbl" & sLocDocType & "Export").Model.Enabled = bDoEnable
.GetControl("txt" & sLocDocType & "ImportPath").Model.Enabled = bDoEnable
.GetControl("txt" & sLocDocType & "ExportPath").Model.Enabled = bDoEnable
.GetControl("chk" & sLocDocType & "SearchSubDir").Model.Enabled = bDoEnable
.GetControl("cmd" & sLocDocType & "Import").Model.Enabled = bDoEnable
.GetControl("cmd" & sLocDocType & "Export").Model.Enabled = bDoEnable
End With
ToggleNextButton()
End Sub
Function MakeSummaryString()
Dim sTmpText As String
Dim i as Integer
Dim Index as Integer
Dim sAddText as String
For i = 0 To ApplCount -1
Index = Applications(i,SBAPPLKEY)
If Applications(i,SBTEMPLCONVERT) Then
' Templates are to be converted
sAddText = ""
If WizardMode = SBMICROSOFTMODE Then
sAddText = sSumMSTemplates(Index) & sCRLF
Else
sAddText = sSumSOTemplates(Index) & sCRLF
End If
sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBTEMPLSOURCE)) & sCRLF
If Applications(i,SBTEMPLRECURSIVE) Then
' Including Subdirectories
sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
End If
sTmpText = sTmpText & sSumSaveDocuments & sCRLF
sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBTEMPLTARGET)) & sCRLF
sTmpText = sTmpText & sCRLF
End If
If Applications(i,SBDOCCONVERT) Then
' Documents are to be converted
If WizardMode = SBMICROSOFTMODE Then
sAddText = sSumMSDocuments(Index) & sCRLF
Else
sAddText = sSumSODocuments(Index) & sCRLF
End If
sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBDOCSOURCE)) & sCRLF
If Applications(i,SBDOCRECURSIVE) Then
' Including Subdirectories
sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
End If
sTmpText = sTmpText & sSumSaveDocuments & sCRLF
sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBDOCTARGET)) & sCRLF
sTmpText = sTmpText & sCRLF
End If
Next i
MakeSummaryString = sTmpText
End Function
Sub FillStep_Summary()
' Todo: Angabe ├╝ber die Vorlagengruppen,bzw. Template-Exportpfad
ImportDialogArea.Title = sTitle
With ImportDialog
.SummaryTextbox.Text = MakeSummaryString()
.cmdGoOn.Enabled = .SummaryTextbox.Text <> ""
.cmdGoOn.Label = sBeginButton
.SummaryHeaderLabel.Label = sSummaryHeader
.Step = 3
End With
ImportDialogArea.GetControl("SummaryHeaderLabel").SetFocus()
End Sub
Sub FillStep_Progress()
With ImportDialog
.cmdBack.Enabled = False
.cmdGoOn.Enabled = False
.hlnProgress.Label = sProgressPage_1
.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
.LabelRetrieval.Label = sProgressPage_2
.LabelCurProgress.Label = sProgressPage_3
.LabelCurDocumentRetrieval.Label = ""
.LabelCurTemplateRetrieval.Label = ""
.LabelCurDocument.Label = ""
.Step = 4
End With
End Sub
Sub SetupMSConfiguration()
iApplSection = 0
Wizardmode = SBMICROSOFTMODE
MaxApplCount = 3
ApplCount = 3
sKeyName(0) = "Software\Microsoft\Office\8.0\Word\Options"
sKeyName(1) = "Software\Microsoft\Office\8.0\Excel\Microsoft Excel"
sKeyName(2) = "Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default"
sValueName(0) = "DOC-PATH"
sValueName(1) = "DefaultPath"
sValueName(2) = ""
' See definition of Filtername-Array about meaning of fields
MSFilterName(0,0) = "doc"
MSFilterName(0,1) = "swriter: StarOffice XML (Writer)"
MSFilterName(0,2) = "sxw"
MSFilterName(1,0) = "xls"
MSFilterName(1,1) = "scalc: StarOffice XML (Calc)"
MSFilterName(1,2) = "sxc"
MSFilterName(2,0) = "ppt"
MSFilterName(2,1) = "simpress: StarOffice XML (Impress)"
MSFilterName(2,2) = "sxi"
MSFilterName(3,0) = "dot"
MSFilterName(3,1) = "swriter: writer_StarOffice_XML_Writer_Template"
MSFilterName(3,2) = "stw"
MSFilterName(4,0) = "xlt"
MSFilterName(4,1) = "scalc: calc_StarOffice_XML_Calc_Template"
MSFilterName(4,2) = "stc"
MSFilterName(5,0) = "pot"
MSFilterName(5,1) = "simpress: impress_StarOffice_XML_Impress_Template"
MSFilterName(5,2) = "sti"
End Sub
Sub SetupXMLConfiguration()
iApplSection = 1000
Wizardmode = SBXMLMODE
ApplCount = 4
MaxApplCount = 4
XMLFilterName(0,0) = "sdw"
XMLFilterName(0,1) = "swriter: StarOffice XML (Writer)"
XMLFilterName(0,2) = "sxw"
XMLFilterName(1,0) = "sdc"
XMLFilterName(1,1) = "scalc: StarOffice XML (Calc)"
XMLFilterName(1,2) = "sxc"
' Todo: Gepacktes 'sdp' Format ber├╝cksichtigen
XMLFilterName(2,0) = "sdd|sda"
XMLFilterName(2,1) = "simpress: StarOffice XML (Impress)|sdraw: StarOffice XML (Draw)"
XMLFilterName(2,2) = "sxi|sxd"
XMLFilterName(3,0) = "smf"
XMLFilterName(3,1) = "smath: StarOffice XML (Math)"
XMLFilterName(3,2) = "sxm"
XMLFilterName(4,0) = "application/vnd.stardivision.writer;application/x-starwriter|application/vnd.stardivision.writer/web"
XMLFilterName(4,1) = "swriter: writer_StarOffice_XML_Writer_Template|swriter/web: writer_web_StarOffice_XML_Writer_Web_Template"
XMLFilterName(4,2) = "stw|stw"
XMLFilterName(5,0) = "application/vnd.stardivision.calc;application/x-starcalc"
XMLFilterName(5,1) = "scalc: calc_StarOffice_XML_Calc_Template"
XMLFilterName(5,2) = "stc"
XMLFilterName(6,0) = "application/vnd.stardivision.impress;application/x-starimpress|application/vnd.stardivision.draw;application/x-stardraw"
XMLFilterName(6,1) = "simpress: impress_StarOffice_XML_Impress_Template|sdraw: draw_StarOffice_XML_Draw_Template"
XMLFilterName(6,2) = "sti|std"
XMLFilterName(7,0) = "sgl"
XMLFilterName(7,1) = "swriter/GlobalDocument: writer_globaldocument_StarOffice_XML_Writer_GlobalDocument"
XMLFilterName(7,2) = "sxg"
End Sub
Function CheckControlPath(oCheckbox as Object, oTextBox as Object, ByVal bDoEnable as Boolean)
Dim sPath as String
If Not bDoEnable Then
CheckControlPath = False
ElseIf oCheckbox.State = 0 Then
CheckControlPath = True
Else
sPath = ConvertToUrl(Trim(oTextBox.Text)
CheckControlPath = oUcb.Exists(sPath)
End If
End Function
Function CheckInputPaths() as Boolean
Dim bChangePage as Boolean
bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateImportPath, True, False, sTitle, False)
bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateExportPath, bChangePage, True, sTitle, False)
bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentImportPath, bChangePage, False, sTitle, False)
bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentExportPath, bChangePage, True, sTitle, False)
CheckInputPaths = bChangePage
End Function
Function CheckTextBoxPath(oTextBox as Object, ByVal bCheck as Boolean, bCreateNew as Boolean, sTitle as String, bgetResources as Boolean) as Boolean
Dim iCreate as Integer
Dim sQueryMessage as String
Dim sUrlPath as String
Dim sMessageNoDir as String
Dim sShowPath as String
Dim oLocUcb as Object
oLocUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
If bGetResources Then
If InitResources("ImportWizard","imp") then
sNoDirCreation = GetResText(1050)
sMsgDirNotThere = GetResText(1051)
sQueryForNewCreation = GetResText(1052)
Else
CheckTextBoxPath() = False
Exit Function
End If
End If
If oTextBox.Enabled Then
If bCheck Then
sShowPath = oTextBox.Text
sUrlPath = ConvertToUrl(sShowPath)
If Not oLocUcb.Exists(sUrlPath) Then
If Not bCreateNew Then
' Sourcedirectories must be existing, Targetdirectories may be created new
sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1")
Msgbox(sQueryMessage,16,sTitle)
CheckTextBoxPath() = False
Exit Function
Else
sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1")
sQueryMessage = sQueryMessage & Chr(13) & sQueryForNewCreation
iCreate = Msgbox (sQueryMessage, 36, sTitle)
If iCreate = 6 Then
On Local Error Goto NOVALIDPATH
oLocUcb.CreateFolder(sUrlPath)
If Not oLocUcb.Exists(sUrlPath) Then
Goto NOVALIDPATH
End If
Else
CheckTextBoxPath() = False
Exit Function
End If
End If
End If
CheckTextBoxPath() = True
Else
CheckTextBoxPath() = False
End If
Else
CheckTextBoxPath() = True
End If
Exit Function
NOVALIDPATH:
sMessageNoDir = ReplaceString(sNoDirCreation, sShowPath, "%1")
Msgbox(sMessageNoDir, 16, sTitle)
CheckTextBoxPath() = False
End Function
Sub InitializeProgressPage(oDialog as Object)
'oDialog.LabelRetrieval.Label = ""
'oDialog.LabelCurProgress.Label = ""
oDialog.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL
oDialog.LabelCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD
End Sub
Sub TakoverFolderName(aEvent as Object)
Dim RefControlName as String
Dim oRefControl
RefControlName = aEvent.Source.Model.Tag
oRefControl = ImportDialogArea.GetControl(RefControlName)
GetFolderName(oRefControl.Model)
ToggleNextButton()
End Sub</script:module>