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