#92590# New Basic Dialogs inserterted; Language Modules removed

This commit is contained in:
Behrend Cornelius
2001-10-01 08:59:25 +00:00
parent f22e1e4f12
commit fce21e37ff
6 changed files with 542 additions and 530 deletions

View File

@@ -1,21 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="AutoText" script:language="StarBasic">&apos; BASIC
Option Explicit
Dim oDocument as Object
Dim sDocumentTitle as String
&apos; Todo: Problem mit der Spaltenbreite lösen
&apos; Internationale Vorlage für Überschrift
Sub Main
Dim oDocument, oTable, oRows, oDocuText, oTitleCursor as Object
Dim oAutoTextContainer, oAutogroup, oAutoText as Object
Dim oCharStyles, oContentStyle, oHeaderStyle, oGroupTitleStyle as Object
Sub Main()
Dim oTable as Object
Dim oRows as Object
Dim oDocuText as Object
Dim oAutoTextCursor as Object
Dim oAutoTextContainer as Object
Dim oAutogroup as Object
Dim oAutoText as Object
Dim oCharStyles as Object
Dim oContentStyle as Object
Dim oHeaderStyle as Object
Dim oGroupTitleStyle as Object
Dim n, m, iAutoCount as Integer
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
LoadLanguage(StarDesktop.ISOLocale.Language)
Dim oLocale as New com.sun.star.lang.Locale
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
oLocale = GetStarOfficeLocale()
strHeading1 = &quot;Überschrift 1&quot;
strGroup = &quot;Bereich:&quot;
strBlockName = &quot;Name des Bausteins&quot;
strBlockShortName = &quot;Kürzel&quot;
strColumnWidth = &quot;13cm&quot;
sDocumentTitle = &quot;Installierte Autotextbausteine&quot;
&apos; Open a new empty document
oDocument = StarDesktop.LoadComponentFromURL(&quot;staroffice:factory/swriter&quot;,&quot;_blank&quot;,0,NoArgs)
oDocument = StarDesktop.LoadComponentFromURL(&quot;private:factory/swriter&quot;,&quot;_blank&quot;,0,NoArgs)
oDocument.DocumentInfo.Title = sDocumentTitle
oDocuText = oDocument.Text
&apos; Create The Character-templates
@@ -23,14 +40,15 @@ Dim n, m, iAutoCount as Integer
&apos; The Characterstyle for the Header that describes the Title of Autotextgroups
oGroupTitleStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oGroupTitleStyle.charWeight = com.sun.star.awt.FontWeight.BOLD
oGroupTitleStyle.CharHeight = 14
oCharStyles.InsertbyName(&quot;AutoTextGroupTitle&quot;, oGroupTitleStyle)
oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
oGroupTitleStyle.CharHeight = 14
&apos; The Characterstyle for the Header that describes the Title of Autotextgroups
oHeaderStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD
oCharStyles.InsertbyName(&quot;AutoTextHeading&quot;, oHeaderStyle)
oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD
&apos; &quot;Ordinary&quot; Table Content
oContentStyle = oDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
@@ -38,23 +56,24 @@ Dim n, m, iAutoCount as Integer
oAutoTextContainer = CreateUnoService(&quot;com.sun.star.text.AutoTextContainer&quot;)
oTitleCursor = oDocuText.CreateTextCursor()
oTitleCursor.CharStyle = &quot;AutoTextGroupTitle&quot;
oAutoTextCursor = oDocuText.CreateTextCursor()
oAutoTextCursor.CharStyleName = &quot;AutoTextGroupTitle&quot;
&apos; Link the Title with the following table
oTitleCursor.ParaKeepTogether = True
oAutoTextCursor.ParaKeepTogether = True
For n = 0 To oAutoTextContainer.Count - 1
oAutoGroup = oAutoTextContainer.GetByIndex(n)
oTitleCursor.SetString(oAutoGroup.Title)
oTitleCursor.CollapseToEnd()
oDocuText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oAutoTextCursor.SetString(oAutoGroup.Title)
oAutoTextCursor.CollapseToEnd()
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oTable = oDocument.CreateInstance(&quot;com.sun.star.text.TextTable&quot;)
&apos; Divide the table if necessary
oTable.Split = True
&apos; oTable.KeepTogether = False
oTable.RepeatHeadLine = True
oTitleCursor.Text.InsertTextContent(oCursor,oTable,False)
oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False)
InsertStringToCell(&quot;AutoText-Title&quot;,oTable.GetCellbyPosition(0,0), &quot;AutoTextHeading&quot;)
InsertStringToCell(&quot;AutoText-Name&quot;,oTable.GetCellbyPosition(1,0), &quot;AutoTextHeading&quot;)
&apos; Insert one row at the bottom of the table
@@ -69,8 +88,8 @@ Dim n, m, iAutoCount as Integer
oRows.InsertbyIndex(m + 2,1)
End If
Next m
oDocuText.insertControlCharacter(oCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oCursor.CollapseToEnd()
oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oAutoTextCursor.CollapseToEnd()
Next n
End Sub
@@ -78,6 +97,7 @@ End Sub
Sub InsertStringToCell(sCellString as String, oCell as Object, sCellStyle as String)
Dim oCellCursor as Object
oCellCursor = oCell.CreateTextCursor()
oCellCursor.CharStyle = sCellStyle
oCellCursor.CharStyleName = sCellStyle
oCell.Text.insertString(oCellCursor,sCellString,False)
End Sub</script:module>
oDocument.CurrentController.Select(oCellCursor)
End Sub</script:module>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ChangeAllChars" script:language="StarBasic">&apos; This macro replaces all characters in a writer-documet through &quot;x&quot; or &quot;X&quot; signs.
&apos; It works on the currently activated document.
Private const UPPERREPLACECHAR = &quot;X&quot;
@@ -15,14 +15,16 @@ Dim i as Integer
Const MBYES = 6
Const MBABORT = 2
Const MBNO = 7
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
Call SetLanguage
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
MSGBOXTITLE = &quot;Change all characters to a &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;This Document is modified: All characters are changed to an &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Shall the document be saved now?&quot;
WARNING = &quot;This macro changes all characters and numbers to an &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; in this document.&quot;
On Local Error GoTo NODOCUMENT
oDocument = StarDesktop.ActiveFrame.Controller.Model
NODOCUMENT:
If Err &lt;&gt; 0 Then
Msgbox(&quot;This Macro extracts all Data of a displayed Writer-Document.&quot; &amp; chr(13) &amp; &quot;Activate a Writer-Document!&quot; , 16, &quot;StarOffice 5.2&quot;)
Msgbox(&quot;This Macro extracts all Data of a displayed Writer-Document.&quot; &amp; chr(13) &amp; &quot;Activate a Writer-Document!&quot; , 16, GetProductName())
Exit Sub
End If
On Local Error Goto 0
@@ -45,11 +47,11 @@ Const MBNO = 7
End If
Select Case sDocType
Case &quot;sWriter&quot;
Case &quot;swriter&quot;
ReplaceAllStrings(oDocument)
Case Else
Msgbox(&quot;This Macro only works with Writer-Documents!&quot;, 16, &quot;StarOffice 5.2&quot;)
Msgbox(&quot;This Macro only works with Writer-Documents!&quot;, 16, GetProductName())
End Select
End Sub
@@ -70,61 +72,4 @@ Sub ReplaceStrings(oContainer as Object, sSearchString, sReplaceString as Strin
oReplaceDesc.Searchstring = sSearchString
oReplaceDesc.ReplaceString = sReplaceString
oReplCount = oContainer.ReplaceAll(oReplaceDesc)
End Sub
Sub SetLanguage
Dim ISOLanguage as String
ISOLanguage = StarDesktop.ISOLocale.Language
Select Case ISOLanguage
Case &quot;en&quot;
MSGBOXTITLE = &quot;Change all characters to a &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;This Document is modified: All characters are changed to an &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Shall the document be saved now?&quot;
WARNING = &quot;This macro changes all characters and numbers to an &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; in this document.&quot;
Case &quot;fr&quot;
MSGBOXTITLE = &quot;Remplacer tous les caractères par &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;Le document a été modifé, la macro remplacera tous les caractères par &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Enregistrer avant de procéder?&quot;
WARNING = &quot;La macro remplacera tous les caractères et nombres par &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; dans le document.&quot;
Case &quot;it&quot;
MSGBOXTITLE = &quot;Sostituire tutti i caratteri &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;Il documento è stato modificato, la macro sostituerà tutti i caratteri con &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Salvare il documento prima di procedere?&quot;
WARNING = &quot;La macro sostituirà tutti i caratteri e numeri con &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; nel documento attivo.&quot;
Case &quot;es&quot;
MSGBOXTITLE = &quot;Sustituir todos los caracteres por &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;Este documento fue cambiado: todos los caracteres fueron sustituidos por &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Desea guardar el documento?&quot;
WARNING = &quot;Esta macro sustitue todos los caracteres y números en este documento por &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;.&quot;
Case &quot;pt&quot;
MSGBOXTITLE = &quot;Substituir todos os caracteres por &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;Este documento foi modificado: todos os caracteres foram substituídos por &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Deseja guardar o documento?&quot;
WARNING = &quot;Esta macro substitui todos os caracteres e números neste documento por &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;.&quot;
Case &quot;nl&quot;
MSGBOXTITLE = &quot;Verander alle tekens in een&apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;Dit document is veranderd. Alle tekens zijn veranderd in een &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Wilt u het document nu opslaan?&quot;
WARNING = &quot;Dit macro verandert alle tekens en cijfers in een &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; in dit document.&quot;
Case &quot;sv&quot;
MSGBOXTITLE = &quot;Byt ut alla bokstäver mot en &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; &quot;
NOTSAVEDTEXT = &quot;Dokumentet har ändrats, med detta makro kommer alla bokstäver att bytas ut mot en &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; . Ska dokumentet säkras/sparas innan?&quot;
WARNING = &quot;Makrot ersätter alla bokstäver och tal i detta dokument med en &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;.&quot;
&apos; Case &quot;da&quot;
&apos; Case &quot;pl&quot;
&apos; Case &quot;ru&quot;
&apos; English &amp; fallback/default
Case Else
MSGBOXTITLE = &quot;Change all characters to a &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;&quot;
NOTSAVEDTEXT = &quot;This Document is modified: All characters are changed to an &quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos;. Shall the document be saved now?&quot;
WARNING = &quot;This macro changes all characters and numbers to an &apos;&quot; &amp; UPPERREPLACECHAR &amp; &quot;&apos; in this document.&quot;
End Select
End Sub
</script:module>
End Sub</script:module>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="GetTexts" script:language="StarBasic">Option Explicit
&apos; Option für doppelte Strings
&apos; Alternativtexte, Namen usw für HTML-Seiten--&gt; ist Anbindung an StarOfficeAPI geplant?
@@ -27,35 +27,34 @@ Sub Main
Dim sDocType as String
Dim oHyperCursor as Object
Dim oCharStyles as Object
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
On Local Error GoTo NODOCUMENT
oDocument = StarDesktop.ActiveFrame.Controller.Model
sDocType = GetDocumentType(oDocument)
NODOCUMENT:
If Err &lt;&gt; 0 Then
Msgbox(&quot;This Macro extracts all Data of the displayed Writer-, Calc or Draw-Documents.&quot; &amp; chr(13) &amp;_
&quot;To start this macro you have to activate a Document first!&quot; , 16, &quot;StarOffice 5.2&quot;)
&quot;To start this macro you have to activate a Document first!&quot; , 16, GetProductName)
Exit Sub
End If
On Local Error Goto 0
&apos; Open a new document where all the texts are inserted
oLogDocument = StarDesktop.LoadComponentFromURL( &quot;staroffice:factory/swriter&quot;,&quot;_blank&quot;,0,NoArgs())
oLogDocument = StarDesktop.LoadComponentFromURL( &quot;private:factory/swriter&quot;,&quot;_blank&quot;,0,NoArgs())
oLogText = oLogDocument.Text
&apos; create and define the character styles of the Log-document
oCharStyles = oLogDocument.StyleFamilies.GetByName(&quot;CharacterStyles&quot;)
oLogHeaderStyle = oLogDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oCharStyles.InsertbyName(&quot;LogHeaderText&quot;, oLogHeaderStyle)
oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD
oLogBodyTextStyle = oLogDocument.createInstance(&quot;com.sun.star.style.CharacterStyle&quot;)
oCharStyles.InsertbyName(&quot;LogHeading&quot;, oLogHeaderStyle)
oCharStyles.InsertbyName(&quot;LogBodyText&quot;, oLogBodyTextStyle)
&apos; Insert the title of the activated document as a hyperlink
oHyperCursor = oLogText.createTextCursor()
oHyperCursor.charWeight = com.sun.star.awt.FontWeight.BOLD
oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
oHyperCursor.gotoStart(False)
oHyperCursor.HyperLinkURL = oDocument.URL
oHyperCursor.HyperLinkTarget = oDocument.URL
@@ -77,14 +76,14 @@ Dim oCharStyles as Object
GetDocumentInfo()
Select Case sDocType
Case &quot;sWriter&quot;
Case &quot;swriter&quot;
GetWriterStrings()
Case &quot;sCalc&quot;
Case &quot;scalc&quot;
GetCalcStrings()
Case &quot;sDraw&quot;
Case &quot;sdraw&quot;
GetDrawStrings()
Case Else
Msgbox(&quot;This Macro only works with Writer-, Calc or Draw/Impress-Documents!&quot;, 16, &quot;StarOffice 5.2&quot;)
Msgbox(&quot;This Macro only works with Writer-, Calc or Draw/Impress-Documents!&quot;, 16, GetProductName())
End Select
End Sub
@@ -134,7 +133,7 @@ Dim BigRange, BigEnum, oCell as Object
BigEnum = BigRange.GetCells.CreateEnumeration
While BigEnum.hasmoreElements
oCell = BigEnum.NextElement
If (oCell.Type = com.sun.star.util.NumberFormat.TEXT) AND (oCell.String &lt;&gt; &quot;&quot;) then
If oCell.String &lt;&gt; &quot;&quot; And Val(oCell.String) = 0then
WriteStringtoLogFile(oCell.String)
End If
Wend
@@ -382,7 +381,7 @@ Dim oPage, oPageElement, oShape as Object
For s = 0 To oPageElement.Count - 1
WriteStringToLogFile(oPageElement.GetByIndex(s).String)
Next s
Else
ElseIf HasUnoInterfaces(oPageElement, &quot;com.sun.star.text.XText&quot;) Then
WriteStringtoLogFile(oPageElement.String)
End If
Next
@@ -512,8 +511,6 @@ End Sub
&apos; ***********************************************LogDocument**************************************************
Sub WriteStringtoLogFile( sString as String)
&apos; Schreibt den String in ein Array
If (Not FieldInArray(LogArray(),LogIndex,sString))AND (NOT ISNULL(sString)) Then
LogArray(LogIndex) = sString
LogIndex = LogIndex + 1
@@ -524,89 +521,9 @@ End Sub
Sub MakeLogHeadLine(HeadText as String)
oLogCursor.CharStyle = &quot;LogHeading&quot;
oLogCursor.CharStyleName = &quot;LogHeaderText&quot;
oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oLogText.insertString(oLogCursor,HeadText,False)
oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False)
oLogCursor.CharStyle = &quot;LogBodyText&quot;
End Sub
&apos;Sub GetHTMLStrings(SearchString as String)
&apos;Dim i,AsciiCount as integer
&apos;Dim AsciiLocChar as string
&apos;Dim TTString,AddString as String
&apos;Dim oTextCursor as object
&apos;Dim LeaveLoop as Boolean
&apos; oSearchDesc = oDocument.createSearchDescriptor()
&apos; oSearchDesc.SearchRegularExpression = True
&apos; oSearchDesc.Searchstring = SearchString &amp; &quot;&quot;&quot;&quot; &amp; &quot;*&quot; &amp; &quot;&quot;&quot;&quot;
&apos; oFoundall = oDocument.FindAll(oSearchDesc)
&apos; For i = 0 to oFoundAll.Count-1
&apos; oFound = oFoundall(i)
&apos; oTextCursor = oDocument.text.CreateTextCursorbyRange(oFound)
&apos; oTextCursor.GotoNextWord(false)
&apos; oTextCursor.GotoStartofWord(True)
&apos; oTextCursor.GoRight(1,True)
&apos; TTString = oTextCursor.String
&apos; If Left(TTString,1) = &quot;&quot;&quot;&quot; Then
&apos; LeaveLoop = False
&apos; oTextCursor.GoRight(1,True)
&apos; Do
&apos; oTextCursor.GoRight(1,True)
&apos; TTString = TTString + Right(oTextCursor.String,1)
&apos; If Right(oTextCursor.String,1) = &quot;&quot;&quot;&quot; Then
&apos; TTString = ReplaceString(TTString,&quot;&quot;,&quot;&quot;&quot;&quot;)
&apos; LeaveLoop = True
&apos; End If
&apos; Loop Until LeaveLoop = True
&apos;
&apos; End If
&apos;
&apos; If TTString &lt;&gt; &quot;&quot; then
&apos; TTString = ReplaceHTMLChars(TTString)
&apos; WriteStringtoLogFile(TTString)
&apos; End if
&apos; Next i
&apos;
&apos;End Sub
&apos; If sDocMimeType = &quot;text/html&quot; then
&apos; FileProperties(0).Name = &quot;FilterName&quot;
&apos; FileProperties(0).Value = &quot;swriter: TEXT&quot;
&apos; FilePath = oDocument.URL
&apos; oDocument.Dispose
&apos;
&apos; oDocument = OpenDocument(FilePath,FileProperties(),StarDesktop) &apos;!!!!!!!
&apos;
&apos; MakeLogHeadLine(&quot;Alternativtexte&quot;)
&apos; GetHTMLStrings(&quot;ALT=&quot;)
&apos;
&apos; MakeLogHeadLine(&quot;Referenzen&quot;)
&apos; GetHTMLStrings(&quot;HREF=&quot;)
&apos;
&apos; MakeLogHeadLine(&quot;Namen&quot;)
&apos; GetHTMLStrings(&quot;NAME=&quot;)
&apos; Else
Sub LoadLibrary(sLibname as String)
Dim oArg(0) as new com.sun.star.beans.PropertyValue
Dim oUrl as new com.sun.star.util.URL
Dim oTrans as Object
Dim oDisp as Object
oArg(0).Name = &quot;LibraryName&quot;
oArg(0).Value = sLibname
oTrans = createUNOService(&quot;com.sun.star.util.URLTransformer&quot;)
oUrl.Complete = &quot;slot:6517&quot;
oTrans.parsestrict(oUrl)
oDisp = StarDesktop.currentFrame.queryDispatch(oUrl, &quot;_self&quot;, 0)
oDisp.dispatch(oUrl, oArg())
End Sub
</script:module>
oLogCursor.CharStyleName = &quot;LogBodyText&quot;
End Sub</script:module>

View File

@@ -1,130 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ReadDir" script:language="StarBasic">Option Explicit
&apos; Todo: Capitalization of ReadDirDlg for CVS
&apos; Verzeichnis StarOne überprüfen (letzte beiden Dateien)
&apos; Ordnung nach Verzeichnis und dann die Dateien ( indem &quot;AAAA&quot; vor den Verzeichnisnamen gesetzt wird).
&apos; Nicht-Verzeichnisnamen abfangen
Const SBBASEWIDTH = 8000
Const SBBASEHEIGHT = 1000
Const SBPAGEX = 800
Const SBPAGEY = 800
Const SBBASECHARHEIGHT = 12
Const SBRELDIST = 1.1
&apos;Public Const SBBASEWIDTH = 8000
&apos;Public Const SBBASEHEIGHT = 1000
Public Const SBPAGEX = 800
Public Const SBPAGEY = 800
Public Const SBRELDIST = 1.3
REM Names of the second Dimension of the Array iLevelPos
Const SBBASEX = 0
Const SBBASEY = 1
&apos; Names of the second Dimension of the Array iLevelPos
Public Const SBBASEX = 0
Public Const SBBASEY = 1
Const SBOLDSTARTX = 2
Const SBOLDSTARTY = 3
Public Const SBOLDSTARTX = 2
Public Const SBOLDSTARTY = 3
Const SBOLDENDX = 4
Const SBOLDENDY = 5
Public Const SBOLDENDX = 4
Public Const SBOLDENDY = 5
Const SBNEWSTARTX = 6
Const SBNEWSTARTY = 7
Public Const SBNEWSTARTX = 6
Public Const SBNEWSTARTY = 7
Const SBNEWENDX = 8
Const SBNEWENDY = 9
Public Const SBNEWENDX = 8
Public Const SBNEWENDY = 9
Public ConnectLevel As Integer
Public iLevelPos(10,9) As Integer
Public iLevelPos(1,9) As Long
Public Source as String
Public iCurLevel, nConnectLevel as Integer
Public nOldWidth, nOldHeight As Integer
Public iCurLevel as Integer
Public nConnectLevel as Integer
Public nOldWidth, nOldHeight As Long
Public nOldX, nOldY, nOldLevel As Integer
Public oOldLeavingLine As Object
Public oOldArrivingLine As Object
Public DlgReadDir as Object
Dim oProgressBar as Object
Dim oDocument As Object
Dim oPage As Object
Sub Main
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
BasicLibraries.LoadLibrary(&quot;Template&quot;)
ReadDirDlg.Load
ReadDirDlg.Show
Dim oStandardTemplate as Object
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
oDocument = StarDesktop.LoadComponentFromURL(&quot;private:factory/sdraw&quot;,&quot;_blank&quot;,0, NoArgs())
oPage = oDocument.DrawPages(0)
oStandardTemplate = oDocument.StyleFamilies.GetByName(&quot;graphics&quot;).GetByName(&quot;Standard&quot;)
oStandardTemplate.CharHeight = 10
oStandardTemplate.TextLeftDistance = 100
oStandardTemplate.TextRightDistance = 100
oStandardTemplate.TextUpperDistance = 50
oStandardTemplate.TextLowerDistance = 50
DlgReadDir = LoadDialog(&quot;Gimmicks&quot;,&quot;ReadDirDlg&quot;)
oProgressBar = DlgReadDir.Model.ProgressBar1
DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings(&quot;Work&quot;))
DlgReadDir.Model.cmdGoOn.DefaultButton = True
DlgReadDir.GetControl(&quot;TextField1&quot;).SetFocus()
DlgReadDir.Execute
End Sub
Sub TreeInfo()
Dim oCurTextShape As Object
Dim oDesktop As Object
Dim oDocument As Object
Dim iCurPage As Integer
Dim oPage As Object
Dim oOldPage As Object
Dim i, n, s as Integer
Dim i as Integer
Dim bStartUpRun As Boolean
Dim FileNames(600,2) as String
Dim CurFile as String
Dim CurFilename as String
Dim BaseLevel as Integer
Dim oController as Object
Dim FileCount as Integer
Dim oStatusline as Object
ReadDirDlg.Unload
bStartUpRun = TRUE
Dim MaxFileIndex as Integer
Dim FileNames() as String
ToggleDialogControls(False)
oProgressBar.ProgressValueMin = 0
oProgressBar.ProgressValueMax = 100
bStartUpRun = True
nOldHeight = 200
nOldY = SBPAGEY
nOldX = SBPAGEX
nOldWidth = SBPAGEX
iCurPage = 0
oDesktop = createUnoService(&quot;com.sun.star.frame.Desktop&quot;)
oDocument = StarDesktop.ActiveFrame.Controller.Model
oPage = oDocument.DrawPages(iCurPage)
oStatusline = oDocument.GetCurrentController.GetFrame.GetStatusIndicator
oStatusLine.Start(&quot;Fortschritt:&quot;,100)
oController = oDocument.GetCurrentController
Source = ConvertToURL(ReadDirdlg.Textbox1.Text)
Source = ConvertToURL(DlgReadDir.Model.TextField1.Text)
BaseLevel = CountCharsInString(Source, &quot;/&quot;, 1)
oStatusline.SetValue(2)
oProgressBar.ProgressValue = 5
DlgReadDir.Model.Label3.Enabled = True
FileNames() = ReadSourceDirectory(Source)
oStatusline.SetValue(8)
DlgReadDir.Model.Label4.Enabled = True
DlgReadDir.Model.Label3.Enabled = False
oProgressBar.ProgressValue = 12
FileNames() = BubbleSortList(FileNames())
oStatusline.SetValue(10)
FileCount = Val(FileNames(0,0))
For i = 1 To FileCount
oStatusLine.SetValue(10 + i/FileCount * 90)
CurFile = FileNames(i,1)
iCurLevel= CountCharsInString(FileNames(i,0), &quot;/&quot;, 1) - BaseLevel
If iCurLevel &lt;&gt; 0 Then
nConnectLevel = iCurLevel- 1
Else
nConnectLevel = iCurLevel
DlgReadDir.Model.Label5.Enabled = True
DlgReadDir.Model.Label4.Enabled = False
oProgressBar.ProgressValue = 20
MaxFileIndex = Ubound(FileNames(),1)
For i = 0 To MaxFileIndex
oProgressBar.ProgressValue = 20 + (i/MaxFileIndex * 80)
CurFilename = FileNames(i,1)
SetNewLevels(FileNames(i,0), BaseLevel)
oCurTextShape = CreateTextShape(oPage, CurFilename)
CheckPageWidth(oCurTextShape.Size.Width)
iLevelPos(iCurLevel,SBBASEY) = oCurTextShape.Position.Y
If i = 0 Then
AdjustPageHeight(oCurTextShape.Size.Height, MaxFileIndex + 1)
End If
REM Add New page If necessary
REM ck IF nOldY + nOldHeight * 1/SBRELDIST &gt; oPage.Height - SBPAGEY Then
IF nOldY + (nOldHeight + SBBASECHARHEIGHT) * 1.5 &gt; oPage.Height - SBPAGEY Then
iCurPage = iCurPage + 1
oDocument.getDrawPages.InsertNewbyIndex(iCurPage)
oPage = oDocument.DrawPages(iCurPage)
oController.SetCurrentPage (oPage)
For n = 0 To nConnectLevel
iLevelPos(n,SBNEWENDY) = nOldY + nOldHeight REM oOldPage.Height
oOldLeavingLine = DrawLine(n, SBNEWSTARTX, SBNEWSTARTY, SBNEWSTARTX, SBNEWENDY, oOldPage)
REM ck SBNEWENDX, SBNEWENDY)
Next
For n = 0 To nConnectLevel
iLevelPos(n,SBNEWSTARTY) = SBPAGEY
Next
nOldY = SBPAGEY
End If
oCurTextShape = CreateTextShape(oPage, CurFile)
REM The Current TextShape has To be connected with a TextShape
REM one Level higher
REM - except For a TextShape In Level 0
REM Line Coordinates
&apos; The Current TextShape has To be connected with a TextShape one Level higher
&apos; except for a TextShape In Level 0:
If Not bStartUpRun Then
REM A leaving Line Is only drawn when level is not 0
&apos; A leaving Line Is only drawn when level is not 0
If iCurLevel&lt;&gt; 0 Then
REM Determine the Coordinates of the arriving Line
&apos; Determine the Coordinates of the arriving Line
iLevelPos(iCurLevel,SBOLDSTARTX) = iLevelPos(nConnectLevel,SBNEWSTARTX)
iLevelPos(iCurLevel,SBOLDSTARTY) = oCurTextShape.Position.Y + 0.5 * oCurTextShape.Size.Height
@@ -133,92 +117,66 @@ REM Determine the Coordinates of the arriving Line
oOldArrivingLine = DrawLine(iCurLevel, SBOLDSTARTX, SBOLDSTARTY, SBOLDENDX, SBOLDENDY, oPage)
REM Determine the End-Coordinates of the last leaving Line
&apos; Determine the End-Coordinates of the last leaving Line
iLevelPos(nConnectLevel,SBNEWENDX) = iLevelPos(nConnectLevel,SBNEWSTARTX)
iLevelPos(nConnectLevel,SBNEWENDY) = oCurTextShape.Position.Y + 0.5 * oCurTextShape.Size.Height
Else
REM On Level 0 the last Leaving Line&apos;s endpoint
REM is the upper edge of the textShape
&apos; On Level 0 the last Leaving Line&apos;s Endpoint is the upper edge of the TextShape
iLevelPos(nConnectLevel,SBNEWENDY) = oCurTextShape.Position.Y
iLevelPos(nConnectLevel,SBNEWENDX) = iLevelPos(nConnectLevel,SBNEWSTARTX)
End If
REM Draw the Connectors To the previous TextShapes
&apos; Draw the Connectors To the previous TextShapes
oOldLeavingLine = DrawLine(nConnectLevel, SBNEWSTARTX, SBNEWSTARTY, SBNEWENDX, SBNEWENDY, oPage)
Else
REM StartingPoint of the leaving edge
&apos; StartingPoint of the leaving Edge
bStartUpRun = FALSE
End If
REM Determine the beginning Coordinates of the leaving Line
&apos; Determine the beginning Coordinates of the leaving Line
iLevelPos(iCurLevel,SBNEWSTARTX) = iLevelPos(iCurLevel,SBBASEX) + 0.5 * oCurTextShape.Size.Width
iLevelPos(iCurLevel,SBNEWSTARTY) = iLevelPos(iCurLevel,SBBASEY) + oCurTextShape.Size.Height
REM Save the values For the Next run
&apos; Save the values For the Next run
nOldHeight = oCurTextShape.Size.Height
nOldX = oCurTextShape.Position.X
nOldWidth = oCurTextShape.Size.Width
nOldLevel = iCurLevel
Set oOldPage = oPage
Next i
oStatusLine.End
Exit Sub
ErrorHandler:
MsgBox error, 0,&quot;Error in Line&quot; &amp; erl
ToggleDialogControls(True)
End Sub
Function CreateTextShape(oPage as Object, Filename as String)
Dim oTextShape As Object
Dim PageWidth, BaseX, TextWidth
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aSize.Width = SBBASEWIDTH
aSize.Height = SBBASEHEIGHT
aPoint.x = CalculateXPoint()
aPoint.y = nOldY + SBRELDIST * nOldHeight
nOldY = aPoint.y
aPoint.X = CalculateXPoint()
aPoint.Y = nOldY + SBRELDIST * nOldHeight
nOldY = aPoint.Y
oTextShape = oDocument.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
oTextShape.Size = aSize
oTextShape.LineStyle = 1
oTextShape.Position = aPoint
oPage.add(oTextShape)
oTextShape.LineStyle = 1
oTextShape.Charheight = SBBASECHARHEIGHT
oTextShape.TextAutoGrowWidth = TRUE
oTextShape.TextAutoGrowHeight = TRUE
oTextShape.String = FileName
REM Configure Size And Position of the TextShape according to its Scripting
aPoint.x = iLevelPos(iCurLevel,SBBASEX)
&apos; Configure Size And Position of the TextShape according to its Scripting
aPoint.X = iLevelPos(iCurLevel,SBBASEX)
oTextShape.Position = aPoint
aSize.Height = SBRELDIST * oTextShape.CharHeight
aSize.Width = SBRELDIST * oTextShape.Size.Width
PageWidth = oPage.Width
TextWidth = aSize.Width
BaseX = aPoint.x
If BaseX + TextWidth &gt; PageWidth - 1000 Then
oPage.Width = 1000 + BaseX + TextWidth
End If
oTextShape.Size = aSize
iLevelPos(iCurLevel,SBBASEY) = oTextShape.Position.Y
CreateTextShape = oTextShape
CreateTextShape() = oTextShape
End Function
Function CalculateXPoint()
REM The current level Is lower than the Old one
&apos; The current level Is lower than the Old one
If (iCurLevel&lt; nOldLevel) And (iCurLevel&lt;&gt; 0) Then
REM ClearArray(iLevelPos(),iCurLevel+1)
&apos; ClearArray(iLevelPos(),iCurLevel+1)
Elseif iCurLevel= 0 Then
iLevelPos(iCurLevel,SBBASEX) = SBPAGEX
REM The current level Is higher than the old one
&apos; The current level Is higher than the old one
Elseif iCurLevel&gt; nOldLevel Then
iLevelPos(iCurLevel,SBBASEX) = iLevelPos(iCurLevel-1,SBBASEX) + nOldWidth + 100
End If
@@ -226,73 +184,125 @@ REM The current level Is higher than the old one
End Function
Function DrawLine(nLevel, nStartX, nStartY, nEndX, nEndY As Integer, oPage as Object)
Dim oConnect As Object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.X = iLevelPos(nLevel,nStartX)
aPoint.Y = iLevelPos(nLevel,nStartY)
aSize.Width = iLevelPos(nLevel,nEndX) - iLevelPos(nLevel,nStartX)
aSize.Height = iLevelPos(nLevel,nEndY) - iLevelPos(nLevel,nStartY)
oConnect = oDocument.createInstance(&quot;com.sun.star.drawing.LineShape&quot;)
oConnect.Position = aPoint
oConnect.Size = aSize
oPage.Add(oConnect)
DrawLine = oConnect
DrawLine() = oConnect
End Function
Sub SourceSearchDialog()
Source = Application.FileDialog( &quot;P&quot;, &quot;Wählen Sie ein Verzeichnis&quot;, &quot;D:\Arbeitsverzeichnis&quot; ) &apos; &quot;Wählen Sie ein Verzeichnis&quot;
If Len( Source ) &gt; 0 Then
ReadDirDlg.Textbox1.Text = Source
Sub GetSourceDirectory()
GetFolderName(DlgReadDir.Model.TextField1)
End Sub
Function ReadSourceDirectory(ByVal Source As String)
Dim i as Integer
Dim m as Integer
Dim n as Integer
Dim s as integer
Dim FileName as string
Dim FileNameList(100,1) as String
Dim DirList(0) as String
Dim oUCBobject as Object
Dim DirContent() as String
Dim SystemPath as String
Dim PathSeparator as String
Dim MaxFileIndex as Integer
PathSeparator = GetPathSeparator()
oUcbobject = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
m = 0
s = 0
DirList(0) = Source
FileNameList(n,0) = Source
SystemPath = ConvertFromUrl(Source)
FileNameList(n,1) = FileNameoutofPath(SystemPath, PathSeparator)
n = 1
Do
Source = DirList(m)
m = m + 1
DirContent() = oUcbObject.GetFolderContents(Source,True)
If Ubound(DirContent()) &lt;&gt; -1 Then
MaxFileIndex = Ubound(DirContent())
For i = 0 to MaxFileIndex
FileName = DirContent(i)
FileNameList(n,0) = FileName
SystemPath = ConvertFromUrl(FileName)
FileNameList(n,1) = FileNameOutofPath(SystemPath, PathSeparator)
n = n + 1
If n &gt; Ubound(FileNameList(),1) Then
ReDim Preserve FileNameList(n + 10,1) as String
End If
If oUcbObject.IsFolder(FileName) Then
s = s + 1
ReDim Preserve DirList(s) as String
DirList(s) = FileName
End If
Next i
End If
Loop Until m &gt; Ubound(DirList()
ReDim Preserve FileNameList(n-1,1) as String
ReadSourceDirectory() = FileNameList()
End Function
Sub CloseDialog
DlgReadDir.EndExecute
End Sub
Sub AdjustPageHeight(lShapeHeight, FileCount)
Dim lNecHeight as Long
Dim lBorders as Long
oDocument.LockControllers
lBorders = oPage.BorderTop + oPage.BorderBottom
lNecHeight = SBPAGEY + (FileCount * SBRELDIST * lShapeHeight)
If lNecHeight &gt; (oPage.Height - lBorders) Then
oPage.Height = lNecHeight + lBorders + 500
End If
oDocument.UnlockControllers
End Sub
Sub SetNewLevels(FileName as String, BaseLevel as Integer)
iCurLevel= CountCharsInString(FileName, &quot;/&quot;, 1) - BaseLevel
If iCurLevel &lt;&gt; 0 Then
nConnectLevel = iCurLevel- 1
Else
nConnectLevel = iCurLevel
End If
If iCurLevel &gt; Ubound(iLevelPos(),1) Then
ReDim Preserve iLevelPos(iCurLevel,9) as Long
End If
End Sub
Sub CheckPageWidth(TextWidth as Long)
Dim PageWidth as Long
Dim BaseX as Long
PageWidth = oPage.Width
BaseX = iLevelPos(iCurLevel,SBBASEX)
If BaseX + TextWidth &gt; PageWidth - 1000 Then
oPage.Width = 1000 + BaseX + TextWidth
End If
End Sub
Function ReadSourceDirectory(ByVal Source As String)
Dim i, m, n, s as integer
Dim FileCount As Integer
Dim FileCountinDir as Integer
Dim FileName as string
Dim FileNameList(2000,1) as String
Dim DirList(200) as String
Dim oUCBobject as Object
oUcbobject = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
&apos;isfolder
m = 0
s = 1
DirList(0) = Source
FileNameList(1,0) = Source
FileNameList(1,1) = GetFileNameoutofPath(Source)
n = 2
Do
Source = DirList(m)
m = m + 1
DirContent = oUcbObject.GetFolderContents(Source,True)
If Ubound(DirContent()) &lt;&gt; -1 Then
FileCountinDir = Ubound(DirContent()) + 1
For i = 0 to FilecountinDir -1
FileName = DirContent(i)
FilenameList(n,0) = FileName
FileNameList(n,1) = GetFileNameOutofPath(FileName)
n = n + 1
If oUcbObject.IsFolder(FileName) Then
DirList(s) = FileName
DirList(0) = CStr(s)
s = s + 1
End If
Next i
End If
Loop Until m = cInt(DirList(0))+ 1
FileNameList(0,0) = n - 1
ReadSourceDirectory = FileNameList()
End Function
</script:module>
Sub ToggleDialogControls(bDoEnable as Boolean)
With DlgReadDir.Model
.cmdGoOn.Enabled = bDoEnable
.cmdGetDir.Enabled = bDoEnable
.Label1.Enabled = bDoEnable
.Label2.Enabled = bDoEnable
.TextField1.Enabled = bDoEnable
End With
End Sub</script:module>

View File

@@ -1,7 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" dlg:id="UserfieldDlg" dlg:style-id="0">
<dlg:styles>
<dlg:style dlg:style-id="0"/>
</dlg:styles>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="UserfieldDlg" dlg:title="Modify Userfields" dlg:left="161" dlg:top="57" dlg:width="281" dlg:height="214">
<dlg:bulletinboard>
<dlg:text dlg:id="Label1" dlg:tab-index="0" dlg:left="6" dlg:top="48" dlg:width="57" dlg:height="8" dlg:value="Label1"/>
<dlg:text dlg:id="Label2" dlg:tab-index="1" dlg:left="6" dlg:top="64" dlg:width="57" dlg:height="8" dlg:value="Label2"/>
<dlg:text dlg:id="Label3" dlg:tab-index="2" dlg:left="6" dlg:top="80" dlg:width="57" dlg:height="8" dlg:value="Label3"/>
<dlg:text dlg:id="Label4" dlg:tab-index="3" dlg:left="6" dlg:top="96" dlg:width="57" dlg:height="8" dlg:value="Label4"/>
<dlg:text dlg:id="Label5" dlg:tab-index="4" dlg:left="6" dlg:top="112" dlg:width="57" dlg:height="8" dlg:value="Label5"/>
<dlg:text dlg:id="Label6" dlg:tab-index="5" dlg:left="6" dlg:top="128" dlg:width="57" dlg:height="8" dlg:value="Label6"/>
<dlg:text dlg:id="Label7" dlg:tab-index="6" dlg:left="6" dlg:top="144" dlg:width="57" dlg:height="8" dlg:value="Label7"/>
<dlg:text dlg:id="Label8" dlg:tab-index="7" dlg:left="6" dlg:top="160" dlg:width="57" dlg:height="8" dlg:value="Label8"/>
<dlg:text dlg:id="Label9" dlg:tab-index="8" dlg:left="6" dlg:top="176" dlg:width="57" dlg:height="8" dlg:value="Label9"/>
<dlg:textfield dlg:id="TextField1" dlg:tab-index="9" dlg:left="65" dlg:top="46" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField2" dlg:tab-index="10" dlg:left="65" dlg:top="62" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField3" dlg:tab-index="11" dlg:left="65" dlg:top="78" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField4" dlg:tab-index="12" dlg:left="65" dlg:top="94" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField5" dlg:tab-index="13" dlg:left="65" dlg:top="110" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField6" dlg:tab-index="14" dlg:left="65" dlg:top="126" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField7" dlg:tab-index="15" dlg:left="65" dlg:top="142" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField8" dlg:tab-index="16" dlg:left="65" dlg:top="158" dlg:width="193" dlg:height="12"/>
<dlg:textfield dlg:id="TextField9" dlg:tab-index="17" dlg:left="65" dlg:top="174" dlg:width="193" dlg:height="12"/>
<dlg:scrollbar dlg:id="ScrollBar1" dlg:tab-index="18" dlg:left="263" dlg:top="46" dlg:width="12" dlg:height="140" dlg:align="vertical">
<script:event script:event-name="on-mouseup" script:location="application" script:macro-name="Gimmicks.Userfields.ScrollControls" script:language="StarBasic"/>
</dlg:scrollbar>
<dlg:button dlg:id="cmdQuit" dlg:tab-index="19" dlg:left="6" dlg:top="193" dlg:width="35" dlg:height="14" dlg:help-text="Quit Macro" dlg:value="Quit">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.StopMacro" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="cmdSave" dlg:tab-index="20" dlg:left="45" dlg:top="193" dlg:width="35" dlg:height="14" dlg:help-text="Save all Data of all users to file" dlg:value="~Save">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.SaveSettings" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="cmdTakeOver" dlg:tab-index="21" dlg:left="84" dlg:top="193" dlg:width="35" dlg:height="14" dlg:help-text="Insert current User Data into Office Application" dlg:value="Se~lect">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.SelectCurrentFields" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="cmdNextUser" dlg:tab-index="22" dlg:left="162" dlg:top="193" dlg:width="35" dlg:height="14" dlg:tag="1" dlg:help-text="Show Data of Next User" dlg:value="Next &gt;&gt;">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.StepToRecord" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="cmdPrevUser" dlg:tab-index="23" dlg:left="123" dlg:top="193" dlg:width="35" dlg:height="14" dlg:tag="-1" dlg:help-text="Show Data of Previous User" dlg:value="&lt;&lt;Previous">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.StepToRecord" script:language="StarBasic"/>
</dlg:button>
<dlg:button dlg:id="CommandButton1" dlg:tab-index="24" dlg:left="201" dlg:top="193" dlg:width="35" dlg:height="14" dlg:help-text="Add new User" dlg:value="~New">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.AddRecord" script:language="StarBasic"/>
</dlg:button>
<dlg:text dlg:id="Label10" dlg:tab-index="25" dlg:left="6" dlg:top="6" dlg:width="269" dlg:height="34" dlg:value="This Macro offers the opportunity to administrate several user Data in a simple way.&#x0a;The User data of several users may be stored in an own file in the directory &lt;ConfigDir&gt; from where they can be inserted as the main user data into the office." dlg:multiline="true"/>
<dlg:button dlg:id="cmdDelete" dlg:tab-index="26" dlg:left="240" dlg:top="193" dlg:width="35" dlg:height="14" dlg:tag="Delete Data of current User" dlg:value="Delete">
<script:event script:event-name="on-performaction" script:location="application" script:macro-name="Gimmicks.Userfields.DeleteCurrentSettings" script:language="StarBasic"/>
</dlg:button>
</dlg:bulletinboard>
</dlg:window>

View File

@@ -1,196 +1,274 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Userfields" script:language="StarBasic">Option Explicit
&apos;Todo: Controlling Scrollbar via Keyboard
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Userfields" script:language="StarBasic">
Public iUserFieldCount as integer
Public LabelArray(10) as Object
Public EditArray(10) as Object
Public UserFieldName(255) as String
Public UserFieldValue(255) as String
Public Const SBMAXFIELDINDEX = 14
Public DlgUserFields as Object
Public oDocument as Object
Public aTextField as Object
Public aTextFieldEnum as Object
Public const MAXFIELDCOUNT = 9
Public UserFieldDataType(14) as String
Public UserFieldDataType(SBMAXFIELDINDEX,1) as String
Public ScrollBarValue as Integer
Public UserFieldFamily(0, SBMAXfIELDINDEX) as String
Public Const SBTBCOUNT = 9
Public oUserDataAccess as Object
Public CurFieldIndex as Integer
Public FilePath as String
Sub StartChangesUserfields
Dim a as Integer
Dim CurElement, TFMaster as Object
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
LoadLanguage(StarDesktop.ISOLocale.Language)
Dim SystemPath as String
BasicLibraries.LoadLibrary(&quot;Tools&quot;)
UserFieldDatatype(0,0) = &quot;COMPANY&quot;
UserFieldDatatype(0,1) = &quot;o&quot;
UserFieldDatatype(1,0) = &quot;FIRSTNAME&quot;
UserFieldDatatype(1,1) = &quot;givenname&quot;
UserFieldDatatype(2,0) = &quot;NAME&quot;
UserFieldDatatype(2,1) = &quot;sn&quot;
UserFieldDatatype(3,0) = &quot;SHORTCUT&quot;
UserFieldDatatype(3,1) = &quot;initials&quot;
UserFieldDatatype(4,0) = &quot;STREET&quot;
UserFieldDatatype(4,1) = &quot;street&quot;
UserFieldDatatype(5,0) = &quot;COUNTRY&quot;
UserFieldDatatype(5,1) = &quot;c&quot;
UserFieldDatatype(6,0) = &quot;ZIP&quot;
UserFieldDatatype(6,1) = &quot;postalcode&quot;
UserFieldDatatype(7,0) = &quot;CITY&quot;
UserFieldDatatype(7,1) = &quot;l&quot;
UserFieldDatatype(8,0) = &quot;TITLE&quot;
UserFieldDatatype(8,1) = &quot;title&quot;
UserFieldDatatype(9,0) = &quot;POSITION&quot;
UserFieldDatatype(9,1) = &quot;position&quot;
UserFieldDatatype(10,0) = &quot;PHONE_PRIVATE&quot;
UserFieldDatatype(10,1) = &quot;homephone&quot;
UserFieldDatatype(11,0) = &quot;PHONE_COMPANY&quot;
UserFieldDatatype(11,1) = &quot;telephonenumber&quot;
UserFieldDatatype(12,0) = &quot;FAX&quot;
UserFieldDatatype(12,1) = &quot;facsimiletelephonenumber&quot;
UserFieldDatatype(13,0) = &quot;EMAIL&quot;
UserFieldDatatype(13,1) = &quot;mail&quot;
UserFieldDatatype(14,0) = &quot;STATE&quot;
UserFieldDatatype(14,1) = &quot;st&quot;
FilePath = GetPathSettings(&quot;Config&quot;, False) &amp; &quot;/&quot; &amp; &quot;UserData.dat&quot;
DlgUserFields = LoadDialog(&quot;Gimmicks&quot;,&quot;UserfieldDlg&quot;)
SystemPath = ConvertFromUrl(FilePath)
DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, &quot;&apos;&quot; &amp; SystemPath &amp; &quot;&apos;&quot;, &quot;&lt;ConfigDir&gt;&quot;)
ScrollBarValue = 0
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;
On Local Error GoTo NODOCUMENT
oDocument = StarDesktop.ActiveFrame.Controller.Model
NODOCUMENT:
If Err &lt;&gt; 0 Then
Msgbox(Error$ &amp; &quot;This Macro gives you the opportunity to change all Userfields of a displayed Document.&quot; &amp; chr(13) &amp;_
&quot;To start this macro you have to activate a Document first!&quot; , 16, &quot;StarOffice 5.2&quot;)
Exit Sub
End If
On Local Error Goto 0
&apos; Define TextFields
aTextfield = oDocument.getTextfields
aTextFieldEnum = aTextField.CreateEnumeration
a = 0
While aTextFieldEnum.hasmoreElements
CurElement = aTextFieldEnum.NextElement
If Not IsNull(CurElement) Then
If CurElement.PropertySetInfo.hasPropertybyName(&quot;Content&quot;) Then
TFMaster = CurElement.TextFieldMaster
a = a + 1
If a &gt;= 255 Then
MsgBox ErrorMsg1, 0 + 16, ErrorHeader
Exit Sub
End If
UserFieldName(a) = UserFieldDataType(CurElement.UserDataType)
UserFieldValue(a) = CurElement.Content
End If
End If
Wend
iUserFieldCount = a
If iUserFieldCount = 0 Then
MsgBox ErrorMsg2, 0+48, ErrorHeader
Exit Sub
End If
UserfieldDlg.Load
Call SetControlArray()
Call FillDialog()
UserFieldDlg.Show
oUserDataAccess = GetRegistryKeyContent(&quot;org.openoffice.UserProfile/Data&quot;, True)
InitializeUserFamily()
FillDialog()
DlgUserFields.Execute
DlgUserFields.Dispose()
End Sub
Sub FillDialog()
Dim a as Integer
Call SetDialogText
For a = 1 To MaxFieldCount
If a &lt;= iUserFieldCount Then
LabelArray(a).Caption = UserFieldName(a)
EditArray(a).Text = UserFieldValue(a)
Else
LabelArray(a).Caption = &quot;&quot;
EditArray(a).Text = &quot;&quot;
LabelArray(a).Enabled = False
EditArray(a).Enabled = false
End If
Next a
If iUserFieldCount &gt; MaxFieldCount Then
UserfieldDlg.VScrollbar.Min = 0
UserfieldDlg.VScrollbar.Max = iUserFieldCount-MaxFieldCount
UserfieldDlg.VScrollbar.LargeChange = MaxFieldCount
UserfieldDlg.VScrollbar.SmallChange = 1
Else
UserfieldDlg.VScrollbar.enabled = False
End If
With DlgUserFields
For a = 1 To SBTBCount
.GetControl(&quot;Label&quot; &amp; a).Model.Label = UserFieldDataType(a-1,0)
.GetControl(&quot;TextField&quot; &amp; a).Model.Text = UserFieldFamily(CurFieldIndex, a-1)
Next a
.Model.ScrollBar1.ScrollValueMax = (SBMAXFIELDINDEX+1) - SBTBCOUNT
.Model.ScrollBar1.BlockIncrement = SBTBCOUNT
.Model.ScrollBar1.LineIncrement = 1
.Model.ScrollBar1.ScrollValue = ScrollBarValue
End With
End Sub
Sub Dlg_Scroll(ScrollValue)
Call ChangeArray(ScrollBarValue)
ScrollBarValue = UserfieldDlg.VScrollbar.Value
If (ScrollBarValue + MaxFieldCount) &gt; iUserFieldCount Then
ScrollBarValue = iUserFieldCount - MaxFieldCount
Sub ScrollControls()
ScrollTextFieldInfo(ScrollBarValue)
ScrollBarValue = DlgUserFields.Model.ScrollBar1.ScrollValue
If (ScrollBarValue + SBTBCOUNT) &gt;= SBMAXFIELDINDEX + 1 Then
ScrollBarValue = (SBMAXFIELDINDEX + 1) - SBTBCOUNT
End If
For a = 1 To MaxFieldCount
LabelArray(a).Caption = UserFieldName(a + ScrollBarValue)
EditArray(a).Text = UserFieldValue(a + ScrollBarValue)
Next a
FillupTextFields()
End Sub
Sub ChangeArray(ByVal ScrollBarValue)
Sub ScrollTextFieldInfo(ByVal iScrollValue as Integer)
Dim a as Integer
For a = 1 To MaxFieldCount
UserFieldValue(a + ScrollBarValue) = EditArray(a).Text
Dim CurIndex as Integer
For a = 1 To SBTBCOUNT
CurIndex = (a-1) + iScrollValue
UserFieldFamily(CurFieldIndex,CurIndex) = DlgUserFields.GetControl(&quot;TextField&quot; &amp; a).Model.Text
Next a
End Sub
Sub Cancel_Click
UserfieldDlg.Hide
Sub StopMacro()
DlgUserFields.EndExecute
End Sub
Sub Save_Click
Sub SaveSettings()
Dim n as Integer
Dim m as Integer
Dim MaxIndex as Integer
ScrollTextFieldInfo(DlgUserFields.Model.ScrollBar1.ScrollValue)
MaxIndex = Ubound(UserFieldFamily(), 1)
Dim FileStrings(MaxIndex) as String
For n = 0 To MaxIndex
FileStrings(n) = &quot;&quot;
For m = 0 To SBMAXFIELDINDEX
FileStrings(n) = FileStrings(n) &amp; UserFieldFamily(n,m) &amp; &quot;;&quot;
Next m
Next n
SaveDataToFile(FilePath, FileStrings(), True)
End Sub
Sub SaveDataToFile(FilePath as String, DataList() as String)
Dim FileChannel as Integer
Dim i as Integer
Dim CurElement, TFMaster as Object
Dim oFile as Object
Dim oOutputStream as Object
Dim oStreamString as Object
Dim oUcb as Object
Dim sCRLF as String
UserfieldDlg.CancelChanges.Enabled = false
UserfieldDlg.SaveChanges.Enabled = false
sCRLF = CHR(10) &amp; CHR(13)
oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
oOutputStream = createUnoService(&quot;com.sun.star.io.TextOutputStream&quot;)
If oUcb.Exists(FilePath) Then
oUcb.Kill(FilePath)
End If
oFile = oUcb.OpenFileReadWrite(FilePath)
oOutputStream.SetOutputStream(oFile.GetOutputStream)
For i = 0 To Ubound(DataList())
oOutputStream.WriteString(DataList(i) &amp; sCRLF)
Next i
oOutputStream.CloseOutput()
End Sub
ChangeArray(UserfieldDlg.VScrollbar.Value)
aTextfield = oDocument.getTextfields
aTextFieldEnum = aTextField.CreateEnumeration
i = 1
While aTextFieldEnum.hasmoreElements
CurElement = aTextFieldEnum.NextElement
If Not IsNull(CurElement) Then
If Curelement.PropertySetInfo.hasPropertybyName(&quot;Content&quot;) Then
If CurElement.Content &lt;&gt; UserFieldValue(i) Then
CurElement.Content = UserFieldValue(i)
End If
i = i + 1
Sub ToggleButtons(ByVal Index as Integer)
Dim i as Integer
CurFieldIndex = Index
DlgUserFields.Model.cmdNextUser.Enabled = CurFieldIndex &lt;&gt; Ubound(UserFieldFamily(), 1)
DlgUserFields.Model.cmdPrevUser.Enabled = CurFieldIndex &lt;&gt; 0
End Sub
Function LoadDataFromFile(FilePath as String, DataList() as String) as Boolean
Dim oInputStream as Object
Dim i as Integer
Dim oUcb as Object
Dim oFile as Object
Dim MaxIndex as Integer
oUcb = createUnoService(&quot;com.sun.star.ucb.SimpleFileAccess&quot;)
If oUcb.Exists(FilePath) Then
MaxIndex = 10
oInputStream = createUnoService(&quot;com.sun.star.io.TextInputStream&quot;)
oFile = oUcb.OpenFileReadWrite(FilePath)
oInputStream.SetInputStream(oFile.GetInputStream)
i = -1
Redim Preserve DataList(MaxIndex) as String
While Not oInputStream.IsEOF
i = i + 1
If i &gt; MaxIndex Then
MaxIndex = MaxIndex + 10
Redim Preserve DataList(MaxIndex) as String
End If
DataList(i) = oInputStream.ReadLine
Wend
If i &gt; -1 And i &lt;&gt; MaxIndex Then
Redim Preserve DataList(i) as String
End If
Wend
aTextField.Refresh
UserfieldDlg.Hide
LoadDataFromFile() = True
oOutputStream.CloseInput()
Else
LoadDataFromFile() = False
End If
End Function
Sub InitializeUserFamily()
Dim FirstIndex as Integer
Dim UserFieldstrings() as String
Dim LocStrings() as String
Dim bFileExists as Boolean
Dim n as Integer
Dim m as Integer
bFileExists = LoadDataFromFile(GetPathSettings(&quot;Config&quot;, False) &amp; &quot;/&quot; &amp; &quot;UserData.dat&quot;, UserFieldStrings())
If bFileExists Then
FirstIndex = Ubound(UserFieldStrings())
ReDim Preserve UserFieldFamily(FirstIndex, SBMAXFIELDINDEX) as String
For n = 0 To FirstIndex
LocStrings() = ArrayOutofString(UserFieldStrings(n), &quot;;&quot;)
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(n,m) = LocStrings(m)
Next m
Next n
Else
ReDim Preserve UserFieldFamily(0,SBMAXFIELDINDEX) as String
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(0,m) = oUserDataAccess.GetByName(UserFieldDataType(m,1))
Next m
End If
ToggleButtons(0)
End Sub
Sub SetControlArray()
Set LabelArray(1) = UserfieldDlg.Label1
Set EditArray(1) = UserfieldDlg.Textbox1
Set LabelArray(2) = UserfieldDlg.Label2
Set EditArray(2) = UserfieldDlg.Textbox2
Set LabelArray(3) = UserfieldDlg.Label3
Set EditArray(3) = UserfieldDlg.Textbox3
Set LabelArray(4) = UserfieldDlg.Label4
Set EditArray(4) = UserfieldDlg.Textbox4
Set LabelArray(5) = UserfieldDlg.Label5
Set EditArray(5) = UserfieldDlg.Textbox5
Set LabelArray(6) = UserfieldDlg.Label6
Set EditArray(6) = UserfieldDlg.Textbox6
Set LabelArray(7) = UserfieldDlg.Label7
Set EditArray(7) = UserfieldDlg.Textbox7
Set LabelArray(8) = UserfieldDlg.Label8
Set EditArray(8) = UserfieldDlg.Textbox8
Set LabelArray(9) = UserfieldDlg.Label9
Set EditArray(9) = UserfieldDlg.Textbox9
Sub AddRecord()
Dim i as Integer
Dim MaxIndex as Integer
For i = 1 To SBTBCount
DlgUserFields.GetControl(&quot;TextField&quot; &amp; i).Model.Text = &quot;&quot;
Next i
MaxIndex = Ubound(UserFieldFamily(),1)
ReDim Preserve UserFieldFamily(MaxIndex + 1, SBMAXFIELDINDEX) as String
ToggleButtons(MaxIndex + 1, 1)
End Sub
Sub SetDialogText
UserfieldDlg.caption = HeaderLabel
UserfieldDlg.HeaderLabel.Caption = HeaderLabel
UserfieldDlg.CancelChanges.Caption = CancelButton
UserfieldDlg.SaveChanges.Caption = SaveButton
Sub FillupTextFields()
Dim a as Integer
Dim CurIndex as Integer
For a = 1 To SBTBCOUNT
CurIndex = (a-1) + ScrollBarValue
DlgUserFields.GetControl(&quot;Label&quot; &amp; a).Model.Label = UserFieldDataType(CurIndex,0)
DlgUserFields.GetControl(&quot;TextField&quot; &amp; a).Model.Text = UserFieldFamily(CurFieldIndex, CurIndex)
Next a
End Sub
</script:module>
Sub StepToRecord(aEvent as Object)
Dim iStep as Integer
iStep = CInt(aEvent.Source.Model.Tag)
ScrollTextFieldInfo(ScrollBarValue)
ToggleButtons(CurFieldIndex + iStep)
FillUpTextFields()
End Sub
Sub SelectCurrentFields()
Dim MaxIndex as Integer
Dim i as Integer
ScrollTextFieldInfo(ScrollBarValue)
MaxIndex = Ubound(UserFieldFamily(),2)
For i = 0 To MaxIndex
oUserDataAccess.ReplaceByName(UserFieldDataType(i,1), UserFieldFamily(CurFieldIndex, i))
Next i
oUserDataAccess.commitChanges()
End Sub
Sub DeleteCurrentSettings()
Dim n as Integer
Dim m as Integer
Dim MaxIndex as Integer
MaxIndex = Ubound(UserFieldFamily(),1)
If CurFieldIndex &lt; MaxIndex Then
For n = CurFieldIndex To MaxIndex - 1
For m = 0 To SBMAXFIELDINDEX
UserFieldFamily(n,m) = UserFieldFamily(n + 1,m)
Next m
Next n
Else
CurFieldIndex = MaxIndex - 1
End If
ReDim Preserve UserFieldFamily(MaxIndex-1, SBMAXfIELDINDEX) as String
FillupTextFields()
ToggleButtons(CurFieldIndex)
End Sub</script:module>