diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /wizards/source/importwizard | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | wizards/source/importwizard/API.xba | 216 | ||||
-rw-r--r-- | wizards/source/importwizard/DialogModul.xba | 484 | ||||
-rw-r--r-- | wizards/source/importwizard/FilesModul.xba | 783 | ||||
-rw-r--r-- | wizards/source/importwizard/ImportDialog.xdl | 97 | ||||
-rw-r--r-- | wizards/source/importwizard/Language.xba | 150 | ||||
-rw-r--r-- | wizards/source/importwizard/Main.xba | 291 | ||||
-rw-r--r-- | wizards/source/importwizard/dialog.xlb | 5 | ||||
-rw-r--r-- | wizards/source/importwizard/script.xlb | 9 |
8 files changed, 2035 insertions, 0 deletions
diff --git a/wizards/source/importwizard/API.xba b/wizards/source/importwizard/API.xba new file mode 100644 index 000000000..97111aeca --- /dev/null +++ b/wizards/source/importwizard/API.xba @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="API" script:language="StarBasic">Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _ + (ByVal hKey As Long, _ + ByVal lpSubKey As String, _ + ByVal ulOptions As Long, _ + ByVal samDesired As Long, _ + phkResult As Long) As Long + +Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" _ + (ByVal hKey As Long, _ + ByVal lpValueName As String, _ + ByVal lpReserved As Long, _ + lpType As Long, _ + lpData As String, _ + lpcbData As Long) As Long + +Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" _ + (ByVal hKey As Long, _ + ByVal lpValueName As String, _ + ByVal lpReserved As Long, _ + lpType As Long, _ + lpData As Long, _ + lpcbData As Long) As Long + +Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" _ + (ByVal hKey As Long, _ + ByVal lpValueName As String, _ + ByVal lpReserved As Long, _ + lpType As Long, _ + ByVal lpData As Long, _ + lpcbData As Long) As Long + +Declare Function RegCloseKeyA Lib "advapi32.dll" Alias "RegCloseKey" _ + (ByVal hKey As Long) As Long + + +Public Const HKEY_CLASSES_ROOT = &H80000000 +Public Const HKEY_CURRENT_USER = &H80000001 +Public Const HKEY_LOCAL_MACHINE = &H80000002 +Public Const HKEY_USERS = &H80000003 +Public Const KEY_ALL_ACCESS = &H3F +Public Const REG_OPTION_NON_VOLATILE = 0 +Public Const REG_SZ As Long = 1 +Public Const REG_DWORD As Long = 4 +Public Const ERROR_NONE = 0 +Public Const ERROR_BADDB = 1 +Public Const ERROR_BADKEY = 2 +Public Const ERROR_CANTOPEN = 3 +Public Const ERROR_CANTREAD = 4 +Public Const ERROR_CANTWRITE = 5 +Public Const ERROR_OUTOFMEMORY = 6 +Public Const ERROR_INVALID_PARAMETER = 7 +Public Const ERROR_ACCESS_DENIED = 8 +Public Const ERROR_INVALID_PARAMETERS = 87 +Public Const ERROR_NO_MORE_ITEMS = 259 +'Public Const KEY_READ = &H20019 + + +Function OpenRegKey(lBaseKey As Long, sKeyName As String) As Variant +Dim LocKeyValue +Dim hKey as Long +Dim lRetValue as Long + lRetValue = RegOpenKeyEx(lBaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) +' lRetValue = QueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Outlook Express\5.0\Default Settings", "Revocation Checking") + If hKey <> 0 Then + RegCloseKeyA (hKey) + End If + OpenRegKey() = lRetValue +End Function + + +Function GetDefaultPath(CurOffice as Integer) As String +Dim sPath as String +Dim Index as Integer + Select Case Wizardmode + Case SBMICROSOFTMODE + Index = Applications(CurOffice,SBAPPLKEY) + If GetGUIType = 1 Then ' Windows + sPath = QueryValue(HKEY_LOCAL_MACHINE, sKeyName(Index), sValueName(Index)) + Else + sPath = "" + End If + If sPath = "" Then + sPath = SOWorkPath + End If + GetDefaultPath = sPath + End Select +End Function + + +Function GetTemplateDefaultPath(Index as Integer) As String +Dim sLocTemplatePath as String +Dim sLocProgrampath as String +Dim Progstring as String +Dim PathList()as String +Dim Maxindex as Integer +Dim OldsLocTemplatePath +Dim sTemplateKeyName as String +Dim sTemplateValueName as String + On Local Error Goto NOVAlIDSYSTEMPATH + Select Case WizardMode + Case SBMICROSOFTMODE + If GetGUIType = 1 Then ' Windows + ' Template directory of Office 97 + sTemplateKeyName = "Software\Microsoft\Office\8.0\Common\FileNew\LocalTemplates" + sTemplateValueName = "" + sLocTemplatePath = QueryValue(HKEY_LOCAL_MACHINE, sTemplateKeyName, sTemplateValueName) + + If sLocTemplatePath = "" Then + ' Retrieve the template directory of Office 2000 + ' Unfortunately there is no existing note about the template directory in + ' the whole registry. + + ' Programdirectory of Office 2000 + sTemplateKeyName = "Software\Microsoft\Office\9.0\Common\InstallRoot" + sTemplateValueName = "Path" + sLocProgrampath = QueryValue(HKEY_LOCAL_MACHINE, sTemplateKeyName, sTemplateValueName) + If sLocProgrampath <> "" Then + If Right(sLocProgrampath, 1) <> "\" Then + sLocProgrampath = sLocProgrampath & "\" + End If + PathList() = ArrayoutofString(sLocProgrampath,"\",Maxindex) + Progstring = "\" & PathList(Maxindex-1) & "\" + OldsLocTemplatePath = DeleteStr(sLocProgramPath,Progstring) + + sLocTemplatePath = OldsLocTemplatePath & "\" & "Templates" + + ' Does this subdirectory "templates" exist at all + If oUcb.Exists(sLocTemplatePath) Then + ' If Not the main directory of the office is the base + sLocTemplatePath = OldsLocTemplatePath + End If + Else + sLocTemplatePath = SOWorkPath + End If + End If + GetTemplateDefaultPath = ConvertToUrl(sLocTemplatePath) + Else + GetTemplateDefaultPath = SOWorkPath + End If + End Select +NOVALIDSYSTEMPATH: + If Err <> 0 Then + GetTemplateDefaultPath() = SOWorkPath + Resume ONITGOES + ONITGOES: + End If +End Function + + +Function QueryValueEx(ByVal lhKey, ByVal szValueName As String, vValue As String) As Long +Dim cch As Long +Dim lrc As Long +Dim lType As Long +Dim lValue As Long +Dim sValue As String +Dim Empty + + On Error GoTo QueryValueExError + + lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch) + If lrc <> ERROR_NONE Then Error 5 + Select Case lType + Case REG_SZ: + sValue = String(cch, 0) + lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch) + If lrc = ERROR_NONE Then + vValue = Left$(sValue, cch) + Else + vValue = Empty + End If + Case REG_DWORD: + lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch) + If lrc = ERROR_NONE Then + vValue = lValue + End If + Case Else + lrc = -1 + End Select +QueryValueExExit: + QueryValueEx = lrc + Exit Function +QueryValueExError: + Resume QueryValueExExit +End Function + + +Function QueryValue(BaseKey As Long, sKeyName As String, sValueName As String) As Variant +Dim lRetVal As Long ' Returnvalue API-Call +Dim hKey As Long ' One key handle +Dim vValue As String ' Key value + + lRetVal = RegOpenKeyEx(BaseKey, sKeyName, 0, KEY_ALL_ACCESS, hKey) + lRetVal = QueryValueEx(hKey, sValueName, vValue) + RegCloseKeyA (hKey) + QueryValue = vValue +End Function +</script:module> diff --git a/wizards/source/importwizard/DialogModul.xba b/wizards/source/importwizard/DialogModul.xba new file mode 100644 index 000000000..0bf782c6b --- /dev/null +++ b/wizards/source/importwizard/DialogModul.xba @@ -0,0 +1,484 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="DialogModul" script:language="StarBasic">Option Explicit + +Public Const bDebugWizard = True + +Public Const SBFIRSTAPPLCHECKED = 0 +Public Const SBSECONDAPPLCHECKED = 1 +Public Const SBTHIRDAPPLCHECKED = 2 +Public Const SBFOURTHAPPLCHECKED = 3 +Public WizardMode as String +Public Const SBMICROSOFTMODE = "MS" +' The absolute maximal Number of possible Applications +Public Const SBMAXAPPLCOUNT = 4 +Public Const Twip = 425 +Public MaxApplCount as Integer +Public CurOffice As Integer +Public SOBitmapPath As String +Public SOWorkPath As String +Public SOTemplatePath as String +Public bCancelTask As Boolean +Public bDoKeepApplValues as Boolean +Public oUcb as Object +Public PathSeparator as String + +Public ApplCount as Integer +Public sKeyName(SBMAXAPPLCOUNT-1) as String +Public sValueName(SBMAXAPPLCOUNT-1) as String +Public sCRLF as String +Public MSFilterName(5,4) as String + +Public Applications(SBMAXAPPLCOUNT-1,9) + +Public Const SBAPPLCONVERT = 0 +Public Const SBDOCCONVERT = 1 +Public Const SBDOCRECURSIVE = 2 +Public Const SBDOCSOURCE = 3 +Public Const SBDOCTARGET = 4 +Public Const SBTEMPLCONVERT = 5 +Public Const SBTEMPLRECURSIVE = 6 +Public Const SBTEMPLSOURCE = 7 +Public Const SBTEMPLTARGET = 8 +Public Const SBAPPLKEY = 9 +Public XMLTemplateList() + +' Application-relating Data are stored in this Array +' according to the following structure: +' Applications(X,0) = True/False (Application is to be converted) +' Applications(X,1) = True/False (Documents are to be converted) +' Applications(X,2) = True/False (Including Subdirectories) +' Applications(X,3) = "File:///..." (SourceUrl of the documents) +' Applications(X,4) = "File///:..." (TargetUrl of the documents) +' Applications(X,5) = True/False (Templates are to be converted) +' Applications(X,6) = True/False (Including Subdirectories) +' Applications(X,7) = "File:///..." (SourceUrl of the templates) +' Applications(X,8) = "File:///..." (TargetUrl of the templates) +' Applications(X,9) = 0 (Key to the original Index of the Applications) + + +Sub FillStep_Welcome() +Dim i as Integer +' bDoKeepApplValues = False + ImportDialogArea.Title = sTitle + With ImportDialog + .cmdHelp.Label = sHelpButton + .cmdCancel.Label = sCancelButton + .cmdBack.Label = sBackButton + .cmdGoOn.Label = sNextButton + .WelcomeTextLabel.Label = sWelcomeTextLabel1 + .WelcomeTextLabel3.Label = sWelcomeTextLabel3 + + .optMSDocuments.Label = sContainerName(0) + .chkMSApplication1.Label = sMsDocumentCheckbox(0) + .chkMSApplication2.Label = sMsDocumentCheckbox(1) + .chkMSApplication3.Label = sMsDocumentCheckbox(2) + + .cmdBack.Enabled = False + .Step = 1 + + If Not oFactoryKey.hasbyName("com.sun.star.text.TextDocument") Then + .chkLogfile.State = 0 + .chkLogfile.Enabled = False + End If + End With + CheckModuleInstallation() + ToggleNextButton() +End Sub + + +Sub FillStep_InputPaths(OfficeIndex as Integer, bStartup as Boolean) +Dim Index as Integer +Dim oNullObject as Object + If bStartup And Not bDoKeepApplValues Then + If ImportDialog.optMSDocuments.State = 1 Then + SetupMSConfiguration() + Else + 'Not supposed to happen - is there an assert in BASIC... + End If + FillUpApplicationList() + End If + CurOffice = OfficeIndex + Index = Applications(CurOffice,SBAPPLKEY) + InitializePathsforCurrentApplication(Index) + With ImportDialog + .chkTemplatePath.Label = sTemplateCheckbox(Index) + .chkDocumentPath.State = Abs(Applications(CurOffice,SBDOCCONVERT)) + .chkDocumentSearchSubDir.State = Abs(Applications(CurOffice,SBDOCRECURSIVE)) + .txtDocumentImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCSOURCE)) + .txtDocumentExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBDOCTARGET)) + .hlnDocuments.Label = sProgressMoreDocs + If WizardMode = SBMICROSOFTMODE Then + ImportDialogArea.Title = sTitle & " - " & sMSDocumentCheckBox(Index) + End If + .chkTemplatePath.Enabled = True + .chkDocumentPath.Enabled = True + .chkTemplatePath.Label = sTemplateCheckbox(Index) + .chkDocumentPath.Label = sDocumentCheckbox(Index) + .hlnTemplates.Label = sProgressMoreTemplates + .chkTemplatePath.State = Abs(Applications(CurOffice,SBTEMPLCONVERT)) + ToggleInputPaths(oNullObject,"Template") + ToggleInputPaths(oNullObject,"Document") + .chkTemplateSearchSubDir.State = Abs(Applications(CurOffice,SBTEMPLRECURSIVE)) + .txtTemplateImportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLSOURCE)) + .txtTemplateExportPath.Text = ConvertFromUrl(Applications(CurOffice,SBTEMPLTARGET)) + .cmdGoOn.Label = sNextButton + .cmdBack.Enabled = True + ImportDialog.Step = 2 + End With + ImportDialogArea.GetControl("chkTemplatePath").SetFocus() + ToggleNextButton() +End Sub + + +Sub FillUpApplicationList() +Dim i as Integer +Dim a as Integer +Dim BoolValue as Boolean + If Not bDoKeepApplValues Then + a = 0 + For i = 1 To ApplCount + If ImportDialog.optMSDocuments.State = 1 Then + BoolValue = ImportDialogArea.GetControl("chkMSApplication" & i).Model.State = 1 + End If + Applications(a,SBAPPLCONVERT) = BoolValue + Applications(a,SBDOCCONVERT) = BoolValue + Applications(a,SBDOCRECURSIVE) = BoolValue + Applications(a,SBDOCSOURCE) = "" ' GetDefaultPath(i) + Applications(a,SBDOCTARGET) = "" ' SOWorkPath + Applications(a,SBTEMPLCONVERT) = BoolValue + Applications(a,SBTEMPLRECURSIVE) = BoolValue + Applications(a,SBTEMPLSOURCE) = "" ' GetTemplateDefaultPath(i) + Applications(a,SBTEMPLTARGET) = "" ' GetTargetTemplatePath(i) + Applications(a,SBAPPLKEY) = i-1 + If BoolValue Then + a = a + 1 + End If + Next i + ApplCount = a + End If +End Sub + + +Sub InitializePathsforCurrentApplication(i as Integer) + AssignPathToCurrentApplication(SBDOCSOURCE, GetDefaultPath(i)) + AssignPathToCurrentApplication(SBDOCTARGET, SOWorkPath) + AssignPathToCurrentApplication(SBTEMPLSOURCE, GetTemplateDefaultPath(i)) + AssignPathToCurrentApplication(SBTEMPLTARGET, GetTargetTemplatePath(i)) +End Sub + + +Sub AssignPathToCurrentApplication(Index as Integer, NewPath as String) + If Applications(CurOffice,Index) = "" Then + If CurOffice > 0 Then + Applications(CurOffice,Index) = Applications(CurOffice-1,Index) + Else + Applications(CurOffice,Index) = NewPath + End If + End If +End Sub + + +Sub SaveStep_InputPath() + Applications(CurOffice,SBDOCCONVERT) = ImportDialog.chkDocumentPath.State = 1 + Applications(CurOffice,SBDOCRECURSIVE) = ImportDialog.chkDocumentSearchSubDir.State = 1 + Applications(CurOffice,SBDOCSOURCE) = ConvertToURL(ImportDialog.txtDocumentImportPath.Text) + Applications(CurOffice,SBDOCTARGET) = ConvertToUrl(ImportDialog.txtDocumentExportPath.Text) + Applications(CurOffice,SBTEMPLCONVERT) = ImportDialog.chkTemplatePath.State = 1 + Applications(CurOffice,SBTEMPLRECURSIVE) = ImportDialog.chkTemplateSearchSubDir.State = 1 + Applications(CurOffice,SBTEMPLSOURCE) = ConvertToURL(ImportDialog.txtTemplateImportPath.Text) + Applications(CurOffice,SBTEMPLTARGET) = ConvertToURL(ImportDialog.txtTemplateExportPath.Text) +End Sub + + +Sub ToggleInputPaths(aEvent as Object, Optional sDocType) +Dim bDoEnable as Boolean +Dim sLocDocType as String +Dim oCheckBox as Object + If Not IsNull(aEvent) Then + sLocDocType = aEvent.Source.Model.Tag + Else + sLocDocType = sDocType + End If + With ImportDialogArea + oCheckBox = .GetControl("chk" & sLocDocType & "Path").Model + bDoEnable = oCheckBox.State = 1 And oCheckBox.Enabled + .GetControl("lbl" & sLocDocType & "Import").Model.Enabled = bDoEnable + .GetControl("lbl" & sLocDocType & "Export").Model.Enabled = bDoEnable + .GetControl("txt" & sLocDocType & "ImportPath").Model.Enabled = bDoEnable + .GetControl("txt" & sLocDocType & "ExportPath").Model.Enabled = bDoEnable + .GetControl("chk" & sLocDocType & "SearchSubDir").Model.Enabled = bDoEnable + .GetControl("cmd" & sLocDocType & "Import").Model.Enabled = bDoEnable + .GetControl("cmd" & sLocDocType & "Export").Model.Enabled = bDoEnable + End With + ToggleNextButton() +End Sub + + +Function MakeSummaryString() +Dim sTmpText As String +Dim i as Integer +Dim Index as Integer +Dim sAddText as String + For i = 0 To ApplCount -1 + Index = Applications(i,SBAPPLKEY) + If Applications(i,SBTEMPLCONVERT) Then + ' Templates are to be converted + sAddText = "" + If WizardMode = SBMICROSOFTMODE Then + sAddText = sSumMSTemplates(Index) & sCRLF + End If + sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBTEMPLSOURCE)) & sCRLF + If Applications(i,SBTEMPLRECURSIVE) Then + ' Including Subdirectories + sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF + End If + sTmpText = sTmpText & sSumSaveDocuments & sCRLF + sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBTEMPLTARGET)) & sCRLF + sTmpText = sTmpText & sCRLF + End If + + If Applications(i,SBDOCCONVERT) Then + ' Documents are to be converted + If WizardMode = SBMICROSOFTMODE Then + sAddText = sSumMSDocuments(Index) & sCRLF + End If + sTmpText = sTmpText & sAddText & ConvertFromUrl(Applications(i,SBDOCSOURCE)) & sCRLF + + If Applications(i,SBDOCRECURSIVE) Then + ' Including Subdirectories + sTmpText = sTmpText & sSumInclusiveSubDir & sCRLF + End If + + sTmpText = sTmpText & sSumSaveDocuments & sCRLF + sTmpText = sTmpText & ConvertFromUrl(Applications(i,SBDOCTARGET)) & sCRLF + sTmpText = sTmpText & sCRLF + End If + Next i + MakeSummaryString = sTmpText +End Function + + +Sub FillStep_Summary() + ImportDialogArea.Title = sTitle + With ImportDialog + .SummaryTextbox.Text = MakeSummaryString() + .cmdGoOn.Enabled = .SummaryTextbox.Text <> "" + .cmdGoOn.Label = sBeginButton + .SummaryHeaderLabel.Label = sSummaryHeader + .Step = 3 + End With + ImportDialogArea.GetControl("SummaryHeaderLabel").SetFocus() +End Sub + + +Sub FillStep_Progress() + With ImportDialog + .cmdBack.Enabled = False + .cmdGoOn.Enabled = False + .hlnProgress.Label = sProgressPage_1 + .LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.BOLD + .LabelRetrieval.Label = sProgressPage_2 + .LabelCurProgress.Label = sProgressPage_3 + .LabelCurDocumentRetrieval.Label = "" + .LabelCurTemplateRetrieval.Label = "" + .LabelCurDocument.Label = "" + .Step = 4 + End With + ImportDialogArea.GetControl("LabelRetrieval").SetFocus() + If ImportDialog.chkLogfile.State = 1 Then + ImportDialog.cmdShowLogFile.DefaultButton = True + End If +End Sub + + +Sub SetupMSConfiguration() + Wizardmode = SBMICROSOFTMODE + MaxApplCount = 3 + ApplCount = 3 + ' chkTemplatePath-Captions + sTemplateCheckBox(0) = GetResText("MSTemplateCheckbox_1_") + sTemplateCheckBox(1) = GetResText("MSTemplateCheckbox_2_") + sTemplateCheckBox(2) = GetResText("MSTemplateCheckbox_3_") + ' DocumentCheckbox- Captions + sDocumentCheckBox(0) = GetResText("MSDocumentCheckbox_1_") + sDocumentCheckBox(1) = GetResText("MSDocumentCheckbox_2_") + sDocumentCheckBox(2) = GetResText("MSDocumentCheckbox_3_") + + sKeyName(0) = "Software\Microsoft\Office\8.0\Word\Options" + sKeyName(1) = "Software\Microsoft\Office\8.0\Excel\Microsoft Excel" + sKeyName(2) = "Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default" + + sValueName(0) = "DOC-PATH" + sValueName(1) = "DefaultPath" + sValueName(2) = "" + +' See definition of Filtername-Array about meaning of fields + MSFilterName(0,0) = "doc|docx|docm" + MSFilterName(0,1) = "writer8|writer8|writer8" + MSFilterName(0,2) = "odt|odt|odt" + MSFilterName(0,3) = sMSDocumentCheckBox(0) + MSFilterName(0,4) = "Word" + + + MSFilterName(1,0) = "xls|xlsx|xlsm" + MSFilterName(1,1) = "calc8|calc8|calc8" + MSFilterName(1,2) = "ods|ods|ods" + MSFilterName(1,3) = sMSDocumentCheckBox(1) + MSFilterName(1,4) = "Excel" + + MSFilterName(2,0) = "ppt|pps|pptx|pub|pptm|ppsx|ppsm" + MSFilterName(2,1) = "impress8|impress8|impress8|impress8|impress8|impress8|impress8" + MSFilterName(2,2) = "odp|odp|odp|odp|odp|odp|odp" + MSFilterName(2,3) = sMSDocumentCheckBox(2) + MSFilterName(2,4) = "PowerPoint/Publisher" + + MSFilterName(3,0) = "dot|dotx|dotm" + MSFilterName(3,1) = "writer8_template|writer8_template|writer8_template" + MSFilterName(3,2) = "ott|ott|ott" + MSFilterName(3,3) = sMSTemplateCheckBox(0) + MSFilterName(3,4) = "Word" + + MSFilterName(4,0) = "xlt|xltx|xltm" + MSFilterName(4,1) = "calc8_template|calc8_template|calc8_template" + MSFilterName(4,2) = "ots|ots|ots" + MSFilterName(4,3) = sMSTemplateCheckBox(1) + MSFilterName(4,4) = "Excel" + + MSFilterName(5,0) = "pot|potx|potm" + MSFilterName(5,1) = "impress8_template|impress8_template|impress8_template" + MSFilterName(5,2) = "otp|otp|otp" + MSFilterName(5,3) = sMSTemplateCheckBox(2) + MSFilterName(5,4) = "PowerPoint" +End Sub + + +Function CheckControlPath(oCheckbox as Object, oTextBox as Object, ByVal bDoEnable as Boolean) +Dim sPath as String + If Not bDoEnable Then + CheckControlPath = False + ElseIf oCheckbox.State = 0 Then + CheckControlPath = True + Else + sPath = ConvertToUrl(Trim(oTextBox.Text)) + CheckControlPath = oUcb.Exists(sPath) + End If +End Function + + +Function CheckInputPaths() as Boolean +Dim bChangePage as Boolean + bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateImportPath, True, False, sTitle, False) + bChangePage = CheckTextBoxPath(ImportDialog.txtTemplateExportPath, bChangePage, True, sTitle, False) + bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentImportPath, bChangePage, False, sTitle, False) + bChangePage = CheckTextBoxPath(ImportDialog.txtDocumentExportPath, bChangePage, True, sTitle, False) + CheckInputPaths = bChangePage +End Function + + +Function CheckTextBoxPath(oTextBox as Object, ByVal bCheck as Boolean, bCreateNew as Boolean, sTitle as String, bgetResources as Boolean) as Boolean +Dim iCreate as Integer +Dim sQueryMessage as String +Dim sUrlPath as String +Dim sMessageNoDir as String +Dim sShowPath as String +Dim oLocUcb as Object + oLocUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") + If bGetResources Then + If InitResources("ImportWizard") then + sNoDirCreation = GetResText("NoDirCreation") + sMsgDirNotThere = GetResText("MsgDirNotThere") + sQueryForNewCreation = GetResText("QueryfornewCreation") + Else + CheckTextBoxPath() = False + Exit Function + End If + End If + If oTextBox.Enabled Then + If bCheck Then + sShowPath = oTextBox.Text + sUrlPath = ConvertToUrl(sShowPath) + If Not oLocUcb.Exists(sUrlPath) Then + If Not bCreateNew Then + ' Sourcedirectories must be existing, Targetdirectories may be created new + sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1") + Msgbox(sQueryMessage,16,sTitle) + CheckTextBoxPath() = False + Exit Function + Else + sQueryMessage = ReplaceString(sMsgDirNotThere, sShowPath,"%1") + sQueryMessage = sQueryMessage & Chr(13) & sQueryForNewCreation + iCreate = Msgbox (sQueryMessage, 36, sTitle) + If iCreate = 6 Then + On Local Error Goto NOVALIDPATH + CreateFolder(sUrlPath) + If Not oLocUcb.Exists(sUrlPath) Then + Goto NOVALIDPATH + End If + Else + CheckTextBoxPath() = False + Exit Function + End If + End If + End If + CheckTextBoxPath() = True + Else + CheckTextBoxPath() = False + End If + Else + CheckTextBoxPath() = True + End If + Exit Function +NOVALIDPATH: + sMessageNoDir = ReplaceString(sNoDirCreation, sShowPath, "%1") + Msgbox(sMessageNoDir, 16, sTitle) + CheckTextBoxPath() = False +End Function + + +Sub InitializeProgressPage(oDialog as Object) + oDialog.LabelRetrieval.FontWeight = com.sun.star.awt.FontWeight.NORMAL + oDialog.LabelCurProgress.FontWeight = com.sun.star.awt.FontWeight.BOLD +End Sub + + +Sub SetProgressDisplay(AbsFound as Integer) + ImportDialog.LabelRetrieval.Label = sProgressPage_2 & " " & ReplaceString(sProgressPage_5, Str(AbsFound) & " ", "%1") + ImportDialog.LabelCurDocumentRetrieval.Label = sProgressFound & " " & CStr(AbsDocuFound) & " " & sProgressMoreDocs + ImportDialog.LabelCurTemplateRetrieval.Label = sProgressFound & " " & CStr(AbsTemplateFound) & " " & sProgressMoreTemplates +End Sub + +Sub TakoverFolderName(aEvent as Object) +Dim RefControlName as String +Dim oRefControl + RefControlName = aEvent.Source.Model.Tag + oRefControl = ImportDialogArea.GetControl(RefControlName) + GetFolderName(oRefControl.Model) + ToggleNextButton() +End Sub + + +Sub FinalizeDialogButtons() + ImportDialog.cmdShowLogFile.Enabled = ((Isnull(oLogDocument) = False) And (ImportDialog.chkLogfile.State = 1)) + ImportDialog.cmdCancel.Enabled = False + ImportDialog.cmdGoOn.Label = sCloseButton + ImportDialog.cmdGoOn.Enabled = True +End Sub +</script:module> diff --git a/wizards/source/importwizard/FilesModul.xba b/wizards/source/importwizard/FilesModul.xba new file mode 100644 index 000000000..cfac77dfe --- /dev/null +++ b/wizards/source/importwizard/FilesModul.xba @@ -0,0 +1,783 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="FilesModul" script:language="StarBasic">Option Explicit + +Public AbsTemplateFound as Integer +Public AbsDocuFound as Integer +Public oLogDocument as Object +Public oLogTable as Object +Public bLogExists as Boolean +Public sComment as String +Public MaxCollectIndex as Integer +Public bInsertRow as Boolean +Public sLogUrl as String +Public sCurPassWord as String +Public FileCount as Integer +Public XMLTemplateCount as Integer +Public PathCollection(7,3) as String +Public bIsFirstLogTable as Boolean + + +Function ReadCollectionPaths(FilesList() as String, sFilterName() as String) +Dim FilterIndex as Integer +Dim bRecursive as Boolean +Dim SearchDir as String +Dim i as Integer +Dim n as Integer +Dim a as Integer +Dim s as Integer +Dim t as Integer +Dim sFileContent() as String +Dim NewList(0,1) as String +Dim Index as Integer +Dim CurFileName as String +Dim CurExtension as String +Dim CurFileContent as String +Dim XMLTemplateContentList() as String +Dim bIsTemplatePath as Boolean +Dim MaxIndex as Integer +Dim NewContentList() as String +Dim XMLTemplateContentString as String +Dim ApplIndex as Integer +Dim bAssignFileName as Boolean +Dim bInterruptSearch as Boolean + bInterruptSearch = False + For i = 0 To MaxCollectIndex + SearchDir = PathCollection(i,0) + bRecursive = PathCollection(i,1) + sFileContent() = ArrayoutofString(PathCollection(i,2), "|") + NewList() = ReadDirectories(SearchDir, bRecursive, False, False, sFileContent(), "") + If InterruptProcess Then + ReadCollectionPaths() = False + Exit Function + End If + If Ubound(NewList()) > -1 Then + bIsTemplatePath = FieldInList("vor", sFileContent) + If bIsTemplatePath Then + XMLTemplateContentString = PathCollection(i,3) + XMLTemplateContentList() = ArrayoutofString(XMLTemplateContentString, "|") + If Ubound(XMLTemplateContentList()) > -1 Then + MaxIndex = Ubound(NewList()) + ReDim Preserve NewList(MaxIndex, 1) as String + ReDim Preserve NewContentList(MaxIndex) as String + a = -1 + For n = 0 To MaxIndex + bAssignFileName = True + If InterruptProcess() Then + ReadCollectionPaths() = False + Exit Function + End If + CurFileContent = "" + CurFileName = NewList(n,0) + If (FieldInList(NewList(n,1), XMLTemplateList())) Then + CurFileContent = GetRealFileContent(CurFileName) + t = SearchArrayforPartString(CurFileContent, XMLTemplateContentList()) + bAssignFileName = (t > -1) + If bAssignFileName Then + CurFileContent = XMLTemplateContentList(t) + End If + NewList(n,1) = CurFileContent + End If + CurExtension = NewList(n,1) + If bAssignFileName Then + If a < n Then + a = a + 1 + NewList(a,0) = CurFileName + NewList(a,1) = CurExtension + If CurFileContent = "" Then + CurFileContent = CurExtension + End If + ApplIndex = GetApplicationIndex(CurFileContent, sFiltername()) + NewContentList(a) = ApplIndex + End If + End If + Next n + If a < MaxIndex And a > -1 Then + ReDim Preserve NewList(a, 1) as String + End If + If a > -1 Then + AddListtoFilesList(FilesList(), NewList(), NewContentList()) + End If + End If + Else + MaxIndex = Ubound(NewList()) + ReDim Preserve NewContentList(MaxIndex) as String + For s = 0 To MaxIndex + CurExtension = NewList(s,1) + NewContentList(s) = GetApplicationIndex(CurExtension, sFiltername()) + Next s + AddListtoFilesList(FilesList(), NewList(), NewContentList()) + End If + End If + Next i + ReadCollectionPaths() = Ubound(FilesList()) > -1 +End Function + + +Function GetApplicationIndex(CurFileContent as String, sFilterName() as String) as Integer +Dim Index as Integer +Dim i as Integer + Index = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent, 0) + If Index >= MaxApplCount Then + Index = Index - MaxApplCount + End If + For i = 0 To MaxApplCount - 1 + If Applications(i, SBAPPLKEY) = Index Then + GetApplicationIndex() = i + Exit Function + End If + Next i + GetApplicationIndex() = - 1 +End Function + + +Function InterruptProcess() as Boolean + If bCancelTask Or RetValue = 0 Then + bConversionIsRunning = False + InterruptProcess() = True + Exit Function + End if + InterruptProcess() = False +End Function + + +Sub AddCollectionPath(ApplIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer) + MaxCollectIndex = MaxCollectIndex + 1 + PathCollection(MaxCollectIndex, 0) = Applications(ApplIndex, DocIndex) + PathCollection(MaxCollectIndex, 1) = Applications(ApplIndex, RecursiveIndex) + AddFilterNameToPathItem(ApplIndex, MaxCollectIndex, sFiltername(), DistIndex) +End Sub + + +Function SetExtension(LocExtension) as String + if (Instr(LocExtension, "vnd.sun.xml.impress")) > 0 then + SetExtension() = "vor|sti|std" + elseif (Instr(LocExtension, "vnd.sun.xml.writer")) > 0 then + SetExtension() = "vor|stw" + elseif (Instr(LocExtension, "vnd.sun.xml.calc")) > 0 then + SetExtension() = "vor|stc" + elseif (Instr(LocExtension, "vnd.sun.xml.draw")) > 0 then + SetExtension() = "vor|std|sti" + endif +End Function + +Sub AddFilterNameToPathItem(ApplIndex as Integer, CollectIndex as Integer, sFiltername() as String, DistIndex as Integer) +Dim iKey as Integer +Dim CurListString as String +Dim LocExtension as String +Dim LocContentString as String +Dim LocXMLTemplateContent as String + iKey = Applications(ApplIndex, SBAPPLKEY) + CurListString = PathCollection(CollectIndex, 2) + LocExtension = sFilterName(iKey +DistIndex, 0) + If Instr(LocExtension, "vnd.sun.xml.") = 1 Then + LocExtension = SetExtension(LocExtension) + LocContentString = sFilterName(iKey +DistIndex, 0) + LocContentString = ReplaceString(LocContentString, "|", ";") + LocXMLTemplateContent = PathCollection(CollectIndex, 3) + If LocXMLTemplateContent = "" Then + LocXMLTemplateContent = LocContentString + Else + LocXMLTemplateContent = LocXMLTemplateContent & "|" & LocContentString + End If + PathCollection(CollectIndex, 3) = LocXMLTemplateContent + End If + If CurListString = "" Then + PathCollection(CollectIndex, 2) = LocExtension + Else + If Instr(CurListString, LocExtension) = 0 Then + PathCollection(CollectIndex, 2) = CurListString & "|" & LocExtension + End If + End If +End Sub + + +Sub CheckIfToAddPathToCollection(ApplIndex as Integer, bDoConvertIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer) +Dim CollectIndex as Integer +Dim bCheckDocuType as Boolean + bCheckDocuType = Applications(ApplIndex, bDoConvertIndex) + If bCheckDocuType Then + CollectIndex = GetIndexInMultiArray(PathCollection(), Applications(ApplIndex,DocIndex), 0) + If (CollectIndex >-1) Then + If Applications(ApplIndex, RecursiveIndex) <> PathCollection(CollectIndex, 1) Then + AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex) + Else + AddFilterNameToPathItem(ApplIndex, CollectIndex, sFilterName(), DistIndex) + End If + Else + AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex) + End If + End If +End Sub + + +Sub CollectPaths(sFiltername() as String) +Dim i as Integer +Dim XMLTemplateContentString as String + MaxCollectIndex = -1 + For i = 0 To ApplCount-1 + CheckIfToAddPathToCollection(i, SBDOCCONVERT, SBDOCSOURCE, SBDOCRECURSIVE, sFilterName(), 0) + Next i + XMLTemplateCount = 0 + XMLTemplateContentString = "" + For i = 0 To ApplCount-1 + CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount) + Next i +End Sub + + +Sub ConvertAllDocuments(sFilterName() as String) +Dim FileProperties(1) as new com.sun.star.beans.PropertyValue +Dim PWFileProperties(2) as New com.sun.star.beans.PropertyValue +Dim WriterWebProperties(0) as new com.sun.star.beans.PropertyValue +Dim OpenProperties(4) as new com.sun.star.beans.PropertyValue +Dim oInteractionHandler as Object +Dim InteractionTypes(0) as Long +Dim FilesList(0,2) as String +Dim sViewPath as String +Dim i as Integer +Dim FilterIndex as Integer +Dim sSourceUrl as String +Dim CurFilename as String +Dim oDocument as Object +Dim sExtension as String +Dim OldExtension as String +Dim CurFound as Integer +Dim TotFound as Integer +Dim TargetStemDir as String +Dim SourceStemDir as String +Dim TargetDir as String +Dim sTargetUrl as String +Dim CurFilterName as String +Dim ApplIndex as Integer +Dim Index as Integer +Dim bIsDocument as Boolean +Dim bDoSave as Boolean +Dim sCurFileExists as String +Dim MaxFileIndex as Integer +Dim bContainsBasicMacro as Boolean +Dim bIsPassWordProtected as Boolean +Dim iOverwrite as Integer +Dim sMimeTypeorExtension as String +Dim sPrevMimeTypeorExtension as String + bConversionisrunning = True + InteractionTypes(0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER + oInteractionHandler = createUnoService("com.sun.star.task.InteractionHandler") + oInteractionHandler.initialize(InteractionTypes()) + iGeneralOverwrite = SBOVERWRITEUNDEFINED + bConversionIsRunning = True + bLogExists = false + AbsTemplateFound = 0 + AbsDocuFound = 0 + CollectPaths(sFiltername()) + If Not ReadCollectionPaths(FilesList(), sFilterName()) Then + TotFound = 0 + SetProgressDisplay(0) + bConversionisrunning = false + FinalizeDialogButtons() + Exit Sub + End If + TotFound = Ubound(FilesList()) + 1 + If FilesList(0,0) = "" Then ' Querying the number of fields in a multidimensional Array is unsecure + TotFound = 0 ' because it will return the value 0 (and not -1) even when the Array is empty + SetProgressDisplay(0) + End If + BubbleSortList(FilesList(), true) + If TotFound > 0 Then + CreateLogDocument(OpenProperties()) + InitializeProgressPage(ImportDialog) + OpenProperties(0).Name = "Hidden" + OpenProperties(0).Value = True + OpenProperties(1).Name = "AsTemplate" + OpenProperties(1).Value = False + OpenProperties(2).Name = "MacroExecutionMode" + OpenProperties(2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE + OpenProperties(3).Name = "UpdateDocMode" + OpenProperties(3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE + OpenProperties(4).Name = "InteractionHandler" + OpenProperties(4).Value = oInteractionHandler + MaxFileIndex = Ubound(FilesList(),1) + FileCount = 0 + For i = 0 To MaxFileIndex + sComment = "" + If InterruptProcess() Then + Exit For + End If + bDoSave = True + sSourceUrl = FilesList(i,0) + sPrevMimeTypeorExtension = sMimeTypeorExtension + sMimeTypeorExtension = FilesList(i,1) + CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex) + ApplIndex = FilesList(i,2) + If sMimeTypeorExtension <> sPrevMimeTypeorExtension Then + CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername()) + End If + If ApplIndex > Ubound(Applications) or (ApplIndex < 0) Then + Msgbox "Applicationindex out of bounds:" & sSourcUrl + End If + sViewPath = ConvertFromUrl(sSourceUrl) ' CutPathView(sSourceUrl, 70) + ImportDialog.LabelCurDocument.Label = Str(i+1) & "/" & MaxFileIndex + 1 & " (" & sViewPath & ")" + Select Case lcase(sExtension) + Case "odt", "ods", "odp", "odg", "odm", "odf" + SourceStemDir = RTrimStr(Applications(ApplIndex,SBDOCSOURCE), "/") + TargetStemDir = RTrimStr(Applications(ApplIndex,SBDOCTARGET), "/") + Case Else ' Templates and Helper-Applications remain + SourceStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLSOURCE), "/") + TargetStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLTARGET), "/") + End Select + sTargetUrl = ReplaceString(sSourceUrl, TargetStemDir, SourceStemDir) + CurFilename = GetFileNameWithoutExtension(sTargetUrl, "/") + OldExtension = GetFileNameExtension(sTargetUrl) + sTargetUrl = RTrimStr(sTargetUrl, OldExtension) + sTargetUrl = sTargetUrl & sExtension + TargetDir = RTrimStr(sTargetUrl, CurFilename & "." & sExtension) + If (oUcb.Exists(sTargetUrl)) Then + If (iGeneralOverwrite <> SBOVERWRITEALWAYS) Then + If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then + ShowOverwriteAllDialog(sTargetUrl, sTitle) + bDoSave = (iGeneralOverwrite = SBOVERWRITEQUERY) Or (iGeneralOverwrite = SBOVERWRITEALWAYS) + Elseif iGeneralOverwrite = SBOVERWRITENEVER Then + bDoSave = False + ElseIf ((iGeneralOverWrite = SBOVERWRITEQUERY) OR (iGeneralOverwrite = SBOVERWRITECANCEL)) Then + ' Todo: According to AS there might come a new feature that storeasUrl could possibly rise a UI dialog. + ' In this case my own UI becomes obsolete + sCurFileExists = ReplaceString(sFileExists, ConvertFromUrl(sTargetUrl), "<1>") + sCurFileExists = ReplaceString(sCurFileExists, chr(13), "<CR>") + iOverWrite = Msgbox (sCurFileExists, 32 + 3, sTitle) + Select Case iOverWrite + Case 1 ' OK + ' In the FileProperty-Bean this is already default + bDoSave = True + Case 2 ' Abort + CancelTask(False) + bDoSave = False + Case 7 ' No + bDoSave = False + End Select + End If + End If + End If + If bDoSave Then + If Not oUcb.Exists(TargetDir) Then + bDoSave = CreateFolder(TargetDir) + End If + If bDoSave Then + oDocument = StarDesktop.LoadComponentFromURL(sSourceUrl, "_default", 0, OpenProperties()) + If Not IsNull(oDocument) Then + InsertSourceUrlToLogDocument(sSourceUrl, "") + bIsPassWordProtected = CheckPassWordProtection(oDocument) + CheckIfMacroExists(oDocument.BasicLibraries, sComment) + On Local Error Goto NOSAVING + If bIsPassWordProtected Then + PWFileProperties(0).Name = "FilterName" + PWFileProperties(0).Value = CurFilterName + PWFileProperties(1).Name = "Overwrite" + PWFileProperties(1).Value = True + PWFileProperties(2).Name = "Password" + PWFileProperties(2).Value = sCurPassWord + oDocument.StoreAsUrl(sTargetUrl, PWFileProperties()) + Else + FileProperties(0).Name = "FilterName" + FileProperties(0).Value = CurFilterName + FileProperties(1).Name = "Overwrite" + FileProperties(1).Value = True + oDocument.StoreAsUrl(sTargetUrl,FileProperties()) + End If + ' Todo: Make sure that an errorbox pops up when saving fails + NOSAVING: + If Err <> 0 Then + sCurcouldnotsaveDocument = ReplaceString(scouldnotsaveDocument, ConvertFromUrl(sTargetUrl), "<1>") + sComment = ConcatComment(sComment, sCurCouldnotsaveDocument) + Resume LETSGO + LETSGO: + Else + FileCount = FileCount + 1 + End If + oDocument.Dispose() + InsertTargetUrlToLogDocument(sTargetUrl, sComment) + Else + sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl), "<1>") + sComment = ConcatComment(sComment, sCurCouldnotopenDocument) + InsertSourceUrlToLogDocument(sSourceUrl, sComment) + End If + End If + End If + Next i + End If + AddLogStatistics() + FinalizeDialogButtons() + bConversionIsRunning = False + Exit Sub +RTError: + Msgbox sRTErrorDesc, 16, sRTErrorHeader +End Sub + + + +Sub AddListtoFilesList(FirstList(), SecList(), NewContentList() as String) +Dim sLocExtension as String +Dim FirstStart as Integer +Dim FirstEnd as Integer +Dim i as Integer +Dim s as Integer + If FirstList(0,0) = "" Then + FirstStart = Ubound(FirstList(),1) + Else + FirstStart = Ubound(FirstList(),1) + 1 + End If + FirstEnd = FirstStart + Ubound(SecList(),1) + ReDim Preserve FirstList(FirstEnd,2) + s = 0 + For i = FirstStart To FirstEnd + FirstList(i,0) = SecList(s,0) + FirstList(i,1) = SecList(s,1) + sLocExtension = lcase(FirstList(i,1)) + Select Case sLocExtension + Case "sdw", "sdc", "sda", "sdd", "smf", "sgl", "doc", "docx", "docm", "xls", "xlsx", "xlsm", "ppt", "pps", "pptx", "pptm", "ppsx", "ppsm", "pub", "sxi", "sxw", "sxd", "sxg", "sxm", "sxc" + AbsDocuFound = AbsDocuFound + 1 + Case else + AbsTemplateFound = AbsTemplateFound + 1 + End Select + FirstList(i,2) = CStr(NewContentList(s)) + s = s + 1 + Next i + SetProgressDisplay(Ubound(FirstList()) + 1) +End Sub + + + +Function GetTargetTemplatePath(Index as Integer) + Select Case WizardMode + Case SBMICROSOFTMODE + GetTargetTemplatePath() = SOTemplatePath & "/" & sTemplateGroupName + End Select +End Function + + +' Retrieves the second value for a next to 'SearchString' in +' a two-dimensional string-Array +Function GetFilterName(sMimetypeorExtension as String, sFilterName(), sExtension as string, FilterIndex as Integer) as String +Dim i as Integer +Dim MaxIndex as Integer +Dim sLocFilterlist() as String + For i = 0 To Ubound(sFiltername(),1) + If Instr(1,sFilterName(i,0),sMimeTypeOrExtension) <> 0 Then + sLocFilterList() = ArrayoutofString(sFiltername(i,0),"|", MaxIndex) + If MaxIndex = 0 Then + sExtension = sFiltername(i,2) + GetFilterName = sFilterName(i,1) + Else + Dim b as Integer + Dim sLocExtensionList() as String + b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList()) + sLocFilterList() = ArrayoutofString(sFiltername(i,1),"|", MaxIndex) + GetFilterName = sLocFilterList(b) + sLocExtensionList() = ArrayoutofString(sFilterName(i,2), "|", MaxIndex) + sExtension = sLocExtensionList(b) + End If + Exit For + End If + Next + FilterIndex = i +End Function + + +Function SearchArrayforPartString(SearchString as String, LocList()) as Integer +Dim i as Integer +Dim a as Integer +Dim StringList() as String + For i = Lbound(LocList(),1) to Ubound(LocList(),1) + StringList() = ArrayoutofString(LocList(i), "|") + For a = 0 To Ubound(StringList()) + If (Instr(1, SearchString, StringList(a)) <> 0) Then + SearchArrayForPartString() = i + Exit Function + End If + Next a + Next i + SearchArrayForPartString() = -1 +End Function + + +Sub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String) +Dim oLogCursor as Object +Dim oLogRows as Object +Dim FilterIndex as Integer +Dim sDocumentType as String +Dim oTextCursor +Dim oCell + If Not bLogExists Then + Exit Sub + End If + FilterIndex = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent, 0) + sDocumentType = sFiltername(FilterIndex,3) + oLogCursor = oLogDocument.Text.createTextCursor() + oLogCursor.GotoEnd(False) + If Not bIsFirstLogTable Then + oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) + Else + bisFirstLogTable = False + End If + oLogCursor.HyperLinkURL = "" + oLogCursor.HyperLinkName = "" + oLogCursor.HyperLinkTarget = "" + oLogCursor.ParaStyleName = "Heading 1" + oLogCursor.setString(sDocumentType) + oLogCursor.CollapsetoEnd() + oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) + oLogTable = oLogDocument.CreateInstance("com.sun.star.text.TextTable") + oLogTable.RepeatHeadline = true + oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True) + oTextCursor = oLogTable.GetCellbyPosition(0,0).createTextCursor() + oTextCursor.SetString(sSourceDocuments) + oTextCursor = oLogTable.GetCellbyPosition(1,0).createTextCursor() + oTextCursor.SetString(sTargetDocuments) + bInsertRow = False +End Sub + + +Function GetSize(iWidth, iHeight) As New com.sun.star.awt.Size +Dim aSize As New com.sun.star.awt.Size + aSize.Width = iWidth + aSize.Height = iHeight + GetSize() = aSize +End Function + + +Sub InsertCommandButtonatViewCursor(oLocDocument, oLocCursor, TargetUrl as String, Optional aSize) +Dim oDocument +Dim oController +Dim oCommandButton +Dim oShape +Dim oDrawPage +Dim oCommandControl +Dim oEvent +Dim oCell + oCommandButton = oLocDocument.createInstance("com.sun.star.form.component.CommandButton") + oShape = oLocDocument.CreateInstance ("com.sun.star.drawing.ControlShape") + If IsMissing(aSize) Then + oShape.Size = GetSize(4000, 600) + End If + oCommandButton.Label = FileNameoutofPath(Targeturl) + oCommandButton.TargetFrame = "_default" + oCommandButton.ButtonType = com.sun.star.form.FormButtonType.URL + oCommandbutton.DispatchUrlInternal = True + oCommandButton.TargetURL = ConverttoUrl(TargetUrl) + oShape.Control = oCommandbutton + oLocCursor.Text.InsertTextContent(oLocCursor, oShape, True) +End Sub + + + +Sub CreateLogDocument(HiddenProperties()) +Dim OpenProperties(0) as new com.sun.star.beans.PropertyValue +Dim NoArgs() +Dim i as Integer +Dim bLogIsThere as Boolean + If ImportDialog.chkLogfile.State = 1 Then + i = 2 + OpenProperties(0).Name = "Hidden" + OpenProperties(0).Value = True + oLogDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_default", 4, OpenProperties()) + SOWorkPath = RTrimStr(SOWorkPath,"/") + sLogUrl = SOWorkPath & "/Logfile.odt" + Do + bLogIsThere = oUcb.Exists(sLogUrl) + If bLogIsThere Then + If i = 2 Then + sLogUrl = ReplaceString(sLogUrl, "/Logfile_2.odt", "/Logfile.odt") + Else + sLogUrl = ReplaceString(sLogUrl, "/Logfile_" & cStr(i) & ".odt", "/Logfile_" & cStr(i-1) & ".odt") + End If + i = i + 1 + End If + Loop Until Not bLogIsThere + bLogExists = True + oLogDocument.StoreAsUrl(sLogUrl, NoArgs()) + End If +End Sub + + +Sub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String) +Dim oCell +Dim oTextCursor +Dim CurFilterTracingpath as String + If (bLogExists) And (sTargetUrl <> "") Then + If sTargetUrl <> "" Then + oCell = oLogTable.GetCellbyPosition(1,oLogTable.Rows.Count-1) + InsertCommentToLogCell(sComment, oCell) + InsertHyperLinkToLogCell(sTargetUrl, oCell) + oLogDocument.Store() + End If + End If +End Sub + + +Sub InsertSourceUrlToLogDocument(SourceUrl as String, sComment) ' +Dim oCell as Object + If bLogExists Then + If bInsertRow Then + oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,1) + Else + bInsertRow = True + End If + oCell = oLogTable.GetCellbyPosition(0,oLogTable.Rows.Count-1) + InsertCommentToLogCell(sComment, oCell) + InsertHyperLinkToLogCell(SourceUrl, oCell) + oLogDocument.Store() + End If +End Sub + + +Sub InsertHyperLinkToLogCell(sUrl as String, oCell as Object) +Dim oLogCursor as Object +Dim LocFileName as String + oLogCursor = oCell.createTextCursor() + oLogCursor.CollapseToStart() + oLogCursor.HyperLinkURL = sUrl + oLogCursor.HyperLinkName = sUrl + oLogCursor.HyperLinkTarget = sUrl + LocFileName = FileNameOutOfPath(sUrl) + oCell.InsertString(oLogCursor, LocFileName,False) +End Sub + + +Sub InsertCommentToLogCell(sComment as string, oCell as Object) +Dim oCommentCursor as Object + If sComment <> "" Then + oCommentCursor = oCell.createTextCursor() + oCell.insertControlCharacter(oCommentCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) + oCell.insertString(oCommentCursor, sComment, false) + End If +End Sub + + +Sub AddLogStatistics() +Dim oCell as Object +Dim oLogCursor as Object +Dim MaxRowIndex as Integer + If bLogExists Then + MaxRowIndex = oLogTable.Rows.Count + sLogSummary = ReplaceString(sLogSummary, FileCount, "<COUNT>") +' oLogTable.Rows.InsertByIndex(MaxRowIndex, 1) +' oCell = oLogTable.GetCellbyPosition(0, MaxRowIndex) +' oLogCursor = oCell.createTextCursor() +' oCell.InsertString(oLogCursor, sLogSummary,False) +' MergeRange(oLogTable, oCell, 1) + + oLogCursor = oLogDocument.Text.CreateTextCursor + oLogCursor.gotoEnd(False) + oLogCursor.HyperLinkURL = "" + oLogCursor.HyperLinkName = "" + oLogCursor.HyperLinkTarget = "" + oLogCursor.SetString(sLogSummary) + oLogDocument.Store() + oLogDocument.Dispose() + bLogExists = False + End If +End Sub + + + +Function CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean +Dim ModuleNames() as String +Dim ModuleName as String +Dim MaxLibIndex as Integer +Dim MaxModuleIndex as Integer +Dim bMacroExists as Boolean +Dim n as Integer +Dim m as Integer +Dim LibName as String +Dim sBasicCode as String +Dim oLibrary as Object + bMacroExists = False + bMacroExists = oBasicLibraries.hasElements + If bMacroExists Then + MaxLibIndex = Ubound(oBasicLibraries.ElementNames()) + For n = 0 To MaxLibIndex + LibName = oBasicLibraries.ElementNames(n) + If oBasicLibraries.isLibraryLoaded(LibName) Then + oLibrary = oBasicLibraries.getbyName(LibName) + If oLibrary.hasElements() Then + MaxModuleIndex = Ubound(oLibrary.ElementNames()) + For m = 0 To MaxModuleIndex + ModuleName = oLibrary.ElementNames(m) + sBasicCode = oLibrary.getbyName(ModuleName) + If sBasicCode <> "" Then + ConcatComment(sComment, sReeditMacro) + CheckIfMacroExists() = True + Exit Function + End If + Next m + End If + End If + Next n + End If + CheckIfMacroExists() = False +End Function + + + +Function CheckPassWordProtection(oDocument as Object) +Dim bIsPassWordProtected as Boolean +Dim i as Integer +Dim oArgs() +Dim MaxIndex as Integer +Dim sblabla as String + bIsPassWordProtected = false + oArgs() = oDocument.getArgs() + MaxIndex = Ubound(oArgs()) + For i = 0 To MaxIndex + sblabla = oArgs(i).Name + If oArgs(i).Name = "Password" Then + bIsPassWordProtected = True + sCurPassWord = oArgs(i).Value + Exit For + End If + Next i + CheckPassWordProtection() = bIsPassWordProtected +End Function + + +Sub OpenLogDocument() + + bShowLogFile = True + ImportDialogArea.endexecute() + +End Sub + + +Sub MergeRange(oTable as Object, oCell as Object, MergeCount as Integer) +Dim oTableCursor as Object + oTableCursor = oTable.createCursorByCellName(oCell.CellName) + oTableCursor.goRight(MergeCount, True) + oTableCursor.mergeRange() +End Sub + + +Function ConcatComment(sComment as String, AdditionalComment as String) + If sComment = "" Then + sComment = AdditionalComment + Else + sComment = sComment & chr(13) + AdditionalComment + End If + ConcatComment = sComment +End Function +</script:module> diff --git a/wizards/source/importwizard/ImportDialog.xdl b/wizards/source/importwizard/ImportDialog.xdl new file mode 100644 index 000000000..1f3fc71ff --- /dev/null +++ b/wizards/source/importwizard/ImportDialog.xdl @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ImportDialog" dlg:left="96" dlg:top="28" dlg:width="270" dlg:height="210" dlg:page="4" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_DIALOG" dlg:closeable="true" dlg:moveable="true" dlg:title="ImportDialog"> + <dlg:bulletinboard> + <dlg:text dlg:id="lblTemplateExport" dlg:tab-index="0" dlg:left="12" dlg:top="94" dlg:width="60" dlg:height="8" dlg:page="2" dlg:value="lblTemplateExport"/> + <dlg:textfield dlg:id="txtTemplateImportPath" dlg:tab-index="1" dlg:left="73" dlg:top="76" dlg:width="170" dlg:height="12" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_LBTEMPLATEPATH"> + <script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleNextButton?language=Basic&location=application" script:language="Script"/> + </dlg:textfield> + <dlg:textfield dlg:id="txtTemplateExportPath" dlg:tab-index="2" dlg:left="73" dlg:top="92" dlg:width="170" dlg:height="12" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_EDTEMPLATEPATH"/> + <dlg:checkbox dlg:id="chkDocumentPath" dlg:tab-index="3" dlg:left="12" dlg:top="121" dlg:width="240" dlg:height="10" dlg:page="2" dlg:tag="Document" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENT" dlg:value="chkDocumentPath" dlg:checked="true"> + <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.ToggleInputPaths?language=Basic&location=application" script:language="Script"/> + </dlg:checkbox> + <dlg:checkbox dlg:id="chkDocumentSearchSubDir" dlg:tab-index="4" dlg:left="12" dlg:top="134" dlg:width="240" dlg:height="10" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENTRECURSE" dlg:value="chkDocumentSearchSubDir" dlg:checked="false"/> + <dlg:text dlg:id="lblDocumentImport" dlg:tab-index="5" dlg:left="10" dlg:top="151" dlg:width="60" dlg:height="8" dlg:page="2" dlg:value="lblDocumentImport"/> + <dlg:text dlg:id="lblDocumentExport" dlg:tab-index="6" dlg:left="10" dlg:top="167" dlg:width="60" dlg:height="8" dlg:page="2" dlg:value="lblDocumentExport"/> + <dlg:textfield dlg:id="txtDocumentImportPath" dlg:tab-index="7" dlg:left="73" dlg:top="149" dlg:width="170" dlg:height="12" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_LBDOCUMENTPATH"> + <script:event script:event-name="on-textchange" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleNextButton?language=Basic&location=application" script:language="Script"/> + </dlg:textfield> + <dlg:textfield dlg:id="txtDocumentExportPath" dlg:tab-index="8" dlg:left="73" dlg:top="165" dlg:width="170" dlg:height="12" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_EDDOCUMENTPATH"/> + <dlg:text dlg:id="SummaryHeaderLabel" dlg:tab-index="9" dlg:left="6" dlg:top="37" dlg:width="258" dlg:height="8" dlg:page="3" dlg:value="SummaryHeaderLabel"/> + <dlg:textfield dlg:id="SummaryTextbox" dlg:tab-index="10" dlg:left="5" dlg:top="48" dlg:width="259" dlg:height="125" dlg:page="3" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_3_TBSUMMARY" dlg:vscroll="true" dlg:multiline="true" dlg:readonly="true"/> + <dlg:text dlg:id="LabelRetrieval" dlg:tab-index="11" dlg:left="10" dlg:top="67" dlg:width="255" dlg:height="8" dlg:page="4" dlg:value="LabelRetrieval"/> + <dlg:text dlg:id="LabelCurTemplateRetrieval" dlg:tab-index="12" dlg:left="15" dlg:top="79" dlg:width="249" dlg:height="8" dlg:page="4" dlg:value="LabelCurTemplateRetrieval"/> + <dlg:text dlg:id="LabelCurDocumentRetrieval" dlg:tab-index="13" dlg:left="15" dlg:top="91" dlg:width="249" dlg:height="8" dlg:page="4" dlg:value="LabelCurDocumentRetrieval"/> + <dlg:text dlg:id="LabelCurProgress" dlg:tab-index="14" dlg:left="10" dlg:top="106" dlg:width="255" dlg:height="8" dlg:page="4" dlg:value="LabelCurProgress"/> + <dlg:text dlg:id="LabelCurDocument" dlg:tab-index="15" dlg:left="15" dlg:top="118" dlg:width="249" dlg:height="20" dlg:page="4" dlg:value="LabelCurDocument" dlg:multiline="true"/> + <dlg:img dlg:id="ImportPreview" dlg:tab-index="16" dlg:left="6" dlg:top="6" dlg:width="258" dlg:height="26" dlg:scale-image="false"/> + <dlg:button dlg:id="cmdBack" dlg:tab-index="17" dlg:left="155" dlg:top="190" dlg:width="50" dlg:height="14" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_0_CMDPREV" dlg:value="cmdBack"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.Main.PrevStep?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdCancel" dlg:tab-index="18" dlg:left="6" dlg:top="190" dlg:width="50" dlg:height="14" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_0_CMDCANCEL" dlg:value="cmdCancel"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.Main.CancelTask?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdHelp" dlg:tab-index="19" dlg:left="65" dlg:top="190" dlg:width="50" dlg:height="14" dlg:value="cmdHelp" dlg:button-type="help"/> + <dlg:button dlg:id="cmdGoOn" dlg:tab-index="20" dlg:left="214" dlg:top="190" dlg:width="50" dlg:height="14" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_0_CMDNEXT" dlg:value="cmdGoOn"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.Main.NextStep?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:text dlg:id="WelcomeTextLabel" dlg:tab-index="21" dlg:left="6" dlg:top="38" dlg:width="258" dlg:height="20" dlg:page="1" dlg:value="WelcomeTextLabel" dlg:multiline="true"/> + <dlg:text dlg:id="WelcomeTextLabel3" dlg:tab-index="22" dlg:left="6" dlg:top="58" dlg:width="258" dlg:height="12" dlg:page="1" dlg:value="WelcomeTextLabel3"/> + <dlg:button dlg:id="cmdTemplateImport" dlg:tab-index="23" dlg:left="248" dlg:top="75" dlg:width="14" dlg:height="14" dlg:page="2" dlg:tag="txtTemplateImportPath" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT" dlg:value="..."> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.TakoverFolderName?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdTemplateExport" dlg:tab-index="24" dlg:left="248" dlg:top="91" dlg:width="14" dlg:height="14" dlg:page="2" dlg:tag="txtTemplateExportPath" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT2" dlg:value="..."> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.TakoverFolderName?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdDocumentImport" dlg:tab-index="25" dlg:left="248" dlg:top="148" dlg:width="14" dlg:height="14" dlg:page="2" dlg:tag="txtDocumentImportPath" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT" dlg:value="..."> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.TakoverFolderName?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdDocumentExport" dlg:tab-index="26" dlg:left="248" dlg:top="164" dlg:width="14" dlg:height="14" dlg:page="2" dlg:tag="txtDocumentExportPath" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT2" dlg:value="..."> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.TakoverFolderName?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:radiogroup> + <dlg:radio dlg:id="optMSDocuments" dlg:tab-index="27" dlg:left="6" dlg:top="72" dlg:width="258" dlg:height="9" dlg:page="1" dlg:tag="MS" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_0_OPTMSDOCUMENTS" dlg:value="optMSDocuments" dlg:checked="true"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleCheckboxes?language=Basic&location=application" script:language="Script"/> + </dlg:radio> + </dlg:radiogroup> + <dlg:checkbox dlg:id="chkMSApplication1" dlg:tab-index="29" dlg:disabled="true" dlg:left="12" dlg:top="85" dlg:width="141" dlg:height="9" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CHKWORD" dlg:value="chkMSApplication1" dlg:checked="false"> + <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleNextButton?language=Basic&location=application" script:language="Script"/> + </dlg:checkbox> + <dlg:checkbox dlg:id="chkMSApplication2" dlg:tab-index="30" dlg:disabled="true" dlg:left="155" dlg:top="85" dlg:width="109" dlg:height="9" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CHKEXCEL" dlg:value="chkMSApplication2" dlg:checked="false"> + <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleNextButton?language=Basic&location=application" script:language="Script"/> + </dlg:checkbox> + <dlg:checkbox dlg:id="chkMSApplication3" dlg:tab-index="31" dlg:disabled="true" dlg:left="12" dlg:top="98" dlg:width="141" dlg:height="9" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CHKPOWERPOINT" dlg:value="chkMSApplication3" dlg:checked="false"> + <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:ImportWizard.Main.ToggleNextButton?language=Basic&location=application" script:language="Script"/> + </dlg:checkbox> + <dlg:checkbox dlg:id="chkTemplatePath" dlg:tab-index="36" dlg:left="12" dlg:top="48" dlg:width="240" dlg:height="10" dlg:page="2" dlg:tag="Template" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATE" dlg:value="chkTemplatePath" dlg:checked="true"> + <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:ImportWizard.DialogModul.ToggleInputPaths?language=Basic&location=application" script:language="Script"/> + </dlg:checkbox> + <dlg:checkbox dlg:id="chkTemplateSearchSubDir" dlg:tab-index="37" dlg:left="12" dlg:top="61" dlg:width="240" dlg:height="10" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATERECURSE" dlg:value="chkTemplateSearchSubDir" dlg:checked="false"/> + <dlg:text dlg:id="lblTemplateImport" dlg:tab-index="38" dlg:left="12" dlg:top="78" dlg:width="60" dlg:height="8" dlg:page="2" dlg:value="lblTemplateImport"/> + <dlg:checkbox dlg:id="chkLogfile" dlg:tab-index="39" dlg:left="6" dlg:top="171" dlg:width="136" dlg:height="9" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGIMPORT_0_CHKLOGFILE" dlg:value="chkLogfile" dlg:checked="true"/> + <dlg:fixedline dlg:id="hlnTemplates" dlg:tab-index="40" dlg:left="6" dlg:top="37" dlg:width="258" dlg:height="8" dlg:page="2" dlg:value="hlnTemplates"/> + <dlg:fixedline dlg:id="hlnDocuments" dlg:tab-index="41" dlg:left="6" dlg:top="110" dlg:width="258" dlg:height="8" dlg:page="2" dlg:value="hlnDocuments"/> + <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="42" dlg:left="6" dlg:top="181" dlg:width="258" dlg:height="6"/> + <dlg:fixedline dlg:id="hlnProgress" dlg:tab-index="43" dlg:left="6" dlg:top="55" dlg:width="258" dlg:height="8" dlg:page="4" dlg:value="hlnProgress"/> + <dlg:button dlg:id="cmdShowLogFile" dlg:tab-index="44" dlg:disabled="true" dlg:left="75" dlg:top="142" dlg:width="120" dlg:height="14" dlg:page="4" dlg:value="cmdShowLogFile"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:ImportWizard.FilesModul.OpenLogDocument?language=Basic&location=application" script:language="Script"/> + </dlg:button> + </dlg:bulletinboard> +</dlg:window> diff --git a/wizards/source/importwizard/Language.xba b/wizards/source/importwizard/Language.xba new file mode 100644 index 000000000..bd890ed63 --- /dev/null +++ b/wizards/source/importwizard/Language.xba @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Language" script:language="StarBasic">Option Explicit + +Public sMSTemplateCheckbox(2) As String +Public sMSDocumentCheckbox(2) As String +Public sTemplateCheckbox(SBMAXAPPLCOUNT-1) As String +Public sDocumentCheckbox(SBMAXAPPLCOUNT-1) As String +Public sTemplateGroupName As String +Public sSearchInSubDir as String +Public sPathErrorTemplates(SBMAXAPPLCOUNT-1) As String +Public sPathErrorDocument(SBMAXAPPLCOUNT-1) As String +Public sPathErrorStarDoc(SBMAXAPPLCOUNT-1) As String +Public sStarDocLabel(SBMAXAPPLCOUNT-1) As String +Public sImportLabel As String, sExportLabel As String +Public SOApplicationName(5) As String +Public sHelpButton As String, sCancelButton As String, sBackButton As String, sNextButton As String +Public sSumInclusiveSubDir As String, sSumSaveDocuments As String +Public sSummaryHeader As String +Public sWelcometextLabel1 As String, sWelcometextLabel3 As String +Public sBeginButton As String, sMsgDirNotThere As String +Public sQueryForNewCreation As String, sPathError3 As String +Public sNoDirCreation As String +Public sProgressMoreDocs As String, sProgressMoreTemplates as String +Public sFileExists As String, sMorePathsError3 As String +Public sConvertError1 As String, sConvertError2 As String, sPathDialogMessage As String +Public sRTErrorDesc As String, sRTErrorHeader As String +Public sProgressPage_1 As String, sProgressPage_2 As String, sProgressPage_3 as String +Public sProgressFound as String, sProgresspage_5 as String +Public sContainerName(1) as String +Public sReady as String, sTitle as String +Public sCloseButton as String +Public sSourceDocuments as String +Public sTargetDocuments as String +Public sSumMSDocuments(3) as String +Public sSumMSTemplates(3) as String +Public ModuleList(3) as String +Public sLogSummary as String +Public sReeditMacro as String +Public sOverwriteallFiles as String +Public sCouldnotopenDocument as String +Public sCurcouldnotopenDocument as String +Public sCouldnotsaveDocument as String +Public sCurcouldnotsaveDocument as String + + +Sub LoadLanguage() + If InitResources("ImportWizard") then + sHelpButton = GetResText("HelpButton") + sCancelButton = GetResText("CancelButton") + sBackButton = GetResText("BackButton") + sNextButton = GetResText("NextButton") + sBeginButton = GetResText("BeginButton") + sCloseButton = GetResText("CloseButton") + + sWelcometextLabel1 = ReplaceString(GetResText("WelcometextLabel1"), GetProductName(),"%PRODUCTNAME") + sWelcometextLabel3 = GetResText("WelcometextLabel3") + + ' Microsoft Documents + sMSTemplateCheckBox(0) = GetResText("MSTemplateCheckbox_1_") + sMSTemplateCheckBox(1) = GetResText("MSTemplateCheckbox_2_") + sMSTemplateCheckBox(2) = GetResText("MSTemplateCheckbox_3_") + + ' DocumentCheckbox- Captions + sMSDocumentCheckBox(0) = GetResText("MSDocumentCheckbox_1_") + sMSDocumentCheckBox(1) = GetResText("MSDocumentCheckbox_2_") + sMSDocumentCheckBox(2) = GetResText("MSDocumentCheckbox_3_") + + 'StarOffice Applicationnames + + sContainerName(0) = GetResText("MSContainerName") + + sSummaryHeader = GetResText("SummaryHeader") + + sTemplateGroupName = GetResText("GroupnameDefault") + + sProgressMoreDocs = GetResText("ProgressMoreDocs") + sProgressMoreTemplates = GetResText("ProgressMoreTemplates") + sNoDirCreation = GetResText("NoDirCreation") + sMsgDirNotThere = GetResText("MsgDirNotThere") + sQueryForNewCreation = GetResText("QueryfornewCreation") + sFileExists = GetResText("FileExists") + sMorePathsError3 = GetResText("MorePathsError3") + sConvertError1 = GetResText("ConvertError1") + sConvertError2 = GetResText("ConvertError2") + sRTErrorDesc = GetResText("RTErrorDesc") + sRTErrorHeader = GetResText("RTErrorHeader") + sOverwriteallFiles = GetResText("OverwriteallFiles") + sReeditMacro = GetResText("ReeditMacro") + sCouldnotsaveDocument = GetResText("CouldNotsaveDocument") + sCouldnotopenDocument = GetResText("CouldNotopenDocument") + sPathDialogMessage = GetResText("PathDialogMessage") + sTitle = GetResText("DialogTitle") + + sProgressPage_1 = GetResText("ProgressPage1") + sProgressPage_2 = GetResText("ProgressPage2") + sProgressPage_3 = GetResText("ProgressPage3") + sProgressFound = GetResText("ProgressFound") + sProgressPage_5 = GetResText("ProgressPage5") + sReady = GetResText("Ready") + sSourceDocuments = GetResText("SourceDocuments") + sTargetDocuments = GetResText("TargetDocuments") + sLogSummary = GetResText("LogfileSummary") + sSumInclusiveSubDir = GetResText("SumInclusiveSubDir") + sSumSaveDocuments = GetResText("SumSaveDokumente") + sSumMSDocuments(0) = GetResText("SumMSTextDocuments") + sSumMSDocuments(1) = GetResText("SumMSTableDocuments") + sSumMSDocuments(2) = GetResText("SumMSDrawDocuments") + sSumMSTemplates(0) = GetResText("SumMSTextTemplates") + sSumMSTemplates(1) = GetResText("SumMSTableTemplates") + sSumMSTemplates(2) = GetResText("SumMSDrawTemplates") + With ImportDialog + sImportLabel = GetResText("TextImportLabel") + sExportLabel = GetResText("TextExportLabel") + sSearchInSubDir = GetResText("SearchInSubDir") + .chkTemplateSearchSubDir.Label = sSearchInSubDir + .lblDocumentImport.Label = sImportLabel + .lblDocumentExport.Label = sExportLabel + .chkDocumentSearchSubDir.Label = sSearchInSubDir + .lblTemplateImport.Label = sImportLabel + .lblTemplateExport.Label = sExportLabel + .chkLogfile.Label = GetResText("CreateLogfile") + .chkLogfile.Helptext = GetResText("LogfileHelpText") + .cmdShowLogFile.Label = GetResText("ShowLogfile") + End With + ModuleList(0) = "com.sun.star.text.TextDocument" + ModuleList(1) = "com.sun.star.sheet.SpreadsheetDocument" + ModuleList(2) = "com.sun.star.drawing.DrawingDocument/com.sun.star.presentation.PresentationDocument" + ModuleList(3) = "com.sun.star.formula.FormulaProperties/com.sun.star.text.GlobalDocument" + End If +End Sub + +</script:module> diff --git a/wizards/source/importwizard/Main.xba b/wizards/source/importwizard/Main.xba new file mode 100644 index 000000000..b8cc8211e --- /dev/null +++ b/wizards/source/importwizard/Main.xba @@ -0,0 +1,291 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Main" script:language="StarBasic">Option Explicit +REM ***** BASIC ***** + +Public HeaderPreviews(4) as Object +Public ImportDialog as Object +Public ImportDialogArea as Object +Public oFactoryKey as Object +Public bShowLogFile as Boolean + +' If the ProgressPage is already on Top The Dialog will be immediately closed when this flag is +' set to False +Public bConversionIsRunning as Boolean +Public RetValue as Integer + +Sub Main() + Dim NoArgs() as New com.sun.star.beans.PropertyValue + bShowLogFile=FALSE + If Not bDebugWizard Then + On Local Error Goto RTError + End If + BasicLibraries.LoadLibrary("Tools") + RetValue = 10 + bIsFirstLogTable = True + bConversionIsRunning = False + sCRLF = CHR(13) & CHR(10) + oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess") + oFactoryKey = GetRegistryKeyContent("org.openoffice.Setup/Office/Factories") + If GetImportWizardPaths() = False Then + Exit Sub + End If + bCancelTask = False + bDoKeepApplValues = False + CurOffice = 0 + ImportDialogArea = LoadDialog("ImportWizard","ImportDialog") + ImportDialog = ImportDialogArea.Model + LoadLanguage() + WizardMode = SBMICROSOFTMODE + MaxApplCount = 3 + FillStep_Welcome() + RepaintHeaderPreview() + ImportDialog.ImportPreview.BackGroundColor = RGB(0,60,126) + ImportDialog.cmdGoOn.DefaultButton = True + ImportDialogArea.GetControl("optMSDocuments").SetFocus() + ToggleCheckboxesWithBoolean(True) + + RetValue = ImportDialogArea.Execute() + If bShowLogFile=TRUE Then + OpenDocument(sLogUrl, NoArgs()) + End if + If RetValue = 0 Then + CancelTask() + End If + ImportDialogArea.Dispose() + End + Exit Sub +RTError: + Msgbox sRTErrorDesc, 16, sRTErrorHeader +End Sub + + +Sub NextStep() +Dim iCurStep as Integer + If Not bDebugWizard Then + On Error Goto RTError + End If + bConversionIsRunning = False + iCurStep = ImportDialog.Step + Select Case iCurStep + Case 1 + FillStep_InputPaths(0, True) + Case 2 + If CheckInputPaths Then + SaveStep_InputPath + If CurOffice < ApplCount - 1 Then + CurOffice = CurOffice + 1 + TakeOverPathSettings() + FillStep_InputPaths(CurOffice, False) + Else + FillStep_Summary() + End If + End If + Case 3 + FillStep_Progress() + Select Case WizardMode + Case SBMICROSOFTMODE + Call ConvertAllDocuments(MSFilterName()) + End Select + Case 4 + CancelTask(True) + End Select + + If ((ImportDialog.chkLogfile.State <> 1) OR (iCurStep <> 3)) Then + ImportDialog.cmdGoOn.DefaultButton = True + End If + + RepaintHeaderPreview() + Exit Sub +RTError: + Msgbox sRTErrorDesc, 16, sRTErrorHeader +End Sub + + +Sub PrevStep() +Dim iCurStep as Integer + If Not bDebugWizard Then + On Error Goto RTError + End If + bConversionIsRunning = False + iCurStep = ImportDialog.Step + Select Case iCurStep + Case 4 + ImportDialog.cmdCancel.Label = sCancelButton + FillStep_Summary() + Case 3 + FillStep_InputPaths(Applcount-1, False) + Case 2 + SaveStep_InputPath + If CurOffice > 0 Then + CurOffice = CurOffice - 1 + FillStep_InputPaths(CurOffice, False) + Else + FillStep_Welcome() + ToggleCheckboxesWithBoolean(True) + bDoKeepApplValues = True + End If + End Select + ImportDialog.cmdGoOn.DefaultButton = True + RepaintHeaderPreview() + Exit Sub +RTError: + Msgbox sRTErrorDesc, 16, sRTErrorHeader +End Sub + + +Sub CancelTask() + If bConversionIsRunning Then + If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then + bCancelTask = True + bInterruptSearch = True + Else + bCancelTask = False + ImportDialog.cmdCancel.Enabled = True + End If + Else + ImportDialogArea.EndExecute() + End If +End Sub + + +Sub TemplateDirSearchDialog() + CallDirSearchDialog(ImportDialog.TemplateImportPath) +End Sub + + +Sub RepaintHeaderPreview() +Dim Bitmap As Object +Dim CurStep as Integer +Dim sBitmapPath as String +Dim LocPrefix as String + CurStep = ImportDialog.Step + LocPrefix = WizardMode + LocPrefix = ReplaceString(LocPrefix,"XML", "SO") + If CurStep = 2 Then + sBitmapPath = SOBitmapPath & LocPrefix & "-Import_" & CurStep & "-" & Applications(CurOffice,SBAPPLKEY) + 1 & ".png" + Else + sBitmapPath = SOBitmapPath & "Import_" & CurStep & ".png" + End If + ImportDialog.ImportPreview.ImageURL = sBitmapPath +End Sub + + +Sub CheckModuleInstallation() +Dim i as Integer + For i = 1 To MaxApplCount + ImportDialogArea.GetControl("chk" & WizardMode & "Application" & i).Model.Enabled = Abs(CheckInstalledModule(i-1)) + Next i +End Sub + + +Function CheckInstalledModule(Index as Integer) as Boolean +Dim ModuleName as String +Dim NameList() as String +Dim MaxIndex as Integer +Dim i as Integer + ModuleName = ModuleList(Index) + If Instr(1,ModuleName,"/") <> 0 Then + CheckInstalledModule() = False + NameList() = ArrayoutOfString(ModuleName,"/", MaxIndex) + For i = 0 To MaxIndex + If oFactoryKey.HasByName(NameList(i)) Then + CheckInstalledModule() = True + End If + Next i + Else + CheckInstalledModule() = oFactoryKey.HasByName(ModuleName) + End If +End Function + + +Sub ToggleCheckboxes(oEvent as Object) +Dim bMSEnable as Boolean + WizardMode = oEvent.Source.Model.Tag + bMSEnable = WizardMode = "MS" + ToggleCheckboxesWithBoolean(bMSEnable) +End Sub + + +Sub ToggleCheckboxesWithBoolean(bMSEnable as Boolean) + If bMSEnable = True Then + WizardMode = SBMICROSOFTMODE + MaxApplCount = 3 + Else + 'Not supposed to happen - is there an assert in BASIC... + End If + With ImportDialogArea + .GetControl("chkMSApplication1").Model.Enabled = bMSEnable + .GetControl("chkMSApplication2").Model.Enabled = bMSEnable + .GetControl("chkMSApplication3").Model.Enabled = bMSEnable + End With + CheckModuleInstallation() + bDoKeepApplValues = False + ToggleNextButton() +End Sub + + +Sub ToggleNextButton() +Dim iCurStep as Integer +Dim bDoEnable as Boolean +Dim i as Integer + iCurStep = ImportDialog.Step + Select Case iCurStep + Case 1 + With ImportDialog + If .optMSDocuments.State = 1 Then + bDoEnable = .chkMSApplication1.State = 1 Or .chkMSApplication2.State = 1 Or .chkMSApplication3.State = 1 + End If + End With + bDoKeepApplValues = False + Case 2 + bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True) + bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable) + End Select + ImportDialog.cmdGoOn.Enabled = bDoEnable +End Sub + + +Sub TakeOverPathSettings() +'Takes over the Pathsettings from the first selected application to the next applications + If Applications(CurOffice,SBDOCSOURCE) = "" Then + Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE) + Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET) + Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE) + Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET) + End If +End Sub + + +Function GetImportWizardPaths() as Boolean + SOBitmapPath = GetOfficeSubPath("Template", "../wizard/bitmap") + If SOBitmapPath <> "" Then + SOWorkPath = GetPathSettings("Work", False) + If SOWorkPath <> "" Then + SOTemplatePath = GetPathSettings("Template_writable",False,0) + If SOTemplatePath <> "" Then + GetImportWizardPaths() = True + Exit Function + End If + End If + End If + GetImportWizardPaths() = False +End Function +</script:module> diff --git a/wizards/source/importwizard/dialog.xlb b/wizards/source/importwizard/dialog.xlb new file mode 100644 index 000000000..f5cc021d5 --- /dev/null +++ b/wizards/source/importwizard/dialog.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ImportWizard" library:readonly="true" library:passwordprotected="false"> + <library:element library:name="ImportDialog"/> +</library:library> diff --git a/wizards/source/importwizard/script.xlb b/wizards/source/importwizard/script.xlb new file mode 100644 index 000000000..2d10f65cb --- /dev/null +++ b/wizards/source/importwizard/script.xlb @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ImportWizard" library:readonly="true" library:passwordprotected="false"> + <library:element library:name="Main"/> + <library:element library:name="DialogModul"/> + <library:element library:name="Language"/> + <library:element library:name="FilesModul"/> + <library:element library:name="API"/> +</library:library> |