home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 March / PCWorld_2003-03_cd.bin / Software / Vyzkuste / openoffice / f_0032 / CalendarMain.xba < prev    next >
Extensible Markup Language  |  2002-02-19  |  7KB  |  222 lines

  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
  4.  
  5. Const _DEBUG = 0
  6.  
  7. ' CalenderMain
  8. Public sCurLangLocale as String
  9. Public sCurCountryLocale as String
  10. ' Dieses Flag dient zur Abfrage ob die individuellen Daten abgespeichert werden sollen.
  11. Public bCalOwnDataChanged as Boolean
  12.  
  13. 'BankHolidayFunctions
  14. Public CalBankholidayName$ (1 To 374)
  15. Public CalTypeOfBankHoliday% (1 To 374)
  16.  
  17. Public Const cHolidayType_None = 0
  18. Public Const cHolidayType_Full = 1
  19. Public Const cHolidayType_Half = 2
  20. Public Const cHolidayType_Own = 4
  21.  
  22. Public cCalSubcmdDeleteSelect_DeleteSelEntry$
  23. Public cCalSubcmdDeleteSelect_DeleteSelEntryTitle$
  24. Public cCalSubcmdSwitchOwnDataOrGeneral_Back$
  25. Public cCalSubcmdSwitchOwnDataOrGeneral_OwnData$
  26.  
  27. 'Language
  28. Public cCalLongMonthNames(11) as String
  29. Public cCalShortMonthNames(11) as String
  30.  
  31. Public sBitmapFilename$
  32. Public sCalendarTitle$, sMonthTitle$, sWizardTitle$, sError$
  33. Public cCalStyleWorkday$, cCalStyleWeekend$
  34.  
  35. ' German only
  36. ' Variablen, die zur Verwaltung der Eingabe der Bundesl├ñnder dienen
  37. Public CalChoosenLand as Integer
  38.  
  39. Public oDocument as Object
  40. Public oSheets as Object
  41. Public oSheet as Object
  42. Public oStatusLine as Object
  43. Public bCancelTask as Boolean
  44.  
  45. ' BL* bedeutet BundesLand*
  46. Public CONST CalBLBayern         = 1
  47. Public CONST CalBLBadenWuert     = 2
  48. Public CONST CalBLBerlin         = 3
  49. Public CONST CalBLBremen         = 4
  50. Public CONST CalBLBrandenburg    = 5
  51. Public CONST CalBLHamburg        = 6
  52. Public CONST CalBLHessen         = 7
  53. Public CONST CalBLMeckPomm       = 8
  54. Public CONST CalBLNiedersachsen  = 9
  55. Public CONST CalBLNordrheinWest  = 10
  56. Public CONST CalBLRheinlandPfalz = 11
  57. Public CONST CalBLSaarland       = 12
  58. Public CONST CalBLSachsen        = 13
  59. Public CONST CalBLSachsenAnhalt  = 14
  60. Public CONST CalBLSchlHolstein   = 15
  61. Public CONST CalBLThueringen     = 16
  62.  
  63. Public DlgCalendar as Object
  64. Public DlgCalModel as Object
  65.  
  66. Sub CalAutopilotTable()
  67. Dim BitmapDir as String
  68. Dim iThisMonth as Integer
  69. 'On Error Goto ErrorHandler
  70.     BasicLibraries.LoadLibrary("Tools")
  71.     bSelectByMouseMove = True
  72.     oDocument = ThisComponent
  73.     oStatusline = oDocument.GetCurrentController.GetFrame.CreateStatusIndicator
  74.     ToggleWindow(False)
  75.     sCurLangLocale = oDocument.CharLocale.Language
  76.     sCurCountryLocale = oDocument.CharLocale.Country
  77.     DlgCalendar = LoadDialog("Schedule", "DlgCalendar")
  78.     DlgCalModel = DlgCalendar.Model
  79.     LoadLanguage(sCurLangLocale)
  80.     CalInitGlobalVariablesDate()
  81.     BitmapDir = GetOfficeSubPath("Template","wizard/bitmap")
  82.     DlgCalModel.imgCountry.ImageURL = BitmapDir & sBitmapFilename
  83.     CalChoosenLand = -2
  84.     CurOwnMonth = -1
  85.     CalLoadOwnData()
  86. '    sCurLanguage = "ja"
  87.     With DlgCalModel
  88.         .cmdDelete.Enabled = False
  89.         .lstMonth.StringItemList() = cCalShortMonthNames()
  90.         Select Case sCurLangLocale
  91.             Case "ja"
  92.                 .lstOwnData.FontName = "HG Mincho Light J"
  93.                 .txtEvent.FontName = "HG Mincho Light J"
  94.             Case "zh"
  95.                 If oDocument.CharLocale.Country = "CN" Then
  96.                     .lstOwnData.FontName = "HG MSung Light SC"
  97.                     .txtEvent.FontName = "HG MSung Light SC"
  98.                 Else
  99.                     .lstOwnData.FontName = "HG MSung Light TC"
  100.                     .txtEvent.FontName = "HG MSung Light TC"
  101.                 End If
  102.             Case "ko"
  103.                 .lstOwnData.FontName = "HG MyeongJo Light K"
  104.                 .txtEvent.FontName = "HG MyeongJo Light K"
  105.         End Select
  106.         .lstOwnEventMonth.StringItemList() = cCalShortMonthNames()
  107.         .optYear.State = 1
  108.         .txtYear.Value = Year(Now())
  109.         .txtYear.Tag = .txtYear.Value
  110.         .Step = 1
  111.     End With
  112.     CalChooseCalendar()  ' month
  113.     iThisMonth = Month(Now)
  114.     DlgCalendar.GetControl("lstMonth").SelectItemPos(iThisMonth-1, True)
  115.     DlgCalendar.GetControl("lstHolidays").SelectItemPos(0,True)
  116.     DlgCalModel.cmdGoOn.DefaultButton = True
  117.     ToggleWindow(True)
  118.     DlgCalendar.GetControl("lblHolidays").Visible = sCurLangLocale  = cLANGUAGE_GERMAN
  119.     DlgCalendar.GetControl("lstHolidays").Visible = sCurLangLocale  = cLANGUAGE_GERMAN    
  120.     fHeightCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Height/198
  121.     fWidthCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Width/166
  122.     DlgCalendar.Execute()
  123.     DlgCalendar.Dispose()
  124.     Exit Sub
  125. ErrorHandler:
  126.     MsgBox(sError$, 16, sWizardTitle$)
  127. End Sub
  128.  
  129.  
  130. Sub CalChooseCalendar()
  131.     With DlgCalModel
  132.         .lstMonth.Enabled = .optMonth.State = 1
  133.         .lblMonth.Enabled = .optMonth.State = 1
  134.     End With
  135. End Sub
  136.  
  137.  
  138. Sub CalcmdCancel()
  139.     Call CalSaveOwnData()
  140.     DlgCalendar.EndExecute     ' Visible = False
  141. End Sub
  142.  
  143.  
  144. Sub CalcmdOk()
  145.     ' cmdOk is called when the Button 'Read' is clicked on
  146.     ' It is either given out a month or a year
  147. Dim i, iSelYear as Integer
  148. Dim SelYear as String
  149. '    DlgCalendar.Visible = False
  150.  
  151.     oSheets = oDocument.sheets
  152.     Call CalSaveOwnData()
  153.     UnprotectSheets(oSheets)
  154.     oSheets.RemovebyName(oSheets.GetbyIndex(0).Name)
  155.     iSelYear = DlgCalModel.txtYear.Value
  156.     Select Case sCurLangLocale
  157.         Case cLANGUAGE_GERMAN
  158.             If Ubound(DlgCalModel.lstHolidays.SelectedItems()) > -1 Then
  159.                 CalChoosenLand = DlgCalModel.lstHolidays.SelectedItems(0)
  160.             Else
  161.                 CalChoosenLand = 0
  162.             End If
  163.             Call CalFindWholeYearHolidays_GERMANY(iSelYear, CalChoosenLand)
  164.         Case cLANGUAGE_ENGLISH
  165.             Call FindWholeYearHolidays_US(iSelYear)
  166.         Case cLANGUAGE_FRENCH
  167.             Call FindWholeYearHolidays_FRANCE(iSelYear)
  168.         Case cLANGUAGE_ITALIAN
  169.             Call FindWholeYearHolidays_ITA(iSelYear)
  170.         Case cLANGUAGE_SPANISH
  171.             Call FindWholeYearHolidays_SPAIN(iSelYear)
  172.         Case cLANGUAGE_PORTUGUESE
  173.             Call FindWholeYearHolidays_PORT(iSelYear)
  174.         Case cLANGUAGE_DUTCH
  175.             Call FindWholeYearHolidays_NL(iSelYear)
  176.         Case cLANGUAGE_SWEDISH
  177.             Call FindWholeYearHolidays_SWED(iSelYear)
  178.         Case cLANGUAGE_DANISH
  179.             Call FindWholeYearHolidays_DK(iSelYear)
  180.         Case cLANGUAGE_POLISH
  181.             Call FindWholeYearHolidays_PL(iSelYear)
  182.         Case cLANGUAGE_RUSSIAN
  183.             Call FindWholeYearHolidays_RU(iSelYear)
  184.         Case cLANGUAGE_JAPANESE
  185.             Call FindWholeYearHolidays_JP(iSelYear)
  186.         Case cLANGUAGE_CHINESE
  187.             If sCurCountryLocale = "TW" Then
  188.                 Call FindWholeYearHolidays_TW(iSelYear)
  189.             Else
  190.                 Call FindWholeYearHolidays_CN(iSelYear)
  191.             End If
  192.     End Select
  193.  
  194.     Call CalInsertOwnDataInTables(iSelYear)
  195.  
  196.     If DlgCalModel.optYear.State = 1 Then
  197.         oSheets.RemovebyName(oSheets.GetbyIndex(0).Name)
  198.         oSheet = oSheets.GetbyIndex(0)
  199.         oSheet.Name = sCalendarTitle$ + " " + iSelYear
  200.         oDocument.AddActionLock
  201.         Call CalCreateYearTable(iSelYear)
  202.     ElseIf DlgCalModel.optMonth.State = 1 Then
  203.         Dim iMonth
  204.         iMonth = DlgCalModel.lstMonth.SelectedItems(0) + 1
  205.         oSheets.RemovebyName(oSheets.GetbyIndex(1).Name)
  206.         oSheet = oSheets.GetbyIndex(0)
  207.         If sMonthTitle = "" Then
  208.             oSheet.Name = cCalLongMonthNames(iMonth-1)
  209.         Else
  210.             oSheet.Name = sMonthTitle + " " + cCalLongMonthNames(iMonth-1)
  211.         End If
  212.         oDocument.AddActionLock
  213.         Call CalCreateMonthTable(iSelYear, iMonth)
  214.     End If
  215.  
  216.     oDocument.RemoveActionLock
  217.     oSheet.protect("")
  218.     oStatusLine.End
  219.     DlgCalendar.EndExecute()
  220.     bCancelTask = True
  221. End Sub
  222. </script:module>