home *** CD-ROM | disk | FTP | other *** search
/ Freelog 52 / Freelog052.iso / Dossier / OpenOffice / f_0066 / DialogModul.xba < prev    next >
Extensible Markup Language  |  2003-06-12  |  25KB  |  558 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="DialogModul" script:language="StarBasic">Option Explicit
  4.  
  5. Public Const bDebugWizard = True
  6.  
  7. Public Const SBFIRSTAPPLCHECKED = 0
  8. Public Const SBSECONDAPPLCHECKED = 1
  9. Public Const SBTHIRDAPPLCHECKED = 2
  10. Public Const SBFOURTHAPPLCHECKED = 3
  11. Public WizardMode as String
  12. Public Const SBMICROSOFTMODE = "MS"
  13. Public Const SBXMLMODE = "SO"
  14. ' The absolute maximal Number of possible Applications
  15. Public Const Twip = 425
  16. Public Const SBMAXAPPLCOUNT = 4
  17. Public MaxApplCount as Integer
  18. Public CurOffice As Integer
  19. Public SOBitmapPath As String
  20. Public SOWorkPath As String
  21. Public SOTemplatePath as String
  22. Public bCancelTask As Boolean
  23. Public bDoKeepApplValues as Boolean
  24. Public iApplSection as Integer
  25. Public oUcb as Object
  26. Public PathSeparator as String
  27.  
  28. Public ApplCount as Integer
  29. Public sKeyName(SBMAXAPPLCOUNT-1) as String
  30. Public sValueName(SBMAXAPPLCOUNT-1) as String
  31. Public sCRLF as String
  32. Public MSFilterName(5,2) as String
  33. Public XMLFilterName(7,2) as String
  34.  
  35. ' e.g.:
  36. ' XMLFilterName(x,0) = "sdw"                         ' in documents we take the extensions; in SO-templates the appropriate Filtername
  37. ' XMLFilterName(x,1) = "swriter: StarWriter 5.0"     ' the filtername of the target-format
  38. ' XMLFilterName(x,2) = "sxw"                         ' the target extension
  39.  
  40. Public Applications(SBMAXAPPLCOUNT-1,9)
  41.  
  42. Public Const SBAPPLCONVERT = 0
  43. Public Const SBDOCCONVERT = 1
  44. Public Const SBDOCRECURSIVE = 2
  45. Public Const SBDOCSOURCE = 3
  46. Public Const SBDOCTARGET = 4
  47. Public Const SBTEMPLCONVERT = 5
  48. Public Const SBTEMPLRECURSIVE = 6
  49. Public Const SBTEMPLSOURCE = 7
  50. Public Const SBTEMPLTARGET = 8
  51. Public Const SBAPPLKEY = 9
  52.  
  53. ' Application-relating Data are stored in this Array
  54. ' according to the following structure:
  55. ' Applications(X,0) = True/False         (Application is to be converted)
  56. ' Applications(X,1) = True/False         (Documents are to be converted)
  57. ' Applications(X,2) = True/False        (Including Subdirectories)
  58. ' Applications(X,3) = "File:///..."        (SourceUrl of the documents)
  59. ' Applications(X,4) = "File///:..."        (TargetUrl of the documents)
  60. ' Applications(X,5) = True/False        (Templates are to be converted)
  61. ' Applications(X,6) = True/False         (Including Subdirectories)
  62. ' Applications(X,7) = "File:///..."        (SourceUrl of the templates)
  63. ' Applications(X,8) = "File:///..."     (TargetUrl of the templates)
  64. ' Applications(X,9) = 0                    (Key to the original Index of the Applications)
  65.  
  66. Public Const SBMAXEXTENSIONLENGTH = 7
  67.  
  68.  
  69. Sub FillStep_Welcome()
  70. Dim i as Integer
  71. '    bDoKeepApplValues = False
  72.     ImportDialogArea.Title = sTitle
  73.     With ImportDialog
  74.         .cmdHelp.Label = sHelpButton
  75.         .cmdCancel.Label = sCancelButton
  76.         .cmdBack.Label = sBackButton
  77.         .cmdGoOn.Label = sNextButton
  78.         .WelcomeTextLabel.Label = sWelcomeTextLabel1
  79.         .WelcomeTextLabel2.Label = sWelcomeTextLabel2
  80.         .WelcomeTextLabel3.Label = sWelcomeTextLabel3
  81.  
  82.         .optMSDocuments.Label = sContainerName(0)
  83.         .chkMSApplication1.Label = sMsDocumentCheckbox(0)
  84.         .chkMSApplication2.Label = sMsDocumentCheckbox(1)
  85.         .chkMSApplication3.Label = sMsDocumentCheckbox(2)
  86.  
  87.         .optSODocuments.Label = sContainerName(1)
  88.         .chkSOApplication1.Label = sSODocumentCheckbox(0)
  89.         .chkSOApplication2.Label = sSODocumentCheckbox(1)
  90.         .chkSOApplication3.Label = sSODocumentCheckbox(2)
  91.         .chkSOApplication4.Label = sSODocumentCheckbox(3)
  92.         .cmdBack.Enabled = False
  93.         .Step = 1
  94.         
  95.         If Not oFactoryKey.hasbyName("com.sun.star.text.TextDocument") Then
  96.             .chkLogfile.State = 0
  97.             .chkLogfile.Enabled = False
  98.         End If    
  99.     End With
  100.     CheckModuleInstallation()
  101.     ToggleNextButton()
  102. End Sub
  103.  
  104.  
  105. Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean)
  106. Dim Index as Integer
  107. Dim oNullObject as Object
  108.     If bStartup And Not bDoKeepApplValues Then
  109.         If ImportDialog.optMSDocuments.State = 1 Then
  110.             SetupMSConfiguration()
  111.         Else
  112.             SetupXMLConfiguration()
  113.         End If
  114.         ' chkTemplatePath-Captions
  115.         GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
  116.         ' DocumentCheckbox- Captions
  117.         GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
  118.         FillUpApplicationList()
  119.     End If
  120.     CurOffice = OfficeIndex
  121.     Index = Applications(CurOffice,SBAPPLKEY)
  122.     InitializePathsforCurrentApplication(Index)
  123.     With ImportDialog
  124.         .chkTemplatePath.Label = sTemplateCheckbox(Index)
  125.         .chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT))
  126.            .chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE))
  127.         .txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE))
  128.         .txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET))
  129.         .hlnDocuments.Label = sProgressMoreDocs
  130.         If WizardMode = SBXMLMODE Then
  131.             ImportDialogArea.Title = sTitle & " - " & sSODocumentCheckBox(Index)
  132.         Else
  133.             ImportDialogArea.Title = sTitle & " - " & sMSDocumentCheckBox(Index)
  134.         End If
  135.         If WizardMode = SBXMLMODE AND Index = 3 Then
  136.             ' Note: SO-Helper Applications are partly treated like templates although they only have documents
  137.             .hlnTemplates.Label = sProgressMoreDocs
  138.             .chkTemplatePath.Label = sSOHelperDocuments(0,0)
  139.             .chkTemplatePath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(0,1))
  140.             .chkDocumentPath.Label = sSOHelperDocuments(1,0)
  141.             .chkDocumentPath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(1,1))
  142.         Else
  143.             .chkTemplatePath.Enabled = True
  144.             .chkDocumentPath.Enabled = True
  145.             .chkTemplatePath.Label = sTemplateCheckbox(Index)
  146.             .chkDocumentPath.Label = sDocumentCheckbox(Index)
  147.             .hlnTemplates.Label = sProgressMoreTemplates
  148.         End If
  149.         .chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT))
  150.         ToggleInputPaths(oNullObject,"Template")
  151.         ToggleInputPaths(oNullObject,"Document")        
  152.         .chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE))
  153.         .txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE))
  154.         .txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET))
  155.         .cmdGoOn.Label = sNextButton
  156.         .cmdBack.Enabled = True
  157.         ImportDialog.Step = 2
  158.     End With
  159.     ImportDialogArea.GetControl("chkTemplatePath").SetFocus()
  160.     ToggleNextButton()
  161. End Sub
  162.  
  163.  
  164. Sub FillUpApplicationList()
  165. Dim i as Integer
  166. Dim a as Integer
  167. Dim BoolValue as Boolean
  168.     If Not bDoKeepApplValues Then
  169.         a = 0
  170.         For i = 1 To ApplCount
  171.             If ImportDialog.optMSDocuments.State = 1 Then
  172.                 BoolValue = ImportDialogArea.GetControl("chkMSApplication" & i).Model.State = 1
  173.             Else
  174.                 BoolValue = ImportDialogArea.GetControl("chkSOApplication" & i).Model.State = 1
  175.             End If
  176.             Applications(a,SBAPPLCONVERT) = BoolValue
  177.             Applications(a,SBDOCCONVERT) = BoolValue
  178.             Applications(a,SBDOCRECURSIVE) = BoolValue
  179.             Applications(a,SBDOCSOURCE) = ""            ' GetDefaultPath(i)
  180.             Applications(a,SBDOCTARGET) = ""            ' SOWorkPath
  181.             Applications(a,SBTEMPLCONVERT) = BoolValue
  182.             Applications(a,SBTEMPLRECURSIVE) = BoolValue
  183.             Applications(a,SBTEMPLSOURCE) = ""             ' GetTemplateDefaultPath(i)
  184.             Applications(a,SBTEMPLTARGET) = ""             ' GetTargetTemplatePath(i)
  185.             Applications(a,SBAPPLKEY) = i-1
  186.             If BoolValue Then 
  187.                 a = a + 1
  188.             End If
  189.         Next i
  190.         ApplCount = a
  191.     End If
  192. End Sub
  193.  
  194.  
  195. Sub InitializePathsforCurrentApplication(i as Integer)
  196.     AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i))
  197.     AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath)
  198.     AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i))
  199.     AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i))
  200. End Sub
  201.  
  202.  
  203. Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String)
  204.     If Applications(CurOffice,Index) = "" Then
  205.         If CurOffice > 0 Then
  206.             Applications(CurOffice,Index) = Applications(CurOffice-1,Index)
  207.         Else
  208.             Applications(CurOffice,Index) = NewPath
  209.         End If
  210.     End If
  211. End Sub
  212.  
  213.  
  214. Sub SaveStep_InputPath()
  215.     Applications(CurOffice,SBDOCCONVERT)  = ImportDialog.chkDocumentPath.State = 1
  216.     Applications(CurOffice,SBDOCRECURSIVE)  = ImportDialog.chkDocumentSearchSubDir.State = 1
  217.     Applications(CurOffice,SBDOCSOURCE)  = ConvertToURL(ImportDialog.txtDocumentImportPath.Text)
  218.     Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text)
  219.     Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State = 1
  220.     Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State = 1
  221.     Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text)
  222.     Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text)
  223. End Sub
  224.  
  225.  
  226. Sub ToggleInputPaths(aEvent as Object, Optional sDocType)
  227. Dim bDoEnable as Boolean
  228. Dim sLocDocType as String
  229. Dim oCheckBox as Object
  230.     If Not IsNull(aEvent) Then
  231.         sLocDocType = aEvent.Source.Model.Tag
  232.     Else
  233.         sLocDocType = sDocType
  234.     End If
  235.     With ImportDialogArea
  236.         oCheckBox = .GetControl("chk" & sLocDocType & "Path").Model
  237.         bDoEnable = oCheckBox.State = 1 And oCheckBox.Enabled
  238.         .GetControl("lbl" & sLocDocType & "Import").Model.Enabled = bDoEnable
  239.         .GetControl("lbl" & sLocDocType & "Export").Model.Enabled = bDoEnable
  240.         .GetControl("txt" & sLocDocType & "ImportPath").Model.Enabled = bDoEnable
  241.         .GetControl("txt" & sLocDocType & "ExportPath").Model.Enabled = bDoEnable
  242.         .GetControl("chk" & sLocDocType & "SearchSubDir").Model.Enabled = bDoEnable
  243.         .GetControl("cmd" & sLocDocType & "Import").Model.Enabled = bDoEnable
  244.         .GetControl("cmd" & sLocDocType & "Export").Model.Enabled = bDoEnable
  245.     End With
  246.     ToggleNextButton()
  247. End Sub
  248.  
  249.  
  250. Function MakeSummaryString()
  251. Dim sTmpText As String
  252. Dim i as Integer
  253. Dim Index as Integer
  254. Dim sAddText as String
  255.     For i = 0 To ApplCount -1
  256.         Index = Applications(i,SBAPPLKEY)
  257.         If     Applications(i,SBTEMPLCONVERT) Then
  258.             ' Templates are to be converted
  259.             sAddText = ""
  260.             If WizardMode = SBMICROSOFTMODE Then
  261.                 sAddText = sSumMSTemplates(Index) & sCRLF
  262.             Else
  263.                 sAddText = sSumSOTemplates(Index) & sCRLF            
  264.             End If
  265.             sTmpText = sTmpText & sAddText &  ConvertFromUrl(Applications(i,SBTEMPLSOURCE)) & sCRLF
  266.             If Applications(i,SBTEMPLRECURSIVE) Then
  267.                 ' Including Subdirectories
  268.                 sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
  269.             End If
  270.             sTmpText = sTmpText & sSumSaveDocuments & sCRLF
  271.             sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBTEMPLTARGET)) & sCRLF
  272.             sTmpText = sTmpText & sCRLF
  273.         End If
  274.  
  275.         If Applications(i,SBDOCCONVERT) Then
  276.             ' Documents are to be converted
  277.             If WizardMode = SBMICROSOFTMODE Then
  278.                 sAddText = sSumMSDocuments(Index) & sCRLF
  279.             Else
  280.                 sAddText = sSumSODocuments(Index) & sCRLF            
  281.             End If
  282.             sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBDOCSOURCE)) & sCRLF
  283.  
  284.             If Applications(i,SBDOCRECURSIVE) Then
  285.                 ' Including Subdirectories
  286.                 sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
  287.             End If
  288.  
  289.             sTmpText = sTmpText & sSumSaveDocuments & sCRLF
  290.             sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBDOCTARGET)) & sCRLF
  291.             sTmpText = sTmpText & sCRLF
  292.         End If
  293.     Next i
  294.     MakeSummaryString = sTmpText
  295. End Function
  296.  
  297.  
  298. Sub FillStep_Summary()
  299.     ImportDialogArea.Title = sTitle
  300.     With ImportDialog
  301.         .SummaryTextbox.Text = MakeSummaryString()
  302.         .cmdGoOn.Enabled = .SummaryTextbox.Text <> ""
  303.         .cmdGoOn.Label = sBeginButton
  304.         .SummaryHeaderLabel.Label = sSummaryHeader
  305.         .Step = 3
  306.     End With
  307.     ImportDialogArea.GetControl("SummaryHeaderLabel").SetFocus()                    
  308. End Sub
  309.  
  310.  
  311. Sub FillStep_Progress()
  312.     With ImportDialog
  313.         .cmdBack.Enabled = False
  314.         .cmdGoOn.Enabled = False
  315.         .hlnProgress.Label = sProgressPage_1
  316.         .LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
  317.             .LabelRetrieval.Label = sProgressPage_2
  318.             .LabelCurProgress.Label = sProgressPage_3
  319.             .LabelCurDocumentRetrieval.Label = ""
  320.             .LabelCurTemplateRetrieval.Label = ""
  321.            .LabelCurDocument.Label = ""
  322.         .Step = 4
  323.     End With
  324.     ImportDialogArea.GetControl("LabelRetrieval").SetFocus()
  325.     If ImportDialog.chkLogfile.State = 1 Then
  326.         ImportDialog.cmdShowLogFile.DefaultButton = True
  327.     End If
  328. End Sub
  329.  
  330.  
  331. Sub    SetupMSConfiguration()
  332.     iApplSection = 0
  333.     Wizardmode = SBMICROSOFTMODE
  334.     MaxApplCount = 3
  335.     ApplCount = 3
  336.  
  337.     sKeyName(0) = "Software\Microsoft\Office\8.0\Word\Options"
  338.     sKeyName(1) = "Software\Microsoft\Office\8.0\Excel\Microsoft Excel"
  339.     sKeyName(2) = "Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default"
  340.  
  341.     sValueName(0) = "DOC-PATH"
  342.     sValueName(1) = "DefaultPath"
  343.     sValueName(2) = ""
  344.  
  345. ' See definition of Filtername-Array about meaning of fields
  346.     MSFilterName(0,0) = "doc"
  347.     MSFilterName(0,1) = "StarOffice XML (Writer)"
  348.     MSFilterName(0,2) = "sxw"
  349.  
  350.     MSFilterName(1,0) = "xls"
  351.     MSFilterName(1,1) = "StarOffice XML (Calc)"
  352.     MSFilterName(1,2) = "sxc"
  353.  
  354.     MSFilterName(2,0) = "ppt"
  355.     MSFilterName(2,1) = "StarOffice XML (Impress)"
  356.     MSFilterName(2,2) = "sxi"
  357.  
  358.     MSFilterName(3,0) = "dot"
  359.     MSFilterName(3,1) = "writer_StarOffice_XML_Writer_Template"
  360.     MSFilterName(3,2) = "stw"
  361.  
  362.     MSFilterName(4,0) = "xlt"
  363.     MSFilterName(4,1) = "calc_StarOffice_XML_Calc_Template"
  364.     MSFilterName(4,2) = "stc"
  365.  
  366.     MSFilterName(5,0) = "pot"
  367.     MSFilterName(5,1) = "impress_StarOffice_XML_Impress_Template"
  368.     MSFilterName(5,2) = "sti"
  369. End Sub
  370.  
  371.  
  372.  
  373. ' This is an extract from "http://util.openoffice.org/source/browse/util/sot/source/base/exchange.cxx?rev=1.25&content-type=text/x-cvsweb-markup"
  374. ' about the listed defined mimetypes that are required to define binary StarOffice templates that have for all applications the same extension ".vor"
  375.  
  376. ' 26 SOT_FORMATSTR_ID_STARWRITER_30*/            { "application/x-openoffice-starwriter-30;windows_formatname=\"StarWriter 3.0\"", "StarWriter 3.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  377. ' 27 SOT_FORMATSTR_ID_STARWRITER_40*/            { "application/x-openoffice-starwriter-40;windows_formatname=\"StarWriter 4.0\"", "StarWriter 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  378. ' 28 SOT_FORMATSTR_ID_STARWRITER_50*/            { "application/x-openoffice-starwriter-50;windows_formatname=\"StarWriter 5.0\"", "StarWriter 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  379.  
  380. ' 29 SOT_FORMATSTR_ID_STARWRITERWEB_40*/        { "application/x-openoffice-starwriterweb-40;windows_formatname=\"StarWriter/Web 4.0\"", "StarWriter/Web 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  381. ' 30 SOT_FORMATSTR_ID_STARWRITERWEB_50*/        { "application/x-openoffice-starwriterweb-50;windows_formatname=\"StarWriter/Web 5.0\"", "StarWriter/Web 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  382.  
  383. ' 31 SOT_FORMATSTR_ID_STARWRITERGLOB_40*/        { "application/x-openoffice-starwriterglob-40;windows_formatname=\"StarWriter/Global 4.0\"", "StarWriter/Global 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  384. ' 32 SOT_FORMATSTR_ID_STARWRITERGLOB_50*/        { "application/x-openoffice-starwriterglob-50;windows_formatname=\"StarWriter/Global 5.0\"", "StarWriter/Global 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  385.  
  386. ' 33 SOT_FORMATSTR_ID_STARDRAW*/                { "application/x-openoffice-stardraw;windows_formatname=\"StarDrawDocument\"", "StarDrawDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  387. ' 34 SOT_FORMATSTR_ID_STARDRAW_40*/                { "application/x-openoffice-stardraw-40;windows_formatname=\"StarDrawDocument 4.0\"", "StarDrawDocument 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  388. ' 36 SOT_FORMATSTR_ID_STARDRAW_50*/                { "application/x-openoffice-stardraw-50;windows_formatname=\"StarDraw 5.0\"", "StarDraw 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  389.  
  390. ' 35 SOT_FORMATSTR_ID_STARIMPRESS_50*/            { "application/x-openoffice-starimpress-50;windows_formatname=\"StarImpress 5.0\"", "StarImpress 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  391.  
  392. ' 37 SOT_FORMATSTR_ID_STARCALC*/                { "application/x-openoffice-starcalc;windows_formatname=\"StarCalcDocument\"", "StarCalcDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  393. ' 38 SOT_FORMATSTR_ID_STARCALC_40*/                { "application/x-openoffice-starcalc-40;windows_formatname=\"StarCalc 4.0\"", "StarCalc 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  394. ' 39 SOT_FORMATSTR_ID_STARCALC_50*/                { "application/x-openoffice-starcalc-50;windows_formatname=\"StarCalc 5.0\"", "StarCalc 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  395.  
  396. ' 40 SOT_FORMATSTR_ID_STARCHART*/                { "application/x-openoffice-starchart;windows_formatname=\"StarChartDocument\"", "StarChartDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  397. ' 41 SOT_FORMATSTR_ID_STARCHART_40*/            { "application/x-openoffice-starchart-40;windows_formatname=\"StarChartDocument 4.0\"", "StarChartDocument 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  398. ' 42 SOT_FORMATSTR_ID_STARCHART_50*/            { "application/x-openoffice-starchart-50;windows_formatname=\"StarChart 5.0\"", "StarChart 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  399.  
  400. ' 46 SOT_FORMATSTR_ID_STARMATH*/                { "application/x-openoffice-starmath;windows_formatname=\"StarMath\"", "StarMath", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  401. ' 47 SOT_FORMATSTR_ID_STARMATH_40*/                { "application/x-openoffice-starmath-40;windows_formatname=\"StarMathDocument 4.0\"", "StarMathDocument 4.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  402. ' 48 SOT_FORMATSTR_ID_STARMATH_50*/                { "application/x-openoffice-starmath-50;windows_formatname=\"StarMath 5.0\"", "StarMath 5.0", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  403.  
  404.  
  405. Sub SetupXMLConfiguration()
  406.     iApplSection = 1000
  407.     Wizardmode = SBXMLMODE
  408.     ApplCount = 4
  409.     MaxApplCount = 4
  410.  
  411.     XMLFilterName(0,0) = "sdw"
  412.     XMLFilterName(0,1) = "StarOffice XML (Writer)"
  413.     XMLFilterName(0,2) = "sxw"
  414.  
  415.     XMLFilterName(1,0) = "sdc"
  416.     XMLFilterName(1,1) = "StarOffice XML (Calc)"
  417.     XMLFilterName(1,2) = "sxc"
  418.  
  419.     XMLFilterName(2,0) = "sdd|sda"
  420.     XMLFilterName(2,1) = "StarOffice XML (Impress)|sdraw: StarOffice XML (Draw)"
  421.     XMLFilterName(2,2) = "sxi|sxd"
  422.  
  423.     XMLFilterName(3,0) = "smf"
  424.     XMLFilterName(3,1) = "StarOffice XML (Math)"
  425.     XMLFilterName(3,2) = "sxm"
  426.  
  427.     XMLFilterName(4,0) = "application/x-openoffice-starwriter|application/vnd.stardivision.writer/web"
  428.     XMLFilterName(4,1) = "writer_StarOffice_XML_Writer_Template|writer_web_StarOffice_XML_Writer_Web_Template"
  429.     XMLFilterName(4,2) = "stw|stw"
  430.  
  431.     XMLFilterName(5,0) = "application/x-openoffice-starcalc"
  432.     XMLFilterName(5,1) = "calc_StarOffice_XML_Calc_Template"
  433.     XMLFilterName(5,2) = "stc"
  434.  
  435.     ' due to bug #108942# impress templates of the version 4.0 have to be handled in a special way because their mimetype 
  436.     ' falsely points to the draw application.
  437.     XMLFilterName(6,0) = "application/x-openoffice-starimpress|application/x-openoffice-stardraw-40|application/x-openoffice-stardraw"
  438.     XMLFilterName(6,1) = "impress_StarOffice_XML_Impress_Template|impress_StarOffice_XML_Impress_Template|draw_StarOffice_XML_Draw_Template"
  439.     XMLFilterName(6,2) = "sti|sti|std"
  440.  
  441.     XMLFilterName(7,0) = "sgl"
  442.     XMLFilterName(7,1) = "writer_globaldocument_StarOffice_XML_Writer_GlobalDocument"
  443.     XMLFilterName(7,2) = "sxg"
  444. End Sub
  445.  
  446.  
  447. Function CheckControlPath(oCheckbox as Object, oTextBox as Object, ByVal bDoEnable as Boolean)
  448. Dim sPath as String
  449.     If Not bDoEnable Then
  450.         CheckControlPath = False
  451.     ElseIf oCheckbox.State = 0 Then
  452.         CheckControlPath = True
  453.     Else
  454.         sPath = ConvertToUrl(Trim(oTextBox.Text)
  455.         CheckControlPath = oUcb.Exists(sPath)
  456.     End If
  457. End Function
  458.  
  459.  
  460. Function CheckInputPaths() as Boolean
  461. Dim bChangePage as Boolean
  462.     bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateImportPath, True, False, sTitle, False)
  463.     bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateExportPath, bChangePage, True, sTitle, False)
  464.     bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentImportPath, bChangePage, False, sTitle, False)
  465.     bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentExportPath, bChangePage, True, sTitle, False)
  466.     CheckInputPaths = bChangePage
  467. End Function
  468.  
  469.  
  470. Function CheckTextBoxPath(oTextBox as Object, ByVal bCheck as Boolean, bCreateNew as Boolean, sTitle as String, bgetResources as Boolean) as Boolean
  471. Dim iCreate as Integer
  472. Dim sQueryMessage as String
  473. Dim sUrlPath as String
  474. Dim sMessageNoDir as String
  475. Dim sShowPath as String
  476. Dim oLocUcb as Object
  477.     oLocUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
  478.     If bGetResources Then
  479.         If InitResources("ImportWizard","imp") then
  480.              sNoDirCreation = GetResText(1050)
  481.             sMsgDirNotThere = GetResText(1051)
  482.             sQueryForNewCreation = GetResText(1052)
  483.         Else
  484.             CheckTextBoxPath() = False
  485.             Exit Function
  486.         End If
  487.     End If
  488.     If oTextBox.Enabled Then
  489.         If bCheck Then
  490.             sShowPath = oTextBox.Text
  491.             sUrlPath = ConvertToUrl(sShowPath)
  492.             If Not oLocUcb.Exists(sUrlPath) Then
  493.                 If Not bCreateNew Then
  494.                     ' Sourcedirectories must be existing, Targetdirectories may be created new
  495.                     sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1")
  496.                     Msgbox(sQueryMessage,16,sTitle)
  497.                     CheckTextBoxPath() = False
  498.                     Exit Function
  499.                 Else
  500.                     sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1")
  501.                     sQueryMessage = sQueryMessage & Chr(13) & sQueryForNewCreation
  502.                     iCreate = Msgbox (sQueryMessage, 36, sTitle)
  503.                     If iCreate = 6 Then
  504.                         On Local Error Goto NOVALIDPATH
  505.                         CreateFolder(sUrlPath)
  506.                         If Not oLocUcb.Exists(sUrlPath) Then
  507.                             Goto NOVALIDPATH
  508.                         End If
  509.                     Else
  510.                         CheckTextBoxPath() = False
  511.                         Exit Function
  512.                     End If
  513.                 End If
  514.             End If
  515.             CheckTextBoxPath() = True
  516.         Else
  517.             CheckTextBoxPath() = False
  518.         End If
  519.     Else
  520.         CheckTextBoxPath() = True
  521.     End If
  522.     Exit Function
  523. NOVALIDPATH:
  524.     sMessageNoDir = ReplaceString(sNoDirCreation, sShowPath, "%1")
  525.     Msgbox(sMessageNoDir, 16, sTitle)
  526.     CheckTextBoxPath() = False
  527. End Function
  528.  
  529.  
  530. Sub InitializeProgressPage(oDialog as Object)
  531.   oDialog.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL
  532.   oDialog.LabelCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD
  533. End Sub
  534.  
  535.  
  536. Sub    SetProgressDisplay(AbsFound as Integer)
  537.     ImportDialog.LabelRetrieval.Label = sProgressPage_2 &  "  " & ReplaceString(sProgressPage_5, Str(AbsFound) & " ", "%1")
  538.     ImportDialog.LabelCurDocumentRetrieval.Label =  sProgressFound & " " & CStr(AbsDocuFound) &  " " & sProgressMoreDocs
  539.     ImportDialog.LabelCurTemplateRetrieval.Label = sProgressFound & " " & CStr(AbsTemplateFound) & " " & sProgressMoreTemplates
  540. End Sub
  541.  
  542. Sub TakoverFolderName(aEvent as Object)
  543. Dim RefControlName as String
  544. Dim oRefControl
  545.     RefControlName = aEvent.Source.Model.Tag
  546.     oRefControl = ImportDialogArea.GetControl(RefControlName)
  547.     GetFolderName(oRefControl.Model)
  548.     ToggleNextButton()
  549. End Sub
  550.  
  551.  
  552. Sub FinalizeDialogButtons()    
  553.     ImportDialog.cmdShowLogFile.Enabled = ((Isnull(oLogDocument) = False) And (ImportDialog.chkLogfile.State = 1))
  554.     ImportDialog.cmdCancel.Enabled = False
  555.     ImportDialog.cmdGoOn.Label = sCloseButton
  556.     ImportDialog.cmdGoOn.Enabled = True
  557. End Sub    
  558. </script:module>