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
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
17 ' User sets the type of minutes
18 BasicLibraries.LoadLibrary(
"Tools
" )
19 TemplateDialog = LoadDialog(
"Template
",
"TemplateDialog
")
20 DialogModel = TemplateDialog.Model
23 DialogModel.OptAgenda2.State = TRUE
26 TemplateDialog.Execute
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
45 Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
48 oDocument = ThisComponent
49 oBookMarks = oDocument.Bookmarks
51 On Local Error Goto NOBOOKMARK
52 TemplateDialog.EndExecute
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
63 oBookMarkCursor = CreateBookmarkCursor(oDocument,
"NextTopic
")
64 If Not IsNull(oBookMarkCursor) Then
65 oTextField = oBookMarkCursor.TextField
66 ' oTextField.TrueContent = sTrueContent
67 oTextField.Content = sTrueContent
71 If Err
<> 0 Then
78 ' Add a new topic to the agenda
79 Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
80 Dim oBaustein, oAutoText, oAutoGroup as Object
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)
93 Msgbox(
"AutoText
'" & oTextField.Content
& "' is not existing. Cannot insert additional topic!
")
96 Msgbox(
"AutoGroupField template is not existing. Cannot insert additional topic!
",
16, DlgAgenda_gMyName )
102 ' Add initials, date and time at bottom of agenda, disable and hide command buttons
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
111 BasicLibraries.LoadLibrary(
"Tools
" )
112 oDocument = ThisComponent
114 oUserField = oDocument.CreateInstance(
"com.sun.star.text.TextField.ExtendedUser
")
115 oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
117 oDateTimeField = oDocument.CreateInstance(
"com.sun.star.text.TextField.DateTime
")
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
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
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)
142 Msgbox
"Bookmark
" & sBookmarkName
& " is not defined!
"
149 Dim AgendaFinished As Boolean
150 Dim BtnAddAgendaTopic As Object
151 Dim BtnFinishAgenda As Object
153 oDocument = ThisComponent
155 BtnAddAgendaTopic = getControlModel(oDocument,
"BtnAddAgendaTopic
")
156 BtnFinishAgenda = getControlModel(oDocument,
"BtnFinishAgenda
")
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))
164 If Not IsNull(BtnFinishAgenda) Then
165 AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE))
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
")
173 oBookmarkCursor = CreateBookMarkCursor(oDocument,
"NextTopic
")
174 oBookMarkCursor.GotoEnd(True)
175 oBookmarkCursor.Text.insertString(oBookmarkCursor,
"",True)
177 AttachBasicMacroToEvent(oDocument,
"OnNew
",
"")
178 AttachBasicMacroToEvent(oDocument,
"OnSave
",
"")
179 AttachBasicMacroToEvent(oDocument,
"OnSaveAs
",
"")
180 AttachBasicMacroToEvent(oDocument,
"OnPrint
",
"")
186 Sub GetOptionValues(Optional aEvent as Object)
188 Dim Taglist() as String
189 If Not IsMissing(aEvent) Then
190 CurTag = aEvent.Source.Model.Tag
192 If DialogModel.OptAgenda1.State = TRUE Then
193 CurTag = DialogModel.OptAgenda1.Tag
195 CurTag = DialogModel.OptAgenda2.Tag
198 Taglist() = ArrayoutOfString(CurTag,
";
")
199 Bookmarkname = TagList(
0)
200 sTrueContent = TagList(
1)