1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*3e02b54dSAndrew Rist<!--***********************************************************
4*3e02b54dSAndrew Rist *
5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
6*3e02b54dSAndrew Rist * or more contributor license agreements.  See the NOTICE file
7*3e02b54dSAndrew Rist * distributed with this work for additional information
8*3e02b54dSAndrew Rist * regarding copyright ownership.  The ASF licenses this file
9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the
10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance
11*3e02b54dSAndrew Rist * with the License.  You may obtain a copy of the License at
12*3e02b54dSAndrew Rist *
13*3e02b54dSAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
14*3e02b54dSAndrew Rist *
15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing,
16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an
17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18*3e02b54dSAndrew Rist * KIND, either express or implied.  See the License for the
19*3e02b54dSAndrew Rist * specific language governing permissions and limitations
20*3e02b54dSAndrew Rist * under the License.
21*3e02b54dSAndrew Rist *
22*3e02b54dSAndrew Rist ***********************************************************-->
23cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="HtmlAutoPilotBasic" script:language="StarBasic">&apos; Variables must be declared
24cdf0e10cSrcweirOption Explicit
25cdf0e10cSrcweir
26cdf0e10cSrcweirPublic CurDocIndex as Integer
27cdf0e10cSrcweirPublic CurWebPageIndex as Integer
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweirPublic bWithBackGraphic as Boolean
31cdf0e10cSrcweirPublic oStyle as Object
32cdf0e10cSrcweir&apos; Maximum number of content templates, style templates and bullets
33cdf0e10cSrcweirConst MaxLayouts = 50
34cdf0e10cSrcweirConst MaxStyles = 100
35cdf0e10cSrcweirConst MaxBullets = 10
36cdf0e10cSrcweir
37cdf0e10cSrcweir&apos;Public NumberOfLayouts%, NumberOfStyles%
38cdf0e10cSrcweir
39cdf0e10cSrcweir&apos; Filled with title, previous, next, home, top, bullet, background, file name
40cdf0e10cSrcweirPublic Style(MaxStyles, 8) as String
41cdf0e10cSrcweir
42cdf0e10cSrcweirPublic Layout$(MaxLayouts, 2)
43cdf0e10cSrcweir
44cdf0e10cSrcweirPublic TextureDir$, BulletDir$, GraphicsDir$, GalleryDir$, PhotosDir$
45cdf0e10cSrcweirPublic SOBitmapPath as String
46cdf0e10cSrcweirPublic CurrentBullet$, CurrentPrev$, CurrentNext$, CurrentHome$, CurrentTop$
47cdf0e10cSrcweirPublic FileStr as String
48cdf0e10cSrcweir
49cdf0e10cSrcweirPublic WebWiz_gWizardName$, WebWiz_gErrContentNotFound$, WebWiz_gErrStyleNotFound$
50cdf0e10cSrcweirPublic WebWiz_gErrMainTemplateError$, WebWiz_gErrWhileReloading$
51cdf0e10cSrcweirPublic WebWiz_gErrWhileLoadStyles$, WebWiz_gErrMsg$, WebWiz_gErrMainDocumentError$
52cdf0e10cSrcweir
53cdf0e10cSrcweirPublic ProgressBar as Object
54cdf0e10cSrcweirPublic ProgressValue As Long
55cdf0e10cSrcweirPublic oBaseDocument as Object
56cdf0e10cSrcweirPublic oViewCursor as Object
57cdf0e10cSrcweirPublic oViewSettings as Object
58cdf0e10cSrcweirPublic NoArgs() as New com.sun.star.beans.PropertyValue
59cdf0e10cSrcweir
60cdf0e10cSrcweirPublic oCursor as Object
61cdf0e10cSrcweirPublic oBookmarks as Object
62cdf0e10cSrcweirPublic oBookMark as Object
63cdf0e10cSrcweir
64cdf0e10cSrcweirPublic oUcb as Object
65cdf0e10cSrcweirPublic MainDialog as Object
66cdf0e10cSrcweirPublic DialogModel as Object
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweirSub Main
70cdf0e10cSrcweirDim RetValue
71cdf0e10cSrcweirOn Local Error Goto GlobalErrorHandler
72cdf0e10cSrcweir	BasicLibraries.LoadLibrary(&quot;Tools&quot;)
73cdf0e10cSrcweir	oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
74cdf0e10cSrcweir	oBaseDocument = StarDesktop.LoadComponentFromURL(&quot;private:factory/swriter/web&quot;, &quot;_default&quot;, 0, NoArgs())
75cdf0e10cSrcweir	oViewSettings = oBaseDocument.CurrentController.ViewSettings
76cdf0e10cSrcweir	oViewCursor = oBaseDocument.GetCurrentController.ViewCursor
77cdf0e10cSrcweir	CurWebPageIndex = -1
78cdf0e10cSrcweir	ProgressBar = oBaseDocument.GetCurrentController.GetFrame.CreateStatusIndicator
79cdf0e10cSrcweir	ProgressBar.Start(&quot;&quot;, 100)
80cdf0e10cSrcweir	SetProgressValue(2)
81cdf0e10cSrcweir	oBaseDocument.LockControllers
82cdf0e10cSrcweir	oViewSettings.ShowTableBoundaries = False
83cdf0e10cSrcweir	If Not GetWebWizardPaths() Then
84cdf0e10cSrcweir		Exit Sub
85cdf0e10cSrcweir	End If
86cdf0e10cSrcweir	LoadLanguage
87cdf0e10cSrcweir	SetProgressValue(10)
88cdf0e10cSrcweir	Layout() = getListBoxArrays(oUcb, &quot;/cnt&quot;)
89cdf0e10cSrcweir	GetCurIndex(DialogModel, Layout(),2)
90cdf0e10cSrcweir	SetProgressValue(30)
91cdf0e10cSrcweir	oCursor = oBasedocument.Text.CreateTextCursor
92cdf0e10cSrcweir	oCursor.InsertDocumentfromURL(FileStr, NoArgs())
93cdf0e10cSrcweir	SetProgressValue(50)
94cdf0e10cSrcweir	Style() = getListBoxArrays(oUcb, &quot;/stl&quot;)
95cdf0e10cSrcweir	SetProgressValue(70)
96cdf0e10cSrcweir	LoadWebPageStyles(oBaseDocument)
97cdf0e10cSrcweir	SetProgressValue(90)
98cdf0e10cSrcweir	oBaseDocument.UnlockControllers
99cdf0e10cSrcweir	OpenWebDialog()
100cdf0e10cSrcweir	SetProgressValue(98)
101cdf0e10cSrcweir	SetProgressValue(0)
102cdf0e10cSrcweir	MainDialog.Model.ImagePreview.BackGroundColor = RGB(0, 60,126)
103cdf0e10cSrcweir	RetValue = MainDialog.Execute
104cdf0e10cSrcweir	Select Case RetValue
105cdf0e10cSrcweir		Case 0
106cdf0e10cSrcweir			MainDialog.Dispose()
107cdf0e10cSrcweir			DisposeDocument(oBaseDocument)
108cdf0e10cSrcweir		Case 1
109cdf0e10cSrcweir			EndDialog()
110cdf0e10cSrcweir			MainDialog.Dispose()
111cdf0e10cSrcweir	End Select
112cdf0e10cSrcweirGLOBALERRORHANDLER:
113cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
114cdf0e10cSrcweir		MsgBox (WebWiz_gErrMsg$, 16, WebWiz_gWizardName$)
115cdf0e10cSrcweir		DisposeDocument(oBaseDocument)
116cdf0e10cSrcweir		RESUME EXITWIZARD
117cdf0e10cSrcweirEXITWIZARD:
118cdf0e10cSrcweir	End If
119cdf0e10cSrcweirEnd Sub
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweirFunction SetProgressValue(iValue as Integer)
123cdf0e10cSrcweir	If iValue = 0 Then
124cdf0e10cSrcweir		ProgressBar.End
125cdf0e10cSrcweir	End If
126cdf0e10cSrcweir	ProgressValue = iValue
127cdf0e10cSrcweir	ProgressBar.Value = iValue
128cdf0e10cSrcweirEnd Function
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweirSub ReloadCurrentDocument()
132cdf0e10cSrcweirDim OldDocIndex as Integer
133cdf0e10cSrcweirOn Local Error Goto ErrorOcurred
134cdf0e10cSrcweir	OldDocIndex = CurDocIndex
135cdf0e10cSrcweir	CurDocIndex = GetCurIndex(DialogModel.lbTemplate, Layout(), 2)
136cdf0e10cSrcweir	If OldDocIndex &lt;&gt; CurDocIndex Then
137cdf0e10cSrcweir		oBaseDocument.LockControllers
138cdf0e10cSrcweir		ToggleDialogControls(False)
139cdf0e10cSrcweir		oCursor = oBaseDocument.Text.CreateTextCursor()
140cdf0e10cSrcweir		oCursor.GotoStart(False)
141cdf0e10cSrcweir		oCursor.GotoEnd(True)
142cdf0e10cSrcweir		oCursor.SetAllPropertiesToDefault()
143cdf0e10cSrcweir		oCursor.InsertDocumentfromURL(FileStr, NoArgs())
144cdf0e10cSrcweir		SetBulletAndGraphics
145cdf0e10cSrcweir		CheckControls(oBaseDocument.DrawPage)
146cdf0e10cSrcweir	ErrorOcurred:
147cdf0e10cSrcweir		If Err &lt;&gt; 0 Then
148cdf0e10cSrcweir			MsgBox(WebWiz_gErrWhileReloading$, 16, WebWiz_gWizardName$)
149cdf0e10cSrcweir		End If
150cdf0e10cSrcweir		oBaseDocument.UnlockControllers
151cdf0e10cSrcweir		oViewCursor.GotoStart(False)
152cdf0e10cSrcweir		ToggleDialogControls(True, &quot;lbTemplate&quot;)
153cdf0e10cSrcweir	End If
154cdf0e10cSrcweirEnd Sub
155cdf0e10cSrcweir
156cdf0e10cSrcweir
157cdf0e10cSrcweir
158cdf0e10cSrcweir
159cdf0e10cSrcweirSub LoadWebPageStyles(aEvent as Object, Optional bStartUp as Boolean)
160cdf0e10cSrcweirDim OldWebPageIndex as Integer
161cdf0e10cSrcweir	OldWebPageIndex = CurWebPageIndex
162cdf0e10cSrcweir	If IsNull(DialogModel) Then
163cdf0e10cSrcweir		CurWebPageIndex = GetCurIndex(DialogModel, Style(), 8)
164cdf0e10cSrcweir	Else
165cdf0e10cSrcweir		CurWebPageIndex = GetCurIndex(DialogModel.lbStyles, Style(), 8)
166cdf0e10cSrcweir	End If
167cdf0e10cSrcweir	If OldWebPageIndex &lt;&gt; CurWebPageIndex Then
168cdf0e10cSrcweir		ToggleDialogControls(False)
169cdf0e10cSrcweir		oBaseDocument.LockControllers
170cdf0e10cSrcweir		bWithBackGraphic = LoadNewStyles(oBaseDocument, DialogModel, CurWebPageIndex, FileStr, Style(), TextureDir)
171cdf0e10cSrcweir		CurrentBullet$ = BulletDir + Style(CurWebPageIndex, 6)
172cdf0e10cSrcweir		CurrentPrev$ = GraphicsDir + Style(CurWebPageIndex, 2)
173cdf0e10cSrcweir		CurrentNext$ = GraphicsDir + Style(CurWebPageIndex, 3)
174cdf0e10cSrcweir		CurrentHome$ = GraphicsDir + Style(CurWebPageIndex, 4)
175cdf0e10cSrcweir		CurrentTop$ = GraphicsDir + Style(CurWebPageIndex, 5)
176cdf0e10cSrcweir		With oBaseDocument.DocumentProperties.UserDefinedProperties
177cdf0e10cSrcweir            .AutoPilotName1 = ExtractGraphicNames(CurWebPageIndex,2)
178cdf0e10cSrcweir            .AutoPilotName2 = ExtractGraphicNames(CurWebPageIndex, 4)
179cdf0e10cSrcweir            .AutoPilotBullet = Style(CurWebPageIndex, 6)
180cdf0e10cSrcweir            .AutoPilotBackground =  Style(CurWebPageIndex, 7)
181cdf0e10cSrcweir		End With
182cdf0e10cSrcweir		SetBulletAndGraphics()
183cdf0e10cSrcweir		CheckControls(oBaseDocument.DrawPage)
184cdf0e10cSrcweir		oViewCursor.GotoStart(False)
185cdf0e10cSrcweir		oBaseDocument.UnlockControllers
186cdf0e10cSrcweir		ToggleDialogControls(True, &quot;lbStyles&quot;)
187cdf0e10cSrcweir	End If
188cdf0e10cSrcweirEnd Sub
189cdf0e10cSrcweir
190cdf0e10cSrcweir
191cdf0e10cSrcweirFunction ExtractGraphicNames(CurIndex as Integer, i as Integer) as String
192cdf0e10cSrcweirDim FieldValue as String
193cdf0e10cSrcweir	FieldValue = GetFileNameWithoutExtension(Style(CurIndex, i))
194cdf0e10cSrcweir	FieldValue = FieldValue &amp; &quot; &quot; &amp;	GetFileNameWithoutExtension(Style(CurIndex, i+1))
195cdf0e10cSrcweir	ExtractGraphicNames = FieldValue
196cdf0e10cSrcweirEnd Function
197cdf0e10cSrcweir
198cdf0e10cSrcweir
199cdf0e10cSrcweirSub SetBulletAndGraphics
200cdf0e10cSrcweir	SetGraphic(&quot;Prev&quot;, CurrentPrev)
201cdf0e10cSrcweir	SetGraphic(&quot;Next&quot;, CurrentNext)
202cdf0e10cSrcweir	SetGraphic(&quot;Home&quot;, CurrentHome)
203cdf0e10cSrcweir	SetGraphic(&quot;Top&quot;, CurrentTop)
204cdf0e10cSrcweir	SetBulletGraphics(CurrentBullet)
205cdf0e10cSrcweir	SetGraphicsToOriginalSize()
206cdf0e10cSrcweirEnd Sub
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweirSub SetGraphicsToOriginalSize()
210cdf0e10cSrcweirDim oGraphics as Object
211cdf0e10cSrcweirDim oGraphic as Object
212cdf0e10cSrcweirDim i as Integer
213cdf0e10cSrcweirDim aActSize as New com.sun.star.awt.Size
214cdf0e10cSrcweir	oGraphics = oBaseDocument.GraphicObjects
215cdf0e10cSrcweir	For i = 0 To oGraphics.Count-1
216cdf0e10cSrcweir		oGraphic = oGraphics.GetByIndex(i)
217cdf0e10cSrcweir		aActSize = oGraphic.ActualSize
218cdf0e10cSrcweir		If aActSize.Height &gt; 0 And aActSize.Width &gt; 0 Then
219cdf0e10cSrcweir			oGraphic.SetSize(aActSize)
220cdf0e10cSrcweir		End If
221cdf0e10cSrcweir	Next i
222cdf0e10cSrcweirEnd Sub
223cdf0e10cSrcweir
224cdf0e10cSrcweir
225cdf0e10cSrcweirSub EndDialog()
226cdf0e10cSrcweir	If DialogModel.chkSaveasTemplate.State = 1 Then
227cdf0e10cSrcweir		&apos; Generating template? Set events later!
228cdf0e10cSrcweir		AttachBasicMacroToEvent(oBaseDocument,&quot;OnNew&quot;, &quot;WebWizard.HtmlAutoPilotBasic.SetEvent()&quot;)
229cdf0e10cSrcweir		&apos; Call the Store template dialog
230cdf0e10cSrcweir		DispatchSlot(5538)
231cdf0e10cSrcweir		AttachBasicMacroToEvent(oBaseDocument,&quot;OnNew&quot;, &quot;&quot;)
232cdf0e10cSrcweir	End If
233cdf0e10cSrcweir	SetEvent()
234cdf0e10cSrcweirEnd Sub
235cdf0e10cSrcweir
236cdf0e10cSrcweir
237cdf0e10cSrcweirSub SetEvent()
238cdf0e10cSrcweirDim oDocument as Object
239cdf0e10cSrcweir&apos; This sub links the events OnSaveDone and OnSaveAsDone to the procedure
240cdf0e10cSrcweir&apos; CopyGraphics. It is invoked when a document is created, either directly
241cdf0e10cSrcweir&apos; from the AutoPilot or from a template. It is not possible to set these
242cdf0e10cSrcweir&apos; links for the template created by the AutoPilot because then it is not
243cdf0e10cSrcweir&apos; possible to modify the template.
244cdf0e10cSrcweir	BasicLibraries.LoadLibrary(&quot;Tools&quot;)
245cdf0e10cSrcweir	oDocument = ThisComponent
246cdf0e10cSrcweir	AttachBasicMacroToEvent(oDocument,&quot;OnSaveDone&quot;, &quot;WebWizard.HtmlAutoPilotBasic.CopyGraphics()&quot;)
247cdf0e10cSrcweir	AttachBasicMacroToEvent(oDocument,&quot;OnSaveAsDone&quot;, &quot;WebWizard.HtmlAutoPilotBasic.CopyGraphics()&quot;)
248cdf0e10cSrcweirEnd Sub
249cdf0e10cSrcweir
250cdf0e10cSrcweir
251cdf0e10cSrcweir
252cdf0e10cSrcweirSub CopyGraphics
253cdf0e10cSrcweir&apos; This sub copies all the graphics used in the document to the same directory the
254cdf0e10cSrcweir&apos; document has been copied into and changes the graphics links in the document.
255cdf0e10cSrcweirDim oGraphicObjects as Object
256cdf0e10cSrcweirDim oGraphic as Object
257cdf0e10cSrcweirDim i as Integer
258cdf0e10cSrcweirDim udProps as Object
259cdf0e10cSrcweirDim SavePath as String
260cdf0e10cSrcweir    BasicLibraries.LoadLibrary(&quot;Tools&quot;)
261cdf0e10cSrcweir	oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
262cdf0e10cSrcweir	GetWebWizardPaths()
263cdf0e10cSrcweir	oBaseDocument = ThisComponent
264cdf0e10cSrcweir&apos;	oBaseDocument.LockControllers()
265cdf0e10cSrcweir
266cdf0e10cSrcweir	&apos; Note: The sub DirectoryNameoutofPath should be change, so that the last character is a slash
267cdf0e10cSrcweir	SavePath = DirectoryNameoutofPath(oBaseDocument.Url, &quot;/&quot;) &amp; &quot;/&quot;
268cdf0e10cSrcweir
269cdf0e10cSrcweir	oGraphicObjects = oBaseDocument.GraphicObjects
270cdf0e10cSrcweir	For i = 0 to oGraphicObjects.Count-1
271cdf0e10cSrcweir		oGraphic = oGraphicObjects.GetbyIndex(i)
272cdf0e10cSrcweir		oGraphic.GraphicUrl = CopyFile(oGraphic.GraphicURL, SavePath)
273cdf0e10cSrcweir	Next i
274cdf0e10cSrcweir
275cdf0e10cSrcweir	ChangeBackGraphicUrl(SavePath)
276cdf0e10cSrcweir
277cdf0e10cSrcweir	BulletUrlsToSavePath(SavePath)
278cdf0e10cSrcweir
279cdf0e10cSrcweir    udProps = oBaseDocument.DocumentProperties.UserDefinedProperties
280cdf0e10cSrcweir    udProps.addProperty(&quot;AutoPilotName1&quot;, 0, &quot;&quot;)
281cdf0e10cSrcweir    udProps.addProperty(&quot;AutoPilotName2&quot;, 0, &quot;&quot;)
282cdf0e10cSrcweir    udProps.addProperty(&quot;AutoPilotBullet&quot;, 0, &quot;&quot;)
283cdf0e10cSrcweir    udProps.addProperty(&quot;AutoPilotBackground&quot;, 0, &quot;&quot;)
284cdf0e10cSrcweir
285cdf0e10cSrcweir	AttachBasicMacroToEvent(oBaseDocument,&quot;OnSaveDone&quot;, &quot;&quot;)
286cdf0e10cSrcweir	AttachBasicMacroToEvent(oBaseDocument,&quot;OnSaveAsDone&quot;, &quot;&quot;)
287cdf0e10cSrcweir	AttachBasicMacroToEvent(oBaseDocument,&quot;OnNew&quot;, &quot;&quot;)
288cdf0e10cSrcweir	oBaseDocument.Store
289cdf0e10cSrcweir&apos;	oBaseDocument.UnlockControllers()
290cdf0e10cSrcweirEnd Sub
291cdf0e10cSrcweir
292cdf0e10cSrcweir
293cdf0e10cSrcweirFunction CopyFile(ByVal SourceUrl as String, TargetDir as String)
294cdf0e10cSrcweirDim sFileName as String
295cdf0e10cSrcweirDim sNewFileUrl as String
296cdf0e10cSrcweir	If oUcb.Exists(TargetDir) Then
297cdf0e10cSrcweir		If Len(TargetDir) &gt; 2 Then
298cdf0e10cSrcweir			sFileName = FileNameoutofPath(SourceUrl)
299cdf0e10cSrcweir			sNewFileUrl = TargetDir &amp; sFileName
300cdf0e10cSrcweir			oUcb.Copy(SourceUrl, sNewFileUrl)
301cdf0e10cSrcweir			CopyFile() = sNewFileUrl
302cdf0e10cSrcweir		End If
303cdf0e10cSrcweir	End If
304cdf0e10cSrcweirEnd Function
305cdf0e10cSrcweir
306cdf0e10cSrcweir
307cdf0e10cSrcweirFunction getListBoxArrays(oUcb as Object, sFileFilter as String)
308cdf0e10cSrcweirDim oDocProps as Object
309cdf0e10cSrcweirDim oListboxControl as Object
310cdf0e10cSrcweirDim Description as String
311cdf0e10cSrcweirDim sField as String
312cdf0e10cSrcweirDim sFieldList() as String
313cdf0e10cSrcweirDim bItemFound as Boolean
314cdf0e10cSrcweirDim MaxIndex as Integer
315cdf0e10cSrcweirDim DirContent() as String
316cdf0e10cSrcweirDim FileName as String
317cdf0e10cSrcweirDim TemplatePath as String
318cdf0e10cSrcweirDim FilterLen as Integer
319cdf0e10cSrcweirDim i as Integer
320cdf0e10cSrcweirDim m as Integer
321cdf0e10cSrcweirDim n as Integer
322cdf0e10cSrcweirDim s as Integer
323cdf0e10cSrcweirDim a as Integer
324cdf0e10cSrcweirDim LocMaxIndex as Integer
325cdf0e10cSrcweirDim Properties()
326cdf0e10cSrcweirDim DimCount as Integer
327cdf0e10cSrcweirDim sExtension as String
328cdf0e10cSrcweir	oDocProps = CreateUnoService(&quot;com.sun.star.document.DocumentProperties&quot;)
329cdf0e10cSrcweir	FilterLen = Len(sFileFilter)
330cdf0e10cSrcweir	bItemFound = False
331cdf0e10cSrcweir	&apos; It has to be made sure that the TemplatePath &lt;&gt; &quot;&quot;
332cdf0e10cSrcweir	TemplatePath = GetOfficeSubPath(&quot;Template&quot;, &quot;wizard/web/&quot;)
333cdf0e10cSrcweir	If TemplatePath = &quot;&quot; Then
334cdf0e10cSrcweir		Dim NullList()
335cdf0e10cSrcweir		getListBoxArrays() = NullList()
336cdf0e10cSrcweir		Exit Function
337cdf0e10cSrcweir	End If
338cdf0e10cSrcweir	DirContent() = oUcb.GetFolderContents(TemplatePath,True)
339cdf0e10cSrcweir	If sFileFilter = &quot;/cnt&quot; Then
340cdf0e10cSrcweir		DimCount = 2
341cdf0e10cSrcweir	Else
342cdf0e10cSrcweir		DimCount = 8
343cdf0e10cSrcweir	End If
344cdf0e10cSrcweir	LocMaxIndex = Ubound(DirContent())
345cdf0e10cSrcweir	Dim List(LocMaxIndex, DimCount) as String
346cdf0e10cSrcweir	Dim SortList(LocMaxIndex,1)
347cdf0e10cSrcweir	For i = 0 to LocMaxIndex
348cdf0e10cSrcweir		SortList(i,0) = DirContent(i)
349cdf0e10cSrcweir		SortList(i,1) = RetrieveDocTitle(oDocProps, DirContent(i))
350cdf0e10cSrcweir	Next i
351cdf0e10cSrcweir	SortList() = BubbleSortList(SortList(),True)
352cdf0e10cSrcweir	For i = 0 to LocMaxIndex
353cdf0e10cSrcweir		DirContent(i) = SortList(i,0)
354cdf0e10cSrcweir	Next i
355cdf0e10cSrcweir	a = 0
356cdf0e10cSrcweir	For i = 0 To LocMaxIndex
357cdf0e10cSrcweir		FileName = DirContent(i)
358cdf0e10cSrcweir		sExtension = Ucase(GetFileNameExtension(FileName))
359cdf0e10cSrcweir		If Instr(1,Filename, sFileFilter) And sExtension = &quot;STW&quot; Then
360cdf0e10cSrcweir			bItemFound = True
361cdf0e10cSrcweir			Description = RetrieveDocTitle(oDocProps, FileName)
362cdf0e10cSrcweir			Properties = oDocProps.UserDefinedProperties.PropertyValues
363cdf0e10cSrcweir			List(a,1) = Description
364cdf0e10cSrcweir			If sFileFilter = &quot;/cnt&quot; Then
365cdf0e10cSrcweir				List(a,2) = Filename
366cdf0e10cSrcweir			Else
367cdf0e10cSrcweir				m = 2
368cdf0e10cSrcweir				For n = 0 To 3
369cdf0e10cSrcweir					sField = Properties(n).Value
370cdf0e10cSrcweir					sFieldList() = ArrayoutofString(sField, &quot; &quot;, MaxIndex)
371cdf0e10cSrcweir					For s = 0 To MaxIndex
372cdf0e10cSrcweir						If m &lt; 6 Then
373cdf0e10cSrcweir					        List(a,m) = sFieldList(s) &amp; &quot;.gif&quot;
374cdf0e10cSrcweir						Else
375cdf0e10cSrcweir					        List(a,m) = sFieldList(s)
376cdf0e10cSrcweir						End If
377cdf0e10cSrcweir						m = m + 1
378cdf0e10cSrcweir					Next s
379cdf0e10cSrcweir				Next n
380cdf0e10cSrcweir				List(a,8) = FileName
381cdf0e10cSrcweir			End If
382cdf0e10cSrcweir			a = a + 1
383cdf0e10cSrcweir		End If
384cdf0e10cSrcweir	Next i
385cdf0e10cSrcweir	If sFileFilter = &quot;/cnt&quot; Then
386cdf0e10cSrcweir		ReDim Preserve List(a-1,2) as String
387cdf0e10cSrcweir	Else
388cdf0e10cSrcweir		ReDim Preserve List(a-1,8) as String
389cdf0e10cSrcweir	End If
390cdf0e10cSrcweir	If Not bItemfound Then
391cdf0e10cSrcweir		MsgBox(WebWiz_gErrContentNotFound$, 16, WebWiz_gWizardName$)
392cdf0e10cSrcweir		DisposeDocument(oBaseDocument)
393cdf0e10cSrcweir		Stop
394cdf0e10cSrcweir	End If
395cdf0e10cSrcweir	getListBoxArrays = List()
396cdf0e10cSrcweirEnd Function
397cdf0e10cSrcweir
398cdf0e10cSrcweir
399cdf0e10cSrcweirSub SetGraphic(sWhich, sGraphicText as String)
400cdf0e10cSrcweirDim oLocCursor as Object
401cdf0e10cSrcweirDim oGraphic as Object
402cdf0e10cSrcweirDim bGetGraphic as Boolean
403cdf0e10cSrcweir	oBookmarks = oBaseDocument.BookMarks
404cdf0e10cSrcweir	If oBookmarks.HasbyName(sWhich)Then
405cdf0e10cSrcweir		oBookMark = oBookmarks.GetbyName(sWhich)
406cdf0e10cSrcweir		oLocCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
407cdf0e10cSrcweir		oGraphic = oBaseDocument.CreateInstance(&quot;com.sun.star.text.GraphicObject&quot;)
408cdf0e10cSrcweir		oLocCursor.GoRight(3,True)
409cdf0e10cSrcweir		oGraphic.AnchorType = 1
410cdf0e10cSrcweir		oGraphic.GraphicURL = ConverttoURL(sGraphicText)
411cdf0e10cSrcweir		oLocCursor.Text.InsertTextContent(oLocCursor, oGraphic, True)
412cdf0e10cSrcweir		oGraphic.Name = sWhich
413cdf0e10cSrcweir	ElseIf oBaseDocument.GraphicObjects.HasbyName(sWhich) Then
414cdf0e10cSrcweir		oGraphic = oBaseDocument.GraphicObjects.GetByName(sWhich)
415cdf0e10cSrcweir		oGraphic.GraphicUrl = sGraphicText
416cdf0e10cSrcweir	End If
417cdf0e10cSrcweirEnd Sub
418cdf0e10cSrcweir
419cdf0e10cSrcweir
420cdf0e10cSrcweirSub CheckControls(oDrawPage as Object)
421cdf0e10cSrcweirDim aForm as Object
422cdf0e10cSrcweirDim m,n as integer
423cdf0e10cSrcweirDim lColor as Long
424cdf0e10cSrcweirDim oControl as Object
425cdf0e10cSrcweir	lColor = oBaseDocument.StyleFamilies.GetbyName(&quot;ParagraphStyles&quot;).GetByName(&quot;Standard&quot;).CharColor
426cdf0e10cSrcweir	&apos;SearchFor all possible Controls
427cdf0e10cSrcweir	For n = 0 to oDrawPage.Forms.Count - 1
428cdf0e10cSrcweir		aForm = oDrawPage.Forms(n)
429cdf0e10cSrcweir		For m = 0 to aForm.Count-1
430cdf0e10cSrcweir			oControl = aForm.GetbyIndex(m)
431cdf0e10cSrcweir			oControl.TextColor = lColor
432cdf0e10cSrcweir		Next
433cdf0e10cSrcweir	Next
434cdf0e10cSrcweirEnd Sub
435cdf0e10cSrcweir
436cdf0e10cSrcweir
437cdf0e10cSrcweirSub RepaintHeaderPreview()
438cdf0e10cSrcweirDim Bitmap As Object
439cdf0e10cSrcweirDim sBitmapPath as String
440cdf0e10cSrcweir	sBitmapPath = SOBitmapPath &amp; &quot;webwizard.bmp&quot;
441cdf0e10cSrcweir	WebWzrd.ImagePreview.ImageURL = sBitmapPath
442cdf0e10cSrcweirEnd Sub
443cdf0e10cSrcweir
444cdf0e10cSrcweir
445cdf0e10cSrcweirSub ToggleDialogControls(ByVal bDoEnable as Boolean, Optional FocusControlName as String)
446cdf0e10cSrcweir	If Not IsNull(DialogModel) Then
447cdf0e10cSrcweir		DialogModel.Enabled = bDoEnable
448cdf0e10cSrcweir		If bDoEnable Then
449cdf0e10cSrcweir			&apos; Enable Controls referring to Background graphic only when this Property is set
450cdf0e10cSrcweir			bDoEnable = bWithBackGraphic
451cdf0e10cSrcweir			ToggleOptionButtons(DialogModel, bDoEnable)
452cdf0e10cSrcweir			MainDialog.GetControl(FocusControlName).SetFocus()
453cdf0e10cSrcweir		End If
454cdf0e10cSrcweir	End If
455cdf0e10cSrcweirEnd Sub
456cdf0e10cSrcweir</script:module>
457