home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 April / PCWorld_2003-04_cd.bin / Software / Komercni / openoffice / f_0032 / CalendarMain.xba < prev    next >
Extensible Markup Language  |  2002-11-01  |  8KB  |  237 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. ' This flag serves as a query if the individual Data should be saved
  11. Public bCalOwnDataChanged as Boolean
  12.  
  13. 'BankHoliday Functions
  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. Public CalChoosenLand as Integer
  36.  
  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
  43.  
  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
  61.  
  62. Public DlgCalendar as Object
  63. Public DlgCalModel as Object
  64.  
  65.  
  66.  
  67. Sub CalAutopilotTable()
  68. Dim BitmapDir as String
  69. Dim iThisMonth as Integer
  70.  
  71. 'On Error Goto ErrorHandler
  72.     BasicLibraries.LoadLibrary("Tools")
  73.     bSelectByMouseMove = True
  74.     oDocument = ThisComponent
  75.     oStatusline = oDocument.GetCurrentController.GetFrame.CreateStatusIndicator
  76.     ToggleWindow(False)
  77.     sCurLangLocale = oDocument.CharLocale.Language
  78.     sCurCountryLocale = oDocument.CharLocale.Country
  79.     DlgCalendar = LoadDialog("Schedule", "DlgCalendar")
  80.     DlgCalModel = DlgCalendar.Model
  81.     LoadLanguage(sCurLangLocale)
  82.     CalInitGlobalVariablesDate()
  83.     BitmapDir = GetOfficeSubPath("Template","wizard/bitmap")
  84.     DlgCalModel.imgCountry.ImageURL = BitmapDir & sBitmapFilename
  85.     CalChoosenLand = -2
  86.     CalLoadOwnData()
  87.     
  88. '    sCurLanguage = "ja"
  89.     With DlgCalModel
  90.         .cmdDelete.Enabled = False
  91.         .lstMonth.StringItemList() = cCalShortMonthNames()
  92.         Select Case sCurLangLocale
  93.             Case "ja"
  94.                 .lstOwnData.FontName = "HG Mincho Light J"
  95.                 .txtEvent.FontName = "HG Mincho Light J"
  96.             Case "zh"
  97.                 If oDocument.CharLocale.Country = "CN" Then
  98.                     .lstOwnData.FontName = "HG MSung Light SC"
  99.                     .txtEvent.FontName = "HG MSung Light SC"
  100.                 Else
  101.                     .lstOwnData.FontName = "HG MSung Light TC"
  102.                     .txtEvent.FontName = "HG MSung Light TC"
  103.                 End If
  104.             Case "ko"
  105.                 .lstOwnData.FontName = "HG MyeongJo Light K"
  106.                 .txtEvent.FontName = "HG MyeongJo Light K"
  107.         End Select
  108.         .lstOwnEventMonth.StringItemList() = cCalShortMonthNames()
  109.         .optYear.State = 1
  110.         .txtYear.Value = Year(Now())
  111.         .txtYear.Tag = .txtYear.Value
  112.         .Step = 1
  113.     End With
  114.     CalChooseCalendar()  ' month
  115.     iThisMonth = Month(Now)
  116.     DlgCalendar.GetControl("lstMonth").SelectItemPos(iThisMonth-1, True)
  117.     DlgCalendar.GetControl("lstHolidays").SelectItemPos(0,True)
  118.     DlgCalModel.cmdGoOn.DefaultButton = True
  119.     ToggleWindow(True)
  120.     DlgCalendar.GetControl("lblHolidays").Visible = sCurLangLocale  = cLANGUAGE_GERMAN
  121.     DlgCalendar.GetControl("lstHolidays").Visible = sCurLangLocale  = cLANGUAGE_GERMAN    
  122.     fHeightCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Height/198
  123.     fWidthCorrFactor = DlgCalendar.GetControl("imgCountry").Size.Width/166
  124.     DlgCalendar.Execute()
  125.     DlgCalendar.Dispose()
  126.     Exit Sub
  127. ErrorHandler:
  128.     MsgBox(sError$, 16, sWizardTitle$)
  129. End Sub
  130.  
  131.  
  132. Sub CalChooseCalendar()
  133.     With DlgCalModel
  134.         .lstMonth.Enabled = .optMonth.State = 1
  135.         .lblMonth.Enabled = .optMonth.State = 1
  136.     End With
  137. End Sub
  138.  
  139.  
  140. Sub CalcmdCancel()
  141.     Call CalSaveOwnData()
  142.     DlgCalendar.EndExecute
  143. End Sub
  144.  
  145.  
  146.  
  147. Sub CalcmdOk()
  148.     ' cmdOk is called when the Button 'Read' is clicked on
  149.     ' It is either given out a month or a year
  150. Dim i as Integer
  151. Dim iSelYear as Integer
  152. Dim SelYear as String
  153.  
  154.     oSheets = oDocument.sheets
  155.     Call CalSaveOwnData()
  156.     UnprotectSheets(oSheets)
  157.     oSheets.RemovebyName(oSheets.GetbyIndex(0).Name)
  158.     iSelYear = DlgCalModel.txtYear.Value
  159.     If DlgCalModel.optYear.State = 1 Then
  160.         oSheets.RemovebyName(oSheets.GetbyIndex(0).Name)
  161.         oSheet = oSheets.GetbyIndex(0)
  162.         oSheet.Name = sCalendarTitle$ + " " + iSelYear
  163.         InsertLocalBankholidays(iSelYear)        
  164.         CalInsertOwnDataInTables(iSelYear)
  165.         oDocument.AddActionLock()
  166.         CalCreateYearTable(iSelYear)
  167.     ElseIf DlgCalModel.optMonth.State = 1 Then
  168.         Dim iMonth
  169.         iMonth = DlgCalModel.lstMonth.SelectedItems(0) + 1
  170.         oSheets.RemovebyName(oSheets.GetbyIndex(1).Name)
  171.         oSheet = oSheets.GetbyIndex(0)
  172.         If sMonthTitle = "" Then
  173.             oSheet.Name = cCalLongMonthNames(iMonth-1)
  174.         Else
  175.             oSheet.Name = sMonthTitle + " " + cCalLongMonthNames(iMonth-1)
  176.         End If
  177.         InsertLocalBankholidays(iSelYear)        
  178.         CalInsertOwnDataInTables(iSelYear)
  179.         oDocument.AddActionLock
  180.         CalCreateMonthTable(iSelYear, iMonth)
  181.     End If
  182.     oDocument.RemoveActionLock
  183. '    oDocument.CalculateAll()
  184.     oSheet.protect("")
  185.     oStatusLine.End
  186.     DlgCalendar.EndExecute()
  187.     bCancelTask = True
  188. End Sub
  189.  
  190.  
  191. Sub InsertLocalBankholidays(iSelYear as Integer)
  192.     Select Case sCurLangLocale
  193.         Case cLANGUAGE_GERMAN
  194.             If Ubound(DlgCalModel.lstHolidays.SelectedItems()) > -1 Then
  195.                 CalChoosenLand = DlgCalModel.lstHolidays.SelectedItems(0)
  196.             Else
  197.                 CalChoosenLand = 0
  198.             End If
  199.             Call CalFindWholeYearHolidays_GERMANY(iSelYear, CalChoosenLand)
  200.         Case cLANGUAGE_ENGLISH
  201.             Call FindWholeYearHolidays_US(iSelYear)
  202.         Case cLANGUAGE_FRENCH
  203.             Call FindWholeYearHolidays_FRANCE(iSelYear)
  204.         Case cLANGUAGE_ITALIAN
  205.             Call FindWholeYearHolidays_ITA(iSelYear)
  206.         Case cLANGUAGE_SPANISH
  207.             Call FindWholeYearHolidays_SPAIN(iSelYear)
  208.         Case cLANGUAGE_PORTUGUESE
  209.             Call FindWholeYearHolidays_PORT(iSelYear)
  210.         Case cLANGUAGE_DUTCH
  211.             Call FindWholeYearHolidays_NL(iSelYear)
  212.         Case cLANGUAGE_SWEDISH
  213.             Call FindWholeYearHolidays_SWED(iSelYear)
  214.         Case cLANGUAGE_DANISH
  215.             Call FindWholeYearHolidays_DK(iSelYear)
  216.         Case cLANGUAGE_POLISH
  217.             Call FindWholeYearHolidays_PL(iSelYear)
  218.         Case cLANGUAGE_RUSSIAN
  219.             Call FindWholeYearHolidays_RU(iSelYear)
  220.         Case cLANGUAGE_JAPANESE
  221.             Call FindWholeYearHolidays_JP(iSelYear)
  222.         Case cLANGUAGE_CHINESE
  223.             If sCurCountryLocale = "TW" Then
  224.                 Call FindWholeYearHolidays_TW(iSelYear)
  225.             Else
  226.                 Call FindWholeYearHolidays_CN(iSelYear)
  227.             End If
  228.         Case cLANGUAGE_GREEK
  229.             Call FindWholeYearHolidays_GREEK(iSelYear)
  230.         Case cLANGUAGE_TURKISH
  231.             Call FindWholeYearHolidays_TRK(iSelYear)
  232.         Case cLANGUAGE_POLISH
  233.             Call FindWholeYearHolidays_PL(iSelYear)
  234.         Case cLANGUAGE_FINNISH
  235.             Call FindWholeYearHolidays_FI(iSelYear)
  236.     End Select
  237. End Sub</script:module>