This commit is contained in:
Jane
2024-07-16 15:55:31 +08:00
parent 8f4ec86367
commit 29bc31ade5
12411 changed files with 8139339 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Autotext" script:language="StarBasic">Option Explicit
Public UserfieldDataType(14) as String
Public oDocAuto as Object
Public BulletList(7) as Integer
Public sTextFieldNotDefined as String
Public sGeneralError as String
Sub Main()
Dim oCursor as Object
Dim oStyles as Object
Dim oSearchDesc as Object
Dim oFoundall as Object
Dim oFound as Object
Dim i as Integer
Dim sFoundString as String
Dim sFoundContent as String
Dim FieldStringThere as String
Dim ULStringThere as String
Dim PHStringThere as String
On Local Error Goto GENERALERROR
&apos; Initialization...
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
If InitResources(&quot;&apos;Template&apos;&quot;) Then
sGeneralError = GetResText(&quot;CorrespondenceMsgError&quot;)
sTextFieldNotDefined = GetResText(&quot;TextField&quot;)
End If
UserfieldDatatype(0) = &quot;COMPANY&quot;
UserfieldDatatype(1) = &quot;FIRSTNAME&quot;
UserfieldDatatype(2) = &quot;NAME&quot;
UserfieldDatatype(3) = &quot;SHORTCUT&quot;
UserfieldDatatype(4) = &quot;STREET&quot;
UserfieldDatatype(5) = &quot;COUNTRY&quot;
UserfieldDatatype(6) = &quot;ZIP&quot;
UserfieldDatatype(7) = &quot;CITY&quot;
UserfieldDatatype(8) = &quot;TITLE&quot;
UserfieldDatatype(9) = &quot;POSITION&quot;
UserfieldDatatype(10) = &quot;PHONE_PRIVATE&quot;
UserfieldDatatype(11) = &quot;PHONE_COMPANY&quot;
UserfieldDatatype(12) = &quot;FAX&quot;
UserfieldDatatype(13) = &quot;EMAIL&quot;
UserfieldDatatype(14) = &quot;STATE&quot;
BulletList(0) = 149
BulletList(1) = 34
BulletList(2) = 65
BulletList(3) = 61
BulletList(4) = 49
BulletList(5) = 47
BulletList(6) = 79
BulletList(7) = 58
oDocAuto = ThisComponent
oStyles = oDocAuto.Stylefamilies.GetByName(&quot;NumberingStyles&quot;)
&apos; Prepare the Search-Descriptor
oSearchDesc = oDocAuto.createsearchDescriptor()
oSearchDesc.SearchRegularExpression = True
oSearchDesc.SearchWords = True
oSearchDesc.SearchString = &quot;&lt;[^&gt;]+&gt;&quot;
oFoundall = oDocAuto.FindAll(oSearchDesc)
&apos;Loop over the foundings
For i = 0 To oFoundAll.Count - 1
oFound = oFoundAll.GetByIndex(i)
sFoundString = oFound.String
&apos;Extract the string inside the brackets
sFoundContent = FindPartString(sFoundString,&quot;&lt;&quot;,&quot;&gt;&quot;,1)
sFoundContent = LTrim(sFoundContent)
&apos; Define the Cursor and place it on the founding
oCursor = oFound.Text.CreateTextCursorbyRange(oFound)
&apos; Find out, which object is to be created...
FieldStringThere = Instr(1,sFoundContent,&quot;Field&quot;)
ULStringThere = Instr(1,sFoundContent,&quot;UL&quot;)
PHStringThere = Instr(1,sFoundContent,&quot;Placeholder&quot;)
If FieldStringThere = 1 Then
CreateUserDatafield(oCursor, sFoundContent)
ElseIf ULStringThere = 1 Then
CreateBullet(oCursor, oStyles)
ElseIf PHStringThere = 1 Then
CreatePlaceholder(oCursor, sFoundContent)
End If
Next i
GENERALERROR:
If Err &lt;&gt; 0 Then
Msgbox(sGeneralError,16, GetProductName())
Resume LETSGO
End If
LETSGO:
End Sub
&apos; creates a User - datafield out of a string with the following structure
&apos; &quot;&lt;field:Company&gt;&quot;
Sub CreateUserDatafield(oCursor, sFoundContent as String)
Dim MaxIndex as Integer
Dim sFoundList(3)
Dim oUserfield as Object
Dim UserInfo as String
Dim UserIndex as Integer
oUserfield = oDocAuto.CreateInstance(&quot;com.sun.star.text.TextField.ExtendedUser&quot;)
sFoundList() = ArrayoutofString(sFoundContent,&quot;:&quot;,MaxIndex)
UserInfo = UCase(LTrim(sFoundList(1)))
UserIndex = IndexInArray(UserInfo, UserfieldDatatype())
If UserIndex &lt;&gt; -1 Then
oUserField.UserDatatype = UserIndex
oCursor.Text.InsertTextContent(oCursor,oUserField,True)
oUserField.IsFixed = True
Else
Msgbox(UserInfo &amp;&quot;: &quot; &amp; sTextFieldNotDefined,16, GetProductName())
End If
End Sub
&apos; Creates a Bullet by setting a soft Formatation on the first unsorted List-Templates with a defined
&apos; Bullet Id
Sub CreateBullet(oCursor, oStyles as Object)
Dim n, m, s as Integer
Dim StyleSet as Boolean
Dim ostyle as Object
Dim StyleName as String
Dim alevel()
StyleSet = False
For s = 0 To Ubound(BulletList())
For n = 0 To oStyles.Count - 1
ostyle = oStyles.getbyindex(n)
StyleName = oStyle.Name
alevel() = ostyle.NumberingRules.getbyindex(0)
&apos; The properties of the style are stored in a Name-Value-Array()
For m = 0 to Ubound(alevel())
&apos; Set the first Numbering template without a bulletID
If (aLevel(m).Name = &quot;BulletId&quot;) Then
If alevel(m).Value = BulletList(s) Then
oCursor.NumberingStyle = StyleName
oCursor.SetString(&quot;&quot;)
exit Sub
End if
End If
Next m
Next n
Next s
If Not StyleSet Then
&apos; The Template with the demanded BulletID is not available, so take the first style in the sequence
&apos; that has a defined Bullet ID
oCursor.NumberingStyleName = oStyles.GetByIndex(5).Name
oCursor.SetString(&quot;&quot;)
End If
End Sub
&apos; Creates a placeholder out of a string with the following structure:
&apos;&lt;placeholder:Showtext:Helptext&gt;
Sub CreatePlaceholder(oCursor as Object, sFoundContent as String)
Dim oPlaceholder as Object
Dim MaxIndex as Integer
Dim sFoundList(3)
oPlaceholder = oDocAuto.CreateInstance(&quot;com.sun.star.text.TextField.JumpEdit&quot;)
sFoundList() = ArrayoutofString(sFoundContent, &quot;:&quot; &amp; chr(34),MaxIndex)
&apos; Delete The Double-quotes
oPlaceholder.Hint = DeleteStr(sFoundList(2),chr(34))
oPlaceholder.placeholder = DeleteStr(sFoundList(1),chr(34))
oCursor.Text.InsertTextContent(oCursor,oPlaceholder,True)
End Sub
</script:module>

View File

@@ -0,0 +1,303 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Correspondence" script:language="StarBasic">Option Explicit
Public msgNoTextmark$, msgError$
Public sAddressbook$
Public Table
Public sCompany$, sFirstName$, sLastName$, sStreet$, sPostalCode$, sCity$, sState$, sInitials$, sPosition$
Public DialogExited
Public oDocument, oText, oBookMarks, oBookMark, oBookMarkCursor, oBookText as Object
Public bTemplate, bDBFields as Boolean
Sub Main
bTemplate = true
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
TemplateDialog = LoadDialog(&quot;Template&quot;, &quot;TemplateDialog&quot;)
DialogModel = TemplateDialog.Model
DialogModel.Step = 2
DialogModel.Optmerge.State = True
LoadLanguageCorrespondence()
TemplateDialog.Execute
TemplateDialog.Dispose()
End Sub
Sub Placeholder
bTemplate = false
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
LoadLanguageCorrespondence()
bDBFields = false
OK()
End Sub
Sub Database
bTemplate = false
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
LoadLanguageCorrespondence()
bDBFields = true
OK()
End Sub
Function LoadLanguageCorrespondence() as Boolean
If InitResources(&quot;&apos;Template&apos;&quot;) Then
msgNoTextmark$ = GetResText(&quot;CorrespondenceDialog_0&quot;) &amp; Chr(13) &amp; Chr(10) &amp; GetResText(&quot;CorrespondenceNoTextmark_1&quot;)
msgError$ = GetResText(&quot;CorrespondenceMsgError&quot;)
If bTemplate Then
DialogModel.Title = GetResText(&quot;CorrespondenceDialog_3&quot;)
DialogModel.CmdCancel.Label = GetResText(&quot;STYLES_2&quot;)
DialogModel.CmdCorrGoOn.Label = GetResText(&quot;STYLES_3&quot;)
DialogModel.OptSingle.Label = GetResText(&quot;CorrespondenceDialog_1&quot;)
DialogModel.Optmerge.Label = GetResText(&quot;CorrespondenceDialog_2&quot;)
DialogModel.FrmLetter.Label = GetResText(&quot;CorrespondenceDialog_0&quot;)
End If
LoadLanguageCorrespondence() = True
Else
msgbox(&quot;Warning: Resource could not be loaded!&quot;)
End If
End Function
Function GetFieldName(oFieldKnot as Object, GeneralFieldName as String)
If oFieldKnot.HasByName(GeneralFieldName) Then
GetFieldName = oFieldKnot.GetByName(GeneralFieldName).AssignedFieldName
Else
GetFieldName = &quot;&quot;
End If
End Function
Sub OK
Dim ParaBreak
Dim sDocLang as String
Dim oSearchDesc as Object
Dim oFoundAll as Object
Dim oFound as Object
Dim sFoundContent as String
Dim sFoundString as String
Dim sDBField as String
Dim i as Integer
Dim oDBAccess as Object
Dim oAddressDialog as Object
Dim oAddressPilot as Object
Dim oFields as Object
Dim oDocSettings as Object
Dim oContext as Object
Dim bDBvalid as Boolean
&apos;On Local Error Goto GENERALERROR
If bTemplate Then
bDBFields = DialogModel.Optmerge.State &apos;database or placeholder
TemplateDialog.EndExecute()
DialogExited = TRUE
End If
If bDBFields Then
oDBAccess = GetRegistryKeyContent(&quot;org.openoffice.Office.DataAccess/AddressBook/&quot;)
sAddressbook = oDBAccess.DataSourceName
bDBvalid = false
oContext = createUnoService( &quot;com.sun.star.sdb.DatabaseContext&quot; )
If (not isNull(oContext)) Then
&apos;Is the previously assigned address data source still valid?
bDBvalid = oContext.hasByName(sAddressbook)
end if
If (bDBvalid = false) Then
oAddressPilot = createUnoService(&quot;com.sun.star.ui.dialogs.AddressBookSourcePilot&quot;)
oAddressPilot.execute
oDBAccess = GetRegistryKeyContent(&quot;org.openoffice.Office.DataAccess/AddressBook/&quot;)
sAddressbook = oDBAccess.DataSourceName
If sAddressbook = &quot;&quot; Then
MsgBox(GetResText(&quot;CorrespondenceNoTextmark_1&quot;))
Exit Sub
End If
End If
oFields = oDBAccess.GetByName(&quot;Fields&quot;)
Table = oDBAccess.GetByName(&quot;Command&quot;)
End If
ParaBreak = com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK
oDocument = ThisComponent
If bDBFields Then
&apos;set the address db as current db at the document
oDocSettings = oDocument.createInstance(&quot;com.sun.star.document.Settings&quot;)
oDocSettings.CurrentDatabaseDataSource = sAddressbook
oDocSettings.CurrentDatabaseCommand = Table
oDocSettings.CurrentDatabaseCommandType = 0
End If
oBookmarks = oDocument.Bookmarks
oText = oDocument.Text
oSearchDesc = oDocument.createsearchDescriptor()
oSearchDesc.SearchRegularExpression = True
oSearchDesc.SearchWords = True
oSearchDesc.SearchString = &quot;&lt;[^&gt;]+&gt;&quot;
oFoundall = oDocument.FindAll(oSearchDesc)
&apos;Loop over the foundings
For i = oFoundAll.Count -1 To 0 Step -1
oFound = oFoundAll.GetByIndex(i)
sFoundString = oFound.String
&apos;Extract the string inside the brackets
sFoundContent = FindPartString(sFoundString,&quot;&lt;&quot;,&quot;&gt;&quot;,1)
sFoundContent = LTrim(sFoundContent)
&apos; Define the Cursor and place it on the founding
oBookmarkCursor = oFound.Text.CreateTextCursorbyRange(oFound)
oBookText = oFound.Text
If bDBFields Then
sDBField = GetFieldname(oFields, sFoundContent)
If sDBField &lt;&gt; &quot;&quot; Then
InsertDBField(sAddressbook, Table, sDBField)
Else
InsertPlaceholder(sFoundContent)
End If
Else
InsertPlaceholder(sFoundContent)
End If
Next i
If bDBFields Then
&apos;Open the DB beamer with the right DB
Dim oDisp as Object
Dim oTransformer
Dim aURL as new com.sun.star.util.URL
aURL.complete = &quot;.component:DB/DataSourceBrowser&quot;
oTransformer = createUnoService(&quot;com.sun.star.util.URLTransformer&quot;)
oTransformer.parseStrict(aURL)
oDisp = oDocument.getCurrentController.getFrame.queryDispatch(aURL, &quot;_beamer&quot;, com.sun.star.frame.FrameSearchFlag.CHILDREN + com.sun.star.frame.FrameSearchFlag.CREATE)
Dim aArgs(3) as new com.sun.star.beans.PropertyValue
aArgs(1).Name = &quot;DataSourceName&quot;
aArgs(1).Value = sAddressbook
aArgs(2).Name = &quot;CommandType&quot;
aArgs(2).Value = com.sun.star.sdb.CommandType.TABLE
aArgs(3).Name = &quot;Command&quot;
aArgs(3).Value = Table
oDisp.dispatch(aURL, aArgs())
End If
GENERALERROR:
If Err &lt;&gt; 0 Then
Msgbox(msgError$,16, GetProductName())
Resume LETSGO
End If
LETSGO:
End Sub
Sub InsertDBField(sDBName as String, sTableName as String, sColName as String)
Dim oFieldMaster, oField as Object
If sColname &lt;&gt; &quot;&quot; Then
oFieldMaster = oDocument.createInstance(&quot;com.sun.star.text.FieldMaster.Database&quot;)
oField = oDocument.createInstance(&quot;com.sun.star.text.TextField.Database&quot;)
oFieldMaster.DataBaseName = sDBName
oFieldMaster.DataBaseName = sDBName
oFieldMaster.DataTableName = sTableName
oFieldMaster.DataColumnName = sColName
oField.AttachTextfieldmaster (oFieldMaster)
oBookText.InsertTextContent(oBookMarkCursor, oField, True)
oField.Content = &quot;&lt;&quot; &amp; sColName &amp; &quot;&gt;&quot;
End If
End Sub
Sub InsertPlaceholder(sColName as String)
Dim oFieldMaster as Object
Dim bCorrectField as Boolean
If sColname &lt;&gt; &quot;&quot; Then
bCorrectField = True
oFieldMaster = oDocument.createInstance(&quot;com.sun.star.text.TextField.JumpEdit&quot;)
Select Case sColName
Case &quot;Company&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_1&quot;)
Case &quot;Department&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_2&quot;)
Case &quot;FirstName&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_3&quot;)
Case &quot;LastName&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_4&quot;)
Case &quot;Street&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_5&quot;)
Case &quot;Country&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_6&quot;)
Case &quot;Zip&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_7&quot;)
Case &quot;City&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_8&quot;)
Case &quot;Title&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_9&quot;)
Case &quot;Position&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_10&quot;)
Case &quot;AddrForm&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_11&quot;)
Case &quot;Code&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_12&quot;)
Case &quot;AddrFormMail&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_13&quot;)
Case &quot;PhonePriv&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_14&quot;)
Case &quot;PhoneComp&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_15&quot;)
Case &quot;Fax&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_16&quot;)
Case &quot;EMail&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_17&quot;)
Case &quot;URL&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_18&quot;)
Case &quot;Note&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_19&quot;)
Case &quot;Altfield1&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_20&quot;)
Case &quot;Altfield2&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_21&quot;)
Case &quot;Altfield3&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_22&quot;)
Case &quot;Altfield4&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_23&quot;)
Case &quot;Id&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_24&quot;)
Case &quot;State&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_25&quot;)
Case &quot;PhoneOffice&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_26&quot;)
Case &quot;Pager&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_27&quot;)
Case &quot;PhoneCell&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_28&quot;)
Case &quot;PhoneOther&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_29&quot;)
Case &quot;CalendarURL&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_30&quot;)
Case &quot;InviteParticipant&quot;
oFieldMaster.PlaceHolder = getResText(&quot;CorrespondenceFields_31&quot;)
Case Else
bCorrectField = False
End Select
If bCorrectField Then
oFieldMaster.Hint = getResText(&quot;CorrespondenceFields_0&quot;)
oBookText.InsertTextContent(oBookMarkCursor, oFieldMaster, True)
End If
End If
End Sub
</script:module>

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="DialogStyles" dlg:left="170" dlg:top="93" dlg:width="120" dlg:height="169" dlg:help-url="HID:WIZARDS_HID_DLGSTYLES_DIALOG" dlg:closeable="true" dlg:moveable="true">
<dlg:bulletinboard>
<dlg:button dlg:id="cmdCancel" dlg:tab-index="0" dlg:left="5" dlg:top="150" dlg:width="50" dlg:height="13" dlg:help-url="HID:WIZARDS_HID_DLGSTYLES_CANCEL" dlg:value="cmdCancel">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Template.Samples.RestoreCurrentStyles?language=Basic&amp;location=application" script:language="Script"/>
</dlg:button>
<dlg:button dlg:id="cmdOk" dlg:tab-index="1" dlg:left="65" dlg:top="150" dlg:width="50" dlg:height="12" dlg:help-url="HID:WIZARDS_HID_DLGSTYLES_OKAY" dlg:value="cmdOk">
<script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Template.Samples.CloseStyleDialog?language=Basic&amp;location=application" script:language="Script"/>
</dlg:button>
<dlg:menulist dlg:id="lbStyles" dlg:tab-index="2" dlg:left="5" dlg:top="5" dlg:width="110" dlg:height="133" dlg:help-url="HID:WIZARDS_HID_DLGSTYLES_LISTBOX">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:Template.Samples.SelectStyle?language=Basic&amp;location=application" script:language="Script"/>
</dlg:menulist>
</dlg:bulletinboard>
</dlg:window>

View File

@@ -0,0 +1,220 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ModuleAgenda" script:language="StarBasic">&apos; All variables must be declared before use
Option Explicit
&apos; Used for &quot;disabling&quot; the cancel button of the dialog
Public DialogExited As Boolean
Dim DlgAgenda_gMyName as String
Public TemplateDialog as Object
Public DialogModel as Object
Public sTrueContent as String
Public Bookmarkname as String
Sub Initialize()
&apos; User sets the type of minutes
BasicLibraries.LoadLibrary( &quot;Tools&quot; )
TemplateDialog = LoadDialog(&quot;Template&quot;, &quot;TemplateDialog&quot;)
DialogModel = TemplateDialog.Model
DialogModel.Step = 1
LoadLanguageAgenda()
DialogModel.OptAgenda2.State = TRUE
GetOptionValues()
DialogExited = FALSE
TemplateDialog.Execute
End Sub
Sub LoadLanguageAgenda()
If InitResources(&quot;&apos;Template&apos;&quot;) Then
DlgAgenda_gMyName = GetResText(&quot;AgendaDlgName&quot;)
DialogModel.CmdCancel.Label = GetResText(&quot;STYLES_2&quot;)
DialogModel.CmdAgdGoon.Label = GetResText(&quot;STYLES_3&quot;)
&apos; DlgAgenda_gMsgNoCancel$ = GetResText(&quot;AgendaDlgNoCancel&quot;)
DialogModel.FrmAgenda.Label = GetResText(&quot;AgendaDlgFrame&quot;)
DialogModel.OptAgenda1.Label = GetResText(&quot;AgendaDlgButton1&quot;)
DialogModel.OptAgenda2.Label = GetResText(&quot;AgendaDlgButton2&quot;)
&apos; DialogModel.OptAgenda1.State = 1
End If
End Sub
Sub ModifyTemplate()
Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
Dim i as Integer
oDocument = ThisComponent
oBookMarks = oDocument.Bookmarks
On Local Error Goto NOBOOKMARK
TemplateDialog.EndExecute
DialogExited = TRUE
oBookmarkCursor = CreateBookmarkCursor(oDocument, BookmarkName)
oBookmarkCursor.Text.insertString(oBookmarkCursor,&quot;&quot;,True)
&apos; Delete all the Bookmarks except for the one named &quot;NextTopic&quot;
For i = oBookmarks.Count-1 To 0 Step -1
oBookMark = oBookMarks.GetByIndex(i)
If oBookMark.Name &lt;&gt; &quot;NextTopic&quot; Then
oBookMark.Dispose()
End If
Next i
oBookMarkCursor = CreateBookmarkCursor(oDocument, &quot;NextTopic&quot;)
If Not IsNull(oBookMarkCursor) Then
oTextField = oBookMarkCursor.TextField
&apos; oTextField.TrueContent = sTrueContent
oTextField.Content = sTrueContent
End If
NOBOOKMARK:
If Err &lt;&gt; 0 Then
RESUME NEXT
End If
End Sub
Sub NewTopic
&apos; Add a new topic to the agenda
Dim oDocument, oBookmarks, oBookmark, oBookmarkCursor, oTextField as Object
Dim oBaustein, oAutoText, oAutoGroup as Object
Dim i as Integer
oDocument = ThisComponent
oBookMarkCursor = CreateBookMarkCursor(oDocument, &quot;NextTopic&quot;)
oTextField = oBookMarkCursor.TextField
oAutoText = CreateUnoService(&quot;com.sun.star.text.AutoTextContainer&quot;)
If oAutoText.HasbyName(&quot;template&quot;) Then
oAutoGroup = oAutoText.GetbyName(&quot;template&quot;)
If oAutoGroup.HasbyName(oTextField.Content) Then
oBaustein = oAutoGroup.GetbyName(oTextField.Content)
oBaustein.ApplyTo(oBookMarkCursor)
Else
Msgbox(&quot;AutoText &apos;&quot; &amp; oTextField.Content &amp; &quot;&apos; is not existing. Cannot insert additional topic!&quot;)
End If
Else
Msgbox(&quot;AutoGroupField template is not existing. Cannot insert additional topic!&quot;, 16, DlgAgenda_gMyName )
End If
End Sub
&apos; Add initials, date and time at bottom of agenda, disable and hide command buttons
Sub FinishAgenda
Dim BtnAddAgendaTopic As Object
Dim BtnFinishAgenda As Object
Dim oUserField, oDateTimeField as Object
Dim oBookmarkCursor as Object
Dim oFormats, oLocale as Object
Dim iDateTimeKey as Integer
BasicLibraries.LoadLibrary( &quot;Tools&quot; )
oDocument = ThisComponent
oUserField = oDocument.CreateInstance(&quot;com.sun.star.text.TextField.ExtendedUser&quot;)
oUserField.UserDatatype = com.sun.star.text.UserDataPart.SHORTCUT
oDateTimeField = oDocument.CreateInstance(&quot;com.sun.star.text.TextField.DateTime&quot;)
&apos; Assign Standardformat to Datetime-Textfield
oFormats = oDocument.Numberformats
oLocale = oDocument.CharLocale
iDateTimeKey = oFormats.GetStandardFormat(com.sun.star.util.NumberFormat.DATETIME,oLocale)
oDateTimeField.NumberFormat = iDateTimeKey
oBookmarkCursor = CreateBookmarkCursor(oDocument, &quot;NextTopic&quot;)
oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oUserField,False)
oBookmarkCursor.Text.InsertString(oBookmarkCursor,&quot; &quot;,False)
oBookmarkCursor.Text.InsertTextContent(oBookmarkCursor,oDateTimeField,False)
BtnAddAgendaTopic = getControlModel(oDocument, &quot;BtnAddAgendaTopic&quot;)
BtnFinishAgenda = getControlModel(oDocument, &quot;BtnFinishAgenda&quot;)
If Not IsNull(BtnAddAgendaTopic) Then BtnAddAgendaTopic.Enabled = FALSE
If Not IsNull(BtnFinishAgenda) Then BtnFinishAgenda.Enabled = FALSE
End Sub
Function CreateBookMarkCursor(oDocument as Object,sBookmarkName as String)
oBookMarks = oDocument.Bookmarks
If oBookmarks.HasbyName(sBookmarkName) Then
oBookMark = oBookMarks.GetbyName(sBookmarkName)
CreateBookMarkCursor = oBookMark.Anchor.Text.CreateTextCursorByRange(oBookMark.Anchor)
Else
Msgbox &quot;Bookmark &quot; &amp; sBookmarkName &amp; &quot; is not defined!&quot;
End If
End Function
Sub DeleteButtons
Dim AgendaFinished As Boolean
Dim BtnAddAgendaTopic As Object
Dim BtnFinishAgenda As Object
oDocument = ThisComponent
BtnAddAgendaTopic = getControlModel(oDocument, &quot;BtnAddAgendaTopic&quot;)
BtnFinishAgenda = getControlModel(oDocument, &quot;BtnFinishAgenda&quot;)
&apos; If buttons could be accessed: If at least one button is disabled, then agenda is finished
AgendaFinished = FALSE
If Not IsNull(BtnAddAgendaTopic) Then
AgendaFinished = (AgendaFinished Or (BtnAddAgendaTopic.Enabled = FALSE))
End If
If Not IsNull(BtnFinishAgenda) Then
AgendaFinished = (AgendaFinished Or (BtnFinishAgenda.Enabled = FALSE))
End If
&apos; Delete Buttons, empty rows at end of document &amp; macro bindings if agenda is finished
If AgendaFinished Then
DisposeControl(oDocument, &quot;BtnAddAgendaTopic&quot;)
DisposeControl(oDocument, &quot;BtnFinishAgenda&quot;)
oBookmarkCursor = CreateBookMarkCursor(oDocument,&quot;NextTopic&quot;)
oBookMarkCursor.GotoEnd(True)
oBookmarkCursor.Text.insertString(oBookmarkCursor,&quot;&quot;,True)
AttachBasicMacroToEvent(oDocument,&quot;OnNew&quot;, &quot;&quot;)
AttachBasicMacroToEvent(oDocument,&quot;OnSave&quot;, &quot;&quot;)
AttachBasicMacroToEvent(oDocument,&quot;OnSaveAs&quot;, &quot;&quot;)
AttachBasicMacroToEvent(oDocument,&quot;OnPrint&quot;, &quot;&quot;)
End If
End Sub
Sub GetOptionValues(Optional aEvent as Object)
Dim CurTag as String
Dim Taglist() as String
If Not IsMissing(aEvent) Then
CurTag = aEvent.Source.Model.Tag
Else
If DialogModel.OptAgenda1.State = TRUE Then
CurTag = DialogModel.OptAgenda1.Tag
Else
CurTag = DialogModel.OptAgenda2.Tag
End If
End If
Taglist() = ArrayoutOfString(CurTag, &quot;;&quot;)
Bookmarkname = TagList(0)
sTrueContent = TagList(1)
End Sub
</script:module>

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Samples" script:language="StarBasic">Option Explicit
Const NumStyles = 18
Const aTempFileName = &quot;Berend_Ilko_Tom_Stella_Volker.stc&quot;
Dim oUcbObject as Object
Public StylesDir as String
Public StylesDialog as Object
Public PathSeparator as String
Public oFamilies as Object
Public aOptions(0) as New com.sun.star.beans.PropertyValue
Public sQueryPath as String
Public NoArgs()as New com.sun.star.beans.PropertyValue
Public aTempURL as String
Public Files(100) as String
&apos;--------------------------------------------------------------------------------------
&apos;Calc Style Section starts here
Sub ShowStyles
&apos;This sub displays the style selection dialog if the current document is a calc document.
Dim TemplateDir, ActFileTitle, DisplayDummy as String
Dim sFilterName(0) as String
Dim StyleNames() as String
Dim LocalizedStyleNames(NumStyles,2) As String
Dim LocalizedStyleName As String
Dim t as Integer
Dim MaxIndex as Integer
Dim StyleNameDef As Variant
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
If InitResources(&quot;&apos;Template&apos;&quot;) then
oDocument = ThisComponent
If oDocument.SupportsService(&quot;com.sun.star.sheet.SpreadsheetDocument&quot;) Then
ToggleWindow(False)
oUcbObject = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
oFamilies = oDocument.StyleFamilies
SaveCurrentStyles(oDocument)
StylesDialog = LoadDialog(&quot;Template&quot;, &quot;DialogStyles&quot;)
DialogModel = StylesDialog.Model
TemplateDir = GetPathSettings(&quot;Template&quot;, False, 0)
StylesDir = GetOfficeSubPath(&quot;Template&quot;, &quot;wizard/styles/&quot;)
sQueryPath = GetOfficeSubPath(&quot;Template&quot;, &quot;../wizard/bitmap/&quot;)
DialogModel.Title = GetResText(&quot;STYLES_0&quot;)
DialogModel.cmdCancel.Label = GetResText(&quot;STYLES_2&quot;)
DialogModel.cmdOk.Label = GetResText(&quot;STYLES_3&quot;)
StyleNameDef = Array("(Standard)", "Autumn Leaves", "Be", "Black and White", "Blackberry Bush", "Blue Jeans", "Fifties Diner", "Glacier", "Green Grapes", "Marine", "Millennium", "Nature", "Neon", "Night", "PC Nostalgia", "Pastel", "Pool Party", "Pumpkin")
For t = 0 to NumStyles - 1
LocalizedStyleNames(t,0) = StyleNameDef(t)
LocalizedStyleNames(t,1) = GetResText(&quot;STYLENAME_&quot; &amp; Trim(Str(t)))
Next t
Stylenames() = ReadDirectories(StylesDir, False, False, True,)
MaxIndex = Ubound(Stylenames())
For t = 0 to MaxIndex
LocalizedStyleName = StringInMultiArray(LocalizedStyleNames(), StyleNames(t,1), 0, 1)
If LocalizedStyleName &lt;&gt; "" Then
StyleNames(t,1) = LocalizedStyleName
End If
Next t
BubbleSortList(Stylenames(),True)
Dim cStyles(MaxIndex)
For t = 0 to MaxIndex
Files(t) = StyleNames(t,0)
cStyles(t) = StyleNames(t,1)
Next t
On Local Error Resume Next
DialogModel.lbStyles.StringItemList() = cStyles()
ToggleWindow(True)
StylesDialog.Execute
End If
End If
End Sub
Sub SelectStyle
&apos;This sub loads the specific styles from a style document and loads them into the
&apos;current document.
Dim StylePath as String
Dim NewStyle as String
Dim Position as Integer
Position = DialogModel.lbStyles.SelectedItems(0)
If Position &gt; -1 Then
ToggleWindow(False)
StylePath = Files(Position)
aOptions(0).Name = &quot;OverwriteStyles&quot;
aOptions(0).Value = true
oFamilies.loadStylesFromURL(StylePath, aOptions())
ToggleWindow(True)
End If
End Sub
Sub SaveCurrentStyles(oDocument as Object)
&apos;This sub stores the current document in the directory to hold temporary files.
On Error Goto ErrorOccurred
aTempURL = GetPathSettings(&quot;Temp&quot;, False)
Dim aRightMost as String
aRightMost = Right(aTempURL, 1)
if aRightMost = &quot;/&quot; Then
aTempURL = aTempURL &amp; aTempFileName
Else
aTempURL = aTempURL &amp; &quot;/&quot; &amp; aTempFileName
End If
While FileExists(aTempURL)
aTempURL=Left(aTempURL,(Len(aTempURL)-4)) &amp; &quot;_1.stc&quot;
Wend
oDocument.storeToURL(aTempURL, NoArgs())
Exit Sub
ErrorOccurred:
MsgBox(GetResText(&quot;STYLES_1&quot;), 16, GetResText(&quot;STYLES_0&quot;))
On Local Error Goto 0
End Sub
Sub RestoreCurrentStyles
&apos;This sub retrieves the styles from the temporarily save document
ToggleWindow(False)
On Local Error Goto NoFile
If FileExists(aTempURL) Then
aOptions(0).Name = &quot;OverwriteStyles&quot;
aOptions(0).Value = true
oFamilies.LoadStylesFromURL(aTempURL, aOptions())
KillTempFile()
End If
StylesDialog.EndExecute
ToggleWindow(True)
NOFILE:
If Err &lt;&gt; 0 Then
Msgbox(&quot;Cannot load Document from &quot; &amp; aTempUrl, 64, GetProductname())
End If
On Local Error Goto 0
End Sub
Sub CloseStyleDialog
KillTempFile()
DialogExited = True
StylesDialog.Endexecute
End Sub
Sub KillTempFile()
If oUcbObject.Exists(aTempUrl) Then
oUcbObject.Kill(aTempUrl)
End If
End Sub
</script:module>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="TemplateDialog" dlg:left="170" dlg:top="93" dlg:width="220" dlg:height="60" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_DIALOG" dlg:closeable="true" dlg:moveable="true">
<dlg:bulletinboard>
<dlg:radiogroup>
<dlg:radio dlg:id="OptAgenda1" dlg:tab-index="0" dlg:left="12" dlg:top="20" dlg:width="144" dlg:height="10" dlg:page="1" dlg:tag="TOP2;PT1" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA1" dlg:value="OptAgenda1">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:Template.ModuleAgenda.GetOptionValues?language=Basic&amp;location=application" script:language="Script"/>
</dlg:radio>
<dlg:radio dlg:id="OptAgenda2" dlg:tab-index="1" dlg:left="12" dlg:top="34" dlg:width="144" dlg:height="10" dlg:page="1" dlg:tag="TOP1;PT2" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA2" dlg:value="OptAgenda2">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.script:Template.ModuleAgenda.GetOptionValues?language=Basic&amp;location=application" script:language="Script"/>
</dlg:radio>
</dlg:radiogroup>
<dlg:button dlg:id="CmdCorrGoOn" dlg:tab-index="2" dlg:left="164" dlg:top="11" dlg:width="50" dlg:height="14" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_LETTEROKAY" dlg:value="CmdCorrGoOn">
<script:event script:event-name="on-performaction" script:macro-name="Template.Correspondence.OK" script:language="StarBasic"/>
</dlg:button>
<dlg:radiogroup>
<dlg:radio dlg:id="OptSingle" dlg:tab-index="3" dlg:left="12" dlg:top="20" dlg:width="144" dlg:height="10" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER1" dlg:value="OptSingle"/>
<dlg:radio dlg:id="Optmerge" dlg:tab-index="4" dlg:left="12" dlg:top="34" dlg:width="144" dlg:height="10" dlg:page="2" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER2" dlg:value="Optmerge"/>
</dlg:radiogroup>
<dlg:button dlg:id="CmdAgdGoon" dlg:tab-index="5" dlg:left="164" dlg:top="11" dlg:width="50" dlg:height="14" dlg:page="1" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_AGENDAOKAY" dlg:value="CmdAgdGoOn">
<script:event script:event-name="on-performaction" script:macro-name="Template.ModuleAgenda.ModifyTemplate" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="CmdCancel" dlg:tab-index="6" dlg:left="164" dlg:top="28" dlg:width="50" dlg:height="14" dlg:help-url="HID:WIZARDS_HID_DLGCORRESPONDENCE_CANCEL" dlg:value="CmdCancel" dlg:button-type="cancel">
<script:event script:event-name="on-performaction" script:macro-name="Template.ModuleAgenda.DisposeDocument" script:language="StarBasic"/>
</dlg:button>
<dlg:fixedline dlg:id="FrmLetter" dlg:tab-index="7" dlg:left="6" dlg:top="6" dlg:width="150" dlg:height="10" dlg:page="2" dlg:value="FrmLetter"/>
<dlg:fixedline dlg:id="FrmAgenda" dlg:tab-index="8" dlg:left="6" dlg:top="6" dlg:width="150" dlg:height="10" dlg:page="1" dlg:value="FrmAgenda"/>
</dlg:bulletinboard>
</dlg:window>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Template" library:readonly="true" library:passwordprotected="false">
<library:element library:name="DialogStyles"/>
<library:element library:name="DlgGreeting"/>
<library:element library:name="TemplateDialog"/>
</library:library>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Template" library:readonly="true" library:passwordprotected="false">
<library:element library:name="ModuleAgenda"/>
<library:element library:name="Correspondence"/>
<library:element library:name="Samples"/>
<library:element library:name="Autotext"/>
</library:library>