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=
"Userfields" script:
language=
"StarBasic">Option Explicit
4 'Todo: Controlling Scrollbar via Keyboard
6 Public Const SBMAXFIELDINDEX =
14
8 Public DlgUserFields as Object
9 Public oDocument as Object
10 Public UserFieldDataType(SBMAXFIELDINDEX,
1) as String
11 Public ScrollBarValue as Integer
12 Public UserFieldFamily(
0, SBMAXfIELDINDEX) as String
13 Public Const SBTBCOUNT =
9
14 Public oUserDataAccess as Object
15 Public CurFieldIndex as Integer
16 Public FilePath as String
18 Sub StartChangesUserfields
19 Dim SystemPath as String
20 BasicLibraries.LoadLibrary(
"Tools
")
21 UserFieldDatatype(
0,
0) =
"COMPANY
"
22 UserFieldDatatype(
0,
1) =
"o
"
23 UserFieldDatatype(
1,
0) =
"FIRSTNAME
"
24 UserFieldDatatype(
1,
1) =
"givenname
"
25 UserFieldDatatype(
2,
0) =
"LASTNAME
"
26 UserFieldDatatype(
2,
1) =
"sn
"
27 UserFieldDatatype(
3,
0) =
"INITIALS
"
28 UserFieldDatatype(
3,
1) =
"initials
"
29 UserFieldDatatype(
4,
0) =
"STREET
"
30 UserFieldDatatype(
4,
1) =
"street
"
31 UserFieldDatatype(
5,
0) =
"COUNTRY
"
32 UserFieldDatatype(
5,
1) =
"c
"
33 UserFieldDatatype(
6,
0) =
"ZIP
"
34 UserFieldDatatype(
6,
1) =
"postalcode
"
35 UserFieldDatatype(
7,
0) =
"CITY
"
36 UserFieldDatatype(
7,
1) =
"l
"
37 UserFieldDatatype(
8,
0) =
"TITLE
"
38 UserFieldDatatype(
8,
1) =
"title
"
39 UserFieldDatatype(
9,
0) =
"POSITION
"
40 UserFieldDatatype(
9,
1) =
"position
"
41 UserFieldDatatype(
10,
0) =
"PHONE_HOME
"
42 UserFieldDatatype(
10,
1) =
"homephone
"
43 UserFieldDatatype(
11,
0) =
"PHONE_WORK
"
44 UserFieldDatatype(
11,
1) =
"telephonenumber
"
45 UserFieldDatatype(
12,
0) =
"FAX
"
46 UserFieldDatatype(
12,
1) =
"facsimiletelephonenumber
"
47 UserFieldDatatype(
13,
0) =
"E-MAIL
"
48 UserFieldDatatype(
13,
1) =
"mail
"
49 UserFieldDatatype(
14,
0) =
"STATE
"
50 UserFieldDatatype(
14,
1) =
"st
"
51 FilePath = GetPathSettings(
"Config
", False)
& "/
" & "UserData.dat
"
52 DlgUserFields = LoadDialog(
"Gimmicks
",
"UserfieldDlg
")
53 SystemPath = ConvertFromUrl(FilePath)
54 DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label,
"'" & SystemPath
& "'",
"<ConfigDir
>")
55 DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, GetProductName(),
"<PRODUCTNAME
>")
56 DlgUserFields.Model.cmdSelect.HelpText = ReplaceString(DlgUserFields.Model.cmdSelect.HelpText, GetProductName(),
"<PRODUCTNAME
>")
58 oUserDataAccess = GetRegistryKeyContent(
"org.openoffice.UserProfile/Data
", True)
59 InitializeUserFamily()
62 DlgUserFields.Dispose()
69 For a =
1 To SBTBCount
70 .GetControl(
"Label
" & a).Model.Label = UserFieldDataType(a-
1,
0)
71 .GetControl(
"TextField
" & a).Model.Text = UserFieldFamily(CurFieldIndex, a-
1)
73 .Model.ScrollBar1.ScrollValueMax = (SBMAXFIELDINDEX+
1) - SBTBCOUNT
74 .Model.ScrollBar1.BlockIncrement = SBTBCOUNT
75 .Model.ScrollBar1.LineIncrement =
1
76 .Model.ScrollBar1.ScrollValue = ScrollBarValue
82 ScrollTextFieldInfo(ScrollBarValue)
83 ScrollBarValue = DlgUserFields.Model.ScrollBar1.ScrollValue
84 If (ScrollBarValue + SBTBCOUNT)
>= SBMAXFIELDINDEX +
1 Then
85 ScrollBarValue = (SBMAXFIELDINDEX +
1) - SBTBCOUNT
91 Sub ScrollTextFieldInfo(ByVal iScrollValue as Integer)
93 Dim CurIndex as Integer
94 For a =
1 To SBTBCOUNT
95 CurIndex = (a-
1) + iScrollValue
96 UserFieldFamily(CurFieldIndex,CurIndex) = DlgUserFields.GetControl(
"TextField
" & a).Model.Text
102 DlgUserFields.EndExecute
109 Dim MaxIndex as Integer
110 ScrollTextFieldInfo(DlgUserFields.Model.ScrollBar1.ScrollValue)
111 MaxIndex = Ubound(UserFieldFamily(),
1)
112 Dim FileStrings(MaxIndex) as String
113 For n =
0 To MaxIndex
114 FileStrings(n) =
""
115 For m =
0 To SBMAXFIELDINDEX
116 FileStrings(n) = FileStrings(n)
& UserFieldFamily(n,m)
& ";
"
119 SaveDataToFile(FilePath, FileStrings(), True)
123 Sub ToggleButtons(ByVal Index as Integer)
125 CurFieldIndex = Index
126 DlgUserFields.Model.cmdNextUser.Enabled = CurFieldIndex
<> Ubound(UserFieldFamily(),
1)
127 DlgUserFields.Model.cmdPrevUser.Enabled = CurFieldIndex
<> 0
131 Sub InitializeUserFamily()
132 Dim FirstIndex as Integer
133 Dim UserFieldstrings() as String
134 Dim LocStrings() as String
135 Dim bFileExists as Boolean
138 bFileExists = LoadDataFromFile(GetPathSettings(
"Config
", False)
& "/
" & "UserData.dat
", UserFieldStrings())
140 FirstIndex = Ubound(UserFieldStrings())
141 ReDim Preserve UserFieldFamily(FirstIndex, SBMAXFIELDINDEX) as String
142 For n =
0 To FirstIndex
143 LocStrings() = ArrayOutofString(UserFieldStrings(n),
";
")
144 For m =
0 To SBMAXFIELDINDEX
145 UserFieldFamily(n,m) = LocStrings(m)
149 ReDim Preserve UserFieldFamily(
0,SBMAXFIELDINDEX) as String
150 For m =
0 To SBMAXFIELDINDEX
151 UserFieldFamily(
0,m) = oUserDataAccess.GetByName(UserFieldDataType(m,
1))
160 Dim MaxIndex as Integer
161 For i =
1 To SBTBCount
162 DlgUserFields.GetControl(
"TextField
" & i).Model.Text =
""
164 MaxIndex = Ubound(UserFieldFamily(),
1)
165 ReDim Preserve UserFieldFamily(MaxIndex +
1, SBMAXFIELDINDEX) as String
166 ToggleButtons(MaxIndex +
1,
1)
170 Sub FillupTextFields()
172 Dim CurIndex as Integer
173 For a =
1 To SBTBCOUNT
174 CurIndex = (a-
1) + ScrollBarValue
175 DlgUserFields.GetControl(
"Label
" & a).Model.Label = UserFieldDataType(CurIndex,
0)
176 DlgUserFields.GetControl(
"TextField
" & a).Model.Text = UserFieldFamily(CurFieldIndex, CurIndex)
181 Sub StepToRecord(aEvent as Object)
183 iStep = CInt(aEvent.Source.Model.Tag)
184 ScrollTextFieldInfo(ScrollBarValue)
185 ToggleButtons(CurFieldIndex + iStep)
190 Sub SelectCurrentFields()
191 Dim MaxIndex as Integer
193 ScrollTextFieldInfo(ScrollBarValue)
194 MaxIndex = Ubound(UserFieldFamily(),
2)
195 For i =
0 To MaxIndex
196 oUserDataAccess.ReplaceByName(UserFieldDataType(i,
1), UserFieldFamily(CurFieldIndex, i))
198 oUserDataAccess.commitChanges()
202 Sub DeleteCurrentSettings()
205 Dim MaxIndex as Integer
206 MaxIndex = Ubound(UserFieldFamily(),
1)
207 If CurFieldIndex
< MaxIndex Then
208 For n = CurFieldIndex To MaxIndex -
1
209 For m =
0 To SBMAXFIELDINDEX
210 UserFieldFamily(n,m) = UserFieldFamily(n +
1,m)
214 CurFieldIndex = MaxIndex -
1
216 ReDim Preserve UserFieldFamily(MaxIndex-
1, SBMAXfIELDINDEX) as String
218 ToggleButtons(CurFieldIndex)
219 End Sub
</script:module>