home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2004 June / VPR0406.ISO / STARSUITE7 / EVALUATION / windows / office7 / f_0080 / DialogModul.xba < prev    next >
Extensible Markup Language  |  2004-01-20  |  28KB  |  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
  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.  
  58. ' Application-relating Data are stored in this Array
  59. ' according to the following structure:
  60. ' Applications(X,0) = True/False         (Application is to be converted)
  61. ' Applications(X,1) = True/False         (Documents are to be converted)
  62. ' Applications(X,2) = True/False        (Including Subdirectories)
  63. ' Applications(X,3) = "File:///..."        (SourceUrl of the documents)
  64. ' Applications(X,4) = "File///:..."        (TargetUrl of the documents)
  65. ' Applications(X,5) = True/False        (Templates are to be converted)
  66. ' Applications(X,6) = True/False         (Including Subdirectories)
  67. ' Applications(X,7) = "File:///..."        (SourceUrl of the templates)
  68. ' Applications(X,8) = "File:///..."     (TargetUrl of the templates)
  69. ' Applications(X,9) = 0                    (Key to the original Index of the Applications)
  70.  
  71. Public Const SBMAXEXTENSIONLENGTH = 7
  72.  
  73.  
  74. Sub FillStep_Welcome()
  75. Dim i as Integer
  76. '    bDoKeepApplValues = False
  77.     ImportDialogArea.Title = sTitle
  78.     With ImportDialog
  79.         .cmdHelp.Label = sHelpButton
  80.         .cmdCancel.Label = sCancelButton
  81.         .cmdBack.Label = sBackButton
  82.         .cmdGoOn.Label = sNextButton
  83.         .WelcomeTextLabel.Label = sWelcomeTextLabel1
  84.         .WelcomeTextLabel2.Label = sWelcomeTextLabel2
  85.         .WelcomeTextLabel3.Label = sWelcomeTextLabel3
  86.  
  87.         .optMSDocuments.Label = sContainerName(0)
  88.         .chkMSApplication1.Label = sMsDocumentCheckbox(0)
  89.         .chkMSApplication2.Label = sMsDocumentCheckbox(1)
  90.         .chkMSApplication3.Label = sMsDocumentCheckbox(2)
  91.  
  92.         .optSODocuments.Label = sContainerName(1)
  93.         .chkSOApplication1.Label = sSODocumentCheckbox(0)
  94.         .chkSOApplication2.Label = sSODocumentCheckbox(1)
  95.         .chkSOApplication3.Label = sSODocumentCheckbox(2)
  96.         .chkSOApplication4.Label = sSODocumentCheckbox(3)
  97.         .cmdBack.Enabled = False
  98.         .Step = 1
  99.         
  100.         If Not oFactoryKey.hasbyName("com.sun.star.text.TextDocument") Then
  101.             .chkLogfile.State = 0
  102.             .chkLogfile.Enabled = False
  103.         End If    
  104.     End With
  105.     CheckModuleInstallation()
  106.     ToggleNextButton()
  107. End Sub
  108.  
  109.  
  110. Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean)
  111. Dim Index as Integer
  112. Dim oNullObject as Object
  113.     If bStartup And Not bDoKeepApplValues Then
  114.         If ImportDialog.optMSDocuments.State = 1 Then
  115.             SetupMSConfiguration()
  116.         Else
  117.             SetupXMLConfiguration()
  118.         End If
  119.         FillUpApplicationList()
  120.     End If
  121.     CurOffice = OfficeIndex
  122.     Index = Applications(CurOffice,SBAPPLKEY)
  123.     InitializePathsforCurrentApplication(Index)
  124.     With ImportDialog
  125.         .chkTemplatePath.Label = sTemplateCheckbox(Index)
  126.         .chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT))
  127.            .chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE))
  128.         .txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE))
  129.         .txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET))
  130.         .hlnDocuments.Label = sProgressMoreDocs
  131.         If WizardMode = SBXMLMODE Then
  132.             ImportDialogArea.Title = sTitle & " - " & sSODocumentCheckBox(Index)
  133.         Else
  134.             ImportDialogArea.Title = sTitle & " - " & sMSDocumentCheckBox(Index)
  135.         End If
  136.         If WizardMode = SBXMLMODE AND Index = 3 Then
  137.             ' Note: SO-Helper Applications are partly treated like templates although they only have documents
  138.             .hlnTemplates.Label = sProgressMoreDocs
  139.             .chkTemplatePath.Label = sSOHelperDocuments(0,0)
  140.             .chkTemplatePath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(0,1))
  141.             .chkDocumentPath.Label = sSOHelperDocuments(1,0)
  142.             .chkDocumentPath.Enabled = oFactoryKey.HasByName(sSOHelperDocuments(1,1))
  143.         Else
  144.             .chkTemplatePath.Enabled = True
  145.             .chkDocumentPath.Enabled = True
  146.             .chkTemplatePath.Label = sTemplateCheckbox(Index)
  147.             .chkDocumentPath.Label = sDocumentCheckbox(Index)
  148.             .hlnTemplates.Label = sProgressMoreTemplates
  149.         End If
  150.         .chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT))
  151.         ToggleInputPaths(oNullObject,"Template")
  152.         ToggleInputPaths(oNullObject,"Document")        
  153.         .chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE))
  154.         .txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE))
  155.         .txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET))
  156.         .cmdGoOn.Label = sNextButton
  157.         .cmdBack.Enabled = True
  158.         ImportDialog.Step = 2
  159.     End With
  160.     ImportDialogArea.GetControl("chkTemplatePath").SetFocus()
  161.     ToggleNextButton()
  162. End Sub
  163.  
  164.  
  165. Sub FillUpApplicationList()
  166. Dim i as Integer
  167. Dim a as Integer
  168. Dim BoolValue as Boolean
  169.     If Not bDoKeepApplValues Then
  170.         a = 0
  171.         For i = 1 To ApplCount
  172.             If ImportDialog.optMSDocuments.State = 1 Then
  173.                 BoolValue = ImportDialogArea.GetControl("chkMSApplication" & i).Model.State = 1
  174.             Else
  175.                 BoolValue = ImportDialogArea.GetControl("chkSOApplication" & i).Model.State = 1
  176.             End If
  177.             Applications(a,SBAPPLCONVERT) = BoolValue
  178.             Applications(a,SBDOCCONVERT) = BoolValue
  179.             Applications(a,SBDOCRECURSIVE) = BoolValue
  180.             Applications(a,SBDOCSOURCE) = ""            ' GetDefaultPath(i)
  181.             Applications(a,SBDOCTARGET) = ""            ' SOWorkPath
  182.             Applications(a,SBTEMPLCONVERT) = BoolValue
  183.             Applications(a,SBTEMPLRECURSIVE) = BoolValue
  184.             Applications(a,SBTEMPLSOURCE) = ""             ' GetTemplateDefaultPath(i)
  185.             Applications(a,SBTEMPLTARGET) = ""             ' GetTargetTemplatePath(i)
  186.             Applications(a,SBAPPLKEY) = i-1
  187.             If BoolValue Then 
  188.                 a = a + 1
  189.             End If
  190.         Next i
  191.         ApplCount = a
  192.     End If
  193. End Sub
  194.  
  195.  
  196. Sub InitializePathsforCurrentApplication(i as Integer)
  197.     AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i))
  198.     AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath)
  199.     AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i))
  200.     AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i))
  201. End Sub
  202.  
  203.  
  204. Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String)
  205.     If Applications(CurOffice,Index) = "" Then
  206.         If CurOffice > 0 Then
  207.             Applications(CurOffice,Index) = Applications(CurOffice-1,Index)
  208.         Else
  209.             Applications(CurOffice,Index) = NewPath
  210.         End If
  211.     End If
  212. End Sub
  213.  
  214.  
  215. Sub SaveStep_InputPath()
  216.     Applications(CurOffice,SBDOCCONVERT)  = ImportDialog.chkDocumentPath.State = 1
  217.     Applications(CurOffice,SBDOCRECURSIVE)  = ImportDialog.chkDocumentSearchSubDir.State = 1
  218.     Applications(CurOffice,SBDOCSOURCE)  = ConvertToURL(ImportDialog.txtDocumentImportPath.Text)
  219.     Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text)
  220.     Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State = 1
  221.     Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State = 1
  222.     Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text)
  223.     Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text)
  224. End Sub
  225.  
  226.  
  227. Sub ToggleInputPaths(aEvent as Object, Optional sDocType)
  228. Dim bDoEnable as Boolean
  229. Dim sLocDocType as String
  230. Dim oCheckBox as Object
  231.     If Not IsNull(aEvent) Then
  232.         sLocDocType = aEvent.Source.Model.Tag
  233.     Else
  234.         sLocDocType = sDocType
  235.     End If
  236.     With ImportDialogArea
  237.         oCheckBox = .GetControl("chk" & sLocDocType & "Path").Model
  238.         bDoEnable = oCheckBox.State = 1 And oCheckBox.Enabled
  239.         .GetControl("lbl" & sLocDocType & "Import").Model.Enabled = bDoEnable
  240.         .GetControl("lbl" & sLocDocType & "Export").Model.Enabled = bDoEnable
  241.         .GetControl("txt" & sLocDocType & "ImportPath").Model.Enabled = bDoEnable
  242.         .GetControl("txt" & sLocDocType & "ExportPath").Model.Enabled = bDoEnable
  243.         .GetControl("chk" & sLocDocType & "SearchSubDir").Model.Enabled = bDoEnable
  244.         .GetControl("cmd" & sLocDocType & "Import").Model.Enabled = bDoEnable
  245.         .GetControl("cmd" & sLocDocType & "Export").Model.Enabled = bDoEnable
  246.     End With
  247.     ToggleNextButton()
  248. End Sub
  249.  
  250.  
  251. Function MakeSummaryString()
  252. Dim sTmpText As String
  253. Dim i as Integer
  254. Dim Index as Integer
  255. Dim sAddText as String
  256.     For i = 0 To ApplCount -1
  257.         Index = Applications(i,SBAPPLKEY)
  258.         GetFilterTracingLogPath(i, Index)
  259.         If     Applications(i,SBTEMPLCONVERT) Then
  260.             ' Templates are to be converted
  261.             sAddText = ""
  262.             If WizardMode = SBMICROSOFTMODE Then
  263.                 sAddText = sSumMSTemplates(Index) & sCRLF
  264.             Else
  265.                 sAddText = sSumSOTemplates(Index) & sCRLF            
  266.             End If
  267.             sTmpText = sTmpText & sAddText &  ConvertFromUrl(Applications(i,SBTEMPLSOURCE)) & sCRLF
  268.             If Applications(i,SBTEMPLRECURSIVE) Then
  269.                 ' Including Subdirectories
  270.                 sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
  271.             End If
  272.             sTmpText = sTmpText & sSumSaveDocuments & sCRLF
  273.             sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBTEMPLTARGET)) & sCRLF
  274.             sTmpText = sTmpText & sCRLF
  275.         End If
  276.  
  277.         If Applications(i,SBDOCCONVERT) Then
  278.             ' Documents are to be converted
  279.             If WizardMode = SBMICROSOFTMODE Then
  280.                 sAddText = sSumMSDocuments(Index) & sCRLF
  281.             Else
  282.                 sAddText = sSumSODocuments(Index) & sCRLF            
  283.             End If
  284.             sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBDOCSOURCE)) & sCRLF
  285.  
  286.             If Applications(i,SBDOCRECURSIVE) Then
  287.                 ' Including Subdirectories
  288.                 sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF
  289.             End If
  290.  
  291.             sTmpText = sTmpText & sSumSaveDocuments & sCRLF
  292.             sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBDOCTARGET)) & sCRLF
  293.             sTmpText = sTmpText & sCRLF
  294.         End If
  295.     Next i
  296.     MakeSummaryString = sTmpText
  297. End Function
  298.  
  299.  
  300. Sub FillStep_Summary()
  301.     ImportDialogArea.Title = sTitle
  302.     With ImportDialog
  303.         .SummaryTextbox.Text = MakeSummaryString()
  304.         .cmdGoOn.Enabled = .SummaryTextbox.Text <> ""
  305.         .cmdGoOn.Label = sBeginButton
  306.         .SummaryHeaderLabel.Label = sSummaryHeader
  307.         .Step = 3
  308.     End With
  309.     ImportDialogArea.GetControl("SummaryHeaderLabel").SetFocus()                    
  310. End Sub
  311.  
  312.  
  313. Sub FillStep_Progress()
  314.     With ImportDialog
  315.         .cmdBack.Enabled = False
  316.         .cmdGoOn.Enabled = False
  317.         .hlnProgress.Label = sProgressPage_1
  318.         .LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD
  319.             .LabelRetrieval.Label = sProgressPage_2
  320.             .LabelCurProgress.Label = sProgressPage_3
  321.             .LabelCurDocumentRetrieval.Label = ""
  322.             .LabelCurTemplateRetrieval.Label = ""
  323.            .LabelCurDocument.Label = ""
  324.         .Step = 4
  325.     End With
  326.     ImportDialogArea.GetControl("LabelRetrieval").SetFocus()
  327.     If ImportDialog.chkLogfile.State = 1 Then
  328.         ImportDialog.cmdShowLogFile.DefaultButton = True
  329.     End If
  330. End Sub
  331.  
  332.  
  333. Sub GetFilterTracingLogPath(i as Integer, Index as Integer)
  334. Dim aNodePath(0) as new com.sun.star.beans.PropertyValue
  335. Dim oMasterKey
  336. Dim oImportKey    
  337. Dim oWordKey
  338. Dim oExcelkey
  339. Dim oPowerpointKey
  340. Dim oFilterService
  341.     aNodePath(0).Name = "nodepath"
  342.     aNodePath(0).Value = "org.openoffice.Office.Tracing"
  343.     oFilterService = createUnoService("com.sun.star.util.FilterTracer")
  344.     bFilterTracingAvailable = Not IsNull(oFilterService)
  345.     If bFilterTracingAvailable Then
  346.         oMasterkey = GetRegistryKeyContent("org.openoffice.Office.Tracing/")
  347.         If oMasterKey.hasbyName("Import") Then
  348.             oImportKey = GetRegistryKeyContent("org.openoffice.Office.Tracing/Import")
  349.             bMSApplFilterTracingAvailable(i) = CheckMSImportAvailability(oImportkey, MSFiltername(Index, 4), FilterTracingLogPath(i), bTakeOverTargetName(i), bTakeOverPathName(i))
  350.         End If
  351.     End If
  352. End Sub
  353.  
  354.  
  355. Function CheckMSImportAvailability(oImportkey, MSApplName as String, MSLogPath as String, bTakeOverTargetname as String, bTakeOverpathName as String) as Boolean
  356. Dim bApplIsAvailable as Boolean
  357. Dim oApplKey
  358. Dim LocApplName as String
  359. Dim LocApplPath as String
  360.     bApplIsAvailable = oImportKey.hasbyName(MSApplName)
  361.     If bApplIsAvailable Then
  362.         oApplKey = oImportKey.getByName(MSApplName)
  363.         bApplIsAvailable = oApplKey.On
  364.         LocApplName = oApplKey.Name
  365.         LocApplPath = oApplKey.Path
  366.         bTakeOverTargetName = (LocApplName = "")
  367.         bTakeOverPathName = (LocApplPath = "")        
  368.         MSLogPath = LocApplPath & "/" & LocApplName & ".log"
  369.     End If
  370.     CheckMSImportAvailability() = bApplIsAvailable
  371. End Function
  372.  
  373.  
  374.  
  375. Sub    SetupMSConfiguration()
  376.     iApplSection = 0
  377.     Wizardmode = SBMICROSOFTMODE
  378.     MaxApplCount = 3
  379.     ApplCount = 3
  380.     ' chkTemplatePath-Captions
  381.     GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
  382.     ' DocumentCheckbox- Captions
  383.     GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
  384.  
  385.     sKeyName(0) = "Software\Microsoft\Office\8.0\Word\Options"
  386.     sKeyName(1) = "Software\Microsoft\Office\8.0\Excel\Microsoft Excel"
  387.     sKeyName(2) = "Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default"
  388.  
  389.     sValueName(0) = "DOC-PATH"
  390.     sValueName(1) = "DefaultPath"
  391.     sValueName(2) = ""
  392.  
  393. ' See definition of Filtername-Array about meaning of fields
  394.     MSFilterName(0,0) = "doc"
  395.     MSFilterName(0,1) = "StarOffice XML (Writer)"
  396.     MSFilterName(0,2) = "sxw"
  397.     MSFilterName(0,3) = sMSDocumentCheckBox(0)
  398.     MSFilterName(0,4) = "Word"
  399.     
  400.  
  401.     MSFilterName(1,0) = "xls"
  402.     MSFilterName(1,1) = "StarOffice XML (Calc)"
  403.     MSFilterName(1,2) = "sxc"
  404.     MSFilterName(1,3) = sMSDocumentCheckBox(1)
  405.     MSFilterName(1,4) = "Excel"
  406.  
  407.     MSFilterName(2,0) = "ppt"
  408.     MSFilterName(2,1) = "StarOffice XML (Impress)"
  409.     MSFilterName(2,2) = "sxi"
  410.     MSFilterName(2,3) = sMSDocumentCheckBox(2)
  411.     MSFilterName(2,4) = "PowerPoint"
  412.  
  413.     MSFilterName(3,0) = "dot"
  414.     MSFilterName(3,1) = "writer_StarOffice_XML_Writer_Template"
  415.     MSFilterName(3,2) = "stw"
  416.     MSFilterName(3,3) = sMSTemplateCheckBox(0)
  417.     MSFilterName(3,4) = "Word"    
  418.     
  419.     MSFilterName(4,0) = "xlt"
  420.     MSFilterName(4,1) = "calc_StarOffice_XML_Calc_Template"
  421.     MSFilterName(4,2) = "stc"
  422.     MSFilterName(4,3) = sMSTemplateCheckBox(1)
  423.     MSFilterName(4,4) = "Excel"    
  424.  
  425.     MSFilterName(5,0) = "pot"
  426.     MSFilterName(5,1) = "impress_StarOffice_XML_Impress_Template"
  427.     MSFilterName(5,2) = "sti"
  428.     MSFilterName(5,3) = sMSTemplateCheckBox(2)
  429.     MSFilterName(5,4) = "PowerPoint"    
  430. End Sub
  431.  
  432.  
  433.  
  434. ' 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"
  435. ' about the listed defined mimetypes that are required to define binary StarOffice templates that have for all applications the same extension ".vor"
  436.  
  437. ' 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 ) },
  438. ' 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 ) },
  439. ' 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 ) },
  440.  
  441. ' 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 ) },
  442. ' 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 ) },
  443.  
  444. ' 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 ) },
  445. ' 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 ) },
  446.  
  447. ' 33 SOT_FORMATSTR_ID_STARDRAW*/                { "application/x-openoffice-stardraw;windows_formatname=\"StarDrawDocument\"", "StarDrawDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  448. ' 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 ) },
  449. ' 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 ) },
  450.  
  451. ' 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 ) },
  452.  
  453. ' 37 SOT_FORMATSTR_ID_STARCALC*/                { "application/x-openoffice-starcalc;windows_formatname=\"StarCalcDocument\"", "StarCalcDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  454. ' 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 ) },
  455. ' 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 ) },
  456.  
  457. ' 40 SOT_FORMATSTR_ID_STARCHART*/                { "application/x-openoffice-starchart;windows_formatname=\"StarChartDocument\"", "StarChartDocument", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  458. ' 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 ) },
  459. ' 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 ) },
  460.  
  461. ' 46 SOT_FORMATSTR_ID_STARMATH*/                { "application/x-openoffice-starmath;windows_formatname=\"StarMath\"", "StarMath", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
  462. ' 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 ) },
  463. ' 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 ) },
  464.  
  465.  
  466. Sub SetupXMLConfiguration()
  467.     iApplSection = 1000
  468.     Wizardmode = SBXMLMODE
  469.     ApplCount = 4
  470.     MaxApplCount = 4
  471.     
  472.     ' chkTemplatePath-Captions
  473.     GetApplResourceArray(1009 + iApplSection, ApplCount, sTemplateCheckBox())
  474.     ' DocumentCheckbox- Captions
  475.     GetApplResourceArray(1009 + iApplSection + ApplCount, ApplCount, sDocumentCheckBox())
  476.  
  477.     XMLFilterName(0,0) = "sdw"
  478.     XMLFilterName(0,1) = "StarOffice XML (Writer)"
  479.     XMLFilterName(0,2) = "sxw"
  480.     XMLFilterName(0,3) = sDocumentCheckBox(0)
  481.  
  482.     XMLFilterName(1,0) = "sdc"
  483.     XMLFilterName(1,1) = "StarOffice XML (Calc)"
  484.     XMLFilterName(1,2) = "sxc"
  485.     XMLFilterName(1,3) = sDocumentCheckBox(1)
  486.  
  487.     XMLFilterName(2,0) = "sdd|sda"
  488.     XMLFilterName(2,1) = "StarOffice XML (Impress)|sdraw: StarOffice XML (Draw)"
  489.     XMLFilterName(2,2) = "sxi|sxd"
  490.     XMLFilterName(2,3) = sDocumentCheckBox(2)
  491.  
  492.     XMLFilterName(3,0) = "smf"
  493.     XMLFilterName(3,1) = "StarOffice XML (Math)"
  494.     XMLFilterName(3,2) = "sxm"
  495.     XMLFilterName(3,3) = sDocumentCheckBox(3)    
  496.  
  497.     XMLFilterName(4,0) = "application/x-openoffice-starwriter|application/vnd.stardivision.writer/web"
  498.     XMLFilterName(4,1) = "writer_StarOffice_XML_Writer_Template|writer_web_StarOffice_XML_Writer_Web_Template"
  499.     XMLFilterName(4,2) = "stw|stw"
  500.     XMLFilterName(4,3) = sTemplateCheckBox(0)
  501.  
  502.  
  503.     XMLFilterName(5,0) = "application/x-openoffice-starcalc"
  504.     XMLFilterName(5,1) = "calc_StarOffice_XML_Calc_Template"
  505.     XMLFilterName(5,2) = "stc"
  506.     XMLFilterName(5,3) = sTemplateCheckBox(1)
  507.  
  508.     ' due to bug #108942# impress templates of the version 4.0 have to be handled in a special way because their mimetype 
  509.     ' falsely points to the draw application.
  510.     XMLFilterName(6,0) = "application/x-openoffice-starimpress|application/x-openoffice-stardraw-40|application/x-openoffice-stardraw"
  511.     XMLFilterName(6,1) = "impress_StarOffice_XML_Impress_Template|impress_StarOffice_XML_Impress_Template|draw_StarOffice_XML_Draw_Template"
  512.     XMLFilterName(6,2) = "sti|sti|std"
  513.     XMLFilterName(6,3) = sTemplateCheckBox(2)
  514.     
  515.  
  516.     XMLFilterName(7,0) = "sgl"
  517.     XMLFilterName(7,1) = "writer_globaldocument_StarOffice_XML_Writer_GlobalDocument"
  518.     XMLFilterName(7,2) = "sxg"
  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>