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="Common" script:language="StarBasic">REM  *****  BASIC  *****
4*cdf0e10cSrcweirOption Explicit
5*cdf0e10cSrcweir
6*cdf0e10cSrcweir
7*cdf0e10cSrcweirFunction LoadNewStyles(oDocument as Object, oDialogModel as Object, CurIndex as Integer, SourceFile as String, Styles() as String, TextureDir as String) as Boolean
8*cdf0e10cSrcweirDim BackGroundURL as String
9*cdf0e10cSrcweirDim oBackGraph as Object
10*cdf0e10cSrcweirDim i, BackColor as Long
11*cdf0e10cSrcweirDim bLocWithBackGraphic as Boolean
12*cdf0e10cSrcweirDim oFamilies as Object, oFamily as Object&apos;, oStyle as Object
13*cdf0e10cSrcweirDim StylesOptions(0) as New com.sun.star.beans.PropertyValue
14*cdf0e10cSrcweir
15*cdf0e10cSrcweir	If SourceFile &lt;&gt; &quot;&quot; Then
16*cdf0e10cSrcweir		StylesOptions(0).Name = &quot;OverwriteStyles&quot;
17*cdf0e10cSrcweir		StylesOptions(0).Value = True
18*cdf0e10cSrcweir		oDocument.StyleFamilies.LoadStylesFromURL(SourceFile, StylesOptions())
19*cdf0e10cSrcweir	End If
20*cdf0e10cSrcweir
21*cdf0e10cSrcweir	&apos; Read array fields for background, bullet &amp; graphics
22*cdf0e10cSrcweir	BackgroundURL = Styles(CurIndex, 7)
23*cdf0e10cSrcweir	If Left(BackgroundURL, 1) &lt;&gt; &quot;#&quot; Then
24*cdf0e10cSrcweir		BackgroundURL = TextureDir + BackgroundURL
25*cdf0e10cSrcweir		bLocWithBackGraphic = True
26*cdf0e10cSrcweir	Else
27*cdf0e10cSrcweir		BackColor = clng(&quot;&amp;H&quot; &amp; Right(BackgroundURL, Len(BackgroundURL)-1))
28*cdf0e10cSrcweir		bLocWithBackGraphic = False
29*cdf0e10cSrcweir	End If
30*cdf0e10cSrcweir	oFamilies = oDocument.StyleFamilies
31*cdf0e10cSrcweir	oFamily = oFamilies.GetbyName(&quot;PageStyles&quot;)
32*cdf0e10cSrcweir	For i = 0 To oFamily.Count - 1
33*cdf0e10cSrcweir		If oFamily.GetByIndex(i).IsInUse Then
34*cdf0e10cSrcweir			oStyle = oFamily.GetbyIndex(i)
35*cdf0e10cSrcweir			If oStyle.PropertySetInfo.HasPropertybyName(&quot;BackGraphicURL&quot;) Then
36*cdf0e10cSrcweir				If Left(BackgroundURL, 1) = &quot;#&quot; Then
37*cdf0e10cSrcweir					oStyle.BackGraphicURL = &quot;&quot;
38*cdf0e10cSrcweir					oStyle.BackColor = BackColor
39*cdf0e10cSrcweir					oStyle.BackTransparent = False
40*cdf0e10cSrcweir				Else
41*cdf0e10cSrcweir					oStyle.BackGraphicUrl = BackGroundURL
42*cdf0e10cSrcweir					SetTileBackgroundorNot(oDialogModel, oStyle)
43*cdf0e10cSrcweir				End If
44*cdf0e10cSrcweir				Exit For
45*cdf0e10cSrcweir			End If
46*cdf0e10cSrcweir		End If
47*cdf0e10cSrcweir	Next i
48*cdf0e10cSrcweir	LoadNewStyles() = bLocWithBackGraphic
49*cdf0e10cSrcweirErrorOcurred:
50*cdf0e10cSrcweir	If Err &lt;&gt; 0 Then
51*cdf0e10cSrcweir		MsgBox (WebWiz_gErrWhileLoadStyles$, 16, WebWiz_gWizardName$)
52*cdf0e10cSrcweir		RESUME EXITSUB
53*cdf0e10cSrcweirEXITSUB:
54*cdf0e10cSrcweir	End If
55*cdf0e10cSrcweirEnd Function
56*cdf0e10cSrcweir
57*cdf0e10cSrcweir
58*cdf0e10cSrcweir
59*cdf0e10cSrcweirSub ChangeBackGraphicUrl(SavePath as String)
60*cdf0e10cSrcweirDim oPageFamily as Object
61*cdf0e10cSrcweirDim i as Integer
62*cdf0e10cSrcweir	oPageFamily = oBaseDocument.StyleFamilies.GetbyName(&quot;PageStyles&quot;)
63*cdf0e10cSrcweir	For i = 0 To oPageFamily.Count - 1
64*cdf0e10cSrcweir		If oPageFamily.GetByIndex(i).IsInUse Then
65*cdf0e10cSrcweir			oStyle = oPageFamily.GetbyIndex(i)
66*cdf0e10cSrcweir			If oStyle.PropertySetInfo.HasPropertybyName(&quot;BackGraphicURL&quot;) Then
67*cdf0e10cSrcweir				If oStyle.BackGraphicUrl &lt;&gt; &quot;&quot; Then
68*cdf0e10cSrcweir					oStyle.BackGraphicUrl = CopyFile(oStyle.BackGraphicUrl, SavePath)
69*cdf0e10cSrcweir					Exit Sub
70*cdf0e10cSrcweir				End If
71*cdf0e10cSrcweir			End If
72*cdf0e10cSrcweir		End If
73*cdf0e10cSrcweir	Next i
74*cdf0e10cSrcweirEnd Sub
75*cdf0e10cSrcweir
76*cdf0e10cSrcweir
77*cdf0e10cSrcweirSub SetBackGraphicStyle(oEvent as Object)
78*cdf0e10cSrcweirDim oFamilies as Object
79*cdf0e10cSrcweirDim oFamily as Object
80*cdf0e10cSrcweirDim i as Integer
81*cdf0e10cSrcweirDim oOptModel as Object
82*cdf0e10cSrcweirDim iBackgroundValue as Integer
83*cdf0e10cSrcweirDim oLocDocument as Object
84*cdf0e10cSrcweir	ooptModel = oEvent.Source.Model
85*cdf0e10cSrcweir	iBackgroundValue = Val(ooptModel.Tag)
86*cdf0e10cSrcweir	oLocDocument = StarDesktop.ActiveFrame.Controller.Model
87*cdf0e10cSrcweir	oLocDocument.LockControllers
88*cdf0e10cSrcweir	oFamilies = oLocDocument.StyleFamilies
89*cdf0e10cSrcweir	oFamily = oFamilies.GetbyName(&quot;PageStyles&quot;)
90*cdf0e10cSrcweir	For i = 0 To oFamily.Count - 1
91*cdf0e10cSrcweir		If oFamily.GetByIndex(i).IsInUse Then
92*cdf0e10cSrcweir			oStyle = oFamily.GetbyIndex(i)
93*cdf0e10cSrcweir			If oStyle.PropertySetInfo.HasPropertybyName(&quot;BackGraphicURL&quot;) Then
94*cdf0e10cSrcweir				oStyle.BackGraphicLocation = iBackgroundValue
95*cdf0e10cSrcweir			End If
96*cdf0e10cSrcweir		End If
97*cdf0e10cSrcweir	Next i
98*cdf0e10cSrcweir	oLocDocument.UnlockControllers
99*cdf0e10cSrcweirEnd Sub
100*cdf0e10cSrcweir
101*cdf0e10cSrcweir
102*cdf0e10cSrcweirSub SetTileBackgroundorNot(DialogModel as Object, oStyle as Object)
103*cdf0e10cSrcweir	If Not IsNull(DialogModel) Then
104*cdf0e10cSrcweir  		If DialogModel.optTiled.State = 1 Then
105*cdf0e10cSrcweir    		oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.TILED
106*cdf0e10cSrcweir  		Else
107*cdf0e10cSrcweir    		oStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.AREA
108*cdf0e10cSrcweir  		End If
109*cdf0e10cSrcweir  	End If
110*cdf0e10cSrcweirEnd Sub
111*cdf0e10cSrcweir
112*cdf0e10cSrcweir
113*cdf0e10cSrcweirSub	ToggleOptionButtons(DialogModel as Object, bDoEnable as Integer)
114*cdf0e10cSrcweir	If Not IsNull(DialogModel) Then
115*cdf0e10cSrcweir		DialogModel.optTiled.Enabled = bDoEnable
116*cdf0e10cSrcweir		DialogModel.optArea.Enabled = bDoEnable
117*cdf0e10cSrcweir		DialogModel.hlnBackground.Enabled = bDoEnable
118*cdf0e10cSrcweir	End If
119*cdf0e10cSrcweirEnd Sub
120*cdf0e10cSrcweir
121*cdf0e10cSrcweir
122*cdf0e10cSrcweirFunction GetCurIndex(oListbox as Object, sList() as String, FileIndex as Integer)
123*cdf0e10cSrcweirDim i as Integer
124*cdf0e10cSrcweirDim n as Integer
125*cdf0e10cSrcweirDim SelValue as String
126*cdf0e10cSrcweirDim MaxIndex as Integer
127*cdf0e10cSrcweir	If IsNull(oListBox) Then
128*cdf0e10cSrcweir		&apos; Startup for WebWizard
129*cdf0e10cSrcweir		SelValue = sList(0,1)
130*cdf0e10cSrcweir	Else
131*cdf0e10cSrcweir		n = oListbox.SelectedItems(0)
132*cdf0e10cSrcweir		SelValue = oListbox.StringItemList(n)
133*cdf0e10cSrcweir	End If
134*cdf0e10cSrcweir	&apos; Find field index for chosen list entry
135*cdf0e10cSrcweir	MaxIndex = Ubound(sList)
136*cdf0e10cSrcweir	For i = 0 To MaxIndex
137*cdf0e10cSrcweir		If sList(i,1) = SelValue Then
138*cdf0e10cSrcweir			FileStr = sList(i, FileIndex)
139*cdf0e10cSrcweir			Exit For
140*cdf0e10cSrcweir		End If
141*cdf0e10cSrcweir	Next
142*cdf0e10cSrcweir	GetCurIndex = i
143*cdf0e10cSrcweirEnd Function
144*cdf0e10cSrcweir
145*cdf0e10cSrcweir</script:module>