1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"Userfields" script:
language=
"StarBasic">Option Explicit
21 'Todo: Controlling Scrollbar via Keyboard
23 Public Const SBMAXFIELDINDEX =
14
25 Public DlgUserFields as Object
26 Public oDocument as Object
27 Public UserFieldDataType(SBMAXFIELDINDEX,
1) as String
28 Public ScrollBarValue as Integer
29 Public UserFieldFamily(
0, SBMAXfIELDINDEX) as String
30 Public Const SBTBCOUNT =
9
31 Public oUserDataAccess as Object
32 Public CurFieldIndex as Integer
33 Public FilePath as String
35 Sub StartChangesUserfields
36 Dim SystemPath as String
37 BasicLibraries.LoadLibrary(
"Tools
")
38 UserFieldDatatype(
0,
0) =
"COMPANY
"
39 UserFieldDatatype(
0,
1) =
"o
"
40 UserFieldDatatype(
1,
0) =
"FIRSTNAME
"
41 UserFieldDatatype(
1,
1) =
"givenname
"
42 UserFieldDatatype(
2,
0) =
"LASTNAME
"
43 UserFieldDatatype(
2,
1) =
"sn
"
44 UserFieldDatatype(
3,
0) =
"INITIALS
"
45 UserFieldDatatype(
3,
1) =
"initials
"
46 UserFieldDatatype(
4,
0) =
"STREET
"
47 UserFieldDatatype(
4,
1) =
"street
"
48 UserFieldDatatype(
5,
0) =
"COUNTRY
"
49 UserFieldDatatype(
5,
1) =
"c
"
50 UserFieldDatatype(
6,
0) =
"ZIP
"
51 UserFieldDatatype(
6,
1) =
"postalcode
"
52 UserFieldDatatype(
7,
0) =
"CITY
"
53 UserFieldDatatype(
7,
1) =
"l
"
54 UserFieldDatatype(
8,
0) =
"TITLE
"
55 UserFieldDatatype(
8,
1) =
"title
"
56 UserFieldDatatype(
9,
0) =
"POSITION
"
57 UserFieldDatatype(
9,
1) =
"position
"
58 UserFieldDatatype(
10,
0) =
"PHONE_HOME
"
59 UserFieldDatatype(
10,
1) =
"homephone
"
60 UserFieldDatatype(
11,
0) =
"PHONE_WORK
"
61 UserFieldDatatype(
11,
1) =
"telephonenumber
"
62 UserFieldDatatype(
12,
0) =
"FAX
"
63 UserFieldDatatype(
12,
1) =
"facsimiletelephonenumber
"
64 UserFieldDatatype(
13,
0) =
"E-MAIL
"
65 UserFieldDatatype(
13,
1) =
"mail
"
66 UserFieldDatatype(
14,
0) =
"STATE
"
67 UserFieldDatatype(
14,
1) =
"st
"
68 FilePath = GetPathSettings(
"Config
", False)
& "/
" & "UserData.dat
"
69 DlgUserFields = LoadDialog(
"Gimmicks
",
"UserfieldDlg
")
70 SystemPath = ConvertFromUrl(FilePath)
71 DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label,
"'" & SystemPath
& "'",
"<ConfigDir
>")
72 DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, GetProductName(),
"<PRODUCTNAME
>")
73 DlgUserFields.Model.cmdSelect.HelpText = ReplaceString(DlgUserFields.Model.cmdSelect.HelpText, GetProductName(),
"<PRODUCTNAME
>")
75 oUserDataAccess = GetRegistryKeyContent(
"org.openoffice.UserProfile/Data
", True)
76 InitializeUserFamily()
79 DlgUserFields.Dispose()
86 For a =
1 To SBTBCount
87 .GetControl(
"Label
" & a).Model.Label = UserFieldDataType(a-
1,
0)
88 .GetControl(
"TextField
" & a).Model.Text = UserFieldFamily(CurFieldIndex, a-
1)
90 .Model.ScrollBar1.ScrollValueMax = (SBMAXFIELDINDEX+
1) - SBTBCOUNT
91 .Model.ScrollBar1.BlockIncrement = SBTBCOUNT
92 .Model.ScrollBar1.LineIncrement =
1
93 .Model.ScrollBar1.ScrollValue = ScrollBarValue
99 ScrollTextFieldInfo(ScrollBarValue)
100 ScrollBarValue = DlgUserFields.Model.ScrollBar1.ScrollValue
101 If (ScrollBarValue + SBTBCOUNT)
>= SBMAXFIELDINDEX +
1 Then
102 ScrollBarValue = (SBMAXFIELDINDEX +
1) - SBTBCOUNT
108 Sub ScrollTextFieldInfo(ByVal iScrollValue as Integer)
110 Dim CurIndex as Integer
111 For a =
1 To SBTBCOUNT
112 CurIndex = (a-
1) + iScrollValue
113 UserFieldFamily(CurFieldIndex,CurIndex) = DlgUserFields.GetControl(
"TextField
" & a).Model.Text
119 DlgUserFields.EndExecute
126 Dim MaxIndex as Integer
127 ScrollTextFieldInfo(DlgUserFields.Model.ScrollBar1.ScrollValue)
128 MaxIndex = Ubound(UserFieldFamily(),
1)
129 Dim FileStrings(MaxIndex) as String
130 For n =
0 To MaxIndex
131 FileStrings(n) =
""
132 For m =
0 To SBMAXFIELDINDEX
133 FileStrings(n) = FileStrings(n)
& UserFieldFamily(n,m)
& ";
"
136 SaveDataToFile(FilePath, FileStrings(), True)
140 Sub ToggleButtons(ByVal Index as Integer)
142 CurFieldIndex = Index
143 DlgUserFields.Model.cmdNextUser.Enabled = CurFieldIndex
<> Ubound(UserFieldFamily(),
1)
144 DlgUserFields.Model.cmdPrevUser.Enabled = CurFieldIndex
<> 0
148 Sub InitializeUserFamily()
149 Dim FirstIndex as Integer
150 Dim UserFieldstrings() as String
151 Dim LocStrings() as String
152 Dim bFileExists as Boolean
155 bFileExists = LoadDataFromFile(GetPathSettings(
"Config
", False)
& "/
" & "UserData.dat
", UserFieldStrings())
157 FirstIndex = Ubound(UserFieldStrings())
158 ReDim Preserve UserFieldFamily(FirstIndex, SBMAXFIELDINDEX) as String
159 For n =
0 To FirstIndex
160 LocStrings() = ArrayOutofString(UserFieldStrings(n),
";
")
161 For m =
0 To SBMAXFIELDINDEX
162 UserFieldFamily(n,m) = LocStrings(m)
166 ReDim Preserve UserFieldFamily(
0,SBMAXFIELDINDEX) as String
167 For m =
0 To SBMAXFIELDINDEX
168 UserFieldFamily(
0,m) = oUserDataAccess.GetByName(UserFieldDataType(m,
1))
177 Dim MaxIndex as Integer
178 For i =
1 To SBTBCount
179 DlgUserFields.GetControl(
"TextField
" & i).Model.Text =
""
181 MaxIndex = Ubound(UserFieldFamily(),
1)
182 ReDim Preserve UserFieldFamily(MaxIndex +
1, SBMAXFIELDINDEX) as String
183 ToggleButtons(MaxIndex +
1,
1)
187 Sub FillupTextFields()
189 Dim CurIndex as Integer
190 For a =
1 To SBTBCOUNT
191 CurIndex = (a-
1) + ScrollBarValue
192 DlgUserFields.GetControl(
"Label
" & a).Model.Label = UserFieldDataType(CurIndex,
0)
193 DlgUserFields.GetControl(
"TextField
" & a).Model.Text = UserFieldFamily(CurFieldIndex, CurIndex)
198 Sub StepToRecord(aEvent as Object)
200 iStep = CInt(aEvent.Source.Model.Tag)
201 ScrollTextFieldInfo(ScrollBarValue)
202 ToggleButtons(CurFieldIndex + iStep)
207 Sub SelectCurrentFields()
208 Dim MaxIndex as Integer
210 ScrollTextFieldInfo(ScrollBarValue)
211 MaxIndex = Ubound(UserFieldFamily(),
2)
212 For i =
0 To MaxIndex
213 oUserDataAccess.ReplaceByName(UserFieldDataType(i,
1), UserFieldFamily(CurFieldIndex, i))
215 oUserDataAccess.commitChanges()
219 Sub DeleteCurrentSettings()
222 Dim MaxIndex as Integer
223 MaxIndex = Ubound(UserFieldFamily(),
1)
224 If CurFieldIndex
< MaxIndex Then
225 For n = CurFieldIndex To MaxIndex -
1
226 For m =
0 To SBMAXFIELDINDEX
227 UserFieldFamily(n,m) = UserFieldFamily(n +
1,m)
231 CurFieldIndex = MaxIndex -
1
233 ReDim Preserve UserFieldFamily(MaxIndex-
1, SBMAXfIELDINDEX) as String
235 ToggleButtons(CurFieldIndex)
236 End Sub
</script:module>