1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="FilesModul" script:language="StarBasic">Option Explicit 4*cdf0e10cSrcweir 5*cdf0e10cSrcweirPublic AbsTemplateFound as Integer 6*cdf0e10cSrcweirPublic AbsDocuFound as Integer 7*cdf0e10cSrcweirPublic oLogDocument as Object 8*cdf0e10cSrcweirPublic oLogTable as Object 9*cdf0e10cSrcweirPublic bLogExists as Boolean 10*cdf0e10cSrcweirPublic sComment as String 11*cdf0e10cSrcweirPublic MaxCollectIndex as Integer 12*cdf0e10cSrcweirPublic bInsertRow as Boolean 13*cdf0e10cSrcweirPublic sLogUrl as String 14*cdf0e10cSrcweirPublic sCurPassWord as String 15*cdf0e10cSrcweirPublic FileCount as Integer 16*cdf0e10cSrcweirPublic XMLTemplateCount as Integer 17*cdf0e10cSrcweirPublic PathCollection(7,3) as String 18*cdf0e10cSrcweirPublic bIsFirstLogTable as Boolean 19*cdf0e10cSrcweirPublic bFilterTracerIsinsideTable as Boolean 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir 22*cdf0e10cSrcweirFunction ReadCollectionPaths(FilesList() as String, sFilterName() as String) 23*cdf0e10cSrcweirDim FilterIndex as Integer 24*cdf0e10cSrcweirDim bRecursive as Boolean 25*cdf0e10cSrcweirDim SearchDir as String 26*cdf0e10cSrcweirDim i as Integer 27*cdf0e10cSrcweirDim n as Integer 28*cdf0e10cSrcweirDim a as Integer 29*cdf0e10cSrcweirDim s as Integer 30*cdf0e10cSrcweirDim t as Integer 31*cdf0e10cSrcweirDim sFileContent() as String 32*cdf0e10cSrcweirDim NewList(0,1) as String 33*cdf0e10cSrcweirDim Index as Integer 34*cdf0e10cSrcweirDim CurFileName as String 35*cdf0e10cSrcweirDim CurExtension as String 36*cdf0e10cSrcweirDim CurFileContent as String 37*cdf0e10cSrcweirDim XMLTemplateContentList() as String 38*cdf0e10cSrcweirDim bIsTemplatePath as Boolean 39*cdf0e10cSrcweirDim MaxIndex as Integer 40*cdf0e10cSrcweirDim NewContentList() as String 41*cdf0e10cSrcweirDim XMLTemplateContentString as String 42*cdf0e10cSrcweirDim ApplIndex as Integer 43*cdf0e10cSrcweirDim bAssignFileName as Boolean 44*cdf0e10cSrcweir bInterruptSearch = False 45*cdf0e10cSrcweir For i = 0 To MaxCollectIndex 46*cdf0e10cSrcweir SearchDir = PathCollection(i,0) 47*cdf0e10cSrcweir bRecursive = PathCollection(i,1) 48*cdf0e10cSrcweir sFileContent() = ArrayoutofString(PathCollection(i,2), "|") 49*cdf0e10cSrcweir NewList() = ReadDirectories(SearchDir, bRecursive, False, False, sFileContent(), "") 50*cdf0e10cSrcweir If InterruptProcess Then 51*cdf0e10cSrcweir ReadCollectionPaths() = False 52*cdf0e10cSrcweir Exit Function 53*cdf0e10cSrcweir End If 54*cdf0e10cSrcweir If Ubound(NewList()) > -1 Then 55*cdf0e10cSrcweir bIsTemplatePath = FieldInList("vor", sFileContent) 56*cdf0e10cSrcweir If bIsTemplatePath Then 57*cdf0e10cSrcweir XMLTemplateContentString = PathCollection(i,3) 58*cdf0e10cSrcweir XMLTemplateContentList() = ArrayoutofString(XMLTemplateContentString, "|") 59*cdf0e10cSrcweir If Ubound(XMLTemplateContentList()) > -1 Then 60*cdf0e10cSrcweir MaxIndex = Ubound(NewList()) 61*cdf0e10cSrcweir ReDim Preserve NewList(MaxIndex, 1) as String 62*cdf0e10cSrcweir ReDim Preserve NewContentList(MaxIndex) as String 63*cdf0e10cSrcweir a = -1 64*cdf0e10cSrcweir For n = 0 To MaxIndex 65*cdf0e10cSrcweir bAssignFileName = True 66*cdf0e10cSrcweir If InterruptProcess() Then 67*cdf0e10cSrcweir ReadCollectionPaths() = False 68*cdf0e10cSrcweir Exit Function 69*cdf0e10cSrcweir End If 70*cdf0e10cSrcweir CurFileContent = "" 71*cdf0e10cSrcweir CurFileName = NewList(n,0) 72*cdf0e10cSrcweir If (FieldInList(NewList(n,1), XMLTemplateList())) Then 73*cdf0e10cSrcweir CurFileContent = GetRealFileContent(CurFileName) 74*cdf0e10cSrcweir t = SearchArrayforPartString(CurFileContent, XMLTemplateContentList()) 75*cdf0e10cSrcweir bAssignFileName = (t > -1) 76*cdf0e10cSrcweir If bAssignFileName Then 77*cdf0e10cSrcweir CurFileContent = XMLTemplateContentList(t) 78*cdf0e10cSrcweir End If 79*cdf0e10cSrcweir NewList(n,1) = CurFileContent 80*cdf0e10cSrcweir End If 81*cdf0e10cSrcweir CurExtension = NewList(n,1) 82*cdf0e10cSrcweir If bAssignFileName Then 83*cdf0e10cSrcweir If a < n Then 84*cdf0e10cSrcweir a = a + 1 85*cdf0e10cSrcweir NewList(a,0) = CurFileName 86*cdf0e10cSrcweir NewList(a,1) = CurExtension 87*cdf0e10cSrcweir If CurFileContent = "" Then 88*cdf0e10cSrcweir CurFileContent = CurExtension 89*cdf0e10cSrcweir End If 90*cdf0e10cSrcweir ApplIndex = GetApplicationIndex(CurFileContent, sFiltername()) 91*cdf0e10cSrcweir NewContentList(a) = ApplIndex 92*cdf0e10cSrcweir End If 93*cdf0e10cSrcweir End If 94*cdf0e10cSrcweir Next n 95*cdf0e10cSrcweir If a < MaxIndex And a > -1 Then 96*cdf0e10cSrcweir ReDim Preserve NewList(a, 1) as String 97*cdf0e10cSrcweir End If 98*cdf0e10cSrcweir If a > -1 Then 99*cdf0e10cSrcweir AddListtoFilesList(FilesList(), NewList(), NewContentList()) 100*cdf0e10cSrcweir End If 101*cdf0e10cSrcweir End If 102*cdf0e10cSrcweir Else 103*cdf0e10cSrcweir MaxIndex = Ubound(NewList()) 104*cdf0e10cSrcweir ReDim Preserve NewContentList(MaxIndex) as String 105*cdf0e10cSrcweir For s = 0 To MaxIndex 106*cdf0e10cSrcweir CurExtension = NewList(s,1) 107*cdf0e10cSrcweir NewContentList(s) = GetApplicationIndex(CurExtension, sFiltername()) 108*cdf0e10cSrcweir Next s 109*cdf0e10cSrcweir AddListtoFilesList(FilesList(), NewList(), NewContentList()) 110*cdf0e10cSrcweir End If 111*cdf0e10cSrcweir End If 112*cdf0e10cSrcweir Next i 113*cdf0e10cSrcweir ReadCollectionPaths() = Ubound(FilesList()) > -1 114*cdf0e10cSrcweirEnd Function 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweirFunction GetApplicationIndex(CurFileContent as String, sFilterName() as String) as Integer 118*cdf0e10cSrcweirDim Index as Integer 119*cdf0e10cSrcweirDim i as Integer 120*cdf0e10cSrcweir Index = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent, 0) 121*cdf0e10cSrcweir If Index >= MaxApplCount Then 122*cdf0e10cSrcweir Index = Index - MaxApplCount 123*cdf0e10cSrcweir End If 124*cdf0e10cSrcweir For i = 0 To MaxApplCount - 1 125*cdf0e10cSrcweir If Applications(i, SBAPPLKEY) = Index Then 126*cdf0e10cSrcweir GetApplicationIndex() = i 127*cdf0e10cSrcweir Exit Function 128*cdf0e10cSrcweir End If 129*cdf0e10cSrcweir Next i 130*cdf0e10cSrcweir GetApplicationIndex() = - 1 131*cdf0e10cSrcweirEnd Function 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir 134*cdf0e10cSrcweirFunction InterruptProcess() as Boolean 135*cdf0e10cSrcweir If bCancelTask Or RetValue = 0 Then 136*cdf0e10cSrcweir bConversionIsRunning = False 137*cdf0e10cSrcweir InterruptProcess() = True 138*cdf0e10cSrcweir Exit Function 139*cdf0e10cSrcweir End if 140*cdf0e10cSrcweir InterruptProcess() = False 141*cdf0e10cSrcweirEnd Function 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir 144*cdf0e10cSrcweirSub AddCollectionPath(ApplIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer) 145*cdf0e10cSrcweir MaxCollectIndex = MaxCollectIndex + 1 146*cdf0e10cSrcweir PathCollection(MaxCollectIndex, 0) = Applications(ApplIndex, DocIndex) 147*cdf0e10cSrcweir PathCollection(MaxCollectIndex, 1) = Applications(ApplIndex, RecursiveIndex) 148*cdf0e10cSrcweir AddFilterNameToPathItem(ApplIndex, MaxCollectIndex, sFiltername(), DistIndex) 149*cdf0e10cSrcweirEnd Sub 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir 152*cdf0e10cSrcweirFunction SetExtension(LocExtension) as String 153*cdf0e10cSrcweir if (Instr(LocExtension, "vnd.sun.xml.impress")) > 0 then 154*cdf0e10cSrcweir SetExtension() = "vor|sti|std" 155*cdf0e10cSrcweir elseif (Instr(LocExtension, "vnd.sun.xml.writer")) > 0 then 156*cdf0e10cSrcweir SetExtension() = "vor|stw" 157*cdf0e10cSrcweir elseif (Instr(LocExtension, "vnd.sun.xml.calc")) > 0 then 158*cdf0e10cSrcweir SetExtension() = "vor|stc" 159*cdf0e10cSrcweir elseif (Instr(LocExtension, "vnd.sun.xml.draw")) > 0 then 160*cdf0e10cSrcweir SetExtension() = "vor|std|sti" 161*cdf0e10cSrcweir endif 162*cdf0e10cSrcweirEnd Function 163*cdf0e10cSrcweir 164*cdf0e10cSrcweirSub AddFilterNameToPathItem(ApplIndex as Integer, CollectIndex as Integer, sFiltername() as String, DistIndex as Integer) 165*cdf0e10cSrcweirDim iKey as Integer 166*cdf0e10cSrcweirDim CurListString as String 167*cdf0e10cSrcweirDim LocExtension as String 168*cdf0e10cSrcweirDim LocContentString as String 169*cdf0e10cSrcweirDim LocXMLTemplateContent as String 170*cdf0e10cSrcweir iKey = Applications(ApplIndex, SBAPPLKEY) 171*cdf0e10cSrcweir CurListString = PathCollection(CollectIndex, 2) 172*cdf0e10cSrcweir LocExtension = sFilterName(iKey +DistIndex, 0) 173*cdf0e10cSrcweir If Len(LocExtension) > SBMAXEXTENSIONLENGTH Then ' 7 == Length of two extensions like 'sda|sdd 174*cdf0e10cSrcweir LocExtension = SetExtension(LocExtension) 175*cdf0e10cSrcweir LocContentString = sFilterName(iKey +DistIndex, 0) 176*cdf0e10cSrcweir LocContentString = ReplaceString(LocContentString, "|", ";") 177*cdf0e10cSrcweir LocXMLTemplateContent = PathCollection(CollectIndex, 3) 178*cdf0e10cSrcweir If LocXMLTemplateContent = "" Then 179*cdf0e10cSrcweir LocXMLTemplateContent = LocContentString 180*cdf0e10cSrcweir Else 181*cdf0e10cSrcweir LocXMLTemplateContent = LocXMLTemplateContent & "|" & LocContentString 182*cdf0e10cSrcweir End If 183*cdf0e10cSrcweir PathCollection(CollectIndex, 3) = LocXMLTemplateContent 184*cdf0e10cSrcweir End If 185*cdf0e10cSrcweir If CurListString = "" Then 186*cdf0e10cSrcweir PathCollection(CollectIndex, 2) = LocExtension 187*cdf0e10cSrcweir Else 188*cdf0e10cSrcweir If Instr(CurListString, LocExtension) = 0 Then 189*cdf0e10cSrcweir PathCollection(CollectIndex, 2) = CurListString & "|" & LocExtension 190*cdf0e10cSrcweir End If 191*cdf0e10cSrcweir End If 192*cdf0e10cSrcweirEnd Sub 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir 195*cdf0e10cSrcweirSub CheckIfToAddPathToCollection(ApplIndex as Integer, bDoConvertIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer) 196*cdf0e10cSrcweirDim CollectIndex as Integer 197*cdf0e10cSrcweirDim bCheckDocuType as Boolean 198*cdf0e10cSrcweir bCheckDocuType = Applications(ApplIndex, bDoConvertIndex) 199*cdf0e10cSrcweir If bCheckDocuType Then 200*cdf0e10cSrcweir CollectIndex = GetIndexInMultiArray(PathCollection(), Applications(ApplIndex,DocIndex), 0) 201*cdf0e10cSrcweir If (CollectIndex >-1) Then 202*cdf0e10cSrcweir If Applications(ApplIndex, RecursiveIndex) <> PathCollection(CollectIndex, 1) Then 203*cdf0e10cSrcweir AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex) 204*cdf0e10cSrcweir Else 205*cdf0e10cSrcweir AddFilterNameToPathItem(ApplIndex, CollectIndex, sFilterName(), DistIndex) 206*cdf0e10cSrcweir End If 207*cdf0e10cSrcweir Else 208*cdf0e10cSrcweir AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex) 209*cdf0e10cSrcweir End If 210*cdf0e10cSrcweir End If 211*cdf0e10cSrcweirEnd Sub 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir 214*cdf0e10cSrcweirSub CollectPaths(sFiltername() as String) 215*cdf0e10cSrcweirDim i as Integer 216*cdf0e10cSrcweirDim XMLTemplateContentString as String 217*cdf0e10cSrcweir MaxCollectIndex = -1 218*cdf0e10cSrcweir For i = 0 To ApplCount-1 219*cdf0e10cSrcweir CheckIfToAddPathToCollection(i, SBDOCCONVERT, SBDOCSOURCE, SBDOCRECURSIVE, sFilterName(), 0) 220*cdf0e10cSrcweir Next i 221*cdf0e10cSrcweir XMLTemplateCount = 0 222*cdf0e10cSrcweir XMLTemplateContentString = "" 223*cdf0e10cSrcweir For i = 0 To ApplCount-1 224*cdf0e10cSrcweir If WizardMode = SBXMLMODE Then 225*cdf0e10cSrcweir XMLTemplateCount = XMLTemplateCount + 1 226*cdf0e10cSrcweir End If 227*cdf0e10cSrcweir CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount) 228*cdf0e10cSrcweir Next i 229*cdf0e10cSrcweirEnd Sub 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir 232*cdf0e10cSrcweirSub ConvertAllDocuments(sFilterName() as String) 233*cdf0e10cSrcweirDim FileProperties(1) as new com.sun.star.beans.PropertyValue 234*cdf0e10cSrcweirDim PWFileProperties(2) as New com.sun.star.beans.PropertyValue 235*cdf0e10cSrcweirDim WriterWebProperties(0) as new com.sun.star.beans.PropertyValue 236*cdf0e10cSrcweirDim OpenProperties(4) as new com.sun.star.beans.PropertyValue 237*cdf0e10cSrcweirDim oInteractionHandler as Object 238*cdf0e10cSrcweirDim InteractionTypes(0) as Long 239*cdf0e10cSrcweirDim FilesList(0,2) as String 240*cdf0e10cSrcweirDim sViewPath as String 241*cdf0e10cSrcweirDim i as Integer 242*cdf0e10cSrcweirDim FilterIndex as Integer 243*cdf0e10cSrcweirDim sSourceUrl as String 244*cdf0e10cSrcweirDim CurFilename as String 245*cdf0e10cSrcweirDim oDocument as Object 246*cdf0e10cSrcweirDim sExtension as String 247*cdf0e10cSrcweirDim OldExtension as String 248*cdf0e10cSrcweirDim CurFound as Integer 249*cdf0e10cSrcweirDim TotFound as Integer 250*cdf0e10cSrcweirDim TargetStemDir as String 251*cdf0e10cSrcweirDim SourceStemDir as String 252*cdf0e10cSrcweirDim TargetDir as String 253*cdf0e10cSrcweirDim sTargetUrl as String 254*cdf0e10cSrcweirDim CurFilterName as String 255*cdf0e10cSrcweirDim ApplIndex as Integer 256*cdf0e10cSrcweirDim Index as Integer 257*cdf0e10cSrcweirDim bIsDocument as Boolean 258*cdf0e10cSrcweirDim bDoSave as Boolean 259*cdf0e10cSrcweirDim sCurFileExists as String 260*cdf0e10cSrcweirDim MaxFileIndex as Integer 261*cdf0e10cSrcweirDim bContainsBasicMacro as Boolean 262*cdf0e10cSrcweirDim bIsPassWordProtected as Boolean 263*cdf0e10cSrcweirDim iOverwrite as Integer 264*cdf0e10cSrcweirDim sMimeTypeorExtension as String 265*cdf0e10cSrcweirDim sPrevMimeTypeorExtension as String 266*cdf0e10cSrcweir bConversionisrunning = True 267*cdf0e10cSrcweir InteractionTypes(0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER 268*cdf0e10cSrcweir oInteractionHandler = createUnoService("com.sun.star.task.InteractionHandler") 269*cdf0e10cSrcweir oInteractionHandler.initialize(InteractionTypes()) 270*cdf0e10cSrcweir iGeneralOverwrite = SBOVERWRITEUNDEFINED 271*cdf0e10cSrcweir bConversionIsRunning = True 272*cdf0e10cSrcweir bLogExists = false 273*cdf0e10cSrcweir AbsTemplateFound = 0 274*cdf0e10cSrcweir AbsDocuFound = 0 275*cdf0e10cSrcweir CollectPaths(sFiltername()) 276*cdf0e10cSrcweir If Not ReadCollectionPaths(FilesList(), sFilterName()) Then 277*cdf0e10cSrcweir TotFound = 0 278*cdf0e10cSrcweir SetProgressDisplay(0) 279*cdf0e10cSrcweir bConversionisrunning = false 280*cdf0e10cSrcweir FinalizeDialogButtons() 281*cdf0e10cSrcweir Exit Sub 282*cdf0e10cSrcweir End If 283*cdf0e10cSrcweir TotFound = Ubound(FilesList()) + 1 284*cdf0e10cSrcweir If FilesList(0,0) = "" Then ' Querying the number of fields in a multidimensionl Array is unsecure 285*cdf0e10cSrcweir TotFound = 0 ' because it will return the value 0 (and not -1) even when the Array is empty 286*cdf0e10cSrcweir SetProgressDisplay(0) 287*cdf0e10cSrcweir End If 288*cdf0e10cSrcweir BubbleSortList(FilesList(), true) 289*cdf0e10cSrcweir If TotFound > 0 Then 290*cdf0e10cSrcweir CreateLogDocument(OpenProperties()) 291*cdf0e10cSrcweir InitializeProgressPage(ImportDialog) 292*cdf0e10cSrcweir OpenProperties(0).Name = "Hidden" 293*cdf0e10cSrcweir OpenProperties(0).Value = True 294*cdf0e10cSrcweir OpenProperties(1).Name = "AsTemplate" 295*cdf0e10cSrcweir OpenProperties(1).Value = False 296*cdf0e10cSrcweir OpenProperties(2).Name = "MacroExecutionMode" 297*cdf0e10cSrcweir OpenProperties(2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE 298*cdf0e10cSrcweir OpenProperties(3).Name = "UpdateDocMode" 299*cdf0e10cSrcweir OpenProperties(3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE 300*cdf0e10cSrcweir OpenProperties(4).Name = "InteractionHandler" 301*cdf0e10cSrcweir OpenProperties(4).Value = oInteractionHandler 302*cdf0e10cSrcweir MaxFileIndex = Ubound(FilesList(),1) 303*cdf0e10cSrcweir FileCount = 0 304*cdf0e10cSrcweir For i = 0 To MaxFileIndex 305*cdf0e10cSrcweir sComment = "" 306*cdf0e10cSrcweir If InterruptProcess() Then 307*cdf0e10cSrcweir Exit For 308*cdf0e10cSrcweir End If 309*cdf0e10cSrcweir bDoSave = True 310*cdf0e10cSrcweir sSourceUrl = FilesList(i,0) 311*cdf0e10cSrcweir sPrevMimeTypeorExtension = sMimeTypeorExtension 312*cdf0e10cSrcweir sMimeTypeorExtension = FilesList(i,1) 313*cdf0e10cSrcweir CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex) 314*cdf0e10cSrcweir ApplIndex = FilesList(i,2) 315*cdf0e10cSrcweir If sMimeTypeorExtension <> sPrevMimeTypeorExtension Then 316*cdf0e10cSrcweir CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername() 317*cdf0e10cSrcweir End If 318*cdf0e10cSrcweir If ApplIndex > Ubound(Applications) or (ApplIndex < 0) Then 319*cdf0e10cSrcweir Msgbox "Applicationindex out of bounds:" & sSourcUrl 320*cdf0e10cSrcweir End If 321*cdf0e10cSrcweir sViewPath = ConvertFromUrl(sSourceUrl) ' CutPathView(sSourceUrl, 70) 322*cdf0e10cSrcweir ImportDialog.LabelCurDocument.Label = Str(i+1) & "/" & MaxFileIndex + 1 & " (" & sViewPath & ")" 323*cdf0e10cSrcweir Select Case lcase(sExtension) 324*cdf0e10cSrcweir Case "odt", "ods", "odp", "odg", "odm", "odf" 325*cdf0e10cSrcweir SourceStemDir = RTrimStr(Applications(ApplIndex,SBDOCSOURCE), "/") 326*cdf0e10cSrcweir TargetStemDir = RTrimStr(Applications(ApplIndex,SBDOCTARGET), "/") 327*cdf0e10cSrcweir Case Else ' Templates and Helper-Applications remain 328*cdf0e10cSrcweir SourceStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLSOURCE), "/") 329*cdf0e10cSrcweir TargetStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLTARGET), "/") 330*cdf0e10cSrcweir End Select 331*cdf0e10cSrcweir sTargetUrl = ReplaceString(sSourceUrl, TargetStemDir, SourceStemDir) 332*cdf0e10cSrcweir CurFilename = GetFileNameWithoutExtension(sTargetUrl, "/") 333*cdf0e10cSrcweir OldExtension = GetFileNameExtension(sTargetUrl) 334*cdf0e10cSrcweir sTargetUrl = RTrimStr(sTargetUrl, OldExtension) 335*cdf0e10cSrcweir sTargetUrl = sTargetUrl & sExtension 336*cdf0e10cSrcweir TargetDir = RTrimStr(sTargetUrl, CurFilename & "." & sExtension) 337*cdf0e10cSrcweir If (oUcb.Exists(sTargetUrl)) Then 338*cdf0e10cSrcweir If (iGeneralOverwrite <> SBOVERWRITEALWAYS) Then 339*cdf0e10cSrcweir If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then 340*cdf0e10cSrcweir ShowOverwriteAllDialog(sTargetUrl, sTitle) 341*cdf0e10cSrcweir bDoSave = (iGeneralOverwrite = SBOVERWRITEQUERY) Or (iGeneralOverwrite = SBOVERWRITEALWAYS) 342*cdf0e10cSrcweir Elseif iGeneralOverwrite = SBOVERWRITENEVER Then 343*cdf0e10cSrcweir bDoSave = False 344*cdf0e10cSrcweir ElseIf ((iGeneralOverWrite = SBOVERWRITEQUERY) OR (iGeneralOverwrite = SBOVERWRITECANCEL)) Then 345*cdf0e10cSrcweir ' Todo: According to AS there might come a new feature that storeasUrl could possibly rise a UI dialog. 346*cdf0e10cSrcweir ' In this case my own UI becomes obsolete 347*cdf0e10cSrcweir sCurFileExists = ReplaceString(sFileExists, ConvertFromUrl(sTargetUrl), "<1>") 348*cdf0e10cSrcweir sCurFileExists = ReplaceString(sCurFileExists, chr(13), "<CR>") 349*cdf0e10cSrcweir iOverWrite = Msgbox (sCurFileExists, 32 + 3, sTitle) 350*cdf0e10cSrcweir Select Case iOverWrite 351*cdf0e10cSrcweir Case 1 ' OK 352*cdf0e10cSrcweir ' In the FileProperty-Bean this is already default 353*cdf0e10cSrcweir bDoSave = True 354*cdf0e10cSrcweir Case 2 ' Abort 355*cdf0e10cSrcweir CancelTask(False) 356*cdf0e10cSrcweir bDoSave = False 357*cdf0e10cSrcweir Case 7 ' No 358*cdf0e10cSrcweir bDoSave = False 359*cdf0e10cSrcweir End Select 360*cdf0e10cSrcweir End If 361*cdf0e10cSrcweir End If 362*cdf0e10cSrcweir End If 363*cdf0e10cSrcweir If bDoSave Then 364*cdf0e10cSrcweir If Not oUcb.Exists(TargetDir) Then 365*cdf0e10cSrcweir bDoSave = CreateFolder(TargetDir) 366*cdf0e10cSrcweir End If 367*cdf0e10cSrcweir If bDoSave Then 368*cdf0e10cSrcweir oDocument = StarDesktop.LoadComponentFromURL(sSourceUrl, "_default", 0, OpenProperties()) 369*cdf0e10cSrcweir If Not IsNull(oDocument) Then 370*cdf0e10cSrcweir InsertSourceUrlToLogDocument(sSourceUrl, "") 371*cdf0e10cSrcweir bIsPassWordProtected = CheckPassWordProtection(oDocument) 372*cdf0e10cSrcweir CheckIfMacroExists(oDocument.BasicLibraries, sComment) 373*cdf0e10cSrcweir On Local Error Goto NOSAVING 374*cdf0e10cSrcweir If bIsPassWordProtected Then 375*cdf0e10cSrcweir PWFileProperties(0).Name = "FilterName" 376*cdf0e10cSrcweir PWFileProperties(0).Value = CurFilterName 377*cdf0e10cSrcweir PWFileProperties(1).Name = "Overwrite" 378*cdf0e10cSrcweir PWFileProperties(1).Value = True 379*cdf0e10cSrcweir PWFileProperties(2).Name = "Password" 380*cdf0e10cSrcweir PWFileProperties(2).Value = sCurPassWord 381*cdf0e10cSrcweir oDocument.StoreAsUrl(sTargetUrl, PWFileProperties()) 382*cdf0e10cSrcweir Else 383*cdf0e10cSrcweir FileProperties(0).Name = "FilterName" 384*cdf0e10cSrcweir FileProperties(0).Value = CurFilterName 385*cdf0e10cSrcweir FileProperties(1).Name = "Overwrite" 386*cdf0e10cSrcweir FileProperties(1).Value = True 387*cdf0e10cSrcweir oDocument.StoreAsUrl(sTargetUrl,FileProperties()) 388*cdf0e10cSrcweir End If 389*cdf0e10cSrcweir ' Todo: Make sure that an errorbox pops up when saving fails 390*cdf0e10cSrcweir NOSAVING: 391*cdf0e10cSrcweir If Err <> 0 Then 392*cdf0e10cSrcweir sCurcouldnotsaveDocument = ReplaceString(scouldnotsaveDocument, ConvertFromUrl(sTargetUrl), "<1>") 393*cdf0e10cSrcweir sComment = ConcatComment(sComment, sCurCouldnotsaveDocument) 394*cdf0e10cSrcweir Resume LETSGO 395*cdf0e10cSrcweir LETSGO: 396*cdf0e10cSrcweir Else 397*cdf0e10cSrcweir FileCount = FileCount + 1 398*cdf0e10cSrcweir End If 399*cdf0e10cSrcweir oDocument.Dispose() 400*cdf0e10cSrcweir InsertTargetUrlToLogDocument(sTargetUrl, sComment, ApplIndex) 401*cdf0e10cSrcweir Else 402*cdf0e10cSrcweir sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl), "<1>") 403*cdf0e10cSrcweir sComment = ConcatComment(sComment, sCurCouldnotopenDocument) 404*cdf0e10cSrcweir InsertSourceUrlToLogDocument(sSourceUrl, sComment) 405*cdf0e10cSrcweir End If 406*cdf0e10cSrcweir End If 407*cdf0e10cSrcweir End If 408*cdf0e10cSrcweir Next i 409*cdf0e10cSrcweir End If 410*cdf0e10cSrcweir AddLogStatistics() 411*cdf0e10cSrcweir FinalizeDialogButtons() 412*cdf0e10cSrcweir bConversionIsRunning = False 413*cdf0e10cSrcweir Exit Sub 414*cdf0e10cSrcweirRTError: 415*cdf0e10cSrcweir Msgbox sRTErrorDesc, 16, sRTErrorHeader 416*cdf0e10cSrcweirEnd Sub 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir 420*cdf0e10cSrcweirSub AddListtoFilesList(FirstList(), SecList(), NewContentList() as String) 421*cdf0e10cSrcweirDim sLocExtension as String 422*cdf0e10cSrcweirDim FirstStart as Integer 423*cdf0e10cSrcweirDim FirstEnd as Integer 424*cdf0e10cSrcweirDim i as Integer 425*cdf0e10cSrcweirDim s as Integer 426*cdf0e10cSrcweir If FirstList(0,0) = "" Then 427*cdf0e10cSrcweir FirstStart = Ubound(FirstList(),1) 428*cdf0e10cSrcweir Else 429*cdf0e10cSrcweir FirstStart = Ubound(FirstList(),1) + 1 430*cdf0e10cSrcweir End If 431*cdf0e10cSrcweir FirstEnd = FirstStart + Ubound(SecList(),1) 432*cdf0e10cSrcweir ReDim Preserve FirstList(FirstEnd,2) 433*cdf0e10cSrcweir s = 0 434*cdf0e10cSrcweir For i = FirstStart To FirstEnd 435*cdf0e10cSrcweir FirstList(i,0) = SecList(s,0) 436*cdf0e10cSrcweir FirstList(i,1) = SecList(s,1) 437*cdf0e10cSrcweir sLocExtension = lcase(FirstList(i,1)) 438*cdf0e10cSrcweir Select Case sLocExtension 439*cdf0e10cSrcweir Case "sdw", "sdc", "sda", "sdd", "smf", "sgl", "doc", "xls", "ppt", "sxi" , "sxw" , "sxd" , "sxg" , "sxm" , "sxc" , "pps" 440*cdf0e10cSrcweir AbsDocuFound = AbsDocuFound + 1 441*cdf0e10cSrcweir Case else 442*cdf0e10cSrcweir AbsTemplateFound = AbsTemplateFound + 1 443*cdf0e10cSrcweir End Select 444*cdf0e10cSrcweir FirstList(i,2) = CStr(NewContentList(s)) 445*cdf0e10cSrcweir s = s + 1 446*cdf0e10cSrcweir Next i 447*cdf0e10cSrcweir SetProgressDisplay(Ubound(FirstList()) + 1) 448*cdf0e10cSrcweirEnd Sub 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir 452*cdf0e10cSrcweirFunction GetTargetTemplatePath(Index as Integer) 453*cdf0e10cSrcweir Select Case WizardMode 454*cdf0e10cSrcweir Case SBMICROSOFTMODE 455*cdf0e10cSrcweir GetTargetTemplatePath() = SOTemplatePath & "/" & sTemplateGroupName 456*cdf0e10cSrcweir Case SBXMLMODE 457*cdf0e10cSrcweir If Index = 3 Then 458*cdf0e10cSrcweir ' Helper Application 459*cdf0e10cSrcweir GetTargetTemplatePath = SOWorkPath 460*cdf0e10cSrcweir Else 461*cdf0e10cSrcweir GetTargetTemplatePath = SOTemplatePath 462*cdf0e10cSrcweir End If 463*cdf0e10cSrcweir End Select 464*cdf0e10cSrcweirEnd Function 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir' Retrieves the second value for a next to 'SearchString' in 468*cdf0e10cSrcweir' a two-dimensional string-Array 469*cdf0e10cSrcweirFunction GetFilterName(sMimetypeorExtension as String, sFilterName(), sExtension as string, FilterIndex as Integer) as String 470*cdf0e10cSrcweirDim i as Integer 471*cdf0e10cSrcweirDim MaxIndex as Integer 472*cdf0e10cSrcweirDim sLocFilterlist() as String 473*cdf0e10cSrcweir For i = 0 To Ubound(sFiltername(),1) 474*cdf0e10cSrcweir If Instr(1,sFilterName(i,0),sMimeTypeOrExtension) <> 0 Then 475*cdf0e10cSrcweir sLocFilterList() = ArrayoutofString(sFiltername(i,0),"|", MaxIndex) 476*cdf0e10cSrcweir If MaxIndex = 0 Then 477*cdf0e10cSrcweir sExtension = sFiltername(i,2) 478*cdf0e10cSrcweir GetFilterName = sFilterName(i,1) 479*cdf0e10cSrcweir Else 480*cdf0e10cSrcweir Dim b as Integer 481*cdf0e10cSrcweir Dim sLocExtensionList() as String 482*cdf0e10cSrcweir b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList()) 483*cdf0e10cSrcweir sLocFilterList() = ArrayoutofString(sFiltername(i,1),"|", MaxIndex) 484*cdf0e10cSrcweir GetFilterName = sLocFilterList(b) 485*cdf0e10cSrcweir sLocExtensionList() = ArrayoutofString(sFilterName(i,2), "|", MaxIndex) 486*cdf0e10cSrcweir sExtension = sLocExtensionList(b) 487*cdf0e10cSrcweir End If 488*cdf0e10cSrcweir Exit For 489*cdf0e10cSrcweir End If 490*cdf0e10cSrcweir Next 491*cdf0e10cSrcweir FilterIndex = i 492*cdf0e10cSrcweirEnd Function 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir 495*cdf0e10cSrcweirFunction SearchArrayforPartString(SearchString as String, LocList()) as Integer 496*cdf0e10cSrcweirDim i as Integer 497*cdf0e10cSrcweirDim a as Integer 498*cdf0e10cSrcweirDim StringList() as String 499*cdf0e10cSrcweir For i = Lbound(LocList(),1) to Ubound(LocList(),1) 500*cdf0e10cSrcweir StringList() = ArrayoutofString(LocList(i), "|") 501*cdf0e10cSrcweir For a = 0 To Ubound(StringList()) 502*cdf0e10cSrcweir If (Instr(1, SearchString, StringList(a)) <> 0) Then 503*cdf0e10cSrcweir SearchArrayForPartString() = i 504*cdf0e10cSrcweir Exit Function 505*cdf0e10cSrcweir End If 506*cdf0e10cSrcweir Next a 507*cdf0e10cSrcweir Next i 508*cdf0e10cSrcweir SearchArrayForPartString() = -1 509*cdf0e10cSrcweirEnd Function 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir 512*cdf0e10cSrcweirSub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String) 513*cdf0e10cSrcweirDim oLogCursor as Object 514*cdf0e10cSrcweirDim oLogRows as Object 515*cdf0e10cSrcweirDim FilterIndex as Integer 516*cdf0e10cSrcweirDim sDocumentType as String 517*cdf0e10cSrcweirDim oTextCursor 518*cdf0e10cSrcweirDim oCell 519*cdf0e10cSrcweir If Not bLogExists Then 520*cdf0e10cSrcweir Exit Sub 521*cdf0e10cSrcweir End If 522*cdf0e10cSrcweir bFilterTracerIsinsideTable = False 523*cdf0e10cSrcweir FilterIndex = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent, 0) 524*cdf0e10cSrcweir sDocumentType = sFiltername(FilterIndex,3) 525*cdf0e10cSrcweir oLogCursor = oLogDocument.Text.createTextCursor() 526*cdf0e10cSrcweir oLogCursor.GotoEnd(False) 527*cdf0e10cSrcweir If Not bIsFirstLogTable Then 528*cdf0e10cSrcweir oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) 529*cdf0e10cSrcweir Else 530*cdf0e10cSrcweir bisFirstLogTable = False 531*cdf0e10cSrcweir End If 532*cdf0e10cSrcweir oLogCursor.HyperLinkURL = "" 533*cdf0e10cSrcweir oLogCursor.HyperLinkName = "" 534*cdf0e10cSrcweir oLogCursor.HyperLinkTarget = "" 535*cdf0e10cSrcweir oLogCursor.ParaStyleName = "Heading 1" 536*cdf0e10cSrcweir oLogCursor.setString(sDocumentType) 537*cdf0e10cSrcweir If WizardMode = SBMICROSOFTMODE Then 538*cdf0e10cSrcweir If bFilterTracingAvailable Then 539*cdf0e10cSrcweir If bMSApplFilterTracingAvailable(ApplIndex) Then 540*cdf0e10cSrcweir Dim CurFilterTracingPath as String 541*cdf0e10cSrcweir CurFilterTracingPath = FilterTracingLogPath(ApplIndex) 542*cdf0e10cSrcweir bFilterTracerIsinsideTable = (bTakeOverTargetName(ApplIndex) Or bTakeOverPathName(ApplIndex)) 543*cdf0e10cSrcweir If Not bFilterTracerIsinsideTable Then 544*cdf0e10cSrcweir oLogCursor.CollapseToEnd() 545*cdf0e10cSrcweir oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) 546*cdf0e10cSrcweir InsertCommandButtonatViewCursor(oLogDocument, oLogCursor, CurFilterTracingPath) 547*cdf0e10cSrcweir End If 548*cdf0e10cSrcweir End If 549*cdf0e10cSrcweir End If 550*cdf0e10cSrcweir End If 551*cdf0e10cSrcweir oLogCursor.CollapsetoEnd() 552*cdf0e10cSrcweir oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) 553*cdf0e10cSrcweir oLogTable = oLogDocument.CreateInstance("com.sun.star.text.TextTable") 554*cdf0e10cSrcweir oLogTable.RepeatHeadline = true 555*cdf0e10cSrcweir If bFilterTracerIsinsideTable Then 556*cdf0e10cSrcweir oLogTable.initialize(2,3) 557*cdf0e10cSrcweir End If 558*cdf0e10cSrcweir oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True) 559*cdf0e10cSrcweir oTextCursor = oLogTable.GetCellbyPosition(0,0).createTextCursor() 560*cdf0e10cSrcweir oTextCursor.SetString(sSourceDocuments) 561*cdf0e10cSrcweir oTextCursor = oLogTable.GetCellbyPosition(1,0).createTextCursor() 562*cdf0e10cSrcweir oTextCursor.SetString(sTargetDocuments) 563*cdf0e10cSrcweir If bFilterTracerIsinsideTable Then 564*cdf0e10cSrcweir oTextCursor = oLogTable.GetCellbyPosition(2,0).createTextCursor() 565*cdf0e10cSrcweir oTextCursor.SetString("FilterTracer") 566*cdf0e10cSrcweir End If 567*cdf0e10cSrcweir bInsertRow = False 568*cdf0e10cSrcweirEnd Sub 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir 571*cdf0e10cSrcweirFunction GetSize(iWidth, iHeight) As New com.sun.star.awt.Size 572*cdf0e10cSrcweirDim aSize As New com.sun.star.awt.Size 573*cdf0e10cSrcweir aSize.Width = iWidth 574*cdf0e10cSrcweir aSize.Height = iHeight 575*cdf0e10cSrcweir GetSize() = aSize 576*cdf0e10cSrcweirEnd Function 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir 579*cdf0e10cSrcweirSub InsertCommandButtonatViewCursor(oLocDocument, oLocCursor, TargetUrl as String, Optional aSize) 580*cdf0e10cSrcweirDim oDocument 581*cdf0e10cSrcweirDim oController 582*cdf0e10cSrcweirDim oCommandButton 583*cdf0e10cSrcweirDim oShape 584*cdf0e10cSrcweirDim oDrawPage 585*cdf0e10cSrcweirDim oCommandControl 586*cdf0e10cSrcweirDim oEvent 587*cdf0e10cSrcweirDim oCell 588*cdf0e10cSrcweir oCommandButton = oLocDocument.createInstance("com.sun.star.form.component.CommandButton") 589*cdf0e10cSrcweir oShape = oLocDocument.CreateInstance ("com.sun.star.drawing.ControlShape") 590*cdf0e10cSrcweir If IsMissing(aSize) Then 591*cdf0e10cSrcweir oShape.Size = GetSize(4000, 600) 592*cdf0e10cSrcweir End If 593*cdf0e10cSrcweir oCommandButton.Label = FileNameoutofPath(Targeturl) 594*cdf0e10cSrcweir oCommandButton.TargetFrame = "_default" 595*cdf0e10cSrcweir oCommandButton.ButtonType = com.sun.star.form.FormButtonType.URL 596*cdf0e10cSrcweir oCommandbutton.DispatchUrlInternal = True 597*cdf0e10cSrcweir oCommandButton.TargetURL = ConverttoUrl(TargetUrl) 598*cdf0e10cSrcweir oShape.Control = oCommandbutton 599*cdf0e10cSrcweir oLocCursor.Text.InsertTextContent(oLocCursor, oShape, True) 600*cdf0e10cSrcweirEnd Sub 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir 604*cdf0e10cSrcweirSub CreateLogDocument(HiddenProperties()) 605*cdf0e10cSrcweirDim OpenProperties(0) as new com.sun.star.beans.PropertyValue 606*cdf0e10cSrcweirDim NoArgs() 607*cdf0e10cSrcweirDim i as Integer 608*cdf0e10cSrcweirDim bLogIsThere as Boolean 609*cdf0e10cSrcweir If ImportDialog.chkLogfile.State = 1 Then 610*cdf0e10cSrcweir i = 2 611*cdf0e10cSrcweir OpenProperties(0).Name = "Hidden" 612*cdf0e10cSrcweir OpenProperties(0).Value = True 613*cdf0e10cSrcweir oLogDocument = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_default", 4, OpenProperties()) 614*cdf0e10cSrcweir SOWorkPath = RTrimStr(SOWorkPath,"/") 615*cdf0e10cSrcweir sLogUrl = SOWorkPath & "/Logfile.odt" 616*cdf0e10cSrcweir Do 617*cdf0e10cSrcweir bLogIsThere = oUcb.Exists(sLogUrl) 618*cdf0e10cSrcweir If bLogIsThere Then 619*cdf0e10cSrcweir If i = 2 Then 620*cdf0e10cSrcweir sLogUrl = ReplaceString(sLogUrl, "/Logfile_2.odt", "/Logfile.odt") 621*cdf0e10cSrcweir Else 622*cdf0e10cSrcweir sLogUrl = ReplaceString(sLogUrl, "/Logfile_" & cStr(i) & ".odt", "/Logfile_" & cStr(i-1) & ".odt") 623*cdf0e10cSrcweir End If 624*cdf0e10cSrcweir i = i + 1 625*cdf0e10cSrcweir End If 626*cdf0e10cSrcweir Loop Until Not bLogIsThere 627*cdf0e10cSrcweir bLogExists = True 628*cdf0e10cSrcweir oLogDocument.StoreAsUrl(sLogUrl, NoArgs()) 629*cdf0e10cSrcweir End If 630*cdf0e10cSrcweirEnd Sub 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir 633*cdf0e10cSrcweirFunction GetFilterTracingLogPath(sTargetUrl as String, ApplIndex) as String 634*cdf0e10cSrcweirDim TargetFileName as String 635*cdf0e10cSrcweirDim sTargetFolder as String 636*cdf0e10cSrcweirDim CurFilterTracingPath as String 637*cdf0e10cSrcweirDim CurFilterTracingname as String 638*cdf0e10cSrcweirDim CurFilterFolder as String 639*cdf0e10cSrcweir CurFilterTracingPath = FilterTracingLogPath(ApplIndex) 640*cdf0e10cSrcweir If bTakeOverTargetName(ApplIndex) Then 641*cdf0e10cSrcweir TargetFilename = GetFileNameWithoutextension(sTargetUrl, "/") 642*cdf0e10cSrcweir CurFilterFolder = DirectoryNameoutofPath(FilterTracingLogPath(ApplIndex), "/") 643*cdf0e10cSrcweir CurFilterTracingpath = CurFilterFolder & "/" & TargetFilename & ".log" 644*cdf0e10cSrcweir End If 645*cdf0e10cSrcweir If bTakeOverPathName(ApplIndex) Then 'Replace the Folder in the FilterTracerpath by the Folder of the targetUrl 646*cdf0e10cSrcweir sTargetFolder = DirectoryNameoutofPath(sTargetUrl,"/") 647*cdf0e10cSrcweir CurFilterTracingPath = sTargetFolder & "/" & FileNameoutofPath(CurFilterTracingPath, "/") 648*cdf0e10cSrcweir End If 649*cdf0e10cSrcweir GetFilterTracingLogPath() = CurFilterTracingPath 650*cdf0e10cSrcweirEnd Function 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir 653*cdf0e10cSrcweirSub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String, ApplIndex as Integer) 654*cdf0e10cSrcweirDim oCell 655*cdf0e10cSrcweirDim oTextCursor 656*cdf0e10cSrcweirDim CurFilterTracingpath as String 657*cdf0e10cSrcweir If (bLogExists) And (sTargetUrl <> "") Then 658*cdf0e10cSrcweir If sTargetUrl <> "" Then 659*cdf0e10cSrcweir oCell = oLogTable.GetCellbyPosition(1,oLogTable.Rows.Count-1) 660*cdf0e10cSrcweir InsertCommentToLogCell(sComment, oCell) 661*cdf0e10cSrcweir InsertHyperLinkToLogCell(sTargetUrl, oCell) 662*cdf0e10cSrcweir If bFilterTracerIsinsideTable Then 663*cdf0e10cSrcweir oCell = oLogTable.getCellByPosition(2, oLogTable.Rows.Count-1) 664*cdf0e10cSrcweir oTextCursor = oCell.Text.CreateTextCursor() 665*cdf0e10cSrcweir CurFilterTracingpath = GetFilterTracingLogPath(sTargetUrl, ApplIndex) 666*cdf0e10cSrcweir InsertCommandButtonatViewCursor(oLogDocument, oTextCursor, CurFilterTracingPath) 667*cdf0e10cSrcweir End If 668*cdf0e10cSrcweir oLogDocument.Store() 669*cdf0e10cSrcweir End If 670*cdf0e10cSrcweir End If 671*cdf0e10cSrcweirEnd Sub 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir 674*cdf0e10cSrcweirSub InsertSourceUrlToLogDocument(SourceUrl as String, sComment) ' 675*cdf0e10cSrcweirDim oCell as Object 676*cdf0e10cSrcweir If bLogExists Then 677*cdf0e10cSrcweir If bInsertRow Then 678*cdf0e10cSrcweir oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,1) 679*cdf0e10cSrcweir Else 680*cdf0e10cSrcweir bInsertRow = True 681*cdf0e10cSrcweir End If 682*cdf0e10cSrcweir oCell = oLogTable.GetCellbyPosition(0,oLogTable.Rows.Count-1) 683*cdf0e10cSrcweir InsertCommentToLogCell(sComment, oCell) 684*cdf0e10cSrcweir InsertHyperLinkToLogCell(SourceUrl, oCell) 685*cdf0e10cSrcweir oLogDocument.Store() 686*cdf0e10cSrcweir End If 687*cdf0e10cSrcweirEnd Sub 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir 690*cdf0e10cSrcweirSub InsertHyperLinkToLogCell(sUrl as String, oCell as Object) 691*cdf0e10cSrcweirDim oLogCursor as Object 692*cdf0e10cSrcweirDim LocFileName as String 693*cdf0e10cSrcweir oLogCursor = oCell.createTextCursor() 694*cdf0e10cSrcweir oLogCursor.CollapseToStart() 695*cdf0e10cSrcweir oLogCursor.HyperLinkURL = sUrl 696*cdf0e10cSrcweir oLogCursor.HyperLinkName = sUrl 697*cdf0e10cSrcweir oLogCursor.HyperLinkTarget = sUrl 698*cdf0e10cSrcweir LocFileName = FileNameOutOfPath(sUrl) 699*cdf0e10cSrcweir oCell.InsertString(oLogCursor, LocFileName,False) 700*cdf0e10cSrcweirEnd Sub 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir 703*cdf0e10cSrcweirSub InsertCommentToLogCell(sComment as string, oCell as Object) 704*cdf0e10cSrcweirDim oCommentCursor as Object 705*cdf0e10cSrcweir If sComment <> "" Then 706*cdf0e10cSrcweir oCommentCursor = oCell.createTextCursor() 707*cdf0e10cSrcweir oCell.insertControlCharacter(oCommentCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False) 708*cdf0e10cSrcweir oCell.insertString(oCommentCursor, sComment, false) 709*cdf0e10cSrcweir End If 710*cdf0e10cSrcweirEnd Sub 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir 713*cdf0e10cSrcweirSub AddLogStatistics() 714*cdf0e10cSrcweirDim oCell as Object 715*cdf0e10cSrcweirDim oLogCursor as Object 716*cdf0e10cSrcweirDim MaxRowIndex as Integer 717*cdf0e10cSrcweir If bLogExists Then 718*cdf0e10cSrcweir MaxRowIndex = oLogTable.Rows.Count 719*cdf0e10cSrcweir sLogSummary = ReplaceString(sLogSummary, FileCount, "<COUNT>") 720*cdf0e10cSrcweir' oLogTable.Rows.InsertByIndex(MaxRowIndex, 1) 721*cdf0e10cSrcweir' oCell = oLogTable.GetCellbyPosition(0, MaxRowIndex) 722*cdf0e10cSrcweir' oLogCursor = oCell.createTextCursor() 723*cdf0e10cSrcweir' oCell.InsertString(oLogCursor, sLogSummary,False) 724*cdf0e10cSrcweir' MergeRange(oLogTable, oCell, 1) 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir oLogCursor = oLogDocument.Text.CreateTextCursor 727*cdf0e10cSrcweir oLogCursor.gotoEnd(False) 728*cdf0e10cSrcweir oLogCursor.HyperLinkURL = "" 729*cdf0e10cSrcweir oLogCursor.HyperLinkName = "" 730*cdf0e10cSrcweir oLogCursor.HyperLinkTarget = "" 731*cdf0e10cSrcweir oLogCursor.SetString(sLogSummary) 732*cdf0e10cSrcweir oLogDocument.Store() 733*cdf0e10cSrcweir oLogDocument.Dispose() 734*cdf0e10cSrcweir bLogExists = False 735*cdf0e10cSrcweir End If 736*cdf0e10cSrcweirEnd Sub 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir 740*cdf0e10cSrcweirFunction CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean 741*cdf0e10cSrcweirDim ModuleNames() as String 742*cdf0e10cSrcweirDim ModuleName as String 743*cdf0e10cSrcweirDim MaxLibIndex as Integer 744*cdf0e10cSrcweirDim MaxModuleIndex as Integer 745*cdf0e10cSrcweirDim bMacroExists as Boolean 746*cdf0e10cSrcweirDim n as Integer 747*cdf0e10cSrcweirDim m as Integer 748*cdf0e10cSrcweirDim LibName as String 749*cdf0e10cSrcweirDim sBasicCode as String 750*cdf0e10cSrcweirDim oLibrary as Object 751*cdf0e10cSrcweir bMacroExists = False 752*cdf0e10cSrcweir bMacroExists = oBasicLibraries.hasElements 753*cdf0e10cSrcweir If bMacroExists Then 754*cdf0e10cSrcweir MaxLibIndex = Ubound(oBasicLibraries.ElementNames()) 755*cdf0e10cSrcweir For n = 0 To MaxLibIndex 756*cdf0e10cSrcweir LibName = oBasicLibraries.ElementNames(n) 757*cdf0e10cSrcweir If oBasicLibraries.isLibraryLoaded(LibName) Then 758*cdf0e10cSrcweir oLibrary = oBasicLibraries.getbyName(LibName) 759*cdf0e10cSrcweir If oLibrary.hasElements() Then 760*cdf0e10cSrcweir MaxModuleIndex = Ubound(oLibrary.ElementNames()) 761*cdf0e10cSrcweir For m = 0 To MaxModuleIndex 762*cdf0e10cSrcweir ModuleName = oLibrary.ElementNames(m) 763*cdf0e10cSrcweir sBasicCode = oLibrary.getbyName(ModuleName) 764*cdf0e10cSrcweir If sBasicCode <> "" Then 765*cdf0e10cSrcweir ConcatComment(sComment, sReeditMacro) 766*cdf0e10cSrcweir CheckIfMacroExists() = True 767*cdf0e10cSrcweir Exit Function 768*cdf0e10cSrcweir End If 769*cdf0e10cSrcweir Next m 770*cdf0e10cSrcweir End If 771*cdf0e10cSrcweir End If 772*cdf0e10cSrcweir Next n 773*cdf0e10cSrcweir End If 774*cdf0e10cSrcweir CheckIfMacroExists() = False 775*cdf0e10cSrcweirEnd Function 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir 779*cdf0e10cSrcweirFunction CheckPassWordProtection(oDocument as Object) 780*cdf0e10cSrcweirDim bIsPassWordProtected as Boolean 781*cdf0e10cSrcweirDim i as Integer 782*cdf0e10cSrcweirDim oArgs() 783*cdf0e10cSrcweirDim MaxIndex as Integer 784*cdf0e10cSrcweirDim sblabla as String 785*cdf0e10cSrcweir bIsPassWordProtected = false 786*cdf0e10cSrcweir oArgs() = oDocument.getArgs() 787*cdf0e10cSrcweir MaxIndex = Ubound(oArgs()) 788*cdf0e10cSrcweir For i = 0 To MaxIndex 789*cdf0e10cSrcweir sblabla = oArgs(i).Name 790*cdf0e10cSrcweir If oArgs(i).Name = "Password" Then 791*cdf0e10cSrcweir bIsPassWordProtected = True 792*cdf0e10cSrcweir sCurPassWord = oArgs(i).Value 793*cdf0e10cSrcweir Exit For 794*cdf0e10cSrcweir End If 795*cdf0e10cSrcweir Next i 796*cdf0e10cSrcweir CheckPassWordProtection() = bIsPassWordProtected 797*cdf0e10cSrcweirEnd Function 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir 800*cdf0e10cSrcweirSub OpenLogDocument() 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir bShowLogFile = True 803*cdf0e10cSrcweir ImportDialogArea.endexecute() 804*cdf0e10cSrcweir 805*cdf0e10cSrcweirEnd Sub 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir 808*cdf0e10cSrcweirSub MergeRange(oTable as Object, oCell as Object, MergeCount as Integer) 809*cdf0e10cSrcweirDim oTableCursor as Object 810*cdf0e10cSrcweir oTableCursor = oTable.createCursorByCellName(oCell.CellName) 811*cdf0e10cSrcweir oTableCursor.goRight(MergeCount, True) 812*cdf0e10cSrcweir oTableCursor.mergeRange() 813*cdf0e10cSrcweirEnd Sub 814*cdf0e10cSrcweir 815*cdf0e10cSrcweir 816*cdf0e10cSrcweirFunction ConcatComment(sComment as String, AdditionalComment as String) 817*cdf0e10cSrcweir If sComment = "" Then 818*cdf0e10cSrcweir sComment = AdditionalComment 819*cdf0e10cSrcweir Else 820*cdf0e10cSrcweir sComment = sComment & chr(13) + AdditionalComment 821*cdf0e10cSrcweir End If 822*cdf0e10cSrcweir ConcatComment = sComment 823*cdf0e10cSrcweirEnd Function 824*cdf0e10cSrcweir</script:module> 825