1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"ModuleAgenda" script:
language=
"StarBasic">' All variables must be declared before use
23 ' Used for
"disabling
" the cancel button of the dialog
24 Public DialogExited As Boolean
25 Dim DlgAgenda_gMyName as String
26 Public TemplateDialog as Object
27 Public DialogModel as Object
28 Public sTrueContent as String
29 Public Bookmarkname as String
34 ' User sets the type of minutes
35 BasicLibraries.LoadLibrary(
"Tools
" )
36 TemplateDialog = LoadDialog(
"Template
",
"TemplateDialog
")
37 DialogModel = TemplateDialog.Model
40 DialogModel.OptAgenda2.State = TRUE
43 TemplateDialog.Execute
47 Sub LoadLanguageAgenda()
48 If InitResources(
"'Template
'") Then
49 DlgAgenda_gMyName = GetResText(
"AgendaDlgName
")
50 DialogModel.CmdCancel.Label = GetResText(
"STYLES_2
")
51 DialogModel.CmdAgdGoon.Label = GetResText(
"STYLES_3
")
52 ' DlgAgenda_gMsgNoCancel$ = GetResText(
"AgendaDlgNoCancel
")
53 DialogModel.FrmAgenda.Label = GetResText(
"AgendaDlgFrame
")
54 DialogModel.OptAgenda1.Label = GetResText(
"AgendaDlgButton1
")
55 DialogModel.OptAgenda2.Label = GetResText(
"AgendaDlgButton2
")
56 ' DialogModel.OptAgenda1.State =
1
62 Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
65 oDocument = ThisComponent
66 oBookMarks = oDocument.Bookmarks
68 On Local Error Goto NOBOOKMARK
69 TemplateDialog.EndExecute
71 oBookmarkCursor = CreateBookmarkCursor(oDocument, BookmarkName)
72 oBookmarkCursor.Text.insertString(oBookmarkCursor,
"",True)
73 ' Delete all the Bookmarks except for the one named
"NextTopic
"
74 For i = oBookmarks.Count-
1 To
0 Step -
1
75 oBookMark = oBookMarks.GetByIndex(i)
76 If oBookMark.Name
<> "NextTopic
" Then
80 oBookMarkCursor = CreateBookmarkCursor(oDocument,
"NextTopic
")
81 If Not IsNull(oBookMarkCursor) Then
82 oTextField = oBookMarkCursor.TextField
83 ' oTextField.TrueContent = sTrueContent
84 oTextField.Content = sTrueContent
88 If Err
<> 0 Then
95 ' Add a new topic to the agenda
96 Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
97 Dim oBaustein, oAutoText, oAutoGroup as Object
100 oDocument = ThisComponent
101 oBookMarkCursor = CreateBookMarkCursor(oDocument,
"NextTopic
")
102 oTextField = oBookMarkCursor.TextField
103 oAutoText = CreateUnoService(
"com.sun.star.text.AutoTextContainer
")
104 If oAutoText.HasbyName(
"template
") Then
105 oAutoGroup = oAutoText.GetbyName(
"template
")
106 If oAutoGroup.HasbyName(oTextField.Content) Then
107 oBaustein = oAutoGroup.GetbyName(oTextField.Content)
108 oBaustein.ApplyTo(oBookMarkCursor)
110 Msgbox(
"AutoText
'" & oTextField.Content
& "' is not existing. Cannot insert additional topic!
")
113 Msgbox(
"AutoGroupField template is not existing. Cannot insert additional topic!
",
16, DlgAgenda_gMyName )
119 ' Add initials, date and time at bottom of agenda, disable and hide command buttons
121 Dim BtnAddAgendaTopic As Object
122 Dim BtnFinishAgenda As Object
123 Dim oUserField, oDateTimeField as Object
124 Dim oBookmarkCursor as Object
125 Dim oFormats, oLocale as Object
126 Dim iDateTimeKey as Integer
128 BasicLibraries.LoadLibrary(
"Tools
" )
129 oDocument = ThisComponent
131 oUserField = oDocument.CreateInstance(
"com.sun.star.text.TextField.ExtendedUser
")
132 oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
134 oDateTimeField = oDocument.CreateInstance(
"com.sun.star.text.TextField.DateTime
")
136 ' Assign Standardformat to Datetime-Textfield
137 oFormats = oDocument.Numberformats
138 oLocale = oDocument.CharLocale
139 iDateTimeKey = oFormats.GetStandardFormat(com.sun.star.util.NumberFormat.DATETIME,oLocale)
140 oDateTimeField.NumberFormat = iDateTimeKey
142 oBookmarkCursor = CreateBookmarkCursor(oDocument,
"NextTopic
")
143 oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False)
144 oBookmarkCursor.Text.InsertString(oBookmarkCursor,
" ",False)
145 oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False)
146 BtnAddAgendaTopic = getControlModel(oDocument,
"BtnAddAgendaTopic
")
147 BtnFinishAgenda = getControlModel(oDocument,
"BtnFinishAgenda
")
148 If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE
149 If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE
153 Function CreateBookMarkCursor(oDocument as Object,sBookmarkName as String)
154 oBookMarks = oDocument.Bookmarks
155 If oBookmarks.HasbyName(sBookmarkName) Then
156 oBookMark = oBookMarks.GetbyName(sBookmarkName)
157 CreateBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
159 Msgbox
"Bookmark
" & sBookmarkName
& " is not defined!
"
166 Dim AgendaFinished As Boolean
167 Dim BtnAddAgendaTopic As Object
168 Dim BtnFinishAgenda As Object
170 oDocument = ThisComponent
172 BtnAddAgendaTopic = getControlModel(oDocument,
"BtnAddAgendaTopic
")
173 BtnFinishAgenda = getControlModel(oDocument,
"BtnFinishAgenda
")
175 ' If buttons could be accessed: If at least one button is disabled, then agenda is finished
176 AgendaFinished = FALSE
177 If Not IsNull(BtnAddAgendaTopic) Then
178 AgendaFinished = (AgendaFinished Or (BtnAddAgendaTopic.Enabled = FALSE))
181 If Not IsNull(BtnFinishAgenda) Then
182 AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE))
185 ' Delete Buttons, empty rows at end of document
& macro bindings if agenda is finished
186 If AgendaFinished Then
187 DisposeControl(oDocument,
"BtnAddAgendaTopic
")
188 DisposeControl(oDocument,
"BtnFinishAgenda
")
190 oBookmarkCursor = CreateBookMarkCursor(oDocument,
"NextTopic
")
191 oBookMarkCursor.GotoEnd(True)
192 oBookmarkCursor.Text.insertString(oBookmarkCursor,
"",True)
194 AttachBasicMacroToEvent(oDocument,
"OnNew
",
"")
195 AttachBasicMacroToEvent(oDocument,
"OnSave
",
"")
196 AttachBasicMacroToEvent(oDocument,
"OnSaveAs
",
"")
197 AttachBasicMacroToEvent(oDocument,
"OnPrint
",
"")
203 Sub GetOptionValues(Optional aEvent as Object)
205 Dim Taglist() as String
206 If Not IsMissing(aEvent) Then
207 CurTag = aEvent.Source.Model.Tag
209 If DialogModel.OptAgenda1.State = TRUE Then
210 CurTag = DialogModel.OptAgenda1.Tag
212 CurTag = DialogModel.OptAgenda2.Tag
215 Taglist() = ArrayoutOfString(CurTag,
";
")
216 Bookmarkname = TagList(
0)
217 sTrueContent = TagList(
1)