2001-04-23 04:46:42 -05:00
<?xml version="1.0" encoding="UTF-8"?>
2001-10-01 03:59:25 -05:00
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Userfields" script:language="StarBasic">Option Explicit
'Todo: Controlling Scrollbar via Keyboard
2001-04-23 04:46:42 -05:00
2001-10-01 03:59:25 -05:00
Public Const SBMAXFIELDINDEX = 14
Public DlgUserFields as Object
2001-04-23 04:46:42 -05:00
Public oDocument as Object
2001-10-01 03:59:25 -05:00
Public UserFieldDataType(SBMAXFIELDINDEX,1) as String
2001-04-23 04:46:42 -05:00
Public ScrollBarValue as Integer
2001-10-01 03:59:25 -05:00
Public UserFieldFamily(0, SBMAXfIELDINDEX) as String
Public Const SBTBCOUNT = 9
Public oUserDataAccess as Object
Public CurFieldIndex as Integer
Public FilePath as String
2001-04-23 04:46:42 -05:00
Sub StartChangesUserfields
2001-10-01 03:59:25 -05:00
Dim SystemPath as String
BasicLibraries.LoadLibrary("Tools")
UserFieldDatatype(0,0) = "COMPANY"
UserFieldDatatype(0,1) = "o"
UserFieldDatatype(1,0) = "FIRSTNAME"
UserFieldDatatype(1,1) = "givenname"
2001-10-08 03:52:01 -05:00
UserFieldDatatype(2,0) = "LASTNAME"
2001-10-01 03:59:25 -05:00
UserFieldDatatype(2,1) = "sn"
2001-10-08 03:52:01 -05:00
UserFieldDatatype(3,0) = "INITIALS"
2001-10-01 03:59:25 -05:00
UserFieldDatatype(3,1) = "initials"
UserFieldDatatype(4,0) = "STREET"
UserFieldDatatype(4,1) = "street"
UserFieldDatatype(5,0) = "COUNTRY"
UserFieldDatatype(5,1) = "c"
UserFieldDatatype(6,0) = "ZIP"
UserFieldDatatype(6,1) = "postalcode"
UserFieldDatatype(7,0) = "CITY"
UserFieldDatatype(7,1) = "l"
UserFieldDatatype(8,0) = "TITLE"
UserFieldDatatype(8,1) = "title"
UserFieldDatatype(9,0) = "POSITION"
UserFieldDatatype(9,1) = "position"
2001-10-08 03:52:01 -05:00
UserFieldDatatype(10,0) = "PHONE_HOME"
2001-10-01 03:59:25 -05:00
UserFieldDatatype(10,1) = "homephone"
2001-10-08 03:52:01 -05:00
UserFieldDatatype(11,0) = "PHONE_WORK"
2001-10-01 03:59:25 -05:00
UserFieldDatatype(11,1) = "telephonenumber"
UserFieldDatatype(12,0) = "FAX"
UserFieldDatatype(12,1) = "facsimiletelephonenumber"
2001-10-08 03:52:01 -05:00
UserFieldDatatype(13,0) = "E-MAIL"
2001-10-01 03:59:25 -05:00
UserFieldDatatype(13,1) = "mail"
UserFieldDatatype(14,0) = "STATE"
UserFieldDatatype(14,1) = "st"
FilePath = GetPathSettings("Config", False) & "/" & "UserData.dat"
DlgUserFields = LoadDialog("Gimmicks","UserfieldDlg")
SystemPath = ConvertFromUrl(FilePath)
DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, "'" & SystemPath & "'", "<ConfigDir>")
2001-10-10 03:26:29 -05:00
DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, GetProductName(), "<PRODUCTNAME>")
DlgUserFields.Model.cmdSelect.HelpText = ReplaceString(DlgUserFields.Model.cmdSelect.HelpText, GetProductName(), "<PRODUCTNAME>")
2001-04-23 04:46:42 -05:00
ScrollBarValue = 0
2001-10-01 03:59:25 -05:00
oUserDataAccess = GetRegistryKeyContent("org.openoffice.UserProfile/Data", True)
InitializeUserFamily()
FillDialog()
DlgUserFields.Execute
DlgUserFields.Dispose()
2001-04-23 04:46:42 -05:00
End Sub
Sub FillDialog()
Dim a as Integer
2001-10-01 03:59:25 -05:00
With DlgUserFields
For a = 1 To SBTBCount
.GetControl("Label" & a).Model.Label = UserFieldDataType(a-1,0)
.GetControl("TextField" & a).Model.Text = UserFieldFamily(CurFieldIndex, a-1)
Next a
.Model.ScrollBar1.ScrollValueMax = (SBMAXFIELDINDEX+1) - SBTBCOUNT
.Model.ScrollBar1.BlockIncrement = SBTBCOUNT
.Model.ScrollBar1.LineIncrement = 1
.Model.ScrollBar1.ScrollValue = ScrollBarValue
End With
End Sub
2001-04-23 04:46:42 -05:00
2001-10-01 03:59:25 -05:00
Sub ScrollControls()
ScrollTextFieldInfo(ScrollBarValue)
ScrollBarValue = DlgUserFields.Model.ScrollBar1.ScrollValue
If (ScrollBarValue + SBTBCOUNT) >= SBMAXFIELDINDEX + 1 Then
ScrollBarValue = (SBMAXFIELDINDEX + 1) - SBTBCOUNT
2001-04-23 04:46:42 -05:00
End If
2001-10-01 03:59:25 -05:00
FillupTextFields()
End Sub
2001-04-23 04:46:42 -05:00
2001-10-01 03:59:25 -05:00
Sub ScrollTextFieldInfo(ByVal iScrollValue as Integer)
Dim a as Integer
Dim CurIndex as Integer
For a = 1 To SBTBCOUNT
CurIndex = (a-1) + iScrollValue
UserFieldFamily(CurFieldIndex,CurIndex) = DlgUserFields.GetControl("TextField" & a).Model.Text
Next a
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub StopMacro()
DlgUserFields.EndExecute
End Sub
2001-04-23 04:46:42 -05:00
2001-10-01 03:59:25 -05:00
Sub SaveSettings()
Dim n as Integer
Dim m as Integer
Dim MaxIndex as Integer
ScrollTextFieldInfo(DlgUserFields.Model.ScrollBar1.ScrollValue)
MaxIndex = Ubound(UserFieldFamily(), 1)
Dim FileStrings(MaxIndex) as String
For n = 0 To MaxIndex
FileStrings(n) = ""
For m = 0 To SBMAXFIELDINDEX
FileStrings(n) = FileStrings(n) & UserFieldFamily(n,m) & ";"
Next m
Next n
SaveDataToFile(FilePath, FileStrings(), True)
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub ToggleButtons(ByVal Index as Integer)
Dim i as Integer
CurFieldIndex = Index
DlgUserFields.Model.cmdNextUser.Enabled = CurFieldIndex <> Ubound(UserFieldFamily(), 1)
DlgUserFields.Model.cmdPrevUser.Enabled = CurFieldIndex <> 0
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub InitializeUserFamily()
Dim FirstIndex as Integer
Dim UserFieldstrings() as String
Dim LocStrings() as String
Dim bFileExists as Boolean
Dim n as Integer
Dim m as Integer
bFileExists = LoadDataFromFile(GetPathSettings("Config", False) & "/" & "UserData.dat", UserFieldStrings())
If bFileExists Then
FirstIndex = Ubound(UserFieldStrings())
ReDim Preserve UserFieldFamily(FirstIndex, SBMAXFIELDINDEX) as String
For n = 0 To FirstIndex
LocStrings() = ArrayOutofString(UserFieldStrings(n), ";")
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(n,m) = LocStrings(m)
Next m
Next n
Else
ReDim Preserve UserFieldFamily(0,SBMAXFIELDINDEX) as String
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(0,m) = oUserDataAccess.GetByName(UserFieldDataType(m,1))
Next m
End If
ToggleButtons(0)
End Sub
Sub AddRecord()
Dim i as Integer
Dim MaxIndex as Integer
For i = 1 To SBTBCount
DlgUserFields.GetControl("TextField" & i).Model.Text = ""
Next i
MaxIndex = Ubound(UserFieldFamily(),1)
ReDim Preserve UserFieldFamily(MaxIndex + 1, SBMAXFIELDINDEX) as String
ToggleButtons(MaxIndex + 1, 1)
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub FillupTextFields()
Dim a as Integer
Dim CurIndex as Integer
For a = 1 To SBTBCOUNT
CurIndex = (a-1) + ScrollBarValue
DlgUserFields.GetControl("Label" & a).Model.Label = UserFieldDataType(CurIndex,0)
DlgUserFields.GetControl("TextField" & a).Model.Text = UserFieldFamily(CurFieldIndex, CurIndex)
Next a
End Sub
2001-04-23 04:46:42 -05:00
2001-10-01 03:59:25 -05:00
Sub StepToRecord(aEvent as Object)
Dim iStep as Integer
iStep = CInt(aEvent.Source.Model.Tag)
ScrollTextFieldInfo(ScrollBarValue)
ToggleButtons(CurFieldIndex + iStep)
FillUpTextFields()
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub SelectCurrentFields()
Dim MaxIndex as Integer
Dim i as Integer
ScrollTextFieldInfo(ScrollBarValue)
MaxIndex = Ubound(UserFieldFamily(),2)
For i = 0 To MaxIndex
oUserDataAccess.ReplaceByName(UserFieldDataType(i,1), UserFieldFamily(CurFieldIndex, i))
Next i
oUserDataAccess.commitChanges()
2001-04-23 04:46:42 -05:00
End Sub
2001-10-01 03:59:25 -05:00
Sub DeleteCurrentSettings()
Dim n as Integer
Dim m as Integer
Dim MaxIndex as Integer
MaxIndex = Ubound(UserFieldFamily(),1)
If CurFieldIndex < MaxIndex Then
For n = CurFieldIndex To MaxIndex - 1
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(n,m) = UserFieldFamily(n + 1,m)
Next m
Next n
Else
CurFieldIndex = MaxIndex - 1
End If
ReDim Preserve UserFieldFamily(MaxIndex-1, SBMAXfIELDINDEX) as String
FillupTextFields()
ToggleButtons(CurFieldIndex)
End Sub</script:module>