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