diff options
Diffstat (limited to 'wizards/source/schedule/OwnEvents.xba')
-rw-r--r-- | wizards/source/schedule/OwnEvents.xba | 262 |
1 files changed, 120 insertions, 142 deletions
diff --git a/wizards/source/schedule/OwnEvents.xba b/wizards/source/schedule/OwnEvents.xba index e43998bc894c..2f2d3074887d 100644 --- a/wizards/source/schedule/OwnEvents.xba +++ b/wizards/source/schedule/OwnEvents.xba @@ -2,14 +2,14 @@ <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> <script:module xmlns:script="http://openoffice.org/2000/script" script:name="OwnEvents" script:language="StarBasic">Option Explicit -Public Const SBYEARUNDEFINED as Integer = -400 -Public Const SBDATEUNDEFINED as Double = -98765432.1 +Dim CurOwnMonth as Integer Sub Main Call CalAutopilotTable() End Sub + Sub CalSaveOwnData() Dim FileName as String Dim FileChannel as Integer @@ -31,188 +31,160 @@ Dim LocList() as String End Sub +Function CalCreateDateFromInput() as Date +' Generiert aus den Eingabedaten der Ereignisseite +' ein Datum im Dateserial Format, +Dim newDate as Date +Dim EvDay as Integer +Dim EvYear as Integer + EvDay = DlgCalModel.txtOwnEventDay.Value + If DlgCalModel.chkEventOnce.State = 1 Then + EvYear = DlgCalModel.txtOwnEventYear.Value + newDate = DateSerial(EvYear, CurOwnMonth, EvDay) + Else + newDate = DateSerial(0, CurOwnMonth, EvDay) + End If + CalCreateDateFromInput = newDate +End Function + + + Function CalCreateDateStrOfInput() as String Dim DateStr as String -Dim CurOwnYear as Integer -Dim CurOwnMonth as Integer -Dim CurOwnDay as Integer -Dim FormatDateStr as String -Dim dblDate as Double -Dim iLen as Integer -Dim iDiff as Integer -Dim i as Integer - CurOwnYear = DlgCalModel.txtOwnEventYear.Value - CurOwnDay = DlgCalModel.txtOwnEventDay.Value - CurOwnMonth = DlgCalendar.GetControl("lstOwnEventMonth").getselectedItemPos() + 1 - if DlgCalModel.chkEventOnce.State = 1 Then - DateStr = DateSerial(CurOwnYear, CurOwnMonth, CurOwnDay) - dblDate = CDbl(DateValue(DateStr)) - FormatDateStr = oNumberFormatter.convertNumberToString(lDateStandardFormat, dblDate) - else - DateStr = DateSerial(0, CurOwnMonth, CurOwnDay) - dblDate = CDbl(DateValue(DateStr)) - FormatDateStr = oNumberFormatter.convertNumberToString(lDateFormat, dblDate) +Dim EvMonth as Integer +Dim EvDay as Integer +Dim CurMonthStr as String + EvDay = DlgCalModel.txtOwnEventDay.Value + If EvDay < 10 Then + DateStr = "0" & EvDay & ". " + Else + DateStr = Cstr(EvDay) & ". " + End If + CurMonthStr = DlgCalModel.lstOwnEventMonth.StringItemList(CurOwnMonth-1) + If Len(CurMonthStr) = 2 Then + CurMonthStr = CurMonthStr & " " End If - iLen = Len(FormatDateStr) - iDiff = 16 - iLen - If iDiff > 0 Then - For i = 0 To iDiff - FormatDateStr = FormatDateStr + " " - Next i + DateStr = DateStr & CurMonthStr + + If DlgCalModel.chkEventOnce.State = 1 And DlgCalModel.txtOwnEventYear.Value <> 0 Then + DateStr = DateStr & " " + DlgCalModel.txtOwnEventYear.Value Else - MsgBox("Invalid DateFormat: 'FormatDateStr'", 16, sWizardTitle) - CalCreateDateStrOfInput = "" - Exit Function - End If - DateStr = FormatDateStr & Trim(DlgCalModel.txtEvent.Text) + DateStr = DateStr + " " + End If + DateStr = DateStr + " " + Trim(DlgCalModel.txtEvent.Text) CalCreateDateStrOfInput = DateStr End Function +Function CalGetDateWithoutYear&(ByVal i as Integer) + CalGetDateWithoutYear& = DateSerial(0, CalGetMonthOfEvent(i), CalGetDayOfEvent(i)) +End Function + Sub CalcmdInsertData() -Dim MaxIndex as Integer -Dim UIDateStr as String Dim DateStr as String +Dim LastIndex as Integer Dim bGetYear as Boolean -Dim NewDate as Double +Dim NewDate as Date Dim bInserted as Boolean +Dim bDateDoubled as Boolean +Dim EvYear as Integer Dim i as Integer -Dim CurOwnDay as Integer -Dim CurOwnMonth as Integer -Dim CurOwnYear as Integer - CurOwnDay = DlgCalModel.txtOwnEventDay.Value - CurOwnMonth = DlgCalendar.GetControl("lstOwnEventMonth").getSelectedItemPos() + 1 +Dim CurDate as Date +Dim CurEvYear as Integer +Dim CurEvMonth as Integer +Dim CurEvDay as Integer + bGetYear = DlgCalModel.chkEventOnce.State = 1 + LastIndex = Ubound(DlgCalModel.lstOwnData.StringItemList()) If bGetYear Then - CurOwnYear = DlgCalModel.txtOwnEventYear.Value - Else - CurOwnYear = SBYEARUNDEFINED + EvYear = DlgCalModel.txtOwnEventYear.Value End If - UIDateStr = CalCreateDateStrOfInput() - NewDate = GetDateUnits(CurOwnDay, CurOwnMonth, CurOwnYear, UIDateStr) - If UIDateStr = "" Then Exit Sub - MaxIndex = Ubound(DlgCalModel.lstOwnData.StringItemList()) - If MaxIndex = -1 Then - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, 0 + 1) + + newDate = CalCreateDateFromInput() + DateStr = CalCreateDateStrOfInput() + If DateStr = "" Then Exit Sub + + ' Es ist noch garnichts vorhanden + If Ubound(DlgCalModel.lstOwnData.StringItemList()) = -1 Then + DlgCalendar.GetControl("lstOwnData").AddItem(DateStr, 0 + 1) bInserted = True Else - Dim CurEvYear(MaxIndex) as Integer - Dim CurEvMonth(MaxIndex) as Integer - Dim CurEvDay(MaxIndex) as Integer - Dim CurDate(MaxIndex) as Double - - ' same Years("no years" are treated like same years) -> delete old entry and insert new one + ' gleiche jahre(auch keine Jahre sind gleiche jahre)->alt löschen neu rein i = 0 Do - CurDate(i) = GetSelectedDateUnits(CurEvDay(i), CurEvMonth(i), CurEvYear(i), i) -' If CurEvYear(i) <> SBYEARUNDEFINED Then - If CurDate(i) = NewDate Then - DlgCalendar.GetControl("lstOwnData").RemoveItems(i,1) - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, i) - bInserted = True - End If -' End If + CurEvYear = CalGetYearOfEvent(i) + CurEvMonth = CalGetMonthOfEvent(i) + CurEvDay = CalGetDayOfEvent(i) + If DateSerial(CurEvYear, CurEvMonth, CurEvDay) = NewDate Then + ' Todo: Abchecken wie das ist mit 'Ereignis einmalig' oder nicht + DlgCalendar.GetControl("lstOwnData").RemoveItems(i,1) + DlgCalendar.GetControl("lstOwnData").AddItem(DateStr, i) + bInserted = True + End If i = i + 1 - Loop Until bInserted Or i > MaxIndex + Loop Until bInserted Or i > LastIndex - ' There exists a date with a certain year number. + ' Es existiert ein Datum mit Jahreszahl. Es wird dasselbe Datum + ' ohne Angabe der Jahreszahl angegeben. If Not bInserted And Not bGetYear Then i = 0 Do - If CurEvYear(i) <> SBYEARUNDEFINED Then - If (CurEvMonth(i) = CurOwnMonth) And (CurEvDay(i) = CurOwnDay) Then - bInserted = True - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, i) + bInserted = CalGetDateWithoutYear(i) = newDate + If bInserted Then + If CalGetYearOfEvent(i) <> 0 Then + DlgCalendar.GetControl("lstOwnData").AddItem(DateStr, i+1) End If - End If + End If i = i + 1 - Loop Until bInserted Or i > MaxIndex + Loop Until bInserted Or i > LastIndex End If - ' the date to be inserted owns a year number. It exists already such a date in the list but without year number + ' Das einzufügende Datum besitzt eine Jahreszahl, es gibt bereits + ' das Datum in der Liste, jedoch ohne Datum. If Not bInserted And bGetYear Then i = 0 Do - If CurEvYear(i) = SBYEARUNDEFINED Then - If (CurEvMonth(i) = CurOwnMonth) And (CurEvDay(i) = CurOwnDay) Then - bInserted = true - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, i) - End If - End If + bInserted = CalGetDateWithoutYear(i) = newDate i = i + 1 - Loop Until bInserted Or i > MaxIndex + If bInserted Then + DlgCalendar.GetControl("lstOwnData").AddItem(DateStr, i) + End If + Loop Until bInserted Or i > LastIndex End If - ' The date is not yet existing and will will be sorted in accordingly - If Not bInserted Then + ' Das Datum ist noch nicht vorhanden und wird richtig einsortiert + If Not bInserted And Not bDateDoubled Then i = 0 Do - bInserted = NewDate < CurDate(i) + CurDate = CalGetDateWithoutYear(i) + bInserted = newDate < CurDate If bInserted Then - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, i) + Exit Do End If i = i + 1 - Loop Until bInserted Or i > MaxIndex - If Not bInserted Then - DlgCalendar.GetControl("lstOwnData").AddItem(UIDateStr, MaxIndex+1) - End If + Loop Until bInserted Or i > LastIndex + DlgCalendar.GetControl("lstOwnData").AddItem(DateStr, i) End If End If + bCalOwnDataChanged = True + Call CalClearInputMask() End Sub -Function GetSelectedDateUnits(CurEvDay as Integer, CurEvMonth as Integer, CurEvYear as Integer, i as Integer) as Double -Dim dblDate as Double -Dim DateStr as String - dblDate = SBDATEUNDEFINED - DateStr = DlgCalModel.lstOwnData.StringItemList(i) - If DateStr <> "" Then - dblDate = GetDateUnits(CurEvDay, CurEvMonth, CurEvYear, DateStr) - End If - GetSelectedDateUnits() = dblDate +Function CalGetYearOfEvent(ByVal ListIndex as Integer) as Integer +Dim YearStr as String + YearStr = DlgCalModel.lstOwnData.StringItemList(ListIndex) + CalGetYearOfEvent = Val(Mid(YearStr, 10, 4)) End Function -Function GetDateUnits(CurEvDay as Integer, CurEvMonth as Integer, CurEvYear as Integer, DateStr) as Double -Dim bEventOnce as String -Dim LocDateStr as String -Dim dblDate as Double -Dim lDate as Long - LocDateStr = Mid(DateStr, 1, 15) - LocDateStr = Trim(LocDateStr) - - bEventOnce = True - On Local Error GoTo NOSTANDARDDATEFORMAT - dblDate = oNumberFormatter.convertStringToNumber(lDateStandardFormat, LocDateStr) -NOSTANDARDDATEFORMAT: - If Err <> 0 Then - bEventOnce = False - Resume GETDATEFORMAT -GETDATEFORMAT: - On Local Error Goto NODATEFORMAT - dblDate = oNumberFormatter.convertStringToNumber(lDateFormat, LocDateStr) - End If - lDate = Clng(dblDate) - CurEvMonth = Month(lDate) - CurEvDay = Day(lDate) - If bEventOnce Then - CurEvYear = Year(lDate) - Else - CurEvYear = SBYEARUNDEFINED - End If - GetDateUnits() = dblDate - Exit Function - GetDateUnits() =SBDATEUNDEFINED -NODATEFORMAT: - If Err <> 0 Then - MsgBox("Error: Date : ' " & LocDateStr & "' is not a valid Format", 16, sWizardTitle) - Resume GETRETURNVALUE -GETRETURNVALUE: - GetDateUnits() = SBDATEUNDEFINED - End If +Function CalGetDayOfEvent(ByVal ListIndex as Integer) as Integer +Dim DayStr as String + DayStr = DlgCalModel.lstOwnData.StringItemList(ListIndex) + CalGetDayOfEvent = Val(Left(DayStr,2)) End Function @@ -224,6 +196,17 @@ Dim NameStr as String End Function +Function CalGetMonthOfEvent(ByVal ListIndex as Integer) as Integer +Dim MonthStr as String + MonthStr = DlgCalModel.lstOwnData.StringItemList(ListIndex) + MonthStr = Mid(MonthStr, 5, 3) + ' In chinese Short Monthnames may be only 2 characters long. + ' In this case the third character is filled up with an empty space + MonthStr = RTrim(MonthStr) + CalGetMonthOfEvent = CalGetIntOfShortMonthName(MonthStr) +End Function + + Function GetOwnYear() If DlgCalModel.chkEventOnce.State = 1 Then GetOwnYear() = DlgCalModel.txtOwnEventYear.Value @@ -233,17 +216,13 @@ Function GetOwnYear() End Function -Sub CheckInsertedDates(Optional ControlEnvironment, Optional CurOwnMonth as Integer) +Sub CheckInsertedDates() Dim EvYear as Long Dim EvDay as Long Dim sEvMonth as String -Dim bDoEnable as Boolean -Dim ListboxName as String - If Not IsMissing(ControlEnvironment) Then - CurOwnMonth = DlgCalendar.GetControl("lstOwnEventMonth").getSelectedItemPos()+1 - End If +Dim bDoEnable as Boolean EvYear = GetOwnYear() - bDoEnable = (EvYear <> 0) And (CurOwnMonth <> 0) + bDoEnable = (EvYear <> 0) And (CurOwnMonth > 0) If bDoEnable Then DlgCalModel.txtOwnEventDay.ValueMax = CalMaxDayInMonth(EvYear, CurOwnMonth) bDoEnable = DlgCalModel.txtOwnEventDay.Value <> 0 @@ -260,9 +239,8 @@ End Sub Sub GetOwnMonth() Dim EvYear as Integer -Dim CurOwnMonth as Integer EvYear = GetOwnYear() CurOwnMonth = DlgCalModel.lstOwnEventMonth.SelectedItems(0) + 1 DlgCalModel.txtOwnEventDay.ValueMax = CalMaxDayInMonth(EvYear, CurOwnMonth) - CheckInsertedDates(,CurOwnMonth) + CheckInsertedDates() End Sub</script:module>
\ No newline at end of file |