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=
"CalendarMain" script:
language=
"StarBasic">Option Explicit
8 Public sCurLangLocale as String
9 Public sCurCountryLocale as String
10 ' This flag serves as a query if the individual Data should be saved
11 Public bCalOwnDataChanged as Boolean
13 'BankHoliday Functions
14 Public CalBankholidayName$ (
1 To
374)
15 Public CalTypeOfBankHoliday% (
1 To
374)
17 Public Const cHolidayType_None =
0
18 Public Const cHolidayType_Full =
1
19 Public Const cHolidayType_Half =
2
20 Public Const cHolidayType_Own =
4
22 Public cCalSubcmdDeleteSelect_DeleteSelEntry$
23 Public cCalSubcmdDeleteSelect_DeleteSelEntryTitle$
24 Public cCalSubcmdSwitchOwnDataOrGeneral_Back$
25 Public cCalSubcmdSwitchOwnDataOrGeneral_OwnData$
28 Public cCalLongMonthNames(
11) as String
29 Public cCalShortMonthNames(
11) as String
31 Public sBitmapFilename$
32 Public sCalendarTitle$, sMonthTitle$, sWizardTitle$, sError$
33 Public cCalStyleWorkday$, cCalStyleWeekend$
35 Public CalChoosenLand as Integer
37 Public oDocument as Object
38 Public oSheets as Object
39 Public oSheet as Object
40 Public oStatusLine as Object
41 Public bCancelTask as Boolean
42 Public oNumberFormatter as Object
44 ' BL* means
"BundesLand
" (for german states only)
45 Public CONST CalBLBayern =
1
46 Public CONST CalBLBadenWuert =
2
47 Public CONST CalBLBerlin =
3
48 Public CONST CalBLBremen =
4
49 Public CONST CalBLBrandenburg =
5
50 Public CONST CalBLHamburg =
6
51 Public CONST CalBLHessen =
7
52 Public CONST CalBLMeckPomm =
8
53 Public CONST CalBLNiedersachsen =
9
54 Public CONST CalBLNordrheinWest =
10
55 Public CONST CalBLRheinlandPfalz =
11
56 Public CONST CalBLSaarland =
12
57 Public CONST CalBLSachsen =
13
58 Public CONST CalBLSachsenAnhalt =
14
59 Public CONST CalBLSchlHolstein =
15
60 Public CONST CalBLThueringen =
16
62 Public DlgCalendar as Object
63 Public DlgCalModel as Object
64 Public lDateFormat as Long
65 Public lDateStandardFormat as Long
69 Sub CalAutopilotTable()
70 Dim BitmapDir as String
71 Dim iThisMonth as Integer
73 'On Error Goto ErrorHandler
74 BasicLibraries.LoadLibrary(
"Tools
")
75 bSelectByMouseMove = True
76 oDocument = ThisComponent
77 oStatusline = oDocument.GetCurrentController.GetFrame.CreateStatusIndicator
79 sCurLangLocale = oDocument.CharLocale.Language
80 sCurCountryLocale = oDocument.CharLocale.Country
81 DlgCalendar = LoadDialog(
"Schedule
",
"DlgCalendar
")
82 DlgCalModel = DlgCalendar.Model
83 LoadLanguage(sCurLangLocale)
84 CalInitGlobalVariablesDate()
85 BitmapDir = GetOfficeSubPath(
"Template
",
"wizard/bitmap
")
86 DlgCalModel.imgCountry.ImageURL = BitmapDir
& sBitmapFilename
91 .cmdDelete.Enabled = False
92 .lstMonth.StringItemList() = cCalShortMonthNames()
93 Select Case sCurLangLocale
94 Case cLANGUAGE_JAPANESE
95 .lstOwnData.FontName =
"HG MinochoL
"
96 .txtEvent.FontName =
"HG MinchoL
"
97 Case cLANGUAGE_CHINESE
98 If oDocument.CharLocale.Country =
"CN
" Then
99 .lstOwnData.FontName =
"FZ Song Ti
"
100 .txtEvent.FontName =
"FZ Song Ti
"
102 .lstOwnData.FontName =
"FZ Ming Ti
"
103 .txtEvent.FontName =
"FZ Ming Ti
"
106 .lstOwnData.FontName =
"Sun Gulim
"
107 .txtEvent.FontName =
"Sun Gulim
"
109 .lstOwnEventMonth.StringItemList() = cCalShortMonthNames()
111 .txtYear.Value = Year(Now())
112 .txtYear.Tag = .txtYear.Value
115 SetupNumberFormatter(sCurLangLocale, sCurCountryLocale)
116 CalChooseCalendar()
' month
117 iThisMonth = Month(Now)
118 DlgCalendar.GetControl(
"lstMonth
").SelectItemPos(iThisMonth-
1, True)
119 DlgCalendar.GetControl(
"lstHolidays
").SelectItemPos(
0,True)
120 DlgCalModel.cmdGoOn.DefaultButton = True
122 DlgCalendar.GetControl(
"lblHolidays
").Visible = sCurLangLocale = cLANGUAGE_GERMAN
123 DlgCalendar.GetControl(
"lstHolidays
").Visible = sCurLangLocale = cLANGUAGE_GERMAN
124 fHeightCorrFactor = DlgCalendar.GetControl(
"imgCountry
").Size.Height/
198
125 fWidthCorrFactor = DlgCalendar.GetControl(
"imgCountry
").Size.Width/
166
126 DlgCalendar.Execute()
127 DlgCalendar.Dispose()
130 MsgBox(sError$,
16, sWizardTitle$)
134 Sub SetupNumberFormatter(sCurLangLocale as String, sCurCountryLocale as String)
135 Dim oFormats as Object
136 Dim DateFormatString as String
137 oFormats = oDocument.getNumberFormats()
138 Select Case sCurLangLocale
139 Case cLANGUAGE_GERMAN
140 DateFormatString =
"TT.MMM
"
141 Case cLANGUAGE_ENGLISH
142 DateFormatString =
"MMM DD
"
143 Case cLANGUAGE_FRENCH
144 DateFormatString =
"JJ/MMM
"
145 Case cLANGUAGE_ITALIAN
146 DateFormatString =
"GG/MMM
"
147 Case cLANGUAGE_SPANISH
148 DateFormatString =
"DD/MMM
"
149 Case cLANGUAGE_PORTUGUESE
150 If sCurCountryLocale =
"BR
" Then
151 DateFormatString =
"DD/MMM
"
153 DateFormatString =
"DD-MMM
"
156 DateFormatString =
"DD/MMM
"
157 Case cLANGUAGE_SWEDISH
158 DateFormatString =
"MMM DD
"
159 Case cLANGUAGE_DANISH
160 DateFormatString =
"DD-MMM
"
161 Case cLANGUAGE_POLISH
162 DateFormatString =
"MMM DD
"
163 Case cLANGUAGE_RUSSIAN
164 DateFormatString =
"MMM DD
"
165 Case cLANGUAGE_JAPANESE
166 DateFormatString =
"M月D日
"
167 Case cLANGUAGE_CHINESE
168 If sCurCountryLocale =
"TW
" Then
169 DateFormatString =
"MMMMD
" &"""" & "日
" & """"
171 DateFormatString =
"M
" & """" & "月
" & """" & "D
" &"""" & "日
" & """"
174 DateFormatString =
"DD/MMM
"
175 Case cLANGUAGE_TURKISH
176 DateFormatString =
"DD/MMM
"
177 Case cLANGUAGE_POLISH
178 DateFormatString =
"MMM DD
"
179 Case cLANGUAGE_FINNISH
180 DateFormatString =
"PP.KKK
"
183 lDateFormat = AddNumberFormat(oFormats, DateFormatString, oDocument.CharLocale)
184 lDateStandardFormat = oFormats.getStandardFormat(com.sun.star.util.NumberFormat.DATE, oDocument.CharLocale)
186 ' lDateStandardFormat = AddNumberFormat(oFormats, StandardDateFormatString, oDocument.CharLocale)
187 oNumberFormatter = createUNOService(
"com.sun.star.util.NumberFormatter
")
188 oNumberFormatter.attachNumberFormatsSupplier(oDocument)
192 Function AddNumberFormat(oNumberFormats as Object, FormatString as String, oLocale as Object) as Long
193 Dim lLocDateFormat as Long
194 lLocDateFormat = oNumberFormats.QueryKey(FormatString, oLocale, True)
195 If lLocDateFormat = -
1 Then
196 lLocDateFormat = oNumberFormats.addNew(FormatString, oLocale)
198 AddNumberFormat() = lLocDateFormat
202 Sub CalChooseCalendar()
204 .lstMonth.Enabled = .optMonth.State =
1
205 .lblMonth.Enabled = .optMonth.State =
1
211 Call CalSaveOwnData()
212 DlgCalendar.EndExecute
217 ' cmdOk is called when the Button
'Read
' is clicked on
218 ' It is either given out a month or a year
219 Dim i, iSelYear as Integer
220 Dim SelYear as String
221 ' DlgCalendar.Visible = False
223 oSheets = oDocument.sheets
224 Call CalSaveOwnData()
225 UnprotectSheets(oSheets)
226 oSheets.RemovebyName(oSheets.GetbyIndex(
0).Name)
227 iSelYear = DlgCalModel.txtYear.Value
228 Select Case sCurLangLocale
229 Case cLANGUAGE_GERMAN
230 If Ubound(DlgCalModel.lstHolidays.SelectedItems())
> -
1 Then
231 CalChoosenLand = DlgCalModel.lstHolidays.SelectedItems(
0)
235 Call CalFindWholeYearHolidays_GERMANY(iSelYear, CalChoosenLand)
236 Case cLANGUAGE_ENGLISH
237 Call FindWholeYearHolidays_US(iSelYear)
238 Case cLANGUAGE_FRENCH
239 Call FindWholeYearHolidays_FRANCE(iSelYear)
240 Case cLANGUAGE_ITALIAN
241 Call FindWholeYearHolidays_ITA(iSelYear)
242 Case cLANGUAGE_SPANISH
243 Call FindWholeYearHolidays_SPAIN(iSelYear)
244 Case cLANGUAGE_PORTUGUESE
245 Call FindWholeYearHolidays_PORT(iSelYear)
247 Call FindWholeYearHolidays_NL(iSelYear)
248 Case cLANGUAGE_SWEDISH
249 Call FindWholeYearHolidays_SWED(iSelYear)
250 Case cLANGUAGE_DANISH
251 Call FindWholeYearHolidays_DK(iSelYear)
252 Case cLANGUAGE_POLISH
253 Call FindWholeYearHolidays_PL(iSelYear)
254 Case cLANGUAGE_RUSSIAN
255 Call FindWholeYearHolidays_RU(iSelYear)
256 Case cLANGUAGE_JAPANESE
257 Call FindWholeYearHolidays_JP(iSelYear)
258 Case cLANGUAGE_CHINESE
259 If sCurCountryLocale =
"TW
" Then
260 Call FindWholeYearHolidays_TW(iSelYear)
262 Call FindWholeYearHolidays_CN(iSelYear)
265 Call FindWholeYearHolidays_GREEK(iSelYear)
266 Case cLANGUAGE_TURKISH
267 Call FindWholeYearHolidays_TRK(iSelYear)
268 Case cLANGUAGE_POLISH
269 Call FindWholeYearHolidays_PL(iSelYear)
270 Case cLANGUAGE_FINNISH
271 Call FindWholeYearHolidays_FI(iSelYear)
274 Call CalInsertOwnDataInTables(iSelYear)
276 If DlgCalModel.optYear.State =
1 Then
277 oSheets.RemovebyName(oSheets.GetbyIndex(
0).Name)
278 oSheet = oSheets.GetbyIndex(
0)
279 oSheet.Name = sCalendarTitle$ +
" " + iSelYear
280 oDocument.AddActionLock
281 Call CalCreateYearTable(iSelYear)
282 ElseIf DlgCalModel.optMonth.State =
1 Then
284 iMonth = DlgCalModel.lstMonth.SelectedItems(
0) +
1
285 oSheets.RemovebyName(oSheets.GetbyIndex(
1).Name)
286 oSheet = oSheets.GetbyIndex(
0)
287 If sMonthTitle =
"" Then
288 oSheet.Name = cCalLongMonthNames(iMonth-
1)
290 oSheet.Name = sMonthTitle +
" " + cCalLongMonthNames(iMonth-
1)
292 oDocument.AddActionLock
293 Call CalCreateMonthTable(iSelYear, iMonth)
296 oDocument.RemoveActionLock
297 oSheet.protect(
"")
299 DlgCalendar.EndExecute()