1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"FilesModul" script:
language=
"StarBasic">Option Explicit
22 Public AbsTemplateFound as Integer
23 Public AbsDocuFound as Integer
24 Public oLogDocument as Object
25 Public oLogTable as Object
26 Public bLogExists as Boolean
27 Public sComment as String
28 Public MaxCollectIndex as Integer
29 Public bInsertRow as Boolean
30 Public sLogUrl as String
31 Public sCurPassWord as String
32 Public FileCount as Integer
33 Public XMLTemplateCount as Integer
34 Public PathCollection(
7,
3) as String
35 Public bIsFirstLogTable as Boolean
38 Function ReadCollectionPaths(FilesList() as String, sFilterName() as String)
39 Dim FilterIndex as Integer
40 Dim bRecursive as Boolean
41 Dim SearchDir as String
47 Dim sFileContent() as String
48 Dim NewList(
0,
1) as String
50 Dim CurFileName as String
51 Dim CurExtension as String
52 Dim CurFileContent as String
53 Dim XMLTemplateContentList() as String
54 Dim bIsTemplatePath as Boolean
55 Dim MaxIndex as Integer
56 Dim NewContentList() as String
57 Dim XMLTemplateContentString as String
58 Dim ApplIndex as Integer
59 Dim bAssignFileName as Boolean
60 Dim bInterruptSearch as Boolean
61 bInterruptSearch = False
62 For i =
0 To MaxCollectIndex
63 SearchDir = PathCollection(i,
0)
64 bRecursive = PathCollection(i,
1)
65 sFileContent() = ArrayoutofString(PathCollection(i,
2),
"|
")
66 NewList() = ReadDirectories(SearchDir, bRecursive, False, False, sFileContent(),
"")
67 If InterruptProcess Then
68 ReadCollectionPaths() = False
71 If Ubound(NewList())
> -
1 Then
72 bIsTemplatePath = FieldInList(
"vor
", sFileContent)
73 If bIsTemplatePath Then
74 XMLTemplateContentString = PathCollection(i,
3)
75 XMLTemplateContentList() = ArrayoutofString(XMLTemplateContentString,
"|
")
76 If Ubound(XMLTemplateContentList())
> -
1 Then
77 MaxIndex = Ubound(NewList())
78 ReDim Preserve NewList(MaxIndex,
1) as String
79 ReDim Preserve NewContentList(MaxIndex) as String
82 bAssignFileName = True
83 If InterruptProcess() Then
84 ReadCollectionPaths() = False
87 CurFileContent =
""
88 CurFileName = NewList(n,
0)
89 If (FieldInList(NewList(n,
1), XMLTemplateList())) Then
90 CurFileContent = GetRealFileContent(CurFileName)
91 t = SearchArrayforPartString(CurFileContent, XMLTemplateContentList())
92 bAssignFileName = (t
> -
1)
93 If bAssignFileName Then
94 CurFileContent = XMLTemplateContentList(t)
96 NewList(n,
1) = CurFileContent
98 CurExtension = NewList(n,
1)
99 If bAssignFileName Then
102 NewList(a,
0) = CurFileName
103 NewList(a,
1) = CurExtension
104 If CurFileContent =
"" Then
105 CurFileContent = CurExtension
107 ApplIndex = GetApplicationIndex(CurFileContent, sFiltername())
108 NewContentList(a) = ApplIndex
112 If a
< MaxIndex And a
> -
1 Then
113 ReDim Preserve NewList(a,
1) as String
116 AddListtoFilesList(FilesList(), NewList(), NewContentList())
120 MaxIndex = Ubound(NewList())
121 ReDim Preserve NewContentList(MaxIndex) as String
122 For s =
0 To MaxIndex
123 CurExtension = NewList(s,
1)
124 NewContentList(s) = GetApplicationIndex(CurExtension, sFiltername())
126 AddListtoFilesList(FilesList(), NewList(), NewContentList())
130 ReadCollectionPaths() = Ubound(FilesList())
> -
1
134 Function GetApplicationIndex(CurFileContent as String, sFilterName() as String) as Integer
137 Index = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent,
0)
138 If Index
>= MaxApplCount Then
139 Index = Index - MaxApplCount
141 For i =
0 To MaxApplCount -
1
142 If Applications(i, SBAPPLKEY) = Index Then
143 GetApplicationIndex() = i
147 GetApplicationIndex() = -
1
151 Function InterruptProcess() as Boolean
152 If bCancelTask Or RetValue =
0 Then
153 bConversionIsRunning = False
154 InterruptProcess() = True
157 InterruptProcess() = False
161 Sub AddCollectionPath(ApplIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer)
162 MaxCollectIndex = MaxCollectIndex +
1
163 PathCollection(MaxCollectIndex,
0) = Applications(ApplIndex, DocIndex)
164 PathCollection(MaxCollectIndex,
1) = Applications(ApplIndex, RecursiveIndex)
165 AddFilterNameToPathItem(ApplIndex, MaxCollectIndex, sFiltername(), DistIndex)
169 Function SetExtension(LocExtension) as String
170 if (Instr(LocExtension,
"vnd.sun.xml.impress
"))
> 0 then
171 SetExtension() =
"vor|sti|std
"
172 elseif (Instr(LocExtension,
"vnd.sun.xml.writer
"))
> 0 then
173 SetExtension() =
"vor|stw
"
174 elseif (Instr(LocExtension,
"vnd.sun.xml.calc
"))
> 0 then
175 SetExtension() =
"vor|stc
"
176 elseif (Instr(LocExtension,
"vnd.sun.xml.draw
"))
> 0 then
177 SetExtension() =
"vor|std|sti
"
181 Sub AddFilterNameToPathItem(ApplIndex as Integer, CollectIndex as Integer, sFiltername() as String, DistIndex as Integer)
183 Dim CurListString as String
184 Dim LocExtension as String
185 Dim LocContentString as String
186 Dim LocXMLTemplateContent as String
187 iKey = Applications(ApplIndex, SBAPPLKEY)
188 CurListString = PathCollection(CollectIndex,
2)
189 LocExtension = sFilterName(iKey +DistIndex,
0)
190 If Len(LocExtension)
> SBMAXEXTENSIONLENGTH Then
' 7 == Length of two extensions like
'sda|sdd
191 LocExtension = SetExtension(LocExtension)
192 LocContentString = sFilterName(iKey +DistIndex,
0)
193 LocContentString = ReplaceString(LocContentString,
"|
",
";
")
194 LocXMLTemplateContent = PathCollection(CollectIndex,
3)
195 If LocXMLTemplateContent =
"" Then
196 LocXMLTemplateContent = LocContentString
198 LocXMLTemplateContent = LocXMLTemplateContent
& "|
" & LocContentString
200 PathCollection(CollectIndex,
3) = LocXMLTemplateContent
202 If CurListString =
"" Then
203 PathCollection(CollectIndex,
2) = LocExtension
205 If Instr(CurListString, LocExtension) =
0 Then
206 PathCollection(CollectIndex,
2) = CurListString
& "|
" & LocExtension
212 Sub CheckIfToAddPathToCollection(ApplIndex as Integer, bDoConvertIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer)
213 Dim CollectIndex as Integer
214 Dim bCheckDocuType as Boolean
215 bCheckDocuType = Applications(ApplIndex, bDoConvertIndex)
216 If bCheckDocuType Then
217 CollectIndex = GetIndexInMultiArray(PathCollection(), Applications(ApplIndex,DocIndex),
0)
218 If (CollectIndex
>-
1) Then
219 If Applications(ApplIndex, RecursiveIndex)
<> PathCollection(CollectIndex,
1) Then
220 AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex)
222 AddFilterNameToPathItem(ApplIndex, CollectIndex, sFilterName(), DistIndex)
225 AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex)
231 Sub CollectPaths(sFiltername() as String)
233 Dim XMLTemplateContentString as String
235 For i =
0 To ApplCount-
1
236 CheckIfToAddPathToCollection(i, SBDOCCONVERT, SBDOCSOURCE, SBDOCRECURSIVE, sFilterName(),
0)
239 XMLTemplateContentString =
""
240 For i =
0 To ApplCount-
1
241 If WizardMode = SBXMLMODE Then
242 XMLTemplateCount = XMLTemplateCount +
1
244 CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount)
249 Sub ConvertAllDocuments(sFilterName() as String)
250 Dim FileProperties(
1) as new com.sun.star.beans.PropertyValue
251 Dim PWFileProperties(
2) as New com.sun.star.beans.PropertyValue
252 Dim WriterWebProperties(
0) as new com.sun.star.beans.PropertyValue
253 Dim OpenProperties(
4) as new com.sun.star.beans.PropertyValue
254 Dim oInteractionHandler as Object
255 Dim InteractionTypes(
0) as Long
256 Dim FilesList(
0,
2) as String
257 Dim sViewPath as String
259 Dim FilterIndex as Integer
260 Dim sSourceUrl as String
261 Dim CurFilename as String
262 Dim oDocument as Object
263 Dim sExtension as String
264 Dim OldExtension as String
265 Dim CurFound as Integer
266 Dim TotFound as Integer
267 Dim TargetStemDir as String
268 Dim SourceStemDir as String
269 Dim TargetDir as String
270 Dim sTargetUrl as String
271 Dim CurFilterName as String
272 Dim ApplIndex as Integer
274 Dim bIsDocument as Boolean
275 Dim bDoSave as Boolean
276 Dim sCurFileExists as String
277 Dim MaxFileIndex as Integer
278 Dim bContainsBasicMacro as Boolean
279 Dim bIsPassWordProtected as Boolean
280 Dim iOverwrite as Integer
281 Dim sMimeTypeorExtension as String
282 Dim sPrevMimeTypeorExtension as String
283 bConversionisrunning = True
284 InteractionTypes(
0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER
285 oInteractionHandler = createUnoService(
"com.sun.star.task.InteractionHandler
")
286 oInteractionHandler.initialize(InteractionTypes())
287 iGeneralOverwrite = SBOVERWRITEUNDEFINED
288 bConversionIsRunning = True
292 CollectPaths(sFiltername())
293 If Not ReadCollectionPaths(FilesList(), sFilterName()) Then
295 SetProgressDisplay(
0)
296 bConversionisrunning = false
297 FinalizeDialogButtons()
300 TotFound = Ubound(FilesList()) +
1
301 If FilesList(
0,
0) =
"" Then
' Querying the number of fields in a multidimensionl Array is unsecure
302 TotFound =
0 ' because it will return the value
0 (and not -
1) even when the Array is empty
303 SetProgressDisplay(
0)
305 BubbleSortList(FilesList(), true)
306 If TotFound
> 0 Then
307 CreateLogDocument(OpenProperties())
308 InitializeProgressPage(ImportDialog)
309 OpenProperties(
0).Name =
"Hidden
"
310 OpenProperties(
0).Value = True
311 OpenProperties(
1).Name =
"AsTemplate
"
312 OpenProperties(
1).Value = False
313 OpenProperties(
2).Name =
"MacroExecutionMode
"
314 OpenProperties(
2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE
315 OpenProperties(
3).Name =
"UpdateDocMode
"
316 OpenProperties(
3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE
317 OpenProperties(
4).Name =
"InteractionHandler
"
318 OpenProperties(
4).Value = oInteractionHandler
319 MaxFileIndex = Ubound(FilesList(),
1)
321 For i =
0 To MaxFileIndex
322 sComment =
""
323 If InterruptProcess() Then
327 sSourceUrl = FilesList(i,
0)
328 sPrevMimeTypeorExtension = sMimeTypeorExtension
329 sMimeTypeorExtension = FilesList(i,
1)
330 CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex)
331 ApplIndex = FilesList(i,
2)
332 If sMimeTypeorExtension
<> sPrevMimeTypeorExtension Then
333 CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername()
335 If ApplIndex
> Ubound(Applications) or (ApplIndex
< 0) Then
336 Msgbox
"Applicationindex out of bounds:
" & sSourcUrl
338 sViewPath = ConvertFromUrl(sSourceUrl)
' CutPathView(sSourceUrl,
70)
339 ImportDialog.LabelCurDocument.Label = Str(i+
1)
& "/
" & MaxFileIndex +
1 & " (
" & sViewPath
& ")
"
340 Select Case lcase(sExtension)
341 Case
"odt
",
"ods
",
"odp
",
"odg
",
"odm
",
"odf
"
342 SourceStemDir = RTrimStr(Applications(ApplIndex,SBDOCSOURCE),
"/
")
343 TargetStemDir = RTrimStr(Applications(ApplIndex,SBDOCTARGET),
"/
")
344 Case Else
' Templates and Helper-Applications remain
345 SourceStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLSOURCE),
"/
")
346 TargetStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLTARGET),
"/
")
348 sTargetUrl = ReplaceString(sSourceUrl, TargetStemDir, SourceStemDir)
349 CurFilename = GetFileNameWithoutExtension(sTargetUrl,
"/
")
350 OldExtension = GetFileNameExtension(sTargetUrl)
351 sTargetUrl = RTrimStr(sTargetUrl, OldExtension)
352 sTargetUrl = sTargetUrl
& sExtension
353 TargetDir = RTrimStr(sTargetUrl, CurFilename
& ".
" & sExtension)
354 If (oUcb.Exists(sTargetUrl)) Then
355 If (iGeneralOverwrite
<> SBOVERWRITEALWAYS) Then
356 If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then
357 ShowOverwriteAllDialog(sTargetUrl, sTitle)
358 bDoSave = (iGeneralOverwrite = SBOVERWRITEQUERY) Or (iGeneralOverwrite = SBOVERWRITEALWAYS)
359 Elseif iGeneralOverwrite = SBOVERWRITENEVER Then
361 ElseIf ((iGeneralOverWrite = SBOVERWRITEQUERY) OR (iGeneralOverwrite = SBOVERWRITECANCEL)) Then
362 ' Todo: According to AS there might come a new feature that storeasUrl could possibly rise a UI dialog.
363 ' In this case my own UI becomes obsolete
364 sCurFileExists = ReplaceString(sFileExists, ConvertFromUrl(sTargetUrl),
"<1>")
365 sCurFileExists = ReplaceString(sCurFileExists, chr(
13),
"<CR
>")
366 iOverWrite = Msgbox (sCurFileExists,
32 +
3, sTitle)
367 Select Case iOverWrite
369 ' In the FileProperty-Bean this is already default
381 If Not oUcb.Exists(TargetDir) Then
382 bDoSave = CreateFolder(TargetDir)
385 oDocument = StarDesktop.LoadComponentFromURL(sSourceUrl,
"_default
",
0, OpenProperties())
386 If Not IsNull(oDocument) Then
387 InsertSourceUrlToLogDocument(sSourceUrl,
"")
388 bIsPassWordProtected = CheckPassWordProtection(oDocument)
389 CheckIfMacroExists(oDocument.BasicLibraries, sComment)
390 On Local Error Goto NOSAVING
391 If bIsPassWordProtected Then
392 PWFileProperties(
0).Name =
"FilterName
"
393 PWFileProperties(
0).Value = CurFilterName
394 PWFileProperties(
1).Name =
"Overwrite
"
395 PWFileProperties(
1).Value = True
396 PWFileProperties(
2).Name =
"Password
"
397 PWFileProperties(
2).Value = sCurPassWord
398 oDocument.StoreAsUrl(sTargetUrl, PWFileProperties())
400 FileProperties(
0).Name =
"FilterName
"
401 FileProperties(
0).Value = CurFilterName
402 FileProperties(
1).Name =
"Overwrite
"
403 FileProperties(
1).Value = True
404 oDocument.StoreAsUrl(sTargetUrl,FileProperties())
406 ' Todo: Make sure that an errorbox pops up when saving fails
408 If Err
<> 0 Then
409 sCurcouldnotsaveDocument = ReplaceString(scouldnotsaveDocument, ConvertFromUrl(sTargetUrl),
"<1>")
410 sComment = ConcatComment(sComment, sCurCouldnotsaveDocument)
414 FileCount = FileCount +
1
417 InsertTargetUrlToLogDocument(sTargetUrl, sComment)
419 sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl),
"<1>")
420 sComment = ConcatComment(sComment, sCurCouldnotopenDocument)
421 InsertSourceUrlToLogDocument(sSourceUrl, sComment)
428 FinalizeDialogButtons()
429 bConversionIsRunning = False
432 Msgbox sRTErrorDesc,
16, sRTErrorHeader
437 Sub AddListtoFilesList(FirstList(), SecList(), NewContentList() as String)
438 Dim sLocExtension as String
439 Dim FirstStart as Integer
440 Dim FirstEnd as Integer
443 If FirstList(
0,
0) =
"" Then
444 FirstStart = Ubound(FirstList(),
1)
446 FirstStart = Ubound(FirstList(),
1) +
1
448 FirstEnd = FirstStart + Ubound(SecList(),
1)
449 ReDim Preserve FirstList(FirstEnd,
2)
451 For i = FirstStart To FirstEnd
452 FirstList(i,
0) = SecList(s,
0)
453 FirstList(i,
1) = SecList(s,
1)
454 sLocExtension = lcase(FirstList(i,
1))
455 Select Case sLocExtension
456 Case
"sdw
",
"sdc
",
"sda
",
"sdd
",
"smf
",
"sgl
",
"doc
",
"xls
",
"ppt
",
"sxi
" ,
"sxw
" ,
"sxd
" ,
"sxg
" ,
"sxm
" ,
"sxc
" ,
"pps
"
457 AbsDocuFound = AbsDocuFound +
1
459 AbsTemplateFound = AbsTemplateFound +
1
461 FirstList(i,
2) = CStr(NewContentList(s))
464 SetProgressDisplay(Ubound(FirstList()) +
1)
469 Function GetTargetTemplatePath(Index as Integer)
470 Select Case WizardMode
472 GetTargetTemplatePath() = SOTemplatePath
& "/
" & sTemplateGroupName
475 ' Helper Application
476 GetTargetTemplatePath = SOWorkPath
478 GetTargetTemplatePath = SOTemplatePath
484 ' Retrieves the second value for a next to
'SearchString
' in
485 ' a two-dimensional string-Array
486 Function GetFilterName(sMimetypeorExtension as String, sFilterName(), sExtension as string, FilterIndex as Integer) as String
488 Dim MaxIndex as Integer
489 Dim sLocFilterlist() as String
490 For i =
0 To Ubound(sFiltername(),
1)
491 If Instr(
1,sFilterName(i,
0),sMimeTypeOrExtension)
<> 0 Then
492 sLocFilterList() = ArrayoutofString(sFiltername(i,
0),
"|
", MaxIndex)
494 sExtension = sFiltername(i,
2)
495 GetFilterName = sFilterName(i,
1)
498 Dim sLocExtensionList() as String
499 b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList())
500 sLocFilterList() = ArrayoutofString(sFiltername(i,
1),
"|
", MaxIndex)
501 GetFilterName = sLocFilterList(b)
502 sLocExtensionList() = ArrayoutofString(sFilterName(i,
2),
"|
", MaxIndex)
503 sExtension = sLocExtensionList(b)
512 Function SearchArrayforPartString(SearchString as String, LocList()) as Integer
515 Dim StringList() as String
516 For i = Lbound(LocList(),
1) to Ubound(LocList(),
1)
517 StringList() = ArrayoutofString(LocList(i),
"|
")
518 For a =
0 To Ubound(StringList())
519 If (Instr(
1, SearchString, StringList(a))
<> 0) Then
520 SearchArrayForPartString() = i
525 SearchArrayForPartString() = -
1
529 Sub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String)
530 Dim oLogCursor as Object
531 Dim oLogRows as Object
532 Dim FilterIndex as Integer
533 Dim sDocumentType as String
536 If Not bLogExists Then
539 FilterIndex = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent,
0)
540 sDocumentType = sFiltername(FilterIndex,
3)
541 oLogCursor = oLogDocument.Text.createTextCursor()
542 oLogCursor.GotoEnd(False)
543 If Not bIsFirstLogTable Then
544 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
546 bisFirstLogTable = False
548 oLogCursor.HyperLinkURL =
""
549 oLogCursor.HyperLinkName =
""
550 oLogCursor.HyperLinkTarget =
""
551 oLogCursor.ParaStyleName =
"Heading
1"
552 oLogCursor.setString(sDocumentType)
553 oLogCursor.CollapsetoEnd()
554 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
555 oLogTable = oLogDocument.CreateInstance(
"com.sun.star.text.TextTable
")
556 oLogTable.RepeatHeadline = true
557 oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True)
558 oTextCursor = oLogTable.GetCellbyPosition(
0,
0).createTextCursor()
559 oTextCursor.SetString(sSourceDocuments)
560 oTextCursor = oLogTable.GetCellbyPosition(
1,
0).createTextCursor()
561 oTextCursor.SetString(sTargetDocuments)
566 Function GetSize(iWidth, iHeight) As New com.sun.star.awt.Size
567 Dim aSize As New com.sun.star.awt.Size
569 aSize.Height = iHeight
574 Sub InsertCommandButtonatViewCursor(oLocDocument, oLocCursor, TargetUrl as String, Optional aSize)
583 oCommandButton = oLocDocument.createInstance(
"com.sun.star.form.component.CommandButton
")
584 oShape = oLocDocument.CreateInstance (
"com.sun.star.drawing.ControlShape
")
585 If IsMissing(aSize) Then
586 oShape.Size = GetSize(
4000,
600)
588 oCommandButton.Label = FileNameoutofPath(Targeturl)
589 oCommandButton.TargetFrame =
"_default
"
590 oCommandButton.ButtonType = com.sun.star.form.FormButtonType.URL
591 oCommandbutton.DispatchUrlInternal = True
592 oCommandButton.TargetURL = ConverttoUrl(TargetUrl)
593 oShape.Control = oCommandbutton
594 oLocCursor.Text.InsertTextContent(oLocCursor, oShape, True)
599 Sub CreateLogDocument(HiddenProperties())
600 Dim OpenProperties(
0) as new com.sun.star.beans.PropertyValue
603 Dim bLogIsThere as Boolean
604 If ImportDialog.chkLogfile.State =
1 Then
606 OpenProperties(
0).Name =
"Hidden
"
607 OpenProperties(
0).Value = True
608 oLogDocument = StarDesktop.LoadComponentFromURL(
"private:factory/swriter
",
"_default
",
4, OpenProperties())
609 SOWorkPath = RTrimStr(SOWorkPath,
"/
")
610 sLogUrl = SOWorkPath
& "/Logfile.odt
"
612 bLogIsThere = oUcb.Exists(sLogUrl)
615 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_2.odt
",
"/Logfile.odt
")
617 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_
" & cStr(i)
& ".odt
",
"/Logfile_
" & cStr(i-
1)
& ".odt
")
621 Loop Until Not bLogIsThere
623 oLogDocument.StoreAsUrl(sLogUrl, NoArgs())
628 Sub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String)
631 Dim CurFilterTracingpath as String
632 If (bLogExists) And (sTargetUrl
<> "") Then
633 If sTargetUrl
<> "" Then
634 oCell = oLogTable.GetCellbyPosition(
1,oLogTable.Rows.Count-
1)
635 InsertCommentToLogCell(sComment, oCell)
636 InsertHyperLinkToLogCell(sTargetUrl, oCell)
643 Sub InsertSourceUrlToLogDocument(SourceUrl as String, sComment)
'
647 oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,
1)
651 oCell = oLogTable.GetCellbyPosition(
0,oLogTable.Rows.Count-
1)
652 InsertCommentToLogCell(sComment, oCell)
653 InsertHyperLinkToLogCell(SourceUrl, oCell)
659 Sub InsertHyperLinkToLogCell(sUrl as String, oCell as Object)
660 Dim oLogCursor as Object
661 Dim LocFileName as String
662 oLogCursor = oCell.createTextCursor()
663 oLogCursor.CollapseToStart()
664 oLogCursor.HyperLinkURL = sUrl
665 oLogCursor.HyperLinkName = sUrl
666 oLogCursor.HyperLinkTarget = sUrl
667 LocFileName = FileNameOutOfPath(sUrl)
668 oCell.InsertString(oLogCursor, LocFileName,False)
672 Sub InsertCommentToLogCell(sComment as string, oCell as Object)
673 Dim oCommentCursor as Object
674 If sComment
<> "" Then
675 oCommentCursor = oCell.createTextCursor()
676 oCell.insertControlCharacter(oCommentCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
677 oCell.insertString(oCommentCursor, sComment, false)
682 Sub AddLogStatistics()
684 Dim oLogCursor as Object
685 Dim MaxRowIndex as Integer
687 MaxRowIndex = oLogTable.Rows.Count
688 sLogSummary = ReplaceString(sLogSummary, FileCount,
"<COUNT
>")
689 ' oLogTable.Rows.InsertByIndex(MaxRowIndex,
1)
690 ' oCell = oLogTable.GetCellbyPosition(
0, MaxRowIndex)
691 ' oLogCursor = oCell.createTextCursor()
692 ' oCell.InsertString(oLogCursor, sLogSummary,False)
693 ' MergeRange(oLogTable, oCell,
1)
695 oLogCursor = oLogDocument.Text.CreateTextCursor
696 oLogCursor.gotoEnd(False)
697 oLogCursor.HyperLinkURL =
""
698 oLogCursor.HyperLinkName =
""
699 oLogCursor.HyperLinkTarget =
""
700 oLogCursor.SetString(sLogSummary)
702 oLogDocument.Dispose()
709 Function CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean
710 Dim ModuleNames() as String
711 Dim ModuleName as String
712 Dim MaxLibIndex as Integer
713 Dim MaxModuleIndex as Integer
714 Dim bMacroExists as Boolean
717 Dim LibName as String
718 Dim sBasicCode as String
719 Dim oLibrary as Object
721 bMacroExists = oBasicLibraries.hasElements
723 MaxLibIndex = Ubound(oBasicLibraries.ElementNames())
724 For n =
0 To MaxLibIndex
725 LibName = oBasicLibraries.ElementNames(n)
726 If oBasicLibraries.isLibraryLoaded(LibName) Then
727 oLibrary = oBasicLibraries.getbyName(LibName)
728 If oLibrary.hasElements() Then
729 MaxModuleIndex = Ubound(oLibrary.ElementNames())
730 For m =
0 To MaxModuleIndex
731 ModuleName = oLibrary.ElementNames(m)
732 sBasicCode = oLibrary.getbyName(ModuleName)
733 If sBasicCode
<> "" Then
734 ConcatComment(sComment, sReeditMacro)
735 CheckIfMacroExists() = True
743 CheckIfMacroExists() = False
748 Function CheckPassWordProtection(oDocument as Object)
749 Dim bIsPassWordProtected as Boolean
752 Dim MaxIndex as Integer
753 Dim sblabla as String
754 bIsPassWordProtected = false
755 oArgs() = oDocument.getArgs()
756 MaxIndex = Ubound(oArgs())
757 For i =
0 To MaxIndex
758 sblabla = oArgs(i).Name
759 If oArgs(i).Name =
"Password
" Then
760 bIsPassWordProtected = True
761 sCurPassWord = oArgs(i).Value
765 CheckPassWordProtection() = bIsPassWordProtected
769 Sub OpenLogDocument()
772 ImportDialogArea.endexecute()
777 Sub MergeRange(oTable as Object, oCell as Object, MergeCount as Integer)
778 Dim oTableCursor as Object
779 oTableCursor = oTable.createCursorByCellName(oCell.CellName)
780 oTableCursor.goRight(MergeCount, True)
781 oTableCursor.mergeRange()
785 Function ConcatComment(sComment as String, AdditionalComment as String)
786 If sComment =
"" Then
787 sComment = AdditionalComment
789 sComment = sComment
& chr(
13) + AdditionalComment
791 ConcatComment = sComment