1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="CalendarMain" script:language="StarBasic">Option Explicit 24 25Const _DEBUG = 0 26 27' CalenderMain 28Public sCurLangLocale as String 29Public sCurCountryLocale as String 30' This flag serves as a query if the individual Data should be saved 31Public bCalOwnDataChanged as Boolean 32 33'BankHoliday Functions 34Public CalBankholidayName$ (1 To 374) 35Public CalTypeOfBankHoliday% (1 To 374) 36 37Public Const cHolidayType_None = 0 38Public Const cHolidayType_Full = 1 39Public Const cHolidayType_Half = 2 40Public Const cHolidayType_Own = 4 41 42Public cCalSubcmdDeleteSelect_DeleteSelEntry$ 43Public cCalSubcmdDeleteSelect_DeleteSelEntryTitle$ 44Public cCalSubcmdSwitchOwnDataOrGeneral_Back$ 45Public cCalSubcmdSwitchOwnDataOrGeneral_OwnData$ 46 47'Language 48Public cCalLongMonthNames(11) as String 49Public cCalShortMonthNames(11) as String 50 51Public sBitmapFilename$ 52Public sCalendarTitle$, sMonthTitle$, sWizardTitle$, sError$ 53Public cCalStyleWorkday$, cCalStyleWeekend$ 54 55Public CalChoosenLand as Integer 56 57Public oDocument as Object 58Public oSheets as Object 59Public oSheet as Object 60Public oStatusLine as Object 61Public bCancelTask as Boolean 62Public oNumberFormatter as Object 63 64' BL* means "BundesLand" (for german states only) 65Public CONST CalBLBayern = 1 66Public CONST CalBLBadenWuert = 2 67Public CONST CalBLBerlin = 3 68Public CONST CalBLBremen = 4 69Public CONST CalBLBrandenburg = 5 70Public CONST CalBLHamburg = 6 71Public CONST CalBLHessen = 7 72Public CONST CalBLMeckPomm = 8 73Public CONST CalBLNiedersachsen = 9 74Public CONST CalBLNordrheinWest = 10 75Public CONST CalBLRheinlandPfalz = 11 76Public CONST CalBLSaarland = 12 77Public CONST CalBLSachsen = 13 78Public CONST CalBLSachsenAnhalt = 14 79Public CONST CalBLSchlHolstein = 15 80Public CONST CalBLThueringen = 16 81 82Public DlgCalendar as Object 83Public DlgCalModel as Object 84Public lDateFormat as Long 85Public lDateStandardFormat as Long 86 87 88 89Sub CalAutopilotTable() 90Dim BitmapDir as String 91Dim iThisMonth as Integer 92 93'On Error Goto ErrorHandler 94 BasicLibraries.LoadLibrary("Tools") 95 bSelectByMouseMove = True 96 oDocument = ThisComponent 97 oStatusline = oDocument.GetCurrentController.GetFrame.CreateStatusIndicator 98 ToggleWindow(False) 99 sCurLangLocale = oDocument.CharLocale.Language 100 sCurCountryLocale = oDocument.CharLocale.Country 101 DlgCalendar = LoadDialog("Schedule", "DlgCalendar") 102 DlgCalModel = DlgCalendar.Model 103 LoadLanguage(sCurLangLocale) 104 CalInitGlobalVariablesDate() 105 BitmapDir = GetOfficeSubPath("Template","../wizard/bitmap") 106 DlgCalModel.imgCountry.ImageURL = BitmapDir & sBitmapFilename 107 CalChoosenLand = -2 108 CalLoadOwnData() 109 110 With DlgCalModel 111 .cmdDelete.Enabled = False 112 .lstMonth.StringItemList() = cCalShortMonthNames() 113 Select Case sCurLangLocale 114 Case cLANGUAGE_JAPANESE 115 .lstOwnData.FontName = "HG MinochoL" 116 .txtEvent.FontName = "HG MinchoL" 117 Case cLANGUAGE_CHINESE 118 If oDocument.CharLocale.Country = "CN" Then 119 .lstOwnData.FontName = "FZ Song Ti" 120 .txtEvent.FontName = "FZ Song Ti" 121 Else 122 .lstOwnData.FontName = "FZ Ming Ti" 123 .txtEvent.FontName = "FZ Ming Ti" 124 End If 125 Case "ko" 126 .lstOwnData.FontName = "Sun Gulim" 127 .txtEvent.FontName = "Sun Gulim" 128 End Select 129 .lstOwnEventMonth.StringItemList() = cCalShortMonthNames() 130 .optYear.State = 1 131 .txtYear.Value = Year(Now()) 132 .txtYear.Tag = .txtYear.Value 133 .Step = 1 134 End With 135 SetupNumberFormatter(sCurLangLocale, sCurCountryLocale) 136 CalChooseCalendar() ' month 137 iThisMonth = Month(Now) 138 DlgCalendar.GetControl("lstMonth").SelectItemPos(iThisMonth-1, True) 139 DlgCalendar.GetControl("lstHolidays").SelectItemPos(0,True) 140 DlgCalModel.cmdGoOn.DefaultButton = True 141 ToggleWindow(True) 142 DlgCalendar.GetControl("lblHolidays").Visible = sCurLangLocale = cLANGUAGE_GERMAN 143 DlgCalendar.GetControl("lstHolidays").Visible = sCurLangLocale = cLANGUAGE_GERMAN 144 fHeightCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Height/198 145 fWidthCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Width/166 146 DlgCalendar.Execute() 147 DlgCalendar.Dispose() 148 Exit Sub 149ErrorHandler: 150 MsgBox(sError$, 16, sWizardTitle$) 151End Sub 152 153 154Sub SetupNumberFormatter(sCurLangLocale as String, sCurCountryLocale as String) 155Dim oFormats as Object 156Dim DateFormatString as String 157 oFormats = oDocument.getNumberFormats() 158 Select Case sCurLangLocale 159 Case cLANGUAGE_GERMAN 160 DateFormatString = "TT.MMM" 161 Case cLANGUAGE_ENGLISH 162 DateFormatString = "MMM DD" 163 Case cLANGUAGE_FRENCH 164 DateFormatString = "JJ/MMM" 165 Case cLANGUAGE_ITALIAN 166 DateFormatString = "GG/MMM" 167 Case cLANGUAGE_SPANISH 168 DateFormatString = "DD/MMM" 169 Case cLANGUAGE_PORTUGUESE 170 If sCurCountryLocale = "BR" Then 171 DateFormatString = "DD/MMM" 172 Else 173 DateFormatString = "DD-MMM" 174 End If 175 Case cLANGUAGE_DUTCH 176 DateFormatString = "DD/MMM" 177 Case cLANGUAGE_SWEDISH 178 DateFormatString = "MMM DD" 179 Case cLANGUAGE_DANISH 180 DateFormatString = "DD-MMM" 181 Case cLANGUAGE_POLISH 182 DateFormatString = "MMM DD" 183 Case cLANGUAGE_RUSSIAN 184 DateFormatString = "MMM DD" 185 Case cLANGUAGE_JAPANESE 186 DateFormatString = "M月D日" 187 Case cLANGUAGE_CHINESE 188 If sCurCountryLocale = "TW" Then 189 DateFormatString = "MMMMD" &"""" & "日" & """" 190 Else 191 DateFormatString = "M" & """" & "月" & """" & "D" &"""" & "日" & """" 192 End If 193 Case cLANGUAGE_GREEK 194 DateFormatString = "DD/MMM" 195 Case cLANGUAGE_TURKISH 196 DateFormatString = "DD/MMM" 197 Case cLANGUAGE_POLISH 198 DateFormatString = "MMM DD" 199 Case cLANGUAGE_FINNISH 200 DateFormatString = "PP.KKK" 201 End Select 202 203 lDateFormat = AddNumberFormat(oFormats, DateFormatString, oDocument.CharLocale) 204 lDateStandardFormat = oFormats.getStandardFormat(com.sun.star.util.NumberFormat.DATE, oDocument.CharLocale) 205 206' lDateStandardFormat = AddNumberFormat(oFormats, StandardDateFormatString, oDocument.CharLocale) 207 oNumberFormatter = createUNOService("com.sun.star.util.NumberFormatter") 208 oNumberFormatter.attachNumberFormatsSupplier(oDocument) 209End Sub 210 211 212Function AddNumberFormat(oNumberFormats as Object, FormatString as String, oLocale as Object) as Long 213Dim lLocDateFormat as Long 214 lLocDateFormat = oNumberFormats.QueryKey(FormatString, oLocale, True) 215 If lLocDateFormat = -1 Then 216 lLocDateFormat = oNumberFormats.addNew(FormatString, oLocale) 217 End If 218 AddNumberFormat() = lLocDateFormat 219End Function 220 221 222Sub CalChooseCalendar() 223 With DlgCalModel 224 .lstMonth.Enabled = .optMonth.State = 1 225 .lblMonth.Enabled = .optMonth.State = 1 226 End With 227End Sub 228 229 230Sub CalcmdCancel() 231 Call CalSaveOwnData() 232 DlgCalendar.EndExecute 233End Sub 234 235 236Sub CalcmdOk() 237 ' cmdOk is called when the Button 'Read' is clicked on 238 ' It is either given out a month or a year 239Dim i, iSelYear as Integer 240Dim SelYear as String 241' DlgCalendar.Visible = False 242 243 oSheets = oDocument.sheets 244 Call CalSaveOwnData() 245 UnprotectSheets(oSheets) 246 oSheets.RemovebyName(oSheets.GetbyIndex(0).Name) 247 iSelYear = DlgCalModel.txtYear.Value 248 Select Case sCurLangLocale 249 Case cLANGUAGE_GERMAN 250 If Ubound(DlgCalModel.lstHolidays.SelectedItems()) > -1 Then 251 CalChoosenLand = DlgCalModel.lstHolidays.SelectedItems(0) 252 Else 253 CalChoosenLand = 0 254 End If 255 Call CalFindWholeYearHolidays_GERMANY(iSelYear, CalChoosenLand) 256 Case cLANGUAGE_ENGLISH 257 Call FindWholeYearHolidays_US(iSelYear) 258 Case cLANGUAGE_FRENCH 259 Call FindWholeYearHolidays_FRANCE(iSelYear) 260 Case cLANGUAGE_ITALIAN 261 Call FindWholeYearHolidays_ITA(iSelYear) 262 Case cLANGUAGE_SPANISH 263 Call FindWholeYearHolidays_SPAIN(iSelYear) 264 Case cLANGUAGE_PORTUGUESE 265 Call FindWholeYearHolidays_PORT(iSelYear) 266 Case cLANGUAGE_DUTCH 267 Call FindWholeYearHolidays_NL(iSelYear) 268 Case cLANGUAGE_SWEDISH 269 Call FindWholeYearHolidays_SWED(iSelYear) 270 Case cLANGUAGE_DANISH 271 Call FindWholeYearHolidays_DK(iSelYear) 272 Case cLANGUAGE_POLISH 273 Call FindWholeYearHolidays_PL(iSelYear) 274 Case cLANGUAGE_RUSSIAN 275 Call FindWholeYearHolidays_RU(iSelYear) 276 Case cLANGUAGE_JAPANESE 277 Call FindWholeYearHolidays_JP(iSelYear) 278 Case cLANGUAGE_CHINESE 279 If sCurCountryLocale = "TW" Then 280 Call FindWholeYearHolidays_TW(iSelYear) 281 Else 282 Call FindWholeYearHolidays_CN(iSelYear) 283 End If 284 Case cLANGUAGE_GREEK 285 Call FindWholeYearHolidays_GREEK(iSelYear) 286 Case cLANGUAGE_TURKISH 287 Call FindWholeYearHolidays_TRK(iSelYear) 288 Case cLANGUAGE_POLISH 289 Call FindWholeYearHolidays_PL(iSelYear) 290 Case cLANGUAGE_FINNISH 291 Call FindWholeYearHolidays_FI(iSelYear) 292 End Select 293 294 Call CalInsertOwnDataInTables(iSelYear) 295 296 If DlgCalModel.optYear.State = 1 Then 297 oSheets.RemovebyName(oSheets.GetbyIndex(0).Name) 298 oSheet = oSheets.GetbyIndex(0) 299 oSheet.Name = sCalendarTitle$ + " " + iSelYear 300 oDocument.AddActionLock 301 Call CalCreateYearTable(iSelYear) 302 ElseIf DlgCalModel.optMonth.State = 1 Then 303 Dim iMonth 304 iMonth = DlgCalModel.lstMonth.SelectedItems(0) + 1 305 oSheets.RemovebyName(oSheets.GetbyIndex(1).Name) 306 oSheet = oSheets.GetbyIndex(0) 307 If sMonthTitle = "" Then 308 oSheet.Name = cCalLongMonthNames(iMonth-1) 309 Else 310 oSheet.Name = sMonthTitle + " " + cCalLongMonthNames(iMonth-1) 311 End If 312 oDocument.AddActionLock 313 Call CalCreateMonthTable(iSelYear, iMonth) 314 End If 315 316 oDocument.RemoveActionLock 317 oSheet.protect("") 318 oStatusLine.End 319 DlgCalendar.EndExecute() 320 bCancelTask = True 321End Sub 322</script:module> 323