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