2001-04-23 04:46:42 -05:00
<?xml version="1.0" encoding="UTF-8"?>
2001-05-30 11:08:07 -05:00
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
2002-01-11 02:49:32 -06:00
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="FilesModul" script:language="StarBasic">Option Explicit
2001-04-23 04:46:42 -05:00
Public AbsTemplateFound as Integer
Public AbsDocuFound as Integer
2001-05-21 09:52:58 -05:00
Public oLogDocument as Object
Public oLogTable as Object
2002-08-08 08:29:54 -05:00
Public bLogExists as Boolean
2002-08-16 09:21:32 -05:00
Public sComment as String
2003-03-27 10:59:30 -06:00
Public MaxCollectIndex as Integer
2001-08-09 10:35:42 -05:00
Public bInsertRow as Boolean
2002-07-15 09:42:29 -05:00
Public sLogUrl as String
Public sCurPassWord as String
2002-08-08 08:29:54 -05:00
Public FileCount as Integer
2003-03-27 10:59:30 -06:00
Public XMLTemplateCount as Integer
Public PathCollection(7,3) as String
2004-03-30 06:38:44 -06:00
Public bIsFirstLogTable as Boolean
Public bFilterTracerIsinsideTable as Boolean
2002-07-15 09:42:29 -05:00
2003-03-27 10:59:30 -06:00
Function ReadCollectionPaths(FilesList() as String, sFilterName() as String)
2001-04-23 04:46:42 -05:00
Dim FilterIndex as Integer
Dim bRecursive as Boolean
2003-03-27 10:59:30 -06:00
Dim SearchDir as String
Dim i as Integer
Dim n as Integer
2001-04-23 04:46:42 -05:00
Dim a as Integer
2003-03-27 10:59:30 -06:00
Dim s as Integer
2003-04-24 09:46:06 -05:00
Dim t as Integer
2001-04-23 04:46:42 -05:00
Dim sFileContent() as String
2003-03-27 10:59:30 -06:00
Dim NewList(0,1) as String
2001-04-23 04:46:42 -05:00
Dim Index as Integer
2003-03-27 10:59:30 -06:00
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
oDocInfo = CreateUnoService("com.sun.star.document.DocumentProperties")
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
2001-04-23 04:46:42 -05:00
End If
2001-05-21 09:52:58 -05:00
If Ubound(NewList()) > -1 Then
2003-03-27 10:59:30 -06:00
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
2003-06-24 01:33:29 -05:00
CurFileContent = ""
2003-03-27 10:59:30 -06:00
CurFileName = NewList(n,0)
2004-10-27 07:45:06 -05:00
If (FieldInList(NewList(n,1), XMLTemplateList())) Then
2003-03-27 10:59:30 -06:00
CurFileContent = GetRealFileContent(oDocInfo, CurFileName)
2003-04-24 09:46:06 -05:00
t = SearchArrayforPartString(CurFileContent, XMLTemplateContentList())
bAssignFileName = (t > -1)
If bAssignFileName Then
CurFileContent = XMLTemplateContentList(t)
End If
2003-03-27 10:59:30 -06:00
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
2003-06-24 01:33:29 -05:00
If CurFileContent = "" Then
CurFileContent = CurExtension
End If
2003-03-27 10:59:30 -06:00
ApplIndex = GetApplicationIndex(CurFileContent, sFiltername())
NewContentList(a) = ApplIndex
End If
End If
Next n
2003-04-24 09:46:06 -05:00
If a < MaxIndex And a > -1 Then
2003-03-27 10:59:30 -06:00
ReDim Preserve NewList(a, 1) as String
End If
2003-05-22 04:18:28 -05:00
If a > -1 Then
AddListtoFilesList(FilesList(), NewList(), NewContentList())
End If
2003-03-27 10:59:30 -06:00
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
2001-05-21 09:52:58 -05:00
End If
2003-03-27 10:59:30 -06:00
Next i
2004-03-30 06:38:44 -06:00
ReadCollectionPaths() = Ubound(FilesList()) > -1
2003-03-27 10:59:30 -06:00
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
2001-04-23 04:46:42 -05:00
End If
2003-03-27 10:59:30 -06:00
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
2001-04-23 04:46:42 -05:00
End Function
2003-03-27 10:59:30 -06:00
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
2004-10-27 07:45:06 -05:00
Function SetExtension(LocExtension) as String
if (Instr(LocExtension, "vnd.sun.xml.impress")) > 0 then
2005-03-23 08:13:39 -06:00
SetExtension() = "vor|sti|std"
2004-10-27 07:45:06 -05:00
elseif (Instr(LocExtension, "vnd.sun.xml.writer")) > 0 then
SetExtension() = "vor|stw"
elseif (Instr(LocExtension, "vnd.sun.xml.calc")) > 0 then
SetExtension() = "vor|stc"
2005-03-23 08:13:39 -06:00
elseif (Instr(LocExtension, "vnd.sun.xml.draw")) > 0 then
SetExtension() = "vor|std|sti"
2004-10-27 07:45:06 -05:00
endif
End Function
2003-03-27 10:59:30 -06:00
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 Len(LocExtension) > SBMAXEXTENSIONLENGTH Then ' 7 == Length of two extensions like 'sda|sdd
2004-10-27 07:45:06 -05:00
LocExtension = SetExtension(LocExtension)
2003-03-27 10:59:30 -06:00
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
2001-04-23 04:46:42 -05:00
Else
2003-03-27 10:59:30 -06:00
If Instr(CurListString, LocExtension) = 0 Then
PathCollection(CollectIndex, 2) = CurListString & "|" & LocExtension
End If
End If
2001-04-23 04:46:42 -05:00
End Sub
2001-05-21 09:52:58 -05:00
2003-03-27 10:59:30 -06:00
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
If WizardMode = SBXMLMODE Then
XMLTemplateCount = XMLTemplateCount + 1
End If
CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount)
Next i
End Sub
Sub ConvertAllDocuments(sFilterName() as String)
2002-09-30 08:54:06 -05:00
Dim FileProperties(1) as new com.sun.star.beans.PropertyValue
Dim PWFileProperties(2) as New com.sun.star.beans.PropertyValue
2001-08-15 06:50:32 -05:00
Dim WriterWebProperties(0) as new com.sun.star.beans.PropertyValue
2002-11-27 08:42:32 -06:00
Dim OpenProperties(4) as new com.sun.star.beans.PropertyValue
Dim oInteractionHandler as Object
Dim InteractionTypes(0) as Long
2001-05-21 09:52:58 -05:00
Dim FilesList(0,2) as String
2001-04-23 04:46:42 -05:00
Dim sViewPath as String
Dim i as Integer
Dim FilterIndex as Integer
2002-11-27 08:42:32 -06:00
Dim sSourceUrl as String
Dim CurFilename as String
2001-04-23 04:46:42 -05:00
Dim oDocument as Object
Dim sExtension as String
Dim OldExtension as String
Dim CurFound as Integer
2001-06-21 08:14:32 -05:00
Dim TotFound as Integer
2001-04-23 04:46:42 -05:00
Dim TargetStemDir as String
Dim SourceStemDir as String
Dim TargetDir as String
2002-11-27 08:42:32 -06:00
Dim sTargetUrl as String
2001-04-23 04:46:42 -05:00
Dim CurFilterName as String
Dim ApplIndex as Integer
Dim Index as Integer
Dim bIsDocument as Boolean
Dim bDoSave as Boolean
Dim sCurFileExists as String
2001-05-21 09:52:58 -05:00
Dim MaxFileIndex as Integer
2002-07-15 09:42:29 -05:00
Dim bContainsBasicMacro as Boolean
Dim bIsPassWordProtected as Boolean
2002-08-16 09:21:32 -05:00
Dim iOverwrite as Integer
2003-05-22 04:18:28 -05:00
Dim sMimeTypeorExtension as String
2004-03-30 06:38:44 -06:00
Dim sPrevMimeTypeorExtension as String
2003-03-27 10:59:30 -06:00
bConversionisrunning = True
2002-11-27 08:42:32 -06:00
InteractionTypes(0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER
oInteractionHandler = createUnoService("com.sun.star.task.InteractionHandler")
oInteractionHandler.initialize(InteractionTypes())
2002-08-16 09:21:32 -05:00
iGeneralOverwrite = SBOVERWRITEUNDEFINED
2003-03-27 10:59:30 -06:00
bConversionIsRunning = True
2002-08-08 08:29:54 -05:00
bLogExists = false
2001-04-23 04:46:42 -05:00
AbsTemplateFound = 0
AbsDocuFound = 0
2003-03-27 10:59:30 -06:00
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 multidimensionl 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
2004-03-30 06:38:44 -06:00
BubbleSortList(FilesList(), true)
2001-06-21 08:14:32 -05:00
If TotFound > 0 Then
2002-08-08 08:29:54 -05:00
CreateLogDocument(OpenProperties())
2001-06-21 08:14:32 -05:00
InitializeProgressPage(ImportDialog)
OpenProperties(0).Name = "Hidden"
OpenProperties(0).Value = True
2001-08-15 06:50:32 -05:00
OpenProperties(1).Name = "AsTemplate"
2002-08-16 09:21:32 -05:00
OpenProperties(1).Value = False
2002-08-14 10:40:35 -05:00
OpenProperties(2).Name = "MacroExecutionMode"
2002-08-16 09:21:32 -05:00
OpenProperties(2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE
2002-08-14 10:40:35 -05:00
OpenProperties(3).Name = "UpdateDocMode"
2002-08-16 09:21:32 -05:00
OpenProperties(3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE
2002-11-27 08:42:32 -06:00
OpenProperties(4).Name = "InteractionHandler"
OpenProperties(4).Value = oInteractionHandler
2001-06-21 08:14:32 -05:00
MaxFileIndex = Ubound(FilesList(),1)
2002-07-08 07:44:13 -05:00
FileCount = 0
2001-06-21 08:14:32 -05:00
For i = 0 To MaxFileIndex
2002-08-16 09:21:32 -05:00
sComment = ""
2003-03-27 10:59:30 -06:00
If InterruptProcess() Then
2002-08-08 08:29:54 -05:00
Exit For
2003-03-27 10:59:30 -06:00
End If
2001-08-10 03:28:06 -05:00
bDoSave = True
2002-11-27 08:42:32 -06:00
sSourceUrl = FilesList(i,0)
2004-03-30 06:38:44 -06:00
sPrevMimeTypeorExtension = sMimeTypeorExtension
2003-05-22 04:18:28 -05:00
sMimeTypeorExtension = FilesList(i,1)
CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex)
2001-06-21 08:14:32 -05:00
ApplIndex = FilesList(i,2)
2004-03-30 06:38:44 -06:00
If sMimeTypeorExtension <> sPrevMimeTypeorExtension Then
CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername()
End If
2003-03-27 10:59:30 -06:00
If ApplIndex > Ubound(Applications) or (ApplIndex < 0) Then
Msgbox "Applicationindex out of bounds:" & sSourcUrl
End If
sViewPath = ConvertFromUrl(sSourceUrl) ' CutPathView(sSourceUrl, 70)
2001-06-21 08:14:32 -05:00
ImportDialog.LabelCurDocument.Label = Str(i+1) & "/" & MaxFileIndex + 1 & " (" & sViewPath & ")"
2003-03-27 10:59:30 -06:00
Select Case lcase(sExtension)
2005-02-21 07:11:25 -06:00
Case "odt", "ods", "odp", "odg", "odm", "odf"
2002-11-27 08:42:32 -06:00
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
2002-08-16 09:21:32 -05:00
If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then
2002-11-27 08:42:32 -06:00
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>")
2002-08-16 09:21:32 -05:00
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
2001-06-21 08:14:32 -05:00
End If
2002-11-27 08:42:32 -06:00
End If
If bDoSave Then
If Not oUcb.Exists(TargetDir) Then
2003-03-27 10:59:30 -06:00
bDoSave = CreateFolder(TargetDir)
2002-11-27 08:42:32 -06:00
End If
2003-03-27 10:59:30 -06:00
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()
2004-03-30 06:38:44 -06:00
InsertTargetUrlToLogDocument(sTargetUrl, sComment, ApplIndex)
2002-09-30 08:54:06 -05:00
Else
2003-03-27 10:59:30 -06:00
sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl), "<1>")
sComment = ConcatComment(sComment, sCurCouldnotopenDocument)
2004-03-30 06:38:44 -06:00
InsertSourceUrlToLogDocument(sSourceUrl, sComment)
2002-07-15 09:42:29 -05:00
End If
2001-06-21 08:14:32 -05:00
End If
End If
Next i
End If
2002-08-08 08:29:54 -05:00
AddLogStatistics()
FinalizeDialogButtons()
2003-03-27 10:59:30 -06:00
bConversionIsRunning = False
2001-04-23 04:46:42 -05:00
Exit Sub
RTError:
Msgbox sRTErrorDesc, 16, sRTErrorHeader
End Sub
2002-07-15 09:42:29 -05:00
2003-03-27 10:59:30 -06:00
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
2001-07-12 04:39:01 -05:00
If FirstList(0,0) = "" Then
FirstStart = Ubound(FirstList(),1)
Else
FirstStart = Ubound(FirstList(),1) + 1
End If
2001-05-21 09:52:58 -05:00
FirstEnd = FirstStart + Ubound(SecList(),1)
ReDim Preserve FirstList(FirstEnd,2)
s = 0
2001-04-23 04:46:42 -05:00
For i = FirstStart To FirstEnd
FirstList(i,0) = SecList(s,0)
FirstList(i,1) = SecList(s,1)
2003-03-27 10:59:30 -06:00
sLocExtension = lcase(FirstList(i,1))
Select Case sLocExtension
2004-10-27 07:45:06 -05:00
Case "sdw", "sdc", "sda", "sdd", "smf", "sgl", "doc", "xls", "ppt", "sxi" , "sxw" , "sxd" , "sxg" , "sxm" , "sxc"
2003-03-27 10:59:30 -06:00
AbsDocuFound = AbsDocuFound + 1
Case else
AbsTemplateFound = AbsTemplateFound + 1
End Select
FirstList(i,2) = CStr(NewContentList(s))
2001-04-23 04:46:42 -05:00
s = s + 1
Next i
2003-03-27 10:59:30 -06:00
SetProgressDisplay(Ubound(FirstList()) + 1)
2001-04-23 04:46:42 -05:00
End Sub
2003-03-27 10:59:30 -06:00
2001-04-23 04:46:42 -05:00
Function GetTargetTemplatePath(Index as Integer)
Select Case WizardMode
Case SBMICROSOFTMODE
2001-07-12 04:39:01 -05:00
GetTargetTemplatePath() = SOTemplatePath & "/" & sTemplateGroupName
2001-04-23 04:46:42 -05:00
Case SBXMLMODE
If Index = 3 Then
' Helper Application
GetTargetTemplatePath = SOWorkPath
Else
GetTargetTemplatePath = SOTemplatePath
End If
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
2003-03-27 10:59:30 -06:00
Dim b as Integer
2001-04-23 04:46:42 -05:00
Dim sLocExtensionList() as String
2003-03-27 10:59:30 -06:00
b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList())
2001-04-23 04:46:42 -05:00
sLocFilterList() = ArrayoutofString(sFiltername(i,1),"|", MaxIndex)
2003-03-27 10:59:30 -06:00
GetFilterName = sLocFilterList(b)
2001-04-23 04:46:42 -05:00
sLocExtensionList() = ArrayoutofString(sFilterName(i,2), "|", MaxIndex)
2003-03-27 10:59:30 -06:00
sExtension = sLocExtensionList(b)
2001-04-23 04:46:42 -05:00
End If
Exit For
End If
Next
FilterIndex = i
End Function
Function SearchArrayforPartString(SearchString as String, LocList()) as Integer
2003-04-24 09:46:06 -05:00
Dim i as Integer
Dim a as Integer
Dim StringList() as String
2001-04-23 04:46:42 -05:00
For i = Lbound(LocList(),1) to Ubound(LocList(),1)
2003-04-24 09:46:06 -05:00
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
2001-05-21 09:52:58 -05:00
End Function
2004-03-30 06:38:44 -06:00
Sub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String)
2001-05-21 09:52:58 -05:00
Dim oLogCursor as Object
Dim oLogRows as Object
2004-03-30 06:38:44 -06:00
Dim FilterIndex as Integer
Dim sDocumentType as String
Dim oTextCursor
Dim oCell
bFilterTracerIsinsideTable = False
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)
If WizardMode = SBMICROSOFTMODE Then
If bFilterTracingAvailable Then
If bMSApplFilterTracingAvailable(ApplIndex) Then
Dim CurFilterTracingPath as String
CurFilterTracingPath = FilterTracingLogPath(ApplIndex)
bFilterTracerIsinsideTable = (bTakeOverTargetName(ApplIndex) Or bTakeOverPathName(ApplIndex))
If Not bFilterTracerIsinsideTable Then
oLogCursor.CollapseToEnd()
oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
InsertCommandButtonatViewCursor(oLogDocument, oLogCursor, CurFilterTracingPath)
End If
End If
End If
End If
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
If bFilterTracerIsinsideTable Then
oLogTable.initialize(2,3)
End If
oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True)
oTextCursor = oLogTable.GetCellbyPosition(0,0).createTextCursor()
oTextCursor.SetString(sSourceDocuments)
oTextCursor = oLogTable.GetCellbyPosition(1,0).createTextCursor()
oTextCursor.SetString(sTargetDocuments)
If bFilterTracerIsinsideTable Then
oTextCursor = oLogTable.GetCellbyPosition(2,0).createTextCursor()
oTextCursor.SetString("FilterTracer")
End If
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
2001-05-21 09:52:58 -05:00
Dim NoArgs()
Dim i as Integer
2002-08-08 08:29:54 -05:00
Dim bLogIsThere as Boolean
2001-05-21 09:52:58 -05:00
If ImportDialog.chkLogfile.State = 1 Then
i = 2
2002-07-15 09:42:29 -05:00
OpenProperties(0).Name = "Hidden"
OpenProperties(0).Value = True
2002-10-16 05:41:42 -05:00
oLogDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_default", 4, OpenProperties())
2001-05-21 09:52:58 -05:00
sLogUrl = SOWorkPath & "/Logfile.sxw"
Do
2002-08-08 08:29:54 -05:00
bLogIsThere = oUcb.Exists(sLogUrl)
If bLogIsThere Then
2001-05-21 09:52:58 -05:00
If i = 2 Then
sLogUrl = ReplaceString(sLogUrl, "/Logfile_2.sxw", "/Logfile.sxw")
Else
sLogUrl = ReplaceString(sLogUrl, "/Logfile_" & cStr(i) & ".sxw", "/Logfile_" & cStr(i-1) & ".sxw")
End If
i = i + 1
End If
2002-08-08 08:29:54 -05:00
Loop Until Not bLogIsThere
bLogExists = True
2001-08-09 10:35:42 -05:00
oLogDocument.StoreAsUrl(sLogUrl, NoArgs())
2002-08-08 08:29:54 -05:00
End If
2001-05-21 09:52:58 -05:00
End Sub
2004-03-30 06:38:44 -06:00
Function GetFilterTracingLogPath(sTargetUrl as String, ApplIndex) as String
Dim TargetFileName as String
Dim sTargetFolder as String
Dim CurFilterTracingPath as String
Dim CurFilterTracingname as String
Dim CurFilterFolder as String
CurFilterTracingPath = FilterTracingLogPath(ApplIndex)
If bTakeOverTargetName(ApplIndex) Then
TargetFilename = GetFileNameWithoutextension(sTargetUrl, "/")
CurFilterFolder = DirectoryNameoutofPath(FilterTracingLogPath(ApplIndex), "/")
CurFilterTracingpath = CurFilterFolder & "/" & TargetFilename & ".log"
End If
If bTakeOverPathName(ApplIndex) Then 'Replace the Folder in the FilterTracerpath by the Folder of the targetUrl
sTargetFolder = DirectoryNameoutofPath(sTargetUrl,"/")
CurFilterTracingPath = sTargetFolder & "/" & FileNameoutofPath(CurFilterTracingPath, "/")
End If
GetFilterTracingLogPath() = CurFilterTracingPath
End Function
Sub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String, ApplIndex as Integer)
Dim oCell
Dim oTextCursor
Dim CurFilterTracingpath as String
2002-11-27 08:42:32 -06:00
If (bLogExists) And (sTargetUrl <> "") Then
If sTargetUrl <> "" Then
oCell = oLogTable.GetCellbyPosition(1,oLogTable.Rows.Count-1)
2004-03-30 06:38:44 -06:00
InsertCommentToLogCell(sComment, oCell)
2002-11-27 08:42:32 -06:00
InsertHyperLinkToLogCell(sTargetUrl, oCell)
2004-03-30 06:38:44 -06:00
If bFilterTracerIsinsideTable Then
oCell = oLogTable.getCellByPosition(2, oLogTable.Rows.Count-1)
oTextCursor = oCell.Text.CreateTextCursor()
CurFilterTracingpath = GetFilterTracingLogPath(sTargetUrl, ApplIndex)
InsertCommandButtonatViewCursor(oLogDocument, oTextCursor, CurFilterTracingPath)
End If
2002-11-27 08:42:32 -06:00
oLogDocument.Store()
End If
End If
End Sub
2002-08-16 09:21:32 -05:00
2002-11-27 08:42:32 -06:00
Sub InsertSourceUrlToLogDocument(SourceUrl as String, sComment) '
2001-08-09 10:35:42 -05:00
Dim oCell as Object
2002-08-08 08:29:54 -05:00
If bLogExists Then
2001-08-09 10:35:42 -05:00
If bInsertRow Then
2001-05-21 09:52:58 -05:00
oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,1)
2001-08-09 10:35:42 -05:00
Else
bInsertRow = True
2001-05-21 09:52:58 -05:00
End If
2002-11-27 08:42:32 -06:00
oCell = oLogTable.GetCellbyPosition(0,oLogTable.Rows.Count-1)
InsertCommentToLogCell(sComment, oCell)
InsertHyperLinkToLogCell(SourceUrl, oCell)
2001-05-21 09:52:58 -05:00
oLogDocument.Store()
End If
2002-07-08 07:44:13 -05:00
End Sub
2002-11-27 08:42:32 -06:00
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
2002-08-08 08:29:54 -05:00
Sub AddLogStatistics()
2002-07-08 07:44:13 -05:00
Dim oCell as Object
Dim oLogCursor as Object
Dim MaxRowIndex as Integer
2002-08-08 08:29:54 -05:00
If bLogExists Then
2002-07-08 07:44:13 -05:00
MaxRowIndex = oLogTable.Rows.Count
sLogSummary = ReplaceString(sLogSummary, FileCount, "<COUNT>")
2004-03-30 06:38:44 -06:00
' 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)
2002-07-08 07:44:13 -05:00
oLogDocument.Store()
2002-08-08 08:29:54 -05:00
oLogDocument.Dispose()
bLogExists = False
2002-07-08 07:44:13 -05:00
End If
2002-07-15 09:42:29 -05:00
End Sub
2002-10-02 10:15:40 -05:00
Function CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean
2002-07-15 09:42:29 -05:00
Dim ModuleNames() as String
2002-10-02 10:15:40 -05:00
Dim ModuleName as String
Dim MaxLibIndex as Integer
Dim MaxModuleIndex as Integer
2002-08-16 09:21:32 -05:00
Dim bMacroExists as Boolean
2002-10-02 10:15:40 -05:00
Dim n as Integer
Dim m as Integer
Dim LibName as String
Dim sBasicCode as String
Dim oLibrary as Object
2002-08-16 09:21:32 -05:00
bMacroExists = False
2002-10-02 10:15:40 -05:00
bMacroExists = oBasicLibraries.hasElements
If bMacroExists Then
MaxLibIndex = Ubound(oBasicLibraries.ElementNames())
For n = 0 To MaxLibIndex
LibName = oBasicLibraries.ElementNames(n)
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
Next n
2002-08-16 09:21:32 -05:00
End If
2002-10-02 10:15:40 -05:00
CheckIfMacroExists() = False
2002-07-15 09:42:29 -05:00
End Function
Function CheckPassWordProtection(oDocument as Object)
Dim bIsPassWordProtected as Boolean
Dim i as Integer
Dim oArgs()
Dim MaxIndex as Integer
2002-09-30 08:54:06 -05:00
Dim sblabla as String
2002-07-15 09:42:29 -05:00
bIsPassWordProtected = false
oArgs() = oDocument.getArgs()
MaxIndex = Ubound(oArgs())
For i = 0 To MaxIndex
2002-09-30 08:54:06 -05:00
sblabla = oArgs(i).Name
If oArgs(i).Name = "Password" Then
2002-07-15 09:42:29 -05:00
bIsPassWordProtected = True
sCurPassWord = oArgs(i).Value
Exit For
End If
Next i
CheckPassWordProtection() = bIsPassWordProtected
End Function
Sub OpenLogDocument()
2005-01-28 08:57:13 -06:00
bShowLogFile = True
ImportDialogArea.endexecute()
2002-08-16 09:21:32 -05:00
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>