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