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=
"OwnEvents" script:
language=
"StarBasic">Option Explicit
5 Public Const SBDATEUNDEFINED as Double = -
98765432.1
8 Call CalAutopilotTable()
13 Dim FileName as String
14 Dim FileChannel as Integer
16 If bCalOwnDataChanged Then
17 FileName = GetPathSettings(
"UserConfig
", False)
& "/
" & "DATE.DAT
"
18 SaveDataToFile(FileName, DlgCalModel.lstOwnData.StringItemList())
24 Dim FileName as String
25 Dim LocList() as String
26 FileName = GetPathSettings(
"UserConfig
", False)
& "/DATE.DAT
"
27 If LoadDataFromFile(FileName, LocList()) Then
28 DlgCalModel.lstOwnData.StringItemList() = LocList()
33 Function CalCreateDateStrOfInput() as String
35 Dim CurOwnMonth as Integer
36 Dim CurOwnDay as Integer
37 Dim FormatDateStr as String
42 CurOwnDay = DlgCalModel.txtOwnEventDay.Value
43 CurOwnMonth = DlgCalendar.GetControl(
"lstOwnEventMonth
").getselectedItemPos() +
1
44 DateStr = DateSerial(
0, CurOwnMonth, CurOwnDay)
45 dblDate = CDbl(DateValue(DateStr))
46 FormatDateStr = oNumberFormatter.convertNumberToString(lDateFormat, dblDate)
47 iLen = Len(FormatDateStr)
51 FormatDateStr = FormatDateStr +
" "
54 MsgBox(
"Invalid DateFormat:
'FormatDateStr
'",
16, sWizardTitle)
55 CalCreateDateStrOfInput =
""
58 DateStr = FormatDateStr
& Trim(DlgCalModel.txtEvent.Text)
59 CalCreateDateStrOfInput = DateStr
64 Sub CalcmdInsertData()
65 Dim MaxIndex as Integer
66 Dim UIDateStr as String
69 Dim bInserted as Boolean
71 Dim CurOwnDay as Integer
72 Dim CurOwnMonth as Integer
73 Dim CurOwnYear as Integer
74 CurOwnDay = DlgCalModel.txtOwnEventDay.Value
75 CurOwnMonth = DlgCalendar.GetControl(
"lstOwnEventMonth
").getSelectedItemPos() +
1
76 UIDateStr = CalCreateDateStrOfInput()
77 NewDate = GetDateUnits(CurOwnDay, CurOwnMonth, UIDateStr)
78 If UIDateStr =
"" Then Exit Sub
79 MaxIndex = Ubound(DlgCalModel.lstOwnData.StringItemList())
81 DlgCalendar.GetControl(
"lstOwnData
").AddItem(UIDateStr,
0 +
1)
84 Dim CurEvMonth(MaxIndex) as Integer
85 Dim CurEvDay(MaxIndex) as Integer
86 Dim CurDate(MaxIndex) as Double
87 ' same Years(
"no years
" are treated like same years) -
> delete old entry and insert new one
90 CurDate(i) = GetSelectedDateUnits(CurEvDay(i), CurEvMonth(i), i)
91 If CurDate(i) = NewDate Then
92 DlgCalendar.GetControl(
"lstOwnData
").RemoveItems(i,
1)
93 DlgCalendar.GetControl(
"lstOwnData
").AddItem(UIDateStr, i)
97 Loop Until bInserted Or i
> MaxIndex
99 ' There exists already a date
100 If Not bInserted Then
103 If (CurEvMonth(i) = CurOwnMonth) And (CurEvDay(i) = CurOwnDay) Then
105 DlgCalendar.GetControl(
"lstOwnData
").RemoveItems(i,
1)
106 DlgCalendar.GetControl(
"lstOwnData
").AddItem(UIDateStr, i)
109 Loop Until bInserted Or i
> MaxIndex
112 ' The date is not yet existing and will will be sorted in accordingly
113 If Not bInserted Then
116 bInserted = NewDate
< CurDate(i)
118 DlgCalendar.GetControl(
"lstOwnData
").AddItem(UIDateStr, i)
121 Loop Until bInserted Or i
> MaxIndex
122 If Not bInserted Then
123 DlgCalendar.GetControl(
"lstOwnData
").AddItem(UIDateStr, MaxIndex+
1)
127 bCalOwnDataChanged = True
128 Call CalClearInputMask()
132 Function GetSelectedDateUnits(CurEvDay as Integer, CurEvMonth as Integer, i as Integer) as Double
133 Dim dblDate as Double
134 Dim DateStr as String
135 dblDate = SBDATEUNDEFINED
136 DateStr = DlgCalModel.lstOwnData.StringItemList(i)
137 If DateStr
<> "" Then
138 dblDate = GetDateUnits(CurEvDay, CurEvMonth, DateStr)
140 GetSelectedDateUnits() = dblDate
144 Function GetDateUnits(CurEvDay as Integer, CurEvMonth as Integer, DateStr) as Double
145 Dim bEventOnce as String
146 Dim LocDateStr as String
147 Dim dblDate as Double
149 LocDateStr = Mid(DateStr,
1,
15)
150 LocDateStr = Trim(LocDateStr)
153 On Local Error Goto NODATEFORMAT
154 dblDate = oNumberFormatter.convertStringToNumber(lDateFormat, LocDateStr)
155 lDate = Clng(dblDate)
156 CurEvMonth = Month(lDate)
157 CurEvDay = Day(lDate)
158 GetDateUnits() = dblDate
160 GetDateUnits() =SBDATEUNDEFINED
162 If Err
<> 0 Then
163 MsgBox(
"Error: Date :
' " & LocDateStr
& "' is not a valid Format
",
16, sWizardTitle)
164 Resume GETRETURNVALUE
166 GetDateUnits() = SBDATEUNDEFINED
171 Function CalGetNameOfEvent(ByVal ListIndex as Integer) as String
172 Dim NameStr as String
173 NameStr = DlgCalModel.lstOwnData.StringItemList(ListIndex)
174 NameStr = Trim (Mid(NameStr,
16))
175 CalGetNameOfEvent = NameStr
180 Sub CheckInsertedDates(Optional ControlEnvironment, Optional CurOwnMonth as Integer)
183 Dim sEvMonth as String
184 Dim bDoEnable as Boolean
185 Dim ListboxName as String
186 Dim MaxValue as Integer
187 If Not IsMissing(ControlEnvironment) Then
188 CurOwnMonth = DlgCalendar.GetControl(
"lstOwnEventMonth
").getSelectedItemPos()+
1
191 bDoEnable = CurOwnMonth
<> 0
193 MaxValue = CalMaxDayInMonth(EvYear, CurOwnMonth)
194 DlgCalModel.txtOwnEventDay.ValueMax = MaxValue
195 If DlgCalModel.txtOwnEventDay.Value
> MaxValue Then
196 DlgCalModel.txtOwnEventDay.Value = MaxValue
198 bDoEnable = DlgCalModel.txtOwnEventDay.Value
<> 0
200 bDoEnable = Ubound(DlgCalModel.lstOwnEventMonth.SelectedItems())
> -
1
202 bDoEnable = LTrim(DlgCalModel.txtEvent.Text)
<> ""
206 DlgCalModel.cmdInsert.Enabled = bDoEnable
211 Dim EvYear as Integer
212 Dim CurOwnMonth as Integer
214 CurOwnMonth = DlgCalModel.lstOwnEventMonth.SelectedItems(
0) +
1
215 DlgCalModel.txtOwnEventDay.ValueMax = CalMaxDayInMonth(EvYear, CurOwnMonth)
216 CheckInsertedDates(,CurOwnMonth)
217 End Sub
</script:module>