home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 October / VPR0210A.ISO / OPENOFFICE / f_0110 / ModuleAgenda.xba < prev    next >
Extensible Markup Language  |  2001-11-12  |  7KB  |  202 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 = ThisComponent
  49.     oBookMarks = oDocument.Bookmarks
  50.  
  51.     On Local Error Goto NOBOOKMARK
  52. ' Todo: auch beim Schlieテ歹n 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. End Sub
  83.  
  84.  
  85. Sub NewTopic
  86. ' Add a new topic to the agenda
  87. Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
  88. Dim oBaustein, oAutoText, oAutoGroup as Object
  89. Dim i as Integer
  90.  
  91.   oDocument = ThisComponent
  92.     oBookMarkCursor = CreateBookMarkCursor(oDocument, "NextTopic")
  93.     oTextField = oBookMarkCursor.TextField
  94.     oAutoText = CreateUnoService("com.sun.star.text.AutoTextContainer")
  95.     If oAutoText.HasbyName("template") Then
  96.         oAutoGroup = oAutoText.GetbyName("template")
  97.         If oAutoGroup.HasbyName(oTextField.Content) Then
  98.             oBaustein = oAutoGroup.GetbyName(oTextField.Content)
  99.             oBaustein.ApplyTo(oBookMarkCursor)
  100.         Else
  101.             Msgbox("AutoText '" & oTextField.Content & "' is not existing. Cannot insert additional topic!")
  102.         End If
  103.     Else
  104.         Msgbox("AutoGroupField template is not existing. Cannot insert additional topic!", 16, DlgAgenda_gMyName )
  105.     End If
  106. End Sub
  107.  
  108.  
  109.  
  110. ' Add initials, date and time at bottom of agenda, disable and hide command buttons
  111. Sub FinishAgenda
  112. Dim BtnAddAgendaTopic As Object
  113. Dim BtnFinishAgenda As Object
  114. Dim oUserField, oDateTimeField as Object
  115. Dim oBookmarkCursor as Object
  116. Dim oFormats, oLocale as Object
  117. Dim iDateTimeKey as Integer
  118.  
  119.         BasicLibraries.LoadLibrary( "Tools" )
  120.   oDocument = ThisComponent
  121.  
  122.     oUserField = oDocument.CreateInstance("com.sun.star.text.TextField.ExtendedUser")
  123.     oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
  124.  
  125.     oDateTimeField = oDocument.CreateInstance("com.sun.star.text.TextField.DateTime")
  126.  
  127.     ' Assign Standardformat to Datetime-Textfield
  128.     oFormats = oDocument.Numberformats
  129.     oLocale = oDocument.CharLocale
  130.     iDateTimeKey = oFormats.GetStandardFormat(com.sun.star.util.NumberFormat.DATETIME,oLocale)
  131.     oDateTimeField.NumberFormat = iDateTimeKey
  132.  
  133.     oBookmarkCursor = CreateBookmarkCursor(oDocument, "NextTopic")
  134.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False)
  135.     oBookmarkCursor.Text.InsertString(oBookmarkCursor," ",False)
  136.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False)
  137.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  138.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  139.     If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE
  140.     If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE
  141. End Sub
  142.  
  143.  
  144. Function CreateBookMarkCursor(oDocument as Object,sBookmarkName as String)
  145.     oBookMarks = oDocument.Bookmarks
  146.     If oBookmarks.HasbyName(sBookmarkName) Then
  147.         oBookMark = oBookMarks.GetbyName(sBookmarkName)
  148.         CreateBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
  149.     Else
  150.         Msgbox "Bookmark " & sBookmarkName &  " is not defined!"
  151.     End If
  152. End Function
  153.  
  154.  
  155.  
  156. Sub DeleteButtons
  157. Dim AgendaFinished As Boolean
  158. Dim BtnAddAgendaTopic As Object
  159. Dim BtnFinishAgenda As Object
  160.  
  161.   oDocument = ThisComponent
  162.  
  163.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  164.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  165.  
  166.     ' If buttons could be accessed: If at least one button is disabled, then agenda is finished
  167.     AgendaFinished = FALSE
  168.     If Not IsNull(BtnAddAgendaTopic) Then
  169.         AgendaFinished = (AgendaFinished Or (BtnAddAgendaTopic.Enabled = FALSE))
  170.     End If
  171.  
  172.     If Not IsNull(BtnFinishAgenda) Then
  173.         AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE))
  174.     End If
  175.  
  176.     ' Delete Buttons, empty rows at end of document & macro bindings if agenda is finished
  177.     If AgendaFinished Then
  178.         DisposeControl(oDocument, "BtnAddAgendaTopic")
  179.         DisposeControl(oDocument, "BtnFinishAgenda")
  180.  
  181.         oBookmarkCursor = CreateBookMarkCursor(oDocument,"NextTopic")
  182.         oBookMarkCursor.GotoEnd(True)
  183.         oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True)
  184.  
  185.         AttachBasicMacroToEvent(oDocument,"OnNew", "")
  186.         AttachBasicMacroToEvent(oDocument,"OnSave", "")
  187.         AttachBasicMacroToEvent(oDocument,"OnSaveAs", "")
  188.         AttachBasicMacroToEvent(oDocument,"OnPrint", "")
  189.     End If
  190. End Sub
  191.  
  192.  
  193. Sub GetOptionValues(aEvent as Object)
  194. Dim CurTag as String
  195. Dim Taglist() as String
  196.     CurTag = aEvent.Source.Model.Tag
  197.     Taglist() = ArrayoutOfString(CurTag, ";")
  198.     Bookmarkname = TagList(0)
  199.     sTrueContent = TagList(1)
  200. End Sub
  201. </script:module>
  202.