diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /wizards/source/gimmicks | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wizards/source/gimmicks')
-rw-r--r-- | wizards/source/gimmicks/AutoText.xba | 114 | ||||
-rw-r--r-- | wizards/source/gimmicks/ChangeAllChars.xba | 92 | ||||
-rw-r--r-- | wizards/source/gimmicks/GetTexts.xba | 536 | ||||
-rw-r--r-- | wizards/source/gimmicks/ReadDir.xba | 322 | ||||
-rw-r--r-- | wizards/source/gimmicks/ReadFolderDlg.xdl | 39 | ||||
-rw-r--r-- | wizards/source/gimmicks/UserfieldDlg.xdl | 66 | ||||
-rw-r--r-- | wizards/source/gimmicks/Userfields.xba | 236 | ||||
-rw-r--r-- | wizards/source/gimmicks/dialog.xlb | 6 | ||||
-rw-r--r-- | wizards/source/gimmicks/readdirs.dlg | bin | 0 -> 3180 bytes | |||
-rw-r--r-- | wizards/source/gimmicks/script.xlb | 9 |
10 files changed, 1420 insertions, 0 deletions
diff --git a/wizards/source/gimmicks/AutoText.xba b/wizards/source/gimmicks/AutoText.xba new file mode 100644 index 000000000..a25d1eed9 --- /dev/null +++ b/wizards/source/gimmicks/AutoText.xba @@ -0,0 +1,114 @@ +<?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">' BASIC +Option Explicit +Dim oDocument as Object +Dim sDocumentTitle as String + + +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("Tools") + sDocumentTitle = "Installed AutoTexts" + + ' Open a new empty document + oDocument = CreateNewDocument("swriter") + If Not IsNull(oDocument) Then + oDocument.DocumentProperties.Title = sDocumentTitle + oDocuText = oDocument.Text + + ' Create The Character-templates + oCharStyles = oDocument.StyleFamilies.GetByName("CharacterStyles") + + ' The Characterstyle for the Header that describes the Title of Autotextgroups + oGroupTitleStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("AutoTextGroupTitle", oGroupTitleStyle) + + oGroupTitleStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD + oGroupTitleStyle.CharHeight = 14 + + ' The Characterstyle for the Header that describes the Title of Autotextgroups + oHeaderStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("AutoTextHeading", oHeaderStyle) + oHeaderStyle.CharWeight = com.sun.star.awt.FontWeight.BOLD + + ' "Ordinary" Table Content + oContentStyle = oDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("TableContent", oContentStyle) + + oAutoTextContainer = CreateUnoService("com.sun.star.text.AutoTextContainer") + + oAutoTextCursor = oDocuText.CreateTextCursor() + + oAutoTextCursor.CharStyleName = "AutoTextGroupTitle" + ' Link the Title with the following table + oAutoTextCursor.ParaKeepTogether = True + + For n = 0 To oAutoTextContainer.Count - 1 + oAutoGroup = oAutoTextContainer.GetByIndex(n) + + oAutoTextCursor.SetString(oAutoGroup.Title) + oAutoTextCursor.CollapseToEnd() + oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + oTable = oDocument.CreateInstance("com.sun.star.text.TextTable") + ' Divide the table if necessary + oTable.Split = True +' oTable.KeepTogether = False + oTable.RepeatHeadLine = True + oAutoTextCursor.Text.InsertTextContent(oAutoTextCursor,oTable,False) + InsertStringToCell("AutoText Name",oTable.GetCellbyPosition(0,0), "AutoTextHeading") + InsertStringToCell("AutoText Shortcut",oTable.GetCellbyPosition(1,0), "AutoTextHeading") + ' Insert one row at the bottom of the table + oRows = oTable.Rows + iAutoCount = oAutoGroup.Count + For m = 0 To iAutoCount-1 + ' Insert the name and the title of all Autotexts + oAutoText = oAutoGroup.GetByIndex(m) + InsertStringToCell(oAutoGroup.Titles(m), oTable.GetCellbyPosition(0, m + 1), "TableContent") + InsertStringToCell(oAutoGroup.ElementNames(m), oTable.GetCellbyPosition(1, m + 1), "TableContent") + If m < iAutoCount-1 Then + oRows.InsertbyIndex(m + 2,1) + End If + Next m + oDocuText.insertControlCharacter(oAutoTextCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + oAutoTextCursor.CollapseToEnd() + Next n + End If +End Sub + + +Sub InsertStringToCell(sCellString as String, oCell as Object, sCellStyle as String) +Dim oCellCursor as Object + oCellCursor = oCell.CreateTextCursor() + oCellCursor.CharStyleName = sCellStyle + oCell.Text.insertString(oCellCursor,sCellString,False) + oDocument.CurrentController.Select(oCellCursor) +End Sub</script:module> diff --git a/wizards/source/gimmicks/ChangeAllChars.xba b/wizards/source/gimmicks/ChangeAllChars.xba new file mode 100644 index 000000000..cdcbc9623 --- /dev/null +++ b/wizards/source/gimmicks/ChangeAllChars.xba @@ -0,0 +1,92 @@ +<?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="ChangeAllChars" script:language="StarBasic">' This macro replaces all characters in a writer-document through "x" or "X" signs. +' It works on the currently activated document. +Private const UPPERREPLACECHAR = "X" +Private const LOWERREPLACECHAR = "x" + +Private MSGBOXTITLE +Private NOTSAVEDTEXT +Private WARNING + +Sub ChangeAllChars ' Change all chars in the active document +Dim oSheets, oPages as Object +Dim i as Integer +Const MBYES = 6 +Const MBABORT = 2 +Const MBNO = 7 + BasicLibraries.LoadLibrary("Tools") + MSGBOXTITLE = "Change All Characters to an '" & UPPERREPLACECHAR & "'" + NOTSAVEDTEXT = "This document has already been modified: All characters will be changed to an " & UPPERREPLACECHAR & "'. Should the document be saved now?" + WARNING = "This macro changes all characters and numbers to an '" & UPPERREPLACECHAR & "' in this document." + + On Local Error GoTo NODOCUMENT + oDocument = StarDesktop.ActiveFrame.Controller.Model + NODOCUMENT: + If Err <> 0 Then + Msgbox(WARNING & chr(13) & "First, activate a Writer document." , 16, GetProductName()) + Exit Sub + End If + On Local Error Goto 0 + + sDocType = GetDocumentType(oDocument) + + If oDocument.IsModified And oDocument.Url <> "" Then + Status = MsgBox(NOTSAVEDTEXT, 3+32, MSGBOXTITLE) + Select Case Status + Case MBYES + oDocument.Store + Case MBABORT, MBNO + End + End Select + Else + Status = MsgBox(WARNING, 3+32, MSGBOXTITLE) + If Status = MBNO Or Status = MBABORT Then ' No, Abort + End + End If + End If + + Select Case sDocType + Case "swriter" + ReplaceAllStrings(oDocument) + + Case Else + Msgbox("This macro only works with Writer documents.", 16, GetProductName()) + End Select +End Sub + + +Sub ReplaceAllStrings(oContainer as Object) + ReplaceStrings(oContainer, "[a-z]", LOWERREPLACECHAR) + ReplaceStrings(oContainer, "[à-þ]", LOWERREPLACECHAR) + ReplaceStrings(oContainer, "[A-Z]", UPPERREPLACECHAR) + ReplaceStrings(oContainer, "[À-ß]", UPPERREPLACECHAR) + ReplaceStrings(oContainer, "[0-9]", UPPERREPLACECHAR) +End Sub + + +Sub ReplaceStrings(oContainer as Object, sSearchString, sReplaceString as String) + oReplaceDesc = oContainer.createReplaceDescriptor() + oReplaceDesc.SearchCaseSensitive = True + oReplaceDesc.SearchRegularExpression = True + oReplaceDesc.Searchstring = sSearchString + oReplaceDesc.ReplaceString = sReplaceString + oReplCount = oContainer.ReplaceAll(oReplaceDesc) +End Sub</script:module> diff --git a/wizards/source/gimmicks/GetTexts.xba b/wizards/source/gimmicks/GetTexts.xba new file mode 100644 index 000000000..af93738fd --- /dev/null +++ b/wizards/source/gimmicks/GetTexts.xba @@ -0,0 +1,536 @@ +<?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="GetTexts" script:language="StarBasic">Option Explicit +' Description: +' This macro extracts the strings out of the currently active document and inserts them into a log document. +' The aim of the macro is to provide the programmer an insight into the OpenOffice API. +' It focuses on how document objects are accessed. +' Therefore not only texts of the document body are retrieved but also texts of general +' document objects like, annotations, charts and general document information. + +Public oLogDocument, oLogText, oLogCursor, oLogHeaderStyle, oLogBodyTextStyle as Object +Public oDocument as Object +Public LogArray(1000) as String +Public LogIndex as Integer +Public oLocHeaderStyle as Object + +Sub Main +Dim sDocType as String +Dim oHyperCursor as Object +Dim oCharStyles as Object + BasicLibraries.LoadLibrary("Tools") + On Local Error GoTo NODOCUMENT + oDocument = StarDesktop.ActiveFrame.Controller.Model + sDocType = GetDocumentType(oDocument) + NODOCUMENT: + If Err <> 0 Then + Msgbox("This macro extracts all data from the active Writer, Calc or Draw/Impress document." & chr(13) &_ + "To start this macro you have to activate a document first." , 16, GetProductName) + Exit Sub + End If + On Local Error Goto 0 + + ' Open a new document where all the texts are inserted + oLogDocument = CreateNewDocument("swriter") + If Not IsNull(oLogDocument) Then + oLogText = oLogDocument.Text + + ' create and define the character styles of the log document + oCharStyles = oLogDocument.StyleFamilies.GetByName("CharacterStyles") + oLogHeaderStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("Log Header", oLogHeaderStyle) + + oLogHeaderStyle.charWeight = com.sun.star.awt.FontWeight.BOLD + oLogBodyTextStyle = oLogDocument.createInstance("com.sun.star.style.CharacterStyle") + oCharStyles.InsertbyName("Log Body", oLogBodyTextStyle) + + ' Insert the title of the activated document as a hyperlink + oHyperCursor = oLogText.createTextCursor() + oHyperCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD + oHyperCursor.gotoStart(False) + oHyperCursor.HyperLinkURL = oDocument.URL + oHyperCursor.HyperLinkTarget = oDocument.URL + If oDocument.DocumentProperties.Title <> "" Then + oHyperCursor.HyperlinkName = oDocument.DocumentProperties.Title + End If + oLogText.insertString(oHyperCursor, oDocument.DocumentProperties.Title, False) + oLogText.insertControlCharacter(oHyperCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + + oLogCursor = oLogText.createTextCursor() + oLogCursor.GotoEnd(False) + ' "Switch off" the Hyperlink - Properties + oLogCursor.SetPropertyToDefault("HyperLinkURL") + oLogCursor.SetPropertyToDefault("HyperLinkTarget") + oLogCursor.SetPropertyToDefault("HyperLinkName") + LogIndex = 0 + + ' Get the Properties of the document + GetDocumentProps() + + Select Case sDocType + Case "swriter" + GetWriterStrings() + Case "scalc" + GetCalcStrings() + Case "sdraw", "simpress" + GetDrawStrings() + Case Else + Msgbox("This macro only works with a Writer, Calc or Draw/Impress document.", 16, GetProductName()) + End Select + End If +End Sub + + +' ***********************************************Calc documents************************************************** + +Sub GetCalcStrings() +Dim i, n as integer +Dim oSheet as Object +Dim SheetName as String +Dim oSheets as Object + ' Create a sequence of all sheets within the document + oSheets = oDocument.Sheets + + For i = 0 to osheets.Count - 1 + oSheet = osheets.GetbyIndex(i) + SheetName = oSheet.Name + MakeLogHeadLine("Sheet No. " & i & " (" & SheetName & ")" ) + + ' Check the "body" of the sheet + GetCellTexts(oSheet) + + If oSheet.IsScenario then + MakeLogHeadLine("Scenario Comments from " & SheetName & "'") + WriteStringtoLogFile(osheet.ScenarioComment) + End if + + GetAnnotations(oSheet, "Annotations from '" & SheetName & "'") + + GetChartStrings(oSheet, "Charts from '" & SheetName & "'") + + GetControlStrings(oSheet.DrawPage, "Controls from '" & SheetName & "'") + Next + + ' Pictures + GetCalcGraphicNames() + + GetNamedRanges() +End Sub + + +Sub GetCellTexts(oSheet as Object) +Dim BigRange, BigEnum, oCell as Object + BigRange = oDocument.CreateInstance("com.sun.star.sheet.SheetCellRanges") + BigRange.InsertbyName("",oSheet) + BigEnum = BigRange.GetCells.CreateEnumeration + While BigEnum.hasmoreElements + oCell = BigEnum.NextElement + If oCell.String <> "" And Val(oCell.String) = 0then + WriteStringtoLogFile(oCell.String) + End If + Wend +End Sub + + +Sub GetAnnotations(oSheet as Object, HeaderLine as String) +Dim oNotes as Object +Dim n as Integer + oNotes = oSheet.getAnnotations + If oNotes.hasElements() then + MakeLogHeadLine(HeaderLine) + For n = 0 to oNotes.Count-1 + WriteStringtoLogFile(oNotes.GetbyIndex(n).String) + Next + End if +End Sub + + +Sub GetNamedRanges() +Dim i as integer + MakeLogHeadLine("Named Ranges") + For i = 0 To oDocument.NamedRanges.Count - 1 + WriteStringtoLogFile(oDocument.NamedRanges.GetbyIndex(i).Name) + Next +End Sub + + +Sub GetCalcGraphicNames() +Dim n,m as integer + MakeLogHeadLine("Graphics") + For n = 0 To oDocument.Drawpages.count-1 + For m = 0 To oDocument.Drawpages.GetbyIndex(n).Count - 1 + WriteStringtoLogFile(oDocument.DrawPages.GetbyIndex(n).GetbyIndex(m).Text.String) + Next m + Next n +End Sub + + +' ***********************************************Writer documents************************************************** + +Sub GetParagraphTexts(oParaObject as Object, HeadLine as String) +Dim ParaEnum as Object +Dim oPara as Object +Dim oTextPortEnum as Object +Dim oTextPortion as Object +Dim i as integer +Dim oCellNames() +Dim oCell as Object + + MakeLogHeadLine(HeadLine) + ParaEnum = oParaObject.Text.CreateEnumeration + + While ParaEnum.HasMoreElements + oPara = ParaEnum.NextElement + + ' Note: The enumeration ParaEnum lists all tables and paragraphs. + ' Therefore we have to find out what kind of object "oPara" actually is + If oPara.supportsService("com.sun.star.text.Paragraph") Then + ' "oPara" is a Paragraph + oTextPortEnum = oPara.createEnumeration + While oTextPortEnum.hasmoreElements + oTextPortion = oTextPortEnum.nextElement() + WriteStringToLogFile(oTextPortion.String) + Wend + Else + ' "oPara" is a table + oCellNames = oPara.CellNames + For i = 0 To Ubound(oCellNames()) + If oCellNames(i) <> "" Then + oCell = oPara.getCellByName(oCellNames(i)) + WriteStringToLogFile(oCell.String) + End If + Next + End If + Wend +End Sub + + +Sub GetChartStrings(oSheet as Object, HeaderLine as String) +Dim i as Integer +Dim aChartObject as Object +Dim aChartDiagram as Object + + MakeLogHeadLine(HeaderLine) + + For i = 0 to oSheet.Charts.Count-1 + aChartObject = oSheet.Charts.GetByIndex(i).EmbeddedObject + If aChartObject.HasSubTitle then + WriteStringToLogFile(aChartObject.SubTitle.String) + End If + + If aChartObject.HasMainTitle then + WriteStringToLogFile(aChartObject.Title.String) + End If + + aChartDiagram = aChartObject.Diagram + + If aChartDiagram.hasXAxisTitle Then + WriteStringToLogFile(aChartDiagram.XAxisTitle) + End If + + If aChartDiagram.hasYAxisTitle Then + WriteStringToLogFile(aChartDiagram.YAxisTitle) + End If + + If aChartDiagram.hasZAxisTitle Then + WriteStringToLogFile(aChartDiagram.ZAxisTitle) + End If + Next i +End Sub + + +Sub GetFrameTexts() +Dim i as integer +Dim oTextFrame as object +Dim oFrameEnum as Object +Dim oFramePort as Object +Dim oFrameTextEnum as Object +Dim oFrameTextPort as Object + + MakeLogHeadLine("Text Frames") + For i = 0 to oDocument.TextFrames.Count-1 + oTextFrame = oDocument.TextFrames.GetbyIndex(i) + WriteStringToLogFile(oTextFrame.Name) + + ' Is the frame bound to the page? + If oTextFrame.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE Then + GetParagraphTexts(oTextFrame, "Text Frame Contents") + End If + + oFrameEnum = oTextFrame.CreateEnumeration + While oFrameEnum.HasMoreElements + oFramePort = oFrameEnum.NextElement + If oFramePort.supportsService("com.sun.star.text.Paragraph") then + oFrameTextEnum = oFramePort.createEnumeration + While oFrameTextEnum.HasMoreElements + oFrameTextPort = oFrameTextEnum.NextElement + If oFrameTextPort.SupportsService("com.sun.star.text.TextFrame") Then + WriteStringtoLogFile(oFrameTextPort.String) + End If + Wend + Else + WriteStringtoLogFile(oFramePort.Name) + End if + Wend + Next +End Sub + + +Sub GetTextFieldStrings() +Dim aTextField as Object +Dim i as integer +Dim CurElement as Object + MakeLogHeadLine("Text Fields") + aTextfield = oDocument.getTextfields.CreateEnumeration + While aTextField.hasmoreElements + CurElement = aTextField.NextElement + If CurElement.PropertySetInfo.hasPropertybyName("Content") Then + WriteStringtoLogFile(CurElement.Content) + ElseIf CurElement.PropertySetInfo.hasPropertybyName("PlaceHolder") Then + WriteStringtoLogFile(CurElement.PlaceHolder) + WriteStringtoLogFile(CurElement.Hint) + ElseIf Curelement.TextFieldMaster.PropertySetInfo.HasPropertybyName("Content") then + WriteStringtoLogFile(CurElement.TextFieldMaster.Content) + End If + Wend +End Sub + + +Sub GetLinkedFileNames() +Dim oDocSections as Object +Dim LinkedFileName as String +Dim i as Integer + If Right(oDocument.URL,3) = "sgl" Then + MakeLogHeadLine("Sub-documents") + oDocSections = oDocument.TextSections + For i = 0 to oDocSections.Count - 1 + LinkedFileName = oDocSections.GetbyIndex(i).FileLink.FileURL + If LinkedFileName <> "" Then + WriteStringToLogFile(LinkedFileName) + End If + Next i + End If +End Sub + + +Sub GetSectionNames() +Dim i as integer +Dim oDocSections as Object + MakeLogHeadLine("Sections") + oDocSections = oDocument.TextSections + For i = 0 to oDocSections.Count-1 + WriteStringtoLogFile(oDocSections.GetbyIndex(i).Name) + Next +End Sub + + +Sub GetWriterStrings() + GetParagraphTexts(oDocument, "Document Body") + GetGraphicNames() + GetStyles() + GetControlStrings(oDocument.DrawPage, "Controls") + GetTextFieldStrings() + GetSectionNames() + GetFrameTexts() + GetHyperLinks + GetLinkedFileNames() +End Sub + + +' ***********************************************Draw/Impress documents************************************************** + +Sub GetDrawPageTitles(LocObject as Object) +Dim n as integer +Dim oPage as Object + + For n = 0 to LocObject.Count - 1 + oPage = LocObject.GetbyIndex(n) + WriteStringtoLogFile(oPage.Name) + ' Is the page a DrawPage and not a MasterPage? + If oPage.supportsService("com.sun.star.drawing.DrawPage")then + ' Get the name of the NotesPage (only relevant for Impress documents) + If oDocument.supportsService("com.sun.star.presentation.PresentationDocument") then + WriteStringtoLogFile(oPage.NotesPage.Name) + End If + End If + Next +End Sub + + +Sub GetPageStrings(oPages as Object) +Dim m, n, s as Integer +Dim oPage, oPageElement, oShape as Object + For n = 0 to oPages.Count-1 + oPage = oPages.GetbyIndex(n) + If oPage.HasElements then + For m = 0 to oPage.Count-1 + oPageElement = oPage.GetByIndex(m) + If HasUnoInterfaces(oPageElement,"com.sun.star.container.XIndexAccess") Then + ' The Object "oPageElement" a group of Shapes, that can be accessed by their index + For s = 0 To oPageElement.Count - 1 + WriteStringToLogFile(oPageElement.GetByIndex(s).String) + Next s + ElseIf HasUnoInterfaces(oPageElement, "com.sun.star.text.XText") Then + WriteStringtoLogFile(oPageElement.String) + End If + Next + End If + Next +End Sub + + +Sub GetDrawStrings() +Dim oDPages, oMPages as Object + + oDPages = oDocument.DrawPages + oMPages = oDocument.Masterpages + + MakeLogHeadLine("Titles") + GetDrawPageTitles(oDPages) + GetDrawPageTitles(oMPages) + + MakeLogHeadLine("Document Body") + GetPageStrings(oDPages) + GetPageStrings(oMPages) +End Sub + + +' ***********************************************Misc************************************************** + +Sub GetDocumentProps() +Dim oDocuProps as Object + MakeLogHeadLine("Document Properties") + oDocuProps = oDocument.DocumentProperties + WriteStringToLogFile(oDocuProps.Title) + WriteStringToLogFile(oDocuProps.Description) + WriteStringToLogFile(oDocuProps.Subject) + WriteStringToLogFile(oDocuProps.Author) + ' WriteStringToLogFile(oDocuProps.UserDefinedProperties.ReplyTo) + ' WriteStringToLogFile(oDocuProps.UserDefinedProperties.Recipient) + ' WriteStringToLogFile(oDocuProps.UserDefinedProperties.References) + ' WriteStringToLogFile(oDocuProps.Keywords) +End Sub + + +Sub GetHyperlinks() +Dim i as integer +Dim oCrsr as Object +Dim oAllHyperLinks as Object +Dim SrchAttributes(0) as new com.sun.star.beans.PropertyValue +Dim oSearchDesc as Object + + MakeLogHeadLine("Hyperlinks") + ' create a Search-Descriptor + oSearchDesc = oDocument.CreateSearchDescriptor + oSearchDesc.Valuesearch = False + + ' define the Search-attributes + srchattributes(0).Name = "HyperLinkURL" + srchattributes(0).Value = "" + oSearchDesc.SetSearchAttributes(SrchAttributes()) + + oAllHyperLinks = oDocument.findAll(oSearchDesc()) + + For i = 0 to oAllHyperLinks.Count - 1 + oFound = oAllHyperLinks(i) + oCrsr = oFound.Text.createTextCursorByRange(oFound) + WriteStringToLogFile(oCrs.HyperLinkURL) 'Url + WriteStringToLogFile(oCrs.HyperLinkTarget) 'Name + WriteStringToLogFile(oCrs.HyperLinkName) 'Frame + Next i +End Sub + + +Sub GetGraphicNames() +Dim i as integer +Dim oDocGraphics as Object + MakeLogHeadLine("Graphics") + oDocGraphics = oDocument.GraphicObjects + For i = 0 to oDocGraphics.count - 1 + WriteStringtoLogFile(oDocGraphics.GetbyIndex(i).Name) + Next +End Sub + + +Sub GetStyles() +Dim m,n as integer + MakeLogHeadLine("User-defined Templates") + + ' Check all StyleFamilies(i.e. PageStyles, ParagraphStyles, CharacterStyles, cellStyles) + For n = 0 to oDocument.StyleFamilies.Count - 1 + For m = 0 to oDocument.StyleFamilies.getbyIndex(n).Count-1 + If oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).IsUserDefined then + WriteStringtoLogFile(oDocument.StyleFamilies.GetbyIndex(n).getbyIndex(m).Name) + End If + Next + Next +End Sub + + +Sub GetControlStrings(oDPage as Object, HeaderLine as String) +Dim aForm as Object +Dim m,n as integer + MakeLogHeadLine(HeaderLine) + 'SearchFor all possible Controls + For n = 0 to oDPage.Forms.Count - 1 + aForm = oDPage.Forms(n) + For m = 0 to aForm.Count-1 + GetControlContent(aForm.GetbyIndex(m)) + Next + Next +End Sub + + +Sub GetControlContent(LocControl as Object) +Dim i as integer + + If LocControl.PropertySetInfo.HasPropertybyName("Label") then + WriteStringtoLogFile(LocControl.Label) + + ElseIf LocControl.SupportsService("com.sun.star.form.component.ListBox") then + For i = 0 to Ubound(LocControl.StringItemList()) + WriteStringtoLogFile(LocControl.StringItemList(i)) + Next + End If + If LocControl.PropertySetInfo.HasPropertybyName("HelpText") then + WriteStringtoLogFile(LocControl.Helptext) + End If +End Sub + +' ***********************************************Log document************************************************** + +Sub WriteStringtoLogFile( sString as String) + If (Not FieldInArray(LogArray(),LogIndex,sString))AND (NOT ISNULL(sString)) Then + LogArray(LogIndex) = sString + LogIndex = LogIndex + 1 + oLogText.insertString(oLogCursor,sString,False) + oLogText.insertControlCharacter(oLogCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,False) + End If +End Sub + + +Sub MakeLogHeadLine(HeadText as String) + oLogCursor.CharStyleName = "Log Header" + 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.CharStyleName = "Log Body" +End Sub +</script:module> diff --git a/wizards/source/gimmicks/ReadDir.xba b/wizards/source/gimmicks/ReadDir.xba new file mode 100644 index 000000000..b60469508 --- /dev/null +++ b/wizards/source/gimmicks/ReadDir.xba @@ -0,0 +1,322 @@ +<?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="ReadDir" script:language="StarBasic">Option Explicit +Public Const SBPAGEX = 800 +Public Const SBPAGEY = 800 +Public Const SBRELDIST = 1.3 + +' Names of the second Dimension of the Array iLevelPos +Public Const SBBASEX = 0 +Public Const SBBASEY = 1 + +Public Const SBOLDSTARTX = 2 +Public Const SBOLDSTARTY = 3 + +Public Const SBOLDENDX = 4 +Public Const SBOLDENDY = 5 + +Public Const SBNEWSTARTX = 6 +Public Const SBNEWSTARTY = 7 + +Public Const SBNEWENDX = 8 +Public Const SBNEWENDY = 9 + +Public ConnectLevel As Integer +Public iLevelPos(1,9) As Long +Public Source as String +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() +Dim oStandardTemplate as Object + BasicLibraries.LoadLibrary("Tools") + oDocument = CreateNewDocument("sdraw") + If Not IsNull(oDocument) Then + oPage = oDocument.DrawPages(0) + oStandardTemplate = oDocument.StyleFamilies.GetByName("graphics").GetByName("standard") + oStandardTemplate.CharHeight = 10 + oStandardTemplate.TextLeftDistance = 100 + oStandardTemplate.TextRightDistance = 100 + oStandardTemplate.TextUpperDistance = 50 + oStandardTemplate.TextLowerDistance = 50 + DlgReadDir = LoadDialog("Gimmicks","ReadFolderDlg") + oProgressBar = DlgReadDir.Model.ProgressBar1 + DlgReadDir.Model.TextField1.Text = ConvertFromUrl(GetPathSettings("Work")) + DlgReadDir.Model.cmdGoOn.DefaultButton = True + DlgReadDir.GetControl("TextField1").SetFocus() + DlgReadDir.Execute + End If +End Sub + + +Sub TreeInfo() +Dim oCurTextShape As Object +Dim i as Integer +Dim bStartUpRun As Boolean +Dim CurFilename as String +Dim BaseLevel as Integer +Dim oController as Object +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 + oController = oDocument.GetCurrentController + Source = ConvertToURL(DlgReadDir.Model.TextField1.Text) + BaseLevel = CountCharsInString(Source, "/", 1) + oProgressBar.ProgressValue = 5 + DlgReadDir.Model.Label3.Enabled = True + FileNames() = ReadSourceDirectory(Source) + DlgReadDir.Model.Label4.Enabled = True + DlgReadDir.Model.Label3.Enabled = False + oProgressBar.ProgressValue = 12 + FileNames() = BubbleSortList(FileNames()) + 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 + ' The Current TextShape has To be connected with a TextShape one Level higher + ' except for a TextShape In Level 0: + If Not bStartUpRun Then + ' A leaving Line Is only drawn when level is not 0 + If iCurLevel<> 0 Then + ' Determine the Coordinates of the arriving Line + iLevelPos(iCurLevel,SBOLDSTARTX) = iLevelPos(nConnectLevel,SBNEWSTARTX) + iLevelPos(iCurLevel,SBOLDSTARTY) = oCurTextShape.Position.Y + 0.5 * oCurTextShape.Size.Height + + iLevelPos(iCurLevel,SBOLDENDX) = iLevelPos(iCurLevel,SBBASEX) + iLevelPos(iCurLevel,SBOLDENDY) = oCurTextShape.Position.Y + 0.5 * oCurTextShape.Size.Height + + oOldArrivingLine = DrawLine(iCurLevel, SBOLDSTARTX, SBOLDSTARTY, SBOLDENDX, SBOLDENDY, oPage) + + ' 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 + ' On Level 0 the last Leaving Line's Endpoint is the upper edge of the TextShape + iLevelPos(nConnectLevel,SBNEWENDY) = oCurTextShape.Position.Y + iLevelPos(nConnectLevel,SBNEWENDX) = iLevelPos(nConnectLevel,SBNEWSTARTX) + End If + ' Draw the Connectors To the previous TextShapes + oOldLeavingLine = DrawLine(nConnectLevel, SBNEWSTARTX, SBNEWSTARTY, SBNEWENDX, SBNEWENDY, oPage) + Else + ' StartingPoint of the leaving Edge + bStartUpRun = FALSE + End If + + ' 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 + + ' Save the values For the Next run + nOldHeight = oCurTextShape.Size.Height + nOldX = oCurTextShape.Position.X + nOldWidth = oCurTextShape.Size.Width + nOldLevel = iCurLevel + Next i + ToggleDialogControls(True) + DlgReadDir.Model.cmdGoOn.Enabled = False +End Sub + + +Function CreateTextShape(oPage as Object, Filename as String) +Dim oTextShape As Object +Dim aPoint As New com.sun.star.awt.Point + + aPoint.X = CalculateXPoint() + aPoint.Y = nOldY + SBRELDIST * nOldHeight + nOldY = aPoint.Y + + oTextShape = oDocument.createInstance("com.sun.star.drawing.TextShape") + oTextShape.LineStyle = 1 + oTextShape.Position = aPoint + + oPage.add(oTextShape) + oTextShape.TextAutoGrowWidth = TRUE + oTextShape.TextAutoGrowHeight = TRUE + oTextShape.String = FileName + + ' Configure Size And Position of the TextShape according to its Scripting + aPoint.X = iLevelPos(iCurLevel,SBBASEX) + oTextShape.Position = aPoint + CreateTextShape() = oTextShape +End Function + + +Function CalculateXPoint() + ' The current level Is lower than the Old one + If (iCurLevel< nOldLevel) And (iCurLevel<> 0) Then + ' ClearArray(iLevelPos(),iCurLevel+1) + Elseif iCurLevel= 0 Then + iLevelPos(iCurLevel,SBBASEX) = SBPAGEX + ' The current level Is higher than the old one + Elseif iCurLevel> nOldLevel Then + iLevelPos(iCurLevel,SBBASEX) = iLevelPos(iCurLevel-1,SBBASEX) + nOldWidth + 100 + End If + CalculateXPoint = iLevelPos(iCurLevel,SBBASEX) +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("com.sun.star.drawing.LineShape") + oConnect.Position = aPoint + oConnect.Size = aSize + oPage.Add(oConnect) + DrawLine() = oConnect +End Function + + +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("com.sun.star.ucb.SimpleFileAccess") + 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()) <> -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 > 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 > 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 > (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, "/", 1) - BaseLevel + If iCurLevel <> 0 Then + nConnectLevel = iCurLevel- 1 + Else + nConnectLevel = iCurLevel + End If + If iCurLevel > 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 > PageWidth - 1000 Then + oPage.Width = 1000 + BaseX + TextWidth + End If +End Sub + + +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> diff --git a/wizards/source/gimmicks/ReadFolderDlg.xdl b/wizards/source/gimmicks/ReadFolderDlg.xdl new file mode 100644 index 000000000..797e97755 --- /dev/null +++ b/wizards/source/gimmicks/ReadFolderDlg.xdl @@ -0,0 +1,39 @@ +<?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="ReadFolderDlg" dlg:left="161" dlg:top="81" dlg:width="180" dlg:height="136" dlg:closeable="true" dlg:moveable="true" dlg:title="Read and Design Recursively"> + <dlg:bulletinboard> + <dlg:button dlg:id="cmdGetDir" dlg:tab-index="0" dlg:left="161" dlg:top="49" dlg:width="14" dlg:height="14" dlg:value="..."> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.ReadDir.GetSourceDirectory?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:textfield dlg:id="TextField1" dlg:tab-index="1" dlg:left="6" dlg:top="50" dlg:width="147" dlg:height="12"/> + <dlg:button dlg:id="cmdCancel" dlg:tab-index="2" dlg:left="49" dlg:top="115" dlg:width="35" dlg:height="14" dlg:value="~Cancel"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.ReadDir.CloseDialog?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdGoOn" dlg:tab-index="3" dlg:left="95" dlg:top="115" dlg:width="35" dlg:height="14" dlg:value="~GoOn"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.ReadDir.TreeInfo?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:text dlg:id="Label1" dlg:tab-index="4" dlg:left="6" dlg:top="38" dlg:width="122" dlg:height="8" dlg:value="Top level path"/> + <dlg:text dlg:id="Label2" dlg:tab-index="5" dlg:left="6" dlg:top="4" dlg:width="168" dlg:height="26" dlg:value="This macro will create a drawing document and design a complete tree view of all subdirectories from a given path." dlg:multiline="true"/> + <dlg:progressmeter dlg:id="ProgressBar1" dlg:tab-index="6" dlg:left="6" dlg:top="101" dlg:width="170" dlg:height="10"/> + <dlg:text dlg:id="Label3" dlg:tab-index="7" dlg:disabled="true" dlg:left="6" dlg:top="69" dlg:width="170" dlg:height="8" dlg:value="Getting the files and subdirectories..."/> + <dlg:text dlg:id="Label4" dlg:tab-index="8" dlg:disabled="true" dlg:left="6" dlg:top="80" dlg:width="170" dlg:height="8" dlg:value="Sorting the files and subdirectories..."/> + <dlg:text dlg:id="Label5" dlg:tab-index="9" dlg:disabled="true" dlg:left="6" dlg:top="91" dlg:width="170" dlg:height="8" dlg:value="Drawing the filestructure..."/> + </dlg:bulletinboard> +</dlg:window>
\ No newline at end of file diff --git a/wizards/source/gimmicks/UserfieldDlg.xdl b/wizards/source/gimmicks/UserfieldDlg.xdl new file mode 100644 index 000000000..efa0eff7e --- /dev/null +++ b/wizards/source/gimmicks/UserfieldDlg.xdl @@ -0,0 +1,66 @@ +<?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="UserfieldDlg" dlg:left="161" dlg:top="57" dlg:width="281" dlg:height="214" dlg:closeable="true" dlg:moveable="true" dlg:title="Modify User Data"> + <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-adjustmentvaluechange" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.ScrollControls?language=Basic&location=application" script:language="Script"/> + </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="Exit Macro" dlg:value="Exit"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.StopMacro?language=Basic&location=application" script:language="Script"/> + </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:macro-name="vnd.sun.star.script:Gimmicks.Userfields.SaveSettings?language=Basic&location=application" script:language="Script"/> + </dlg:button> + <dlg:button dlg:id="cmdSelect" dlg:tab-index="21" dlg:left="84" dlg:top="193" dlg:width="35" dlg:height="14" dlg:help-text="Replace the User Data in <PRODUCTNAME> With the User Data Above" dlg:value="Se~lect"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.SelectCurrentFields?language=Basic&location=application" script:language="Script"/> + </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 >>"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.StepToRecord?language=Basic&location=application" script:language="Script"/> + </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="<<Previous"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.StepToRecord?language=Basic&location=application" script:language="Script"/> + </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 Data for New User" dlg:value="~New"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.AddRecord?language=Basic&location=application" script:language="Script"/> + </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 lets you easily administrate several user profiles.
The user data of several users may be stored in a single file in the directory <ConfigDir>. From there, you can select a particular user whose data is then the current user data in <PRODUCTNAME>." 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:help-text="Delete Data of Current User" dlg:value="Delete"> + <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:Gimmicks.Userfields.DeleteCurrentSettings?language=Basic&location=application" script:language="Script"/> + </dlg:button> + </dlg:bulletinboard> +</dlg:window>
\ No newline at end of file diff --git a/wizards/source/gimmicks/Userfields.xba b/wizards/source/gimmicks/Userfields.xba new file mode 100644 index 000000000..17426cb49 --- /dev/null +++ b/wizards/source/gimmicks/Userfields.xba @@ -0,0 +1,236 @@ +<?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="Userfields" script:language="StarBasic">Option Explicit +'Todo: Controlling Scrollbar via Keyboard + +Public Const SBMAXFIELDINDEX = 14 + +Public DlgUserFields as Object +Public oDocument as Object +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 SystemPath as String + BasicLibraries.LoadLibrary("Tools") + UserFieldDatatype(0,0) = "COMPANY" + UserFieldDatatype(0,1) = "o" + UserFieldDatatype(1,0) = "FIRSTNAME" + UserFieldDatatype(1,1) = "givenname" + UserFieldDatatype(2,0) = "LASTNAME" + UserFieldDatatype(2,1) = "sn" + UserFieldDatatype(3,0) = "INITIALS" + UserFieldDatatype(3,1) = "initials" + UserFieldDatatype(4,0) = "STREET" + UserFieldDatatype(4,1) = "street" + UserFieldDatatype(5,0) = "COUNTRY" + UserFieldDatatype(5,1) = "c" + UserFieldDatatype(6,0) = "ZIP" + UserFieldDatatype(6,1) = "postalcode" + UserFieldDatatype(7,0) = "CITY" + UserFieldDatatype(7,1) = "l" + UserFieldDatatype(8,0) = "TITLE" + UserFieldDatatype(8,1) = "title" + UserFieldDatatype(9,0) = "POSITION" + UserFieldDatatype(9,1) = "position" + UserFieldDatatype(10,0) = "PHONE_HOME" + UserFieldDatatype(10,1) = "homephone" + UserFieldDatatype(11,0) = "PHONE_WORK" + UserFieldDatatype(11,1) = "telephonenumber" + UserFieldDatatype(12,0) = "FAX" + UserFieldDatatype(12,1) = "facsimiletelephonenumber" + UserFieldDatatype(13,0) = "E-MAIL" + UserFieldDatatype(13,1) = "mail" + UserFieldDatatype(14,0) = "STATE" + UserFieldDatatype(14,1) = "st" + FilePath = GetPathSettings("Config", False) & "/" & "UserData.dat" + DlgUserFields = LoadDialog("Gimmicks","UserfieldDlg") + SystemPath = ConvertFromUrl(FilePath) + DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, "'" & SystemPath & "'", "<ConfigDir>") + DlgUserFields.Model.Label10.Label = ReplaceString(DlgUserFields.Model.Label10.Label, GetProductName(), "<PRODUCTNAME>") + DlgUserFields.Model.cmdSelect.HelpText = ReplaceString(DlgUserFields.Model.cmdSelect.HelpText, GetProductName(), "<PRODUCTNAME>") + ScrollBarValue = 0 + oUserDataAccess = GetRegistryKeyContent("org.openoffice.UserProfile/Data", True) + InitializeUserFamily() + FillDialog() + DlgUserFields.Execute + DlgUserFields.Dispose() +End Sub + + +Sub FillDialog() +Dim a as Integer + With DlgUserFields + For a = 1 To SBTBCount + .GetControl("Label" & a).Model.Label = UserFieldDataType(a-1,0) + .GetControl("TextField" & 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 ScrollControls() + ScrollTextFieldInfo(ScrollBarValue) + ScrollBarValue = DlgUserFields.Model.ScrollBar1.ScrollValue + If (ScrollBarValue + SBTBCOUNT) >= SBMAXFIELDINDEX + 1 Then + ScrollBarValue = (SBMAXFIELDINDEX + 1) - SBTBCOUNT + End If + FillupTextFields() +End Sub + + +Sub ScrollTextFieldInfo(ByVal iScrollValue as Integer) +Dim a as Integer +Dim CurIndex as Integer + For a = 1 To SBTBCOUNT + CurIndex = (a-1) + iScrollValue + UserFieldFamily(CurFieldIndex,CurIndex) = DlgUserFields.GetControl("TextField" & a).Model.Text + Next a +End Sub + + +Sub StopMacro() + DlgUserFields.EndExecute +End Sub + + +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) = "" + For m = 0 To SBMAXFIELDINDEX + FileStrings(n) = FileStrings(n) & UserFieldFamily(n,m) & ";" + Next m + Next n + SaveDataToFile(FilePath, FileStrings(), True) +End Sub + + +Sub ToggleButtons(ByVal Index as Integer) +Dim i as Integer + CurFieldIndex = Index + DlgUserFields.Model.cmdNextUser.Enabled = CurFieldIndex <> Ubound(UserFieldFamily(), 1) + DlgUserFields.Model.cmdPrevUser.Enabled = CurFieldIndex <> 0 +End Sub + + +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("Config", False) & "/" & "UserData.dat", UserFieldStrings()) + If bFileExists Then + FirstIndex = Ubound(UserFieldStrings()) + ReDim Preserve UserFieldFamily(FirstIndex, SBMAXFIELDINDEX) as String + For n = 0 To FirstIndex + LocStrings() = ArrayOutofString(UserFieldStrings(n), ";") + 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 AddRecord() +Dim i as Integer +Dim MaxIndex as Integer + For i = 1 To SBTBCount + DlgUserFields.GetControl("TextField" & i).Model.Text = "" + Next i + MaxIndex = Ubound(UserFieldFamily(),1) + ReDim Preserve UserFieldFamily(MaxIndex + 1, SBMAXFIELDINDEX) as String + ToggleButtons(MaxIndex + 1, 1) +End Sub + + +Sub FillupTextFields() +Dim a as Integer +Dim CurIndex as Integer + For a = 1 To SBTBCOUNT + CurIndex = (a-1) + ScrollBarValue + DlgUserFields.GetControl("Label" & a).Model.Label = UserFieldDataType(CurIndex,0) + DlgUserFields.GetControl("TextField" & a).Model.Text = UserFieldFamily(CurFieldIndex, CurIndex) + Next a +End Sub + + +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 < 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>
\ No newline at end of file diff --git a/wizards/source/gimmicks/dialog.xlb b/wizards/source/gimmicks/dialog.xlb new file mode 100644 index 000000000..22271dacb --- /dev/null +++ b/wizards/source/gimmicks/dialog.xlb @@ -0,0 +1,6 @@ +<?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="Gimmicks" library:readonly="false" library:passwordprotected="false"> + <library:element library:name="UserfieldDlg"/> + <library:element library:name="ReadFolderDlg"/> +</library:library> diff --git a/wizards/source/gimmicks/readdirs.dlg b/wizards/source/gimmicks/readdirs.dlg Binary files differnew file mode 100644 index 000000000..20a89426d --- /dev/null +++ b/wizards/source/gimmicks/readdirs.dlg diff --git a/wizards/source/gimmicks/script.xlb b/wizards/source/gimmicks/script.xlb new file mode 100644 index 000000000..5c820ba43 --- /dev/null +++ b/wizards/source/gimmicks/script.xlb @@ -0,0 +1,9 @@ +<?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="Gimmicks" library:readonly="false" library:passwordprotected="false"> + <library:element library:name="GetTexts"/> + <library:element library:name="Userfields"/> + <library:element library:name="ChangeAllChars"/> + <library:element library:name="AutoText"/> + <library:element library:name="ReadDir"/> +</library:library> |