1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"FilesModul" script:
language=
"StarBasic">Option Explicit
5 Public AbsTemplateFound as Integer
6 Public AbsDocuFound as Integer
7 Public oLogDocument as Object
8 Public oLogTable as Object
9 Public bLogExists as Boolean
10 Public sComment as String
11 Public MaxCollectIndex as Integer
12 Public bInsertRow as Boolean
13 Public sLogUrl as String
14 Public sCurPassWord as String
15 Public FileCount as Integer
16 Public XMLTemplateCount as Integer
17 Public PathCollection(
7,
3) as String
18 Public bIsFirstLogTable as Boolean
19 Public bFilterTracerIsinsideTable as Boolean
22 Function ReadCollectionPaths(FilesList() as String, sFilterName() as String)
23 Dim FilterIndex as Integer
24 Dim bRecursive as Boolean
25 Dim SearchDir as String
31 Dim sFileContent() as String
32 Dim NewList(
0,
1) as String
34 Dim CurFileName as String
35 Dim CurExtension as String
36 Dim CurFileContent as String
37 Dim XMLTemplateContentList() as String
38 Dim bIsTemplatePath as Boolean
39 Dim MaxIndex as Integer
40 Dim NewContentList() as String
41 Dim XMLTemplateContentString as String
42 Dim ApplIndex as Integer
43 Dim bAssignFileName as Boolean
44 Dim bInterruptSearch as Boolean
45 bInterruptSearch = False
46 For i =
0 To MaxCollectIndex
47 SearchDir = PathCollection(i,
0)
48 bRecursive = PathCollection(i,
1)
49 sFileContent() = ArrayoutofString(PathCollection(i,
2),
"|
")
50 NewList() = ReadDirectories(SearchDir, bRecursive, False, False, sFileContent(),
"")
51 If InterruptProcess Then
52 ReadCollectionPaths() = False
55 If Ubound(NewList())
> -
1 Then
56 bIsTemplatePath = FieldInList(
"vor
", sFileContent)
57 If bIsTemplatePath Then
58 XMLTemplateContentString = PathCollection(i,
3)
59 XMLTemplateContentList() = ArrayoutofString(XMLTemplateContentString,
"|
")
60 If Ubound(XMLTemplateContentList())
> -
1 Then
61 MaxIndex = Ubound(NewList())
62 ReDim Preserve NewList(MaxIndex,
1) as String
63 ReDim Preserve NewContentList(MaxIndex) as String
66 bAssignFileName = True
67 If InterruptProcess() Then
68 ReadCollectionPaths() = False
71 CurFileContent =
""
72 CurFileName = NewList(n,
0)
73 If (FieldInList(NewList(n,
1), XMLTemplateList())) Then
74 CurFileContent = GetRealFileContent(CurFileName)
75 t = SearchArrayforPartString(CurFileContent, XMLTemplateContentList())
76 bAssignFileName = (t
> -
1)
77 If bAssignFileName Then
78 CurFileContent = XMLTemplateContentList(t)
80 NewList(n,
1) = CurFileContent
82 CurExtension = NewList(n,
1)
83 If bAssignFileName Then
86 NewList(a,
0) = CurFileName
87 NewList(a,
1) = CurExtension
88 If CurFileContent =
"" Then
89 CurFileContent = CurExtension
91 ApplIndex = GetApplicationIndex(CurFileContent, sFiltername())
92 NewContentList(a) = ApplIndex
96 If a
< MaxIndex And a
> -
1 Then
97 ReDim Preserve NewList(a,
1) as String
100 AddListtoFilesList(FilesList(), NewList(), NewContentList())
104 MaxIndex = Ubound(NewList())
105 ReDim Preserve NewContentList(MaxIndex) as String
106 For s =
0 To MaxIndex
107 CurExtension = NewList(s,
1)
108 NewContentList(s) = GetApplicationIndex(CurExtension, sFiltername())
110 AddListtoFilesList(FilesList(), NewList(), NewContentList())
114 ReadCollectionPaths() = Ubound(FilesList())
> -
1
118 Function GetApplicationIndex(CurFileContent as String, sFilterName() as String) as Integer
121 Index = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent,
0)
122 If Index
>= MaxApplCount Then
123 Index = Index - MaxApplCount
125 For i =
0 To MaxApplCount -
1
126 If Applications(i, SBAPPLKEY) = Index Then
127 GetApplicationIndex() = i
131 GetApplicationIndex() = -
1
135 Function InterruptProcess() as Boolean
136 If bCancelTask Or RetValue =
0 Then
137 bConversionIsRunning = False
138 InterruptProcess() = True
141 InterruptProcess() = False
145 Sub AddCollectionPath(ApplIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer)
146 MaxCollectIndex = MaxCollectIndex +
1
147 PathCollection(MaxCollectIndex,
0) = Applications(ApplIndex, DocIndex)
148 PathCollection(MaxCollectIndex,
1) = Applications(ApplIndex, RecursiveIndex)
149 AddFilterNameToPathItem(ApplIndex, MaxCollectIndex, sFiltername(), DistIndex)
153 Function SetExtension(LocExtension) as String
154 if (Instr(LocExtension,
"vnd.sun.xml.impress
"))
> 0 then
155 SetExtension() =
"vor|sti|std
"
156 elseif (Instr(LocExtension,
"vnd.sun.xml.writer
"))
> 0 then
157 SetExtension() =
"vor|stw
"
158 elseif (Instr(LocExtension,
"vnd.sun.xml.calc
"))
> 0 then
159 SetExtension() =
"vor|stc
"
160 elseif (Instr(LocExtension,
"vnd.sun.xml.draw
"))
> 0 then
161 SetExtension() =
"vor|std|sti
"
165 Sub AddFilterNameToPathItem(ApplIndex as Integer, CollectIndex as Integer, sFiltername() as String, DistIndex as Integer)
167 Dim CurListString as String
168 Dim LocExtension as String
169 Dim LocContentString as String
170 Dim LocXMLTemplateContent as String
171 iKey = Applications(ApplIndex, SBAPPLKEY)
172 CurListString = PathCollection(CollectIndex,
2)
173 LocExtension = sFilterName(iKey +DistIndex,
0)
174 If Len(LocExtension)
> SBMAXEXTENSIONLENGTH Then
' 7 == Length of two extensions like
'sda|sdd
175 LocExtension = SetExtension(LocExtension)
176 LocContentString = sFilterName(iKey +DistIndex,
0)
177 LocContentString = ReplaceString(LocContentString,
"|
",
";
")
178 LocXMLTemplateContent = PathCollection(CollectIndex,
3)
179 If LocXMLTemplateContent =
"" Then
180 LocXMLTemplateContent = LocContentString
182 LocXMLTemplateContent = LocXMLTemplateContent
& "|
" & LocContentString
184 PathCollection(CollectIndex,
3) = LocXMLTemplateContent
186 If CurListString =
"" Then
187 PathCollection(CollectIndex,
2) = LocExtension
189 If Instr(CurListString, LocExtension) =
0 Then
190 PathCollection(CollectIndex,
2) = CurListString
& "|
" & LocExtension
196 Sub CheckIfToAddPathToCollection(ApplIndex as Integer, bDoConvertIndex as Integer, DocIndex as Integer, RecursiveIndex as Integer, sFiltername() as String, DistIndex as Integer)
197 Dim CollectIndex as Integer
198 Dim bCheckDocuType as Boolean
199 bCheckDocuType = Applications(ApplIndex, bDoConvertIndex)
200 If bCheckDocuType Then
201 CollectIndex = GetIndexInMultiArray(PathCollection(), Applications(ApplIndex,DocIndex),
0)
202 If (CollectIndex
>-
1) Then
203 If Applications(ApplIndex, RecursiveIndex)
<> PathCollection(CollectIndex,
1) Then
204 AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex)
206 AddFilterNameToPathItem(ApplIndex, CollectIndex, sFilterName(), DistIndex)
209 AddCollectionPath(ApplIndex, DocIndex, RecursiveIndex, sFilterName(), DistIndex)
215 Sub CollectPaths(sFiltername() as String)
217 Dim XMLTemplateContentString as String
219 For i =
0 To ApplCount-
1
220 CheckIfToAddPathToCollection(i, SBDOCCONVERT, SBDOCSOURCE, SBDOCRECURSIVE, sFilterName(),
0)
223 XMLTemplateContentString =
""
224 For i =
0 To ApplCount-
1
225 If WizardMode = SBXMLMODE Then
226 XMLTemplateCount = XMLTemplateCount +
1
228 CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount)
233 Sub ConvertAllDocuments(sFilterName() as String)
234 Dim FileProperties(
1) as new com.sun.star.beans.PropertyValue
235 Dim PWFileProperties(
2) as New com.sun.star.beans.PropertyValue
236 Dim WriterWebProperties(
0) as new com.sun.star.beans.PropertyValue
237 Dim OpenProperties(
4) as new com.sun.star.beans.PropertyValue
238 Dim oInteractionHandler as Object
239 Dim InteractionTypes(
0) as Long
240 Dim FilesList(
0,
2) as String
241 Dim sViewPath as String
243 Dim FilterIndex as Integer
244 Dim sSourceUrl as String
245 Dim CurFilename as String
246 Dim oDocument as Object
247 Dim sExtension as String
248 Dim OldExtension as String
249 Dim CurFound as Integer
250 Dim TotFound as Integer
251 Dim TargetStemDir as String
252 Dim SourceStemDir as String
253 Dim TargetDir as String
254 Dim sTargetUrl as String
255 Dim CurFilterName as String
256 Dim ApplIndex as Integer
258 Dim bIsDocument as Boolean
259 Dim bDoSave as Boolean
260 Dim sCurFileExists as String
261 Dim MaxFileIndex as Integer
262 Dim bContainsBasicMacro as Boolean
263 Dim bIsPassWordProtected as Boolean
264 Dim iOverwrite as Integer
265 Dim sMimeTypeorExtension as String
266 Dim sPrevMimeTypeorExtension as String
267 bConversionisrunning = True
268 InteractionTypes(
0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER
269 oInteractionHandler = createUnoService(
"com.sun.star.task.InteractionHandler
")
270 oInteractionHandler.initialize(InteractionTypes())
271 iGeneralOverwrite = SBOVERWRITEUNDEFINED
272 bConversionIsRunning = True
276 CollectPaths(sFiltername())
277 If Not ReadCollectionPaths(FilesList(), sFilterName()) Then
279 SetProgressDisplay(
0)
280 bConversionisrunning = false
281 FinalizeDialogButtons()
284 TotFound = Ubound(FilesList()) +
1
285 If FilesList(
0,
0) =
"" Then
' Querying the number of fields in a multidimensionl Array is unsecure
286 TotFound =
0 ' because it will return the value
0 (and not -
1) even when the Array is empty
287 SetProgressDisplay(
0)
289 BubbleSortList(FilesList(), true)
290 If TotFound
> 0 Then
291 CreateLogDocument(OpenProperties())
292 InitializeProgressPage(ImportDialog)
293 OpenProperties(
0).Name =
"Hidden
"
294 OpenProperties(
0).Value = True
295 OpenProperties(
1).Name =
"AsTemplate
"
296 OpenProperties(
1).Value = False
297 OpenProperties(
2).Name =
"MacroExecutionMode
"
298 OpenProperties(
2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE
299 OpenProperties(
3).Name =
"UpdateDocMode
"
300 OpenProperties(
3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE
301 OpenProperties(
4).Name =
"InteractionHandler
"
302 OpenProperties(
4).Value = oInteractionHandler
303 MaxFileIndex = Ubound(FilesList(),
1)
305 For i =
0 To MaxFileIndex
306 sComment =
""
307 If InterruptProcess() Then
311 sSourceUrl = FilesList(i,
0)
312 sPrevMimeTypeorExtension = sMimeTypeorExtension
313 sMimeTypeorExtension = FilesList(i,
1)
314 CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex)
315 ApplIndex = FilesList(i,
2)
316 If sMimeTypeorExtension
<> sPrevMimeTypeorExtension Then
317 CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername()
319 If ApplIndex
> Ubound(Applications) or (ApplIndex
< 0) Then
320 Msgbox
"Applicationindex out of bounds:
" & sSourcUrl
322 sViewPath = ConvertFromUrl(sSourceUrl)
' CutPathView(sSourceUrl,
70)
323 ImportDialog.LabelCurDocument.Label = Str(i+
1)
& "/
" & MaxFileIndex +
1 & " (
" & sViewPath
& ")
"
324 Select Case lcase(sExtension)
325 Case
"odt
",
"ods
",
"odp
",
"odg
",
"odm
",
"odf
"
326 SourceStemDir = RTrimStr(Applications(ApplIndex,SBDOCSOURCE),
"/
")
327 TargetStemDir = RTrimStr(Applications(ApplIndex,SBDOCTARGET),
"/
")
328 Case Else
' Templates and Helper-Applications remain
329 SourceStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLSOURCE),
"/
")
330 TargetStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLTARGET),
"/
")
332 sTargetUrl = ReplaceString(sSourceUrl, TargetStemDir, SourceStemDir)
333 CurFilename = GetFileNameWithoutExtension(sTargetUrl,
"/
")
334 OldExtension = GetFileNameExtension(sTargetUrl)
335 sTargetUrl = RTrimStr(sTargetUrl, OldExtension)
336 sTargetUrl = sTargetUrl
& sExtension
337 TargetDir = RTrimStr(sTargetUrl, CurFilename
& ".
" & sExtension)
338 If (oUcb.Exists(sTargetUrl)) Then
339 If (iGeneralOverwrite
<> SBOVERWRITEALWAYS) Then
340 If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then
341 ShowOverwriteAllDialog(sTargetUrl, sTitle)
342 bDoSave = (iGeneralOverwrite = SBOVERWRITEQUERY) Or (iGeneralOverwrite = SBOVERWRITEALWAYS)
343 Elseif iGeneralOverwrite = SBOVERWRITENEVER Then
345 ElseIf ((iGeneralOverWrite = SBOVERWRITEQUERY) OR (iGeneralOverwrite = SBOVERWRITECANCEL)) Then
346 ' Todo: According to AS there might come a new feature that storeasUrl could possibly rise a UI dialog.
347 ' In this case my own UI becomes obsolete
348 sCurFileExists = ReplaceString(sFileExists, ConvertFromUrl(sTargetUrl),
"<1>")
349 sCurFileExists = ReplaceString(sCurFileExists, chr(
13),
"<CR
>")
350 iOverWrite = Msgbox (sCurFileExists,
32 +
3, sTitle)
351 Select Case iOverWrite
353 ' In the FileProperty-Bean this is already default
365 If Not oUcb.Exists(TargetDir) Then
366 bDoSave = CreateFolder(TargetDir)
369 oDocument = StarDesktop.LoadComponentFromURL(sSourceUrl,
"_default
",
0, OpenProperties())
370 If Not IsNull(oDocument) Then
371 InsertSourceUrlToLogDocument(sSourceUrl,
"")
372 bIsPassWordProtected = CheckPassWordProtection(oDocument)
373 CheckIfMacroExists(oDocument.BasicLibraries, sComment)
374 On Local Error Goto NOSAVING
375 If bIsPassWordProtected Then
376 PWFileProperties(
0).Name =
"FilterName
"
377 PWFileProperties(
0).Value = CurFilterName
378 PWFileProperties(
1).Name =
"Overwrite
"
379 PWFileProperties(
1).Value = True
380 PWFileProperties(
2).Name =
"Password
"
381 PWFileProperties(
2).Value = sCurPassWord
382 oDocument.StoreAsUrl(sTargetUrl, PWFileProperties())
384 FileProperties(
0).Name =
"FilterName
"
385 FileProperties(
0).Value = CurFilterName
386 FileProperties(
1).Name =
"Overwrite
"
387 FileProperties(
1).Value = True
388 oDocument.StoreAsUrl(sTargetUrl,FileProperties())
390 ' Todo: Make sure that an errorbox pops up when saving fails
392 If Err
<> 0 Then
393 sCurcouldnotsaveDocument = ReplaceString(scouldnotsaveDocument, ConvertFromUrl(sTargetUrl),
"<1>")
394 sComment = ConcatComment(sComment, sCurCouldnotsaveDocument)
398 FileCount = FileCount +
1
401 InsertTargetUrlToLogDocument(sTargetUrl, sComment, ApplIndex)
403 sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl),
"<1>")
404 sComment = ConcatComment(sComment, sCurCouldnotopenDocument)
405 InsertSourceUrlToLogDocument(sSourceUrl, sComment)
412 FinalizeDialogButtons()
413 bConversionIsRunning = False
416 Msgbox sRTErrorDesc,
16, sRTErrorHeader
421 Sub AddListtoFilesList(FirstList(), SecList(), NewContentList() as String)
422 Dim sLocExtension as String
423 Dim FirstStart as Integer
424 Dim FirstEnd as Integer
427 If FirstList(
0,
0) =
"" Then
428 FirstStart = Ubound(FirstList(),
1)
430 FirstStart = Ubound(FirstList(),
1) +
1
432 FirstEnd = FirstStart + Ubound(SecList(),
1)
433 ReDim Preserve FirstList(FirstEnd,
2)
435 For i = FirstStart To FirstEnd
436 FirstList(i,
0) = SecList(s,
0)
437 FirstList(i,
1) = SecList(s,
1)
438 sLocExtension = lcase(FirstList(i,
1))
439 Select Case sLocExtension
440 Case
"sdw
",
"sdc
",
"sda
",
"sdd
",
"smf
",
"sgl
",
"doc
",
"xls
",
"ppt
",
"sxi
" ,
"sxw
" ,
"sxd
" ,
"sxg
" ,
"sxm
" ,
"sxc
" ,
"pps
"
441 AbsDocuFound = AbsDocuFound +
1
443 AbsTemplateFound = AbsTemplateFound +
1
445 FirstList(i,
2) = CStr(NewContentList(s))
448 SetProgressDisplay(Ubound(FirstList()) +
1)
453 Function GetTargetTemplatePath(Index as Integer)
454 Select Case WizardMode
456 GetTargetTemplatePath() = SOTemplatePath
& "/
" & sTemplateGroupName
459 ' Helper Application
460 GetTargetTemplatePath = SOWorkPath
462 GetTargetTemplatePath = SOTemplatePath
468 ' Retrieves the second value for a next to
'SearchString
' in
469 ' a two-dimensional string-Array
470 Function GetFilterName(sMimetypeorExtension as String, sFilterName(), sExtension as string, FilterIndex as Integer) as String
472 Dim MaxIndex as Integer
473 Dim sLocFilterlist() as String
474 For i =
0 To Ubound(sFiltername(),
1)
475 If Instr(
1,sFilterName(i,
0),sMimeTypeOrExtension)
<> 0 Then
476 sLocFilterList() = ArrayoutofString(sFiltername(i,
0),
"|
", MaxIndex)
478 sExtension = sFiltername(i,
2)
479 GetFilterName = sFilterName(i,
1)
482 Dim sLocExtensionList() as String
483 b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList())
484 sLocFilterList() = ArrayoutofString(sFiltername(i,
1),
"|
", MaxIndex)
485 GetFilterName = sLocFilterList(b)
486 sLocExtensionList() = ArrayoutofString(sFilterName(i,
2),
"|
", MaxIndex)
487 sExtension = sLocExtensionList(b)
496 Function SearchArrayforPartString(SearchString as String, LocList()) as Integer
499 Dim StringList() as String
500 For i = Lbound(LocList(),
1) to Ubound(LocList(),
1)
501 StringList() = ArrayoutofString(LocList(i),
"|
")
502 For a =
0 To Ubound(StringList())
503 If (Instr(
1, SearchString, StringList(a))
<> 0) Then
504 SearchArrayForPartString() = i
509 SearchArrayForPartString() = -
1
513 Sub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String)
514 Dim oLogCursor as Object
515 Dim oLogRows as Object
516 Dim FilterIndex as Integer
517 Dim sDocumentType as String
520 If Not bLogExists Then
523 bFilterTracerIsinsideTable = False
524 FilterIndex = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent,
0)
525 sDocumentType = sFiltername(FilterIndex,
3)
526 oLogCursor = oLogDocument.Text.createTextCursor()
527 oLogCursor.GotoEnd(False)
528 If Not bIsFirstLogTable Then
529 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
531 bisFirstLogTable = False
533 oLogCursor.HyperLinkURL =
""
534 oLogCursor.HyperLinkName =
""
535 oLogCursor.HyperLinkTarget =
""
536 oLogCursor.ParaStyleName =
"Heading
1"
537 oLogCursor.setString(sDocumentType)
538 If WizardMode = SBMICROSOFTMODE Then
539 If bFilterTracingAvailable Then
540 If bMSApplFilterTracingAvailable(ApplIndex) Then
541 Dim CurFilterTracingPath as String
542 CurFilterTracingPath = FilterTracingLogPath(ApplIndex)
543 bFilterTracerIsinsideTable = (bTakeOverTargetName(ApplIndex) Or bTakeOverPathName(ApplIndex))
544 If Not bFilterTracerIsinsideTable Then
545 oLogCursor.CollapseToEnd()
546 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
547 InsertCommandButtonatViewCursor(oLogDocument, oLogCursor, CurFilterTracingPath)
552 oLogCursor.CollapsetoEnd()
553 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
554 oLogTable = oLogDocument.CreateInstance(
"com.sun.star.text.TextTable
")
555 oLogTable.RepeatHeadline = true
556 If bFilterTracerIsinsideTable Then
557 oLogTable.initialize(
2,
3)
559 oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True)
560 oTextCursor = oLogTable.GetCellbyPosition(
0,
0).createTextCursor()
561 oTextCursor.SetString(sSourceDocuments)
562 oTextCursor = oLogTable.GetCellbyPosition(
1,
0).createTextCursor()
563 oTextCursor.SetString(sTargetDocuments)
564 If bFilterTracerIsinsideTable Then
565 oTextCursor = oLogTable.GetCellbyPosition(
2,
0).createTextCursor()
566 oTextCursor.SetString(
"FilterTracer
")
572 Function GetSize(iWidth, iHeight) As New com.sun.star.awt.Size
573 Dim aSize As New com.sun.star.awt.Size
575 aSize.Height = iHeight
580 Sub InsertCommandButtonatViewCursor(oLocDocument, oLocCursor, TargetUrl as String, Optional aSize)
589 oCommandButton = oLocDocument.createInstance(
"com.sun.star.form.component.CommandButton
")
590 oShape = oLocDocument.CreateInstance (
"com.sun.star.drawing.ControlShape
")
591 If IsMissing(aSize) Then
592 oShape.Size = GetSize(
4000,
600)
594 oCommandButton.Label = FileNameoutofPath(Targeturl)
595 oCommandButton.TargetFrame =
"_default
"
596 oCommandButton.ButtonType = com.sun.star.form.FormButtonType.URL
597 oCommandbutton.DispatchUrlInternal = True
598 oCommandButton.TargetURL = ConverttoUrl(TargetUrl)
599 oShape.Control = oCommandbutton
600 oLocCursor.Text.InsertTextContent(oLocCursor, oShape, True)
605 Sub CreateLogDocument(HiddenProperties())
606 Dim OpenProperties(
0) as new com.sun.star.beans.PropertyValue
609 Dim bLogIsThere as Boolean
610 If ImportDialog.chkLogfile.State =
1 Then
612 OpenProperties(
0).Name =
"Hidden
"
613 OpenProperties(
0).Value = True
614 oLogDocument = StarDesktop.LoadComponentFromURL(
"private:factory/swriter
",
"_default
",
4, OpenProperties())
615 SOWorkPath = RTrimStr(SOWorkPath,
"/
")
616 sLogUrl = SOWorkPath
& "/Logfile.odt
"
618 bLogIsThere = oUcb.Exists(sLogUrl)
621 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_2.odt
",
"/Logfile.odt
")
623 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_
" & cStr(i)
& ".odt
",
"/Logfile_
" & cStr(i-
1)
& ".odt
")
627 Loop Until Not bLogIsThere
629 oLogDocument.StoreAsUrl(sLogUrl, NoArgs())
634 Function GetFilterTracingLogPath(sTargetUrl as String, ApplIndex) as String
635 Dim TargetFileName as String
636 Dim sTargetFolder as String
637 Dim CurFilterTracingPath as String
638 Dim CurFilterTracingname as String
639 Dim CurFilterFolder as String
640 CurFilterTracingPath = FilterTracingLogPath(ApplIndex)
641 If bTakeOverTargetName(ApplIndex) Then
642 TargetFilename = GetFileNameWithoutextension(sTargetUrl,
"/
")
643 CurFilterFolder = DirectoryNameoutofPath(FilterTracingLogPath(ApplIndex),
"/
")
644 CurFilterTracingpath = CurFilterFolder
& "/
" & TargetFilename
& ".log
"
646 If bTakeOverPathName(ApplIndex) Then
'Replace the Folder in the FilterTracerpath by the Folder of the targetUrl
647 sTargetFolder = DirectoryNameoutofPath(sTargetUrl,
"/
")
648 CurFilterTracingPath = sTargetFolder
& "/
" & FileNameoutofPath(CurFilterTracingPath,
"/
")
650 GetFilterTracingLogPath() = CurFilterTracingPath
654 Sub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String, ApplIndex as Integer)
657 Dim CurFilterTracingpath as String
658 If (bLogExists) And (sTargetUrl
<> "") Then
659 If sTargetUrl
<> "" Then
660 oCell = oLogTable.GetCellbyPosition(
1,oLogTable.Rows.Count-
1)
661 InsertCommentToLogCell(sComment, oCell)
662 InsertHyperLinkToLogCell(sTargetUrl, oCell)
663 If bFilterTracerIsinsideTable Then
664 oCell = oLogTable.getCellByPosition(
2, oLogTable.Rows.Count-
1)
665 oTextCursor = oCell.Text.CreateTextCursor()
666 CurFilterTracingpath = GetFilterTracingLogPath(sTargetUrl, ApplIndex)
667 InsertCommandButtonatViewCursor(oLogDocument, oTextCursor, CurFilterTracingPath)
675 Sub InsertSourceUrlToLogDocument(SourceUrl as String, sComment)
'
679 oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,
1)
683 oCell = oLogTable.GetCellbyPosition(
0,oLogTable.Rows.Count-
1)
684 InsertCommentToLogCell(sComment, oCell)
685 InsertHyperLinkToLogCell(SourceUrl, oCell)
691 Sub InsertHyperLinkToLogCell(sUrl as String, oCell as Object)
692 Dim oLogCursor as Object
693 Dim LocFileName as String
694 oLogCursor = oCell.createTextCursor()
695 oLogCursor.CollapseToStart()
696 oLogCursor.HyperLinkURL = sUrl
697 oLogCursor.HyperLinkName = sUrl
698 oLogCursor.HyperLinkTarget = sUrl
699 LocFileName = FileNameOutOfPath(sUrl)
700 oCell.InsertString(oLogCursor, LocFileName,False)
704 Sub InsertCommentToLogCell(sComment as string, oCell as Object)
705 Dim oCommentCursor as Object
706 If sComment
<> "" Then
707 oCommentCursor = oCell.createTextCursor()
708 oCell.insertControlCharacter(oCommentCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
709 oCell.insertString(oCommentCursor, sComment, false)
714 Sub AddLogStatistics()
716 Dim oLogCursor as Object
717 Dim MaxRowIndex as Integer
719 MaxRowIndex = oLogTable.Rows.Count
720 sLogSummary = ReplaceString(sLogSummary, FileCount,
"<COUNT
>")
721 ' oLogTable.Rows.InsertByIndex(MaxRowIndex,
1)
722 ' oCell = oLogTable.GetCellbyPosition(
0, MaxRowIndex)
723 ' oLogCursor = oCell.createTextCursor()
724 ' oCell.InsertString(oLogCursor, sLogSummary,False)
725 ' MergeRange(oLogTable, oCell,
1)
727 oLogCursor = oLogDocument.Text.CreateTextCursor
728 oLogCursor.gotoEnd(False)
729 oLogCursor.HyperLinkURL =
""
730 oLogCursor.HyperLinkName =
""
731 oLogCursor.HyperLinkTarget =
""
732 oLogCursor.SetString(sLogSummary)
734 oLogDocument.Dispose()
741 Function CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean
742 Dim ModuleNames() as String
743 Dim ModuleName as String
744 Dim MaxLibIndex as Integer
745 Dim MaxModuleIndex as Integer
746 Dim bMacroExists as Boolean
749 Dim LibName as String
750 Dim sBasicCode as String
751 Dim oLibrary as Object
753 bMacroExists = oBasicLibraries.hasElements
755 MaxLibIndex = Ubound(oBasicLibraries.ElementNames())
756 For n =
0 To MaxLibIndex
757 LibName = oBasicLibraries.ElementNames(n)
758 If oBasicLibraries.isLibraryLoaded(LibName) Then
759 oLibrary = oBasicLibraries.getbyName(LibName)
760 If oLibrary.hasElements() Then
761 MaxModuleIndex = Ubound(oLibrary.ElementNames())
762 For m =
0 To MaxModuleIndex
763 ModuleName = oLibrary.ElementNames(m)
764 sBasicCode = oLibrary.getbyName(ModuleName)
765 If sBasicCode
<> "" Then
766 ConcatComment(sComment, sReeditMacro)
767 CheckIfMacroExists() = True
775 CheckIfMacroExists() = False
780 Function CheckPassWordProtection(oDocument as Object)
781 Dim bIsPassWordProtected as Boolean
784 Dim MaxIndex as Integer
785 Dim sblabla as String
786 bIsPassWordProtected = false
787 oArgs() = oDocument.getArgs()
788 MaxIndex = Ubound(oArgs())
789 For i =
0 To MaxIndex
790 sblabla = oArgs(i).Name
791 If oArgs(i).Name =
"Password
" Then
792 bIsPassWordProtected = True
793 sCurPassWord = oArgs(i).Value
797 CheckPassWordProtection() = bIsPassWordProtected
801 Sub OpenLogDocument()
804 ImportDialogArea.endexecute()
809 Sub MergeRange(oTable as Object, oCell as Object, MergeCount as Integer)
810 Dim oTableCursor as Object
811 oTableCursor = oTable.createCursorByCellName(oCell.CellName)
812 oTableCursor.goRight(MergeCount, True)
813 oTableCursor.mergeRange()
817 Function ConcatComment(sComment as String, AdditionalComment as String)
818 If sComment =
"" Then
819 sComment = AdditionalComment
821 sComment = sComment
& chr(
13) + AdditionalComment
823 ConcatComment = sComment