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