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 Public TemplateDialog as Object 10 Public DialogModel as Object 11 Public sTrueContent as String 12 Public Bookmarkname as String 13 14 15 16 Sub Initialize() 17 ' User sets the type of minutes 18 BasicLibraries.LoadLibrary( "Tools" ) 19 TemplateDialog = LoadDialog("Template", "TemplateDialog") 20 DialogModel = TemplateDialog.Model 21 DialogModel.Step = 1 22 LoadLanguageAgenda() 23 DialogModel.OptAgenda2.State = TRUE 24 GetOptionValues() 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 TemplateDialog.EndExecute 53 DialogExited = TRUE 54 oBookmarkCursor = CreateBookmarkCursor(oDocument, BookmarkName) 55 oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True) 56 ' Delete all the Bookmarks except for the one named "NextTopic" 57 For i = oBookmarks.Count-1 To 0 Step -1 58 oBookMark = oBookMarks.GetByIndex(i) 59 If oBookMark.Name <> "NextTopic" Then 60 oBookMark.Dispose() 61 End If 62 Next i 63 oBookMarkCursor = CreateBookmarkCursor(oDocument, "NextTopic") 64 If Not IsNull(oBookMarkCursor) Then 65 oTextField = oBookMarkCursor.TextField 66 ' oTextField.TrueContent = sTrueContent 67 oTextField.Content = sTrueContent 68 End If 69 70 NOBOOKMARK: 71 If Err <> 0 Then 72 RESUME NEXT 73 End If 74 End Sub 75 76 77 Sub NewTopic 78 ' Add a new topic to the agenda 79 Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object 80 Dim oBaustein, oAutoText, oAutoGroup as Object 81 Dim i as Integer 82 83 oDocument = ThisComponent 84 oBookMarkCursor = CreateBookMarkCursor(oDocument, "NextTopic") 85 oTextField = oBookMarkCursor.TextField 86 oAutoText = CreateUnoService("com.sun.star.text.AutoTextContainer") 87 If oAutoText.HasbyName("template") Then 88 oAutoGroup = oAutoText.GetbyName("template") 89 If oAutoGroup.HasbyName(oTextField.Content) Then 90 oBaustein = oAutoGroup.GetbyName(oTextField.Content) 91 oBaustein.ApplyTo(oBookMarkCursor) 92 Else 93 Msgbox("AutoText '" & oTextField.Content & "' is not existing. Cannot insert additional topic!") 94 End If 95 Else 96 Msgbox("AutoGroupField template is not existing. Cannot insert additional topic!", 16, DlgAgenda_gMyName ) 97 End If 98 End Sub 99 100 101 102 ' Add initials, date and time at bottom of agenda, disable and hide command buttons 103 Sub FinishAgenda 104 Dim BtnAddAgendaTopic As Object 105 Dim BtnFinishAgenda As Object 106 Dim oUserField, oDateTimeField as Object 107 Dim oBookmarkCursor as Object 108 Dim oFormats, oLocale as Object 109 Dim iDateTimeKey as Integer 110 111 BasicLibraries.LoadLibrary( "Tools" ) 112 oDocument = ThisComponent 113 114 oUserField = oDocument.CreateInstance("com.sun.star.text.TextField.ExtendedUser") 115 oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT 116 117 oDateTimeField = oDocument.CreateInstance("com.sun.star.text.TextField.DateTime") 118 119 ' Assign Standardformat to Datetime-Textfield 120 oFormats = oDocument.Numberformats 121 oLocale = oDocument.CharLocale 122 iDateTimeKey = oFormats.GetStandardFormat(com.sun.star.util.NumberFormat.DATETIME,oLocale) 123 oDateTimeField.NumberFormat = iDateTimeKey 124 125 oBookmarkCursor = CreateBookmarkCursor(oDocument, "NextTopic") 126 oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False) 127 oBookmarkCursor.Text.InsertString(oBookmarkCursor," ",False) 128 oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False) 129 BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic") 130 BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda") 131 If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE 132 If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE 133 End Sub 134 135 136 Function CreateBookMarkCursor(oDocument as Object,sBookmarkName as String) 137 oBookMarks = oDocument.Bookmarks 138 If oBookmarks.HasbyName(sBookmarkName) Then 139 oBookMark = oBookMarks.GetbyName(sBookmarkName) 140 CreateBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor) 141 Else 142 Msgbox "Bookmark " & sBookmarkName & " is not defined!" 143 End If 144 End Function 145 146 147 148 Sub DeleteButtons 149 Dim AgendaFinished As Boolean 150 Dim BtnAddAgendaTopic As Object 151 Dim BtnFinishAgenda As Object 152 153 oDocument = ThisComponent 154 155 BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic") 156 BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda") 157 158 ' If buttons could be accessed: If at least one button is disabled, then agenda is finished 159 AgendaFinished = FALSE 160 If Not IsNull(BtnAddAgendaTopic) Then 161 AgendaFinished = (AgendaFinished Or (BtnAddAgendaTopic.Enabled = FALSE)) 162 End If 163 164 If Not IsNull(BtnFinishAgenda) Then 165 AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE)) 166 End If 167 168 ' Delete Buttons, empty rows at end of document & macro bindings if agenda is finished 169 If AgendaFinished Then 170 DisposeControl(oDocument, "BtnAddAgendaTopic") 171 DisposeControl(oDocument, "BtnFinishAgenda") 172 173 oBookmarkCursor = CreateBookMarkCursor(oDocument,"NextTopic") 174 oBookMarkCursor.GotoEnd(True) 175 oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True) 176 177 AttachBasicMacroToEvent(oDocument,"OnNew", "") 178 AttachBasicMacroToEvent(oDocument,"OnSave", "") 179 AttachBasicMacroToEvent(oDocument,"OnSaveAs", "") 180 AttachBasicMacroToEvent(oDocument,"OnPrint", "") 181 End If 182 End Sub 183 184 185 186 Sub GetOptionValues(Optional aEvent as Object) 187 Dim CurTag as String 188 Dim Taglist() as String 189 If Not IsMissing(aEvent) Then 190 CurTag = aEvent.Source.Model.Tag 191 Else 192 If DialogModel.OptAgenda1.State = TRUE Then 193 CurTag = DialogModel.OptAgenda1.Tag 194 Else 195 CurTag = DialogModel.OptAgenda2.Tag 196 End If 197 End If 198 Taglist() = ArrayoutOfString(CurTag, ";") 199 Bookmarkname = TagList(0) 200 sTrueContent = TagList(1) 201 End Sub 202 203 </script:module>