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">' All variables must be declared before use 24*b1cdbd2cSJim JagielskiOption Explicit 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski' Used for "disabling" 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' User sets the type of minutes 38*b1cdbd2cSJim Jagielski BasicLibraries.LoadLibrary( "Tools" ) 39*b1cdbd2cSJim Jagielski TemplateDialog = LoadDialog("Template", "TemplateDialog") 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("'Template'", "tpl") 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' 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' 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,"",True) 76*b1cdbd2cSJim Jagielski ' Delete all the Bookmarks except for the one named "NextTopic" 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 <> "NextTopic" Then 80*b1cdbd2cSJim Jagielski oBookMark.Dispose() 81*b1cdbd2cSJim Jagielski End If 82*b1cdbd2cSJim Jagielski Next i 83*b1cdbd2cSJim Jagielski oBookMarkCursor = CreateBookmarkCursor(oDocument, "NextTopic") 84*b1cdbd2cSJim Jagielski If Not IsNull(oBookMarkCursor) Then 85*b1cdbd2cSJim Jagielski oTextField = oBookMarkCursor.TextField 86*b1cdbd2cSJim Jagielski' 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 <> 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' 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, "NextTopic") 105*b1cdbd2cSJim Jagielski oTextField = oBookMarkCursor.TextField 106*b1cdbd2cSJim Jagielski oAutoText = CreateUnoService("com.sun.star.text.AutoTextContainer") 107*b1cdbd2cSJim Jagielski If oAutoText.HasbyName("template") Then 108*b1cdbd2cSJim Jagielski oAutoGroup = oAutoText.GetbyName("template") 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("AutoText '" & oTextField.Content & "' is not existing. Cannot insert additional topic!") 114*b1cdbd2cSJim Jagielski End If 115*b1cdbd2cSJim Jagielski Else 116*b1cdbd2cSJim Jagielski Msgbox("AutoGroupField template is not existing. Cannot insert additional topic!", 16, DlgAgenda_gMyName ) 117*b1cdbd2cSJim Jagielski End If 118*b1cdbd2cSJim JagielskiEnd Sub 119*b1cdbd2cSJim Jagielski 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski' 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( "Tools" ) 132*b1cdbd2cSJim Jagielski oDocument = ThisComponent 133*b1cdbd2cSJim Jagielski 134*b1cdbd2cSJim Jagielski oUserField = oDocument.CreateInstance("com.sun.star.text.TextField.ExtendedUser") 135*b1cdbd2cSJim Jagielski oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski oDateTimeField = oDocument.CreateInstance("com.sun.star.text.TextField.DateTime") 138*b1cdbd2cSJim Jagielski 139*b1cdbd2cSJim Jagielski ' 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, "NextTopic") 146*b1cdbd2cSJim Jagielski oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False) 147*b1cdbd2cSJim Jagielski oBookmarkCursor.Text.InsertString(oBookmarkCursor," ",False) 148*b1cdbd2cSJim Jagielski oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False) 149*b1cdbd2cSJim Jagielski BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic") 150*b1cdbd2cSJim Jagielski BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda") 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 "Bookmark " & sBookmarkName & " is not defined!" 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, "BtnAddAgendaTopic") 176*b1cdbd2cSJim Jagielski BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda") 177*b1cdbd2cSJim Jagielski 178*b1cdbd2cSJim Jagielski ' 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 ' Delete Buttons, empty rows at end of document & macro bindings if agenda is finished 189*b1cdbd2cSJim Jagielski If AgendaFinished Then 190*b1cdbd2cSJim Jagielski DisposeControl(oDocument, "BtnAddAgendaTopic") 191*b1cdbd2cSJim Jagielski DisposeControl(oDocument, "BtnFinishAgenda") 192*b1cdbd2cSJim Jagielski 193*b1cdbd2cSJim Jagielski oBookmarkCursor = CreateBookMarkCursor(oDocument,"NextTopic") 194*b1cdbd2cSJim Jagielski oBookMarkCursor.GotoEnd(True) 195*b1cdbd2cSJim Jagielski oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True) 196*b1cdbd2cSJim Jagielski 197*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnNew", "") 198*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnSave", "") 199*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnSaveAs", "") 200*b1cdbd2cSJim Jagielski AttachBasicMacroToEvent(oDocument,"OnPrint", "") 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, ";") 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