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