home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri Kaikille K-CD 2002 #3 / K-CD_2002-03.iso / OpenOffice / f_0109 / ModuleAgenda.xba < prev    next >
Extensible Markup Language  |  2001-06-08  |  8KB  |  203 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="ModuleAgenda" script:language="StarBasic">' All variables must be declared before use
  4. Option Explicit
  5.  
  6. ' Used for "disabling" the cancel button of the dialog
  7. Public DialogExited As Boolean
  8. Dim DlgAgenda_gMyName as String
  9. 'Dim DlgAgenda_gMsgNoCancel$
  10. Public TemplateDialog as Object
  11. Public DialogModel as Object
  12. Public sTrueContent as String
  13. Public Bookmarkname as String
  14.  
  15.  
  16.  
  17. Sub Initialize()
  18. ' User sets the type of minutes
  19.         BasicLibraries.LoadLibrary( "Tools" )
  20.     TemplateDialog = LoadDialog("Template", "TemplateDialog")
  21.     DialogModel = TemplateDialog.Model
  22.     DialogModel.Step = 1
  23.     LoadLanguageAgenda()
  24.     DialogModel.OptAgenda2.State = TRUE
  25.     DialogExited = FALSE
  26.     TemplateDialog.Execute
  27. End Sub
  28.  
  29.  
  30. Sub LoadLanguageAgenda()
  31.     If InitResources("'Template'", "tpl") Then
  32.         DlgAgenda_gMyName = GetResText(1200)
  33.         DialogModel.CmdCancel.Label = GetResText(1102)
  34.         DialogModel.CmdAgdGoon.Label = GetResText(1103)
  35. '        DlgAgenda_gMsgNoCancel$ = GetResText(1201)
  36.         DialogModel.FrmAgenda.Label = GetResText(1202)
  37.         DialogModel.OptAgenda1.Label = GetResText(1203)
  38.         DialogModel.OptAgenda2.Label = GetResText(1204)
  39. '        DialogModel.OptAgenda1.State = 1
  40.     End If
  41. End Sub
  42.  
  43.  
  44. Sub ModifyTemplate()
  45. Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
  46. Dim i as Integer
  47.  
  48.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  49.     oBookMarks = oDocument.Bookmarks
  50.  
  51.     On Local Error Goto NOBOOKMARK
  52. ' Todo: auch beim Schlie├ƒen des Dialogs muss was passieren
  53.     TemplateDialog.EndExecute
  54.     DialogExited = TRUE
  55.     oBookmarkCursor = CreateBookmarkCursor(oDocument, BookmarkName)
  56.     oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True)
  57.     ' Delete all the Bookmarks except for the one named "NextTopic"
  58.     For i = oBookmarks.Count-1 To 0 Step -1
  59.         oBookMark = oBookMarks.GetByIndex(i)
  60.         If oBookMark.Name <> "NextTopic" Then
  61.             oBookMark.Dispose()
  62.         End If
  63.     Next i
  64.     oBookMarkCursor = CreateBookmarkCursor(oDocument, "NextTopic")
  65.     If Not IsNull(oBookMarkCursor) Then
  66.         oTextField = oBookMarkCursor.TextField
  67. ' Todo: Was ist mit der Property 'TrueContent' geschehen?
  68. '        oTextField.TrueContent =     sTrueContent
  69.         oTextField.Content = sTrueContent
  70.     End If
  71.  
  72.     NOBOOKMARK:
  73.     If Err <> 0 Then
  74.         RESUME NEXT
  75.     End If
  76. End Sub
  77.  
  78.  
  79. ' Attention This Sub is also called from the correspondence stuff
  80. Sub DisposeDocument
  81.     TemplateDialog.EndExecute
  82.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  83.     oDocument.Dispose
  84. End Sub
  85.  
  86.  
  87. Sub NewTopic
  88. ' Add a new topic to the agenda
  89. Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
  90. Dim oBaustein, oAutoText, oAutoGroup as Object
  91. Dim i as Integer
  92.  
  93.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  94.     oBookMarkCursor = CreateBookMarkCursor(oDocument, "NextTopic")
  95.     oTextField = oBookMarkCursor.TextField
  96.     oAutoText = CreateUnoService("com.sun.star.text.AutoTextContainer")
  97.     If oAutoText.HasbyName("template") Then
  98.         oAutoGroup = oAutoText.GetbyName("template")
  99.         If oAutoGroup.HasbyName(oTextField.Content) Then
  100.             oBaustein = oAutoGroup.GetbyName(oTextField.Content)
  101.             oBaustein.ApplyTo(oBookMarkCursor)
  102.         Else
  103.             Msgbox("AutoText '" & oTextField.Content & "' is not existing. Cannot insert additional topic!")
  104.         End If
  105.     Else
  106.         Msgbox("AutoGroupField template is not existing. Cannot insert additional topic!", 16, DlgAgenda_gMyName )
  107.     End If
  108. End Sub
  109.  
  110.  
  111.  
  112. ' Add initials, date and time at bottom of agenda, disable and hide command buttons
  113. Sub FinishAgenda
  114. Dim BtnAddAgendaTopic As Object
  115. Dim BtnFinishAgenda As Object
  116. Dim oUserField, oDateTimeField as Object
  117. Dim oBookmarkCursor as Object
  118. Dim oFormats, oLocale as Object
  119. Dim iDateTimeKey as Integer
  120.  
  121.         BasicLibraries.LoadLibrary( "Tools" )
  122.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  123.  
  124.     oUserField = oDocument.CreateInstance("com.sun.star.text.TextField.ExtendedUser")
  125.     oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
  126.  
  127.     oDateTimeField = oDocument.CreateInstance("com.sun.star.text.TextField.DateTime")
  128.  
  129.     ' Assign Standardformat to Datetime-Textfield
  130.     oFormats = oDocument.Numberformats
  131.     oLocale = oDocument.CharLocale
  132.     iDateTimeKey = oFormats.GetStandardFormat(com.sun.star.util.NumberFormat.DATETIME,oLocale)
  133.     oDateTimeField.NumberFormat = iDateTimeKey
  134.  
  135.     oBookmarkCursor = CreateBookmarkCursor(oDocument, "NextTopic")
  136.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False)
  137.     oBookmarkCursor.Text.InsertString(oBookmarkCursor," ",False)
  138.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False)
  139.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  140.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  141.     If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE
  142.     If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE
  143. End Sub
  144.  
  145.  
  146. Function CreateBookMarkCursor(oDocument as Object,sBookmarkName as String)
  147.     oBookMarks = oDocument.Bookmarks
  148.     If oBookmarks.HasbyName(sBookmarkName) Then
  149.         oBookMark = oBookMarks.GetbyName(sBookmarkName)
  150.         CreateBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
  151.     Else
  152.         Msgbox "Bookmark " & sBookmarkName &  " is not defined!"
  153.     End If
  154. End Function
  155.  
  156.  
  157.  
  158. Sub DeleteButtons
  159. Dim AgendaFinished As Boolean
  160. Dim BtnAddAgendaTopic As Object
  161. Dim BtnFinishAgenda As Object
  162.  
  163.     oDocument = StarDesktop.ActiveFrame.Controller.Model
  164.  
  165.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  166.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  167.  
  168.     ' If buttons could be accessed: If at least one button is disabled, then agenda is finished
  169.     AgendaFinished = FALSE
  170.     If Not IsNull(BtnAddAgendaTopic) Then
  171.         AgendaFinished = (AgendaFinished Or (BtnAddAgendaTopic.Enabled = FALSE))
  172.     End If
  173.  
  174.     If Not IsNull(BtnFinishAgenda) Then
  175.         AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE))
  176.     End If
  177.  
  178.     ' Delete Buttons, empty rows at end of document & macro bindings if agenda is finished
  179.     If AgendaFinished Then
  180.         DisposeControl(oDocument, "BtnAddAgendaTopic")
  181.         DisposeControl(oDocument, "BtnFinishAgenda")
  182.  
  183.         oBookmarkCursor = CreateBookMarkCursor(oDocument,"NextTopic")
  184.         oBookMarkCursor.GotoEnd(True)
  185.         oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True)
  186.  
  187.         AttachBasicMacroToEvent(oDocument,"OnNew", "")
  188.         AttachBasicMacroToEvent(oDocument,"OnSave", "")
  189.         AttachBasicMacroToEvent(oDocument,"OnSaveAs", "")
  190.         AttachBasicMacroToEvent(oDocument,"OnPrint", "")
  191.     End If
  192. End Sub
  193.  
  194.  
  195. Sub GetOptionValues(aEvent as Object)
  196. Dim CurTag as String
  197. Dim Taglist() as String
  198.     CurTag = aEvent.Source.Model.Tag
  199.     Taglist() = ArrayoutOfString(CurTag, ";")
  200.     Bookmarkname = TagList(0)
  201.     sTrueContent = TagList(1)
  202. End Sub
  203. </script:module>