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 Instr(LocExtension,
"vnd.sun.xml.
") =
1 Then
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 CheckIfToAddPathToCollection(i, SBTEMPLCONVERT, SBTEMPLSOURCE, SBTEMPLRECURSIVE, sFilterName(), MaxApplCount)
246 Sub ConvertAllDocuments(sFilterName() as String)
247 Dim FileProperties(
1) as new com.sun.star.beans.PropertyValue
248 Dim PWFileProperties(
2) as New com.sun.star.beans.PropertyValue
249 Dim WriterWebProperties(
0) as new com.sun.star.beans.PropertyValue
250 Dim OpenProperties(
4) as new com.sun.star.beans.PropertyValue
251 Dim oInteractionHandler as Object
252 Dim InteractionTypes(
0) as Long
253 Dim FilesList(
0,
2) as String
254 Dim sViewPath as String
256 Dim FilterIndex as Integer
257 Dim sSourceUrl as String
258 Dim CurFilename as String
259 Dim oDocument as Object
260 Dim sExtension as String
261 Dim OldExtension as String
262 Dim CurFound as Integer
263 Dim TotFound as Integer
264 Dim TargetStemDir as String
265 Dim SourceStemDir as String
266 Dim TargetDir as String
267 Dim sTargetUrl as String
268 Dim CurFilterName as String
269 Dim ApplIndex as Integer
271 Dim bIsDocument as Boolean
272 Dim bDoSave as Boolean
273 Dim sCurFileExists as String
274 Dim MaxFileIndex as Integer
275 Dim bContainsBasicMacro as Boolean
276 Dim bIsPassWordProtected as Boolean
277 Dim iOverwrite as Integer
278 Dim sMimeTypeorExtension as String
279 Dim sPrevMimeTypeorExtension as String
280 bConversionisrunning = True
281 InteractionTypes(
0) = com.sun.star.task.PasswordRequestMode.PASSWORD_REENTER
282 oInteractionHandler = createUnoService(
"com.sun.star.task.InteractionHandler
")
283 oInteractionHandler.initialize(InteractionTypes())
284 iGeneralOverwrite = SBOVERWRITEUNDEFINED
285 bConversionIsRunning = True
289 CollectPaths(sFiltername())
290 If Not ReadCollectionPaths(FilesList(), sFilterName()) Then
292 SetProgressDisplay(
0)
293 bConversionisrunning = false
294 FinalizeDialogButtons()
297 TotFound = Ubound(FilesList()) +
1
298 If FilesList(
0,
0) =
"" Then
' Querying the number of fields in a multidimensional Array is unsecure
299 TotFound =
0 ' because it will return the value
0 (and not -
1) even when the Array is empty
300 SetProgressDisplay(
0)
302 BubbleSortList(FilesList(), true)
303 If TotFound
> 0 Then
304 CreateLogDocument(OpenProperties())
305 InitializeProgressPage(ImportDialog)
306 OpenProperties(
0).Name =
"Hidden
"
307 OpenProperties(
0).Value = True
308 OpenProperties(
1).Name =
"AsTemplate
"
309 OpenProperties(
1).Value = False
310 OpenProperties(
2).Name =
"MacroExecutionMode
"
311 OpenProperties(
2).Value = com.sun.star.document.MacroExecMode.NEVER_EXECUTE
312 OpenProperties(
3).Name =
"UpdateDocMode
"
313 OpenProperties(
3).Value = com.sun.star.document.UpdateDocMode.NO_UPDATE
314 OpenProperties(
4).Name =
"InteractionHandler
"
315 OpenProperties(
4).Value = oInteractionHandler
316 MaxFileIndex = Ubound(FilesList(),
1)
318 For i =
0 To MaxFileIndex
319 sComment =
""
320 If InterruptProcess() Then
324 sSourceUrl = FilesList(i,
0)
325 sPrevMimeTypeorExtension = sMimeTypeorExtension
326 sMimeTypeorExtension = FilesList(i,
1)
327 CurFiltername = GetFilterName(sMimeTypeorExtension, sFilterName(), sExtension, FilterIndex)
328 ApplIndex = FilesList(i,
2)
329 If sMimeTypeorExtension
<> sPrevMimeTypeorExtension Then
330 CreateLogTable(ApplIndex, sMimeTypeOrExtension, sFiltername())
332 If ApplIndex
> Ubound(Applications) or (ApplIndex
< 0) Then
333 Msgbox
"Applicationindex out of bounds:
" & sSourcUrl
335 sViewPath = ConvertFromUrl(sSourceUrl)
' CutPathView(sSourceUrl,
70)
336 ImportDialog.LabelCurDocument.Label = Str(i+
1)
& "/
" & MaxFileIndex +
1 & " (
" & sViewPath
& ")
"
337 Select Case lcase(sExtension)
338 Case
"odt
",
"ods
",
"odp
",
"odg
",
"odm
",
"odf
"
339 SourceStemDir = RTrimStr(Applications(ApplIndex,SBDOCSOURCE),
"/
")
340 TargetStemDir = RTrimStr(Applications(ApplIndex,SBDOCTARGET),
"/
")
341 Case Else
' Templates and Helper-Applications remain
342 SourceStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLSOURCE),
"/
")
343 TargetStemDir = RTrimStr(Applications(ApplIndex,SBTEMPLTARGET),
"/
")
345 sTargetUrl = ReplaceString(sSourceUrl, TargetStemDir, SourceStemDir)
346 CurFilename = GetFileNameWithoutExtension(sTargetUrl,
"/
")
347 OldExtension = GetFileNameExtension(sTargetUrl)
348 sTargetUrl = RTrimStr(sTargetUrl, OldExtension)
349 sTargetUrl = sTargetUrl
& sExtension
350 TargetDir = RTrimStr(sTargetUrl, CurFilename
& ".
" & sExtension)
351 If (oUcb.Exists(sTargetUrl)) Then
352 If (iGeneralOverwrite
<> SBOVERWRITEALWAYS) Then
353 If (iGeneralOverwrite = SBOVERWRITEUNDEFINED) Then
354 ShowOverwriteAllDialog(sTargetUrl, sTitle)
355 bDoSave = (iGeneralOverwrite = SBOVERWRITEQUERY) Or (iGeneralOverwrite = SBOVERWRITEALWAYS)
356 Elseif iGeneralOverwrite = SBOVERWRITENEVER Then
358 ElseIf ((iGeneralOverWrite = SBOVERWRITEQUERY) OR (iGeneralOverwrite = SBOVERWRITECANCEL)) Then
359 ' Todo: According to AS there might come a new feature that storeasUrl could possibly rise a UI dialog.
360 ' In this case my own UI becomes obsolete
361 sCurFileExists = ReplaceString(sFileExists, ConvertFromUrl(sTargetUrl),
"<1>")
362 sCurFileExists = ReplaceString(sCurFileExists, chr(
13),
"<CR
>")
363 iOverWrite = Msgbox (sCurFileExists,
32 +
3, sTitle)
364 Select Case iOverWrite
366 ' In the FileProperty-Bean this is already default
378 If Not oUcb.Exists(TargetDir) Then
379 bDoSave = CreateFolder(TargetDir)
382 oDocument = StarDesktop.LoadComponentFromURL(sSourceUrl,
"_default
",
0, OpenProperties())
383 If Not IsNull(oDocument) Then
384 InsertSourceUrlToLogDocument(sSourceUrl,
"")
385 bIsPassWordProtected = CheckPassWordProtection(oDocument)
386 CheckIfMacroExists(oDocument.BasicLibraries, sComment)
387 On Local Error Goto NOSAVING
388 If bIsPassWordProtected Then
389 PWFileProperties(
0).Name =
"FilterName
"
390 PWFileProperties(
0).Value = CurFilterName
391 PWFileProperties(
1).Name =
"Overwrite
"
392 PWFileProperties(
1).Value = True
393 PWFileProperties(
2).Name =
"Password
"
394 PWFileProperties(
2).Value = sCurPassWord
395 oDocument.StoreAsUrl(sTargetUrl, PWFileProperties())
397 FileProperties(
0).Name =
"FilterName
"
398 FileProperties(
0).Value = CurFilterName
399 FileProperties(
1).Name =
"Overwrite
"
400 FileProperties(
1).Value = True
401 oDocument.StoreAsUrl(sTargetUrl,FileProperties())
403 ' Todo: Make sure that an errorbox pops up when saving fails
405 If Err
<> 0 Then
406 sCurcouldnotsaveDocument = ReplaceString(scouldnotsaveDocument, ConvertFromUrl(sTargetUrl),
"<1>")
407 sComment = ConcatComment(sComment, sCurCouldnotsaveDocument)
411 FileCount = FileCount +
1
414 InsertTargetUrlToLogDocument(sTargetUrl, sComment)
416 sCurcouldnotopenDocument = ReplaceString(scouldnotopenDocument, ConvertFromUrl(sSourceUrl),
"<1>")
417 sComment = ConcatComment(sComment, sCurCouldnotopenDocument)
418 InsertSourceUrlToLogDocument(sSourceUrl, sComment)
425 FinalizeDialogButtons()
426 bConversionIsRunning = False
429 Msgbox sRTErrorDesc,
16, sRTErrorHeader
434 Sub AddListtoFilesList(FirstList(), SecList(), NewContentList() as String)
435 Dim sLocExtension as String
436 Dim FirstStart as Integer
437 Dim FirstEnd as Integer
440 If FirstList(
0,
0) =
"" Then
441 FirstStart = Ubound(FirstList(),
1)
443 FirstStart = Ubound(FirstList(),
1) +
1
445 FirstEnd = FirstStart + Ubound(SecList(),
1)
446 ReDim Preserve FirstList(FirstEnd,
2)
448 For i = FirstStart To FirstEnd
449 FirstList(i,
0) = SecList(s,
0)
450 FirstList(i,
1) = SecList(s,
1)
451 sLocExtension = lcase(FirstList(i,
1))
452 Select Case sLocExtension
453 Case
"sdw
",
"sdc
",
"sda
",
"sdd
",
"smf
",
"sgl
",
"doc
",
"docx
",
"docm
",
"xls
",
"xlsx
",
"xlsm
",
"ppt
",
"pps
",
"pptx
",
"pptm
",
"ppsx
",
"ppsm
",
"pub
",
"sxi
",
"sxw
",
"sxd
",
"sxg
",
"sxm
",
"sxc
"
454 AbsDocuFound = AbsDocuFound +
1
456 AbsTemplateFound = AbsTemplateFound +
1
458 FirstList(i,
2) = CStr(NewContentList(s))
461 SetProgressDisplay(Ubound(FirstList()) +
1)
466 Function GetTargetTemplatePath(Index as Integer)
467 Select Case WizardMode
469 GetTargetTemplatePath() = SOTemplatePath
& "/
" & sTemplateGroupName
474 ' Retrieves the second value for a next to
'SearchString
' in
475 ' a two-dimensional string-Array
476 Function GetFilterName(sMimetypeorExtension as String, sFilterName(), sExtension as string, FilterIndex as Integer) as String
478 Dim MaxIndex as Integer
479 Dim sLocFilterlist() as String
480 For i =
0 To Ubound(sFiltername(),
1)
481 If Instr(
1,sFilterName(i,
0),sMimeTypeOrExtension)
<> 0 Then
482 sLocFilterList() = ArrayoutofString(sFiltername(i,
0),
"|
", MaxIndex)
484 sExtension = sFiltername(i,
2)
485 GetFilterName = sFilterName(i,
1)
488 Dim sLocExtensionList() as String
489 b = SearchArrayForPartString(sMimetypeOrExtension, sLocFilterList())
490 sLocFilterList() = ArrayoutofString(sFiltername(i,
1),
"|
", MaxIndex)
491 GetFilterName = sLocFilterList(b)
492 sLocExtensionList() = ArrayoutofString(sFilterName(i,
2),
"|
", MaxIndex)
493 sExtension = sLocExtensionList(b)
502 Function SearchArrayforPartString(SearchString as String, LocList()) as Integer
505 Dim StringList() as String
506 For i = Lbound(LocList(),
1) to Ubound(LocList(),
1)
507 StringList() = ArrayoutofString(LocList(i),
"|
")
508 For a =
0 To Ubound(StringList())
509 If (Instr(
1, SearchString, StringList(a))
<> 0) Then
510 SearchArrayForPartString() = i
515 SearchArrayForPartString() = -
1
519 Sub CreateLogTable(ApplIndex as Integer, CurFileContent as String, sFilterName() as String)
520 Dim oLogCursor as Object
521 Dim oLogRows as Object
522 Dim FilterIndex as Integer
523 Dim sDocumentType as String
526 If Not bLogExists Then
529 FilterIndex = GetIndexForPartStringinMultiArray(sFilterName(), CurFileContent,
0)
530 sDocumentType = sFiltername(FilterIndex,
3)
531 oLogCursor = oLogDocument.Text.createTextCursor()
532 oLogCursor.GotoEnd(False)
533 If Not bIsFirstLogTable Then
534 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
536 bisFirstLogTable = False
538 oLogCursor.HyperLinkURL =
""
539 oLogCursor.HyperLinkName =
""
540 oLogCursor.HyperLinkTarget =
""
541 oLogCursor.ParaStyleName =
"Heading
1"
542 oLogCursor.setString(sDocumentType)
543 oLogCursor.CollapsetoEnd()
544 oLogDocument.Text.insertControlCharacter(oLogCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
545 oLogTable = oLogDocument.CreateInstance(
"com.sun.star.text.TextTable
")
546 oLogTable.RepeatHeadline = true
547 oLogCursor.Text.InsertTextContent(oLogCursor, oLogTable, True)
548 oTextCursor = oLogTable.GetCellbyPosition(
0,
0).createTextCursor()
549 oTextCursor.SetString(sSourceDocuments)
550 oTextCursor = oLogTable.GetCellbyPosition(
1,
0).createTextCursor()
551 oTextCursor.SetString(sTargetDocuments)
556 Function GetSize(iWidth, iHeight) As New com.sun.star.awt.Size
557 Dim aSize As New com.sun.star.awt.Size
559 aSize.Height = iHeight
564 Sub InsertCommandButtonatViewCursor(oLocDocument, oLocCursor, TargetUrl as String, Optional aSize)
573 oCommandButton = oLocDocument.createInstance(
"com.sun.star.form.component.CommandButton
")
574 oShape = oLocDocument.CreateInstance (
"com.sun.star.drawing.ControlShape
")
575 If IsMissing(aSize) Then
576 oShape.Size = GetSize(
4000,
600)
578 oCommandButton.Label = FileNameoutofPath(Targeturl)
579 oCommandButton.TargetFrame =
"_default
"
580 oCommandButton.ButtonType = com.sun.star.form.FormButtonType.URL
581 oCommandbutton.DispatchUrlInternal = True
582 oCommandButton.TargetURL = ConverttoUrl(TargetUrl)
583 oShape.Control = oCommandbutton
584 oLocCursor.Text.InsertTextContent(oLocCursor, oShape, True)
589 Sub CreateLogDocument(HiddenProperties())
590 Dim OpenProperties(
0) as new com.sun.star.beans.PropertyValue
593 Dim bLogIsThere as Boolean
594 If ImportDialog.chkLogfile.State =
1 Then
596 OpenProperties(
0).Name =
"Hidden
"
597 OpenProperties(
0).Value = True
598 oLogDocument = StarDesktop.LoadComponentFromURL(
"private:factory/swriter
",
"_default
",
4, OpenProperties())
599 SOWorkPath = RTrimStr(SOWorkPath,
"/
")
600 sLogUrl = SOWorkPath
& "/Logfile.odt
"
602 bLogIsThere = oUcb.Exists(sLogUrl)
605 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_2.odt
",
"/Logfile.odt
")
607 sLogUrl = ReplaceString(sLogUrl,
"/Logfile_
" & cStr(i)
& ".odt
",
"/Logfile_
" & cStr(i-
1)
& ".odt
")
611 Loop Until Not bLogIsThere
613 oLogDocument.StoreAsUrl(sLogUrl, NoArgs())
618 Sub InsertTargetUrlToLogDocument(sTargetUrl as String, sComment as String)
621 Dim CurFilterTracingpath as String
622 If (bLogExists) And (sTargetUrl
<> "") Then
623 If sTargetUrl
<> "" Then
624 oCell = oLogTable.GetCellbyPosition(
1,oLogTable.Rows.Count-
1)
625 InsertCommentToLogCell(sComment, oCell)
626 InsertHyperLinkToLogCell(sTargetUrl, oCell)
633 Sub InsertSourceUrlToLogDocument(SourceUrl as String, sComment)
'
637 oLogTable.Rows.InsertByIndex(oLogTable.Rows.Count,
1)
641 oCell = oLogTable.GetCellbyPosition(
0,oLogTable.Rows.Count-
1)
642 InsertCommentToLogCell(sComment, oCell)
643 InsertHyperLinkToLogCell(SourceUrl, oCell)
649 Sub InsertHyperLinkToLogCell(sUrl as String, oCell as Object)
650 Dim oLogCursor as Object
651 Dim LocFileName as String
652 oLogCursor = oCell.createTextCursor()
653 oLogCursor.CollapseToStart()
654 oLogCursor.HyperLinkURL = sUrl
655 oLogCursor.HyperLinkName = sUrl
656 oLogCursor.HyperLinkTarget = sUrl
657 LocFileName = FileNameOutOfPath(sUrl)
658 oCell.InsertString(oLogCursor, LocFileName,False)
662 Sub InsertCommentToLogCell(sComment as string, oCell as Object)
663 Dim oCommentCursor as Object
664 If sComment
<> "" Then
665 oCommentCursor = oCell.createTextCursor()
666 oCell.insertControlCharacter(oCommentCursor, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
667 oCell.insertString(oCommentCursor, sComment, false)
672 Sub AddLogStatistics()
674 Dim oLogCursor as Object
675 Dim MaxRowIndex as Integer
677 MaxRowIndex = oLogTable.Rows.Count
678 sLogSummary = ReplaceString(sLogSummary, FileCount,
"<COUNT
>")
679 ' oLogTable.Rows.InsertByIndex(MaxRowIndex,
1)
680 ' oCell = oLogTable.GetCellbyPosition(
0, MaxRowIndex)
681 ' oLogCursor = oCell.createTextCursor()
682 ' oCell.InsertString(oLogCursor, sLogSummary,False)
683 ' MergeRange(oLogTable, oCell,
1)
685 oLogCursor = oLogDocument.Text.CreateTextCursor
686 oLogCursor.gotoEnd(False)
687 oLogCursor.HyperLinkURL =
""
688 oLogCursor.HyperLinkName =
""
689 oLogCursor.HyperLinkTarget =
""
690 oLogCursor.SetString(sLogSummary)
692 oLogDocument.Dispose()
699 Function CheckIfMacroExists(oBasicLibraries as Object, sComment as String) as Boolean
700 Dim ModuleNames() as String
701 Dim ModuleName as String
702 Dim MaxLibIndex as Integer
703 Dim MaxModuleIndex as Integer
704 Dim bMacroExists as Boolean
707 Dim LibName as String
708 Dim sBasicCode as String
709 Dim oLibrary as Object
711 bMacroExists = oBasicLibraries.hasElements
713 MaxLibIndex = Ubound(oBasicLibraries.ElementNames())
714 For n =
0 To MaxLibIndex
715 LibName = oBasicLibraries.ElementNames(n)
716 If oBasicLibraries.isLibraryLoaded(LibName) Then
717 oLibrary = oBasicLibraries.getbyName(LibName)
718 If oLibrary.hasElements() Then
719 MaxModuleIndex = Ubound(oLibrary.ElementNames())
720 For m =
0 To MaxModuleIndex
721 ModuleName = oLibrary.ElementNames(m)
722 sBasicCode = oLibrary.getbyName(ModuleName)
723 If sBasicCode
<> "" Then
724 ConcatComment(sComment, sReeditMacro)
725 CheckIfMacroExists() = True
733 CheckIfMacroExists() = False
738 Function CheckPassWordProtection(oDocument as Object)
739 Dim bIsPassWordProtected as Boolean
742 Dim MaxIndex as Integer
743 Dim sblabla as String
744 bIsPassWordProtected = false
745 oArgs() = oDocument.getArgs()
746 MaxIndex = Ubound(oArgs())
747 For i =
0 To MaxIndex
748 sblabla = oArgs(i).Name
749 If oArgs(i).Name =
"Password
" Then
750 bIsPassWordProtected = True
751 sCurPassWord = oArgs(i).Value
755 CheckPassWordProtection() = bIsPassWordProtected
759 Sub OpenLogDocument()
762 ImportDialogArea.endexecute()
767 Sub MergeRange(oTable as Object, oCell as Object, MergeCount as Integer)
768 Dim oTableCursor as Object
769 oTableCursor = oTable.createCursorByCellName(oCell.CellName)
770 oTableCursor.goRight(MergeCount, True)
771 oTableCursor.mergeRange()
775 Function ConcatComment(sComment as String, AdditionalComment as String)
776 If sComment =
"" Then
777 sComment = AdditionalComment
779 sComment = sComment
& chr(
13) + AdditionalComment
781 ConcatComment = sComment