home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Bureautique / OpenOffice / Apache_OpenOffice_4.1.1_Win_x86_install_fr.exe / openoffice1.cab / ModuleAgenda.xba < prev    next >
Extensible Markup Language  |  2014-02-25  |  8KB  |  224 lines

  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">' All variables must be declared before use
  24. Option Explicit
  25.  
  26. ' Used for "disabling" the cancel button of the dialog
  27. Public DialogExited As Boolean
  28. Dim DlgAgenda_gMyName as String
  29. Public TemplateDialog as Object
  30. Public DialogModel as Object
  31. Public sTrueContent as String
  32. Public Bookmarkname as String
  33.  
  34.  
  35.  
  36. Sub Initialize()
  37. ' User sets the type of minutes
  38.         BasicLibraries.LoadLibrary( "Tools" )
  39.     TemplateDialog = LoadDialog("Template", "TemplateDialog")
  40.     DialogModel = TemplateDialog.Model
  41.     DialogModel.Step = 1
  42.     LoadLanguageAgenda()
  43.     DialogModel.OptAgenda2.State = TRUE
  44.     GetOptionValues()
  45.     DialogExited = FALSE
  46.     TemplateDialog.Execute
  47. End Sub
  48.  
  49.  
  50. Sub LoadLanguageAgenda()
  51.     If InitResources("'Template'", "tpl") Then
  52.         DlgAgenda_gMyName = GetResText(1200)
  53.         DialogModel.CmdCancel.Label = GetResText(1102)
  54.         DialogModel.CmdAgdGoon.Label = GetResText(1103)
  55. '        DlgAgenda_gMsgNoCancel$ = GetResText(1201)
  56.         DialogModel.FrmAgenda.Label = GetResText(1202)
  57.         DialogModel.OptAgenda1.Label = GetResText(1203)
  58.         DialogModel.OptAgenda2.Label = GetResText(1204)
  59. '        DialogModel.OptAgenda1.State = 1
  60.     End If
  61. End Sub
  62.  
  63.  
  64. Sub ModifyTemplate()
  65. Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
  66. Dim 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,"",True)
  76.     ' Delete all the Bookmarks except for the one named "NextTopic"
  77.     For i = oBookmarks.Count-1 To 0 Step -1
  78.         oBookMark = oBookMarks.GetByIndex(i)
  79.         If oBookMark.Name <> "NextTopic" Then
  80.             oBookMark.Dispose()
  81.         End If
  82.     Next i
  83.     oBookMarkCursor = CreateBookmarkCursor(oDocument, "NextTopic")
  84.     If Not IsNull(oBookMarkCursor) Then
  85.         oTextField = oBookMarkCursor.TextField
  86. '        oTextField.TrueContent =     sTrueContent
  87.         oTextField.Content = sTrueContent
  88.     End If
  89.  
  90.     NOBOOKMARK:
  91.     If Err <> 0 Then
  92.         RESUME NEXT
  93.     End If
  94. End Sub
  95.  
  96.  
  97. Sub NewTopic
  98. ' Add a new topic to the agenda
  99. Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
  100. Dim oBaustein, oAutoText, oAutoGroup as Object
  101. Dim i as Integer
  102.  
  103.       oDocument = ThisComponent
  104.     oBookMarkCursor = CreateBookMarkCursor(oDocument, "NextTopic")
  105.     oTextField = oBookMarkCursor.TextField
  106.     oAutoText = CreateUnoService("com.sun.star.text.AutoTextContainer")
  107.     If oAutoText.HasbyName("template") Then
  108.         oAutoGroup = oAutoText.GetbyName("template")
  109.         If oAutoGroup.HasbyName(oTextField.Content) Then
  110.             oBaustein = oAutoGroup.GetbyName(oTextField.Content)
  111.             oBaustein.ApplyTo(oBookMarkCursor)
  112.         Else
  113.             Msgbox("AutoText '" & oTextField.Content & "' is not existing. Cannot insert additional topic!")
  114.         End If
  115.     Else
  116.         Msgbox("AutoGroupField template is not existing. Cannot insert additional topic!", 16, DlgAgenda_gMyName )
  117.     End If
  118. End Sub
  119.  
  120.  
  121.  
  122. ' Add initials, date and time at bottom of agenda, disable and hide command buttons
  123. Sub FinishAgenda
  124. Dim BtnAddAgendaTopic As Object
  125. Dim BtnFinishAgenda As Object
  126. Dim oUserField, oDateTimeField as Object
  127. Dim oBookmarkCursor as Object
  128. Dim oFormats, oLocale as Object
  129. Dim iDateTimeKey as Integer
  130.  
  131.         BasicLibraries.LoadLibrary( "Tools" )
  132.   oDocument = ThisComponent
  133.  
  134.     oUserField = oDocument.CreateInstance("com.sun.star.text.TextField.ExtendedUser")
  135.     oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
  136.  
  137.     oDateTimeField = oDocument.CreateInstance("com.sun.star.text.TextField.DateTime")
  138.  
  139.     ' 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, "NextTopic")
  146.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False)
  147.     oBookmarkCursor.Text.InsertString(oBookmarkCursor," ",False)
  148.     oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False)
  149.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  150.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  151.     If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE
  152.     If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE
  153. End Sub
  154.  
  155.  
  156. Function 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 "Bookmark " & sBookmarkName &  " is not defined!"
  163.     End If
  164. End Function
  165.  
  166.  
  167.  
  168. Sub DeleteButtons
  169. Dim AgendaFinished As Boolean
  170. Dim BtnAddAgendaTopic As Object
  171. Dim BtnFinishAgenda As Object
  172.  
  173.   oDocument = ThisComponent
  174.  
  175.     BtnAddAgendaTopic = getControlModel(oDocument, "BtnAddAgendaTopic")
  176.     BtnFinishAgenda = getControlModel(oDocument, "BtnFinishAgenda")
  177.  
  178.     ' 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.     ' Delete Buttons, empty rows at end of document & macro bindings if agenda is finished
  189.     If AgendaFinished Then
  190.         DisposeControl(oDocument, "BtnAddAgendaTopic")
  191.         DisposeControl(oDocument, "BtnFinishAgenda")
  192.  
  193.         oBookmarkCursor = CreateBookMarkCursor(oDocument,"NextTopic")
  194.         oBookMarkCursor.GotoEnd(True)
  195.         oBookmarkCursor.Text.insertString(oBookmarkCursor,"",True)
  196.  
  197.         AttachBasicMacroToEvent(oDocument,"OnNew", "")
  198.         AttachBasicMacroToEvent(oDocument,"OnSave", "")
  199.         AttachBasicMacroToEvent(oDocument,"OnSaveAs", "")
  200.         AttachBasicMacroToEvent(oDocument,"OnPrint", "")
  201.     End If
  202. End Sub
  203.  
  204.  
  205.  
  206. Sub GetOptionValues(Optional aEvent as Object)
  207. Dim CurTag as String
  208. Dim 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, ";")
  219.     Bookmarkname = TagList(0)
  220.     sTrueContent = TagList(1)
  221. End Sub
  222.  
  223. </script:module>
  224.