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