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