Die Bibliothek Tools

So greifen Sie auf diesen Befehl zu:

Wählen Sie Extras – Makros – LibreOffice Basic – Bearbeiten… und den Container Anwendungsmakros.


note

Diese Bibliothek muss vor der Ausführung geladen werden. Führen Sie die folgende Anweisung aus, bevor Sie irgendein Makro ausführen, das diese Bibliothek benötigt:
GlobalScope.BasicLibraries.LoadLibrary("Tools")


Modul Debug

Modul ListBox

Modul Misc

Modul ModuleControls

Modul Strings

Modul UCB

Modul Debug

Funktionen und Unterprogramme zum Debuggen von Basic-Makros.

ActivateReadOnlyFlag


            Sub ActivateReadOnlyFlag()
        

DeactivateReadOnlyFlag


            Sub DeactivateReadOnlyFlag()
        

SetBasicReadOnlyFlag


            Sub SetBasicReadOnlyFlag(bReadOnly as Boolean)
        

WritedbgInfo


            Sub WritedbgInfo(LocObject as Object)
        

WriteDbgString


            Sub WriteDbgString(LocString as String)
        

ShowArray


            Sub ShowArray(LocArray())
        

ShowPropertyValues


            Sub ShowPropertyValues(oLocObject as Object)
        

ShowNameValuePair


            Sub ShowNameValuePair(Pair())
        

ShowElementNames

' Retrieves all the Elements of aSequence of an object, with the

' possibility to define a filter(sfilter <> "")


            Sub ShowElementNames(
            oLocElements() as Object,
            Optional sFiltername as String)
        

ShowSupportedServiceNames

' Retrieves all the supported servicenames of an object, with the

' possibility to define a filter(sfilter <> "")


            Sub ShowSupportedServiceNames(
            oLocObject as Object,
            Optional sFilterName as String)
        

ShowAvailableServiceNames

' Retrieves all the available Servicenames of an object, with the

' possibility to define a filter(sfilter <> "")


            Sub ShowAvailableServiceNames(
            oLocObject as Object, 
            Optional sFilterName as String)
        

ShowCommands


            Sub ShowCommands(oLocObject as Object)
        

ProtectCurrentSheets


            Sub ProtectCurrentSheets()
        

FillDocument


            Sub FillDocument()
        

Modul ListBox

Funktionen und Subroutinen zur Handhabung von ListBox-Elementen.

Warnsymbol

Diese Hilfeseite benötigt weitere Arbeit, um korrekt und vollständig zu sein. Bitte treten Sie dem LibreOffice-Projekt bei und helfen Sie uns, die fehlenden Informationen zu vervollständigen. Besuchen Sie unsere Webseite zum Schreiben von Hilfeinhalten (englisch).


Modul Misc

Weitere Funktionen und Subroutinen.

RegisterNewDataSource


            Function RegisterNewDataSource(
            DSName as  String, 
            PropertyList(), 
            Optional DriverProperties() 
            as New com.sun.star.beans.PropertyValue)
        

ConnecttoDatabase


            Function ConnecttoDatabase(
            DSName as String, 
            UserID as String, 
            Password as String, 
            Optional Propertylist(), 
            Optional DriverProperties() 
            as New com.sun.star.beans.PropertyValue)
        

GetStarOfficeLocale


            Function GetStarOfficeLocale() 
            as New com.sun.star.lang.Locale
        

GetRegistryKeyContent


            Function GetRegistryKeyContent(
            sKeyName as string, 
            Optional bforUpdate as Boolean)
        

Beispiel


            Sub GetUserData()
            BasicLibraries.LoadLibrary("Tools")
            Dim oData As Object
            oData = GetRegistryKeyContent("org.openoffice.UserProfile/Data", True)
            MsgBox oData.givenname & " " & oData.sn
            End Sub
        

GetProductname


            Function GetProductname() as String
        

OpenDocument

' Opens a Document, checks beforehand, whether it has to be loaded or whether it is already on the desktop. If the parameter bDisposable is set to False then the returned document should not be disposed afterwards, because it is already opened.


            Function OpenDocument(
            DocPath as String, 
            Args(), 
            Optional bDisposable as Boolean)
        

TaskonDesktop


            Function TaskonDesktop(DocPath as String) as Boolean
        

RetrieveFileName

' Retrieves a FileName out of a StarOffice-Document.


            Function RetrieveFileName(LocDoc as Object)
        

GetPathSettings

' Gets a special configured PathSetting.


            Function GetPathSettings(
            sPathType as String,
            Optional bshowall as Boolean, 
            Optional ListIndex as integer) as String
        

GetOfficeSubPath

' Gets the fully qualified path to a subdirectory of the Template Directory, e. g. with the parameter "wizard/bitmap". The parameter must be passed over in Url-scription. The return-Value is in Urlscription.


            Function GetOfficeSubPath(
            sOfficePath as String, 
            ByVal sSubDir as String)
        

ShowNoOfficePathError


            Sub ShowNoOfficePathError() 
        

InitResources


            Function InitResources(
            Description, 
            ShortDescription as String) as boolean
        

GetResText


            Function GetResText( nID as integer ) As string
        

CutPathView


            Function CutPathView(
            sDocUrl as String, 
            Optional PathLen as Integer)
        

DeleteInputCells

' Deletes the content of all cells that are softformatted according to the 'InputStyleName'.


            Sub DeleteInputCells(
            oSheet as Object, 
            InputStyleName as String)
        

ChangeValueofRange

' Inserts a certain String to all cells of a Range that is passed over either as an object or as the RangeName.


            Sub ChangeValueofRange(
            oSheet as Object, 
            Range, 
            ReplaceValue, 
            Optional StyleName as String)
        

ReplaceRangeValues


            Sub ReplaceRangeValues(
            oRange as Object, 
            ReplaceValue)
        

GetValueofCellbyName

' Returns the Value of the first cell of a Range.


            Function GetValueofCellbyName(
            oSheet as Object, 
            sCellName as String)
        

DuplicateRow


            Function DuplicateRow(
            oSheet as Object, 
            RangeName as String)
        

GetStringofCellbyName

' Returns the String of the first cell of a Range.


            Function GetStringofCellbyName(
            oSheet as Object, 
            sCellName as String)
        

GetCellByName

' Returns a named Cell


            Function GetCellByName(
            oSheet as Object, 
            sCellName as String) as Object
        

ChangeCellValue

' Changes the numeric Value of a cell by transmitting the String of the numeric Value.


            Sub ChangeCellValue(
            oCell as Object, 
            ValueString as String)
        

GetDocumentType


            Function GetDocumentType(oDocument)
        

GetNumberFormatType


            Function GetNumberFormatType(
            oDocFormats, 
            oFormatObject as Object) as Integer
        

ProtectSheets


            Sub ProtectSheets(Optional oSheets as Object)
        

UnprotectSheets


            Sub UnprotectSheets(Optional oSheets as Object)
        

GetRowIndex


            Function GetRowIndex(
            oSheet as Object, 
            RowName as String)
        

GetColumnIndex


            Function GetColumnIndex(
            oSheet as Object, 
            ColName as String)
        

CopySheetbyName


            Function CopySheetbyName(
            oSheets as Object, 
            OldName as String, 
            NewName as String, 
            DestPos as Integer) as Object
        

ToggleWindow

' Dis-or enables a Window and adjusts the mousepointer accordingly


            Sub ToggleWindow(bDoEnable as Boolean)
        

CheckNewSheetname


            Function CheckNewSheetname(
            oSheets as Object, 
            Sheetname as String, 
            Optional oLocale) as String
        

AddNewSheetName


            Sub AddNewSheetName(
            oSheets as Object, 
            ByVal SheetName as String)
        

GetSheetIndex


            Function GetSheetIndex(oSheets, sName) as Integer
        

GetLastUsedRow


            Function GetLastUsedRow(oSheet as Object) as Integer
        

ModifyBorderLineWidth

' Note To set a one lined frame you have to set the inner width to 0 In the API all Units that refer to pt-Heights are "1/100mm" The convert factor from 1pt to 1/100 mm is approximately 35


            Function ModifyBorderLineWidth(
            ByVal oStyleBorder, 
            iInnerLineWidth as Integer, 
            iOuterLineWidth as Integer)
        

AttachBasicMacroToEvent


            Sub AttachBasicMacroToEvent(
            oDocument as Object, 
            EventName as String, 
            SubPath as String)
        

ModifyPropertyValue


            Function ModifyPropertyValue(
            oContent() as New com.sun.star.beans.PropertyValue, 
            TargetProperties() 
            as New com.sun.star.beans.PropertyValue)
        

GetPropertyValueIndex


            Function GetPropertyValueIndex(
            SearchName as String, 
            TargetProperties() 
            as New com.sun.star.beans.PropertyValue ) as Integer
        

DispatchSlot


            Sub DispatchSlot(SlotID as Integer)
        

IsFatOffice

'returns the type of the office application FatOffice = 0, WebTop = 1 This routine has to be changed if the Product Name is being changed!


            Function IsFatOffice() As Boolean
        

ToggleDesignMode


            Sub ToggleDesignMode(oDocument as Object)
        

isHighContrast


            Function isHighContrast(oPeer as Object)
        

CreateNewDocument


            Function CreateNewDocument(
            sType as String, 
            Optional sAddMsg as String) as Object
        

DisposeDocument

' This Sub has been used in order to ensure that after disposing a document from the backing window it is returned to the backing window, so the office won't be closed


            Sub DisposeDocument(oDocument as Object)
        

CalIsLeapYear

'Function to calculate if the year is a leap year


            Function CalIsLeapYear(
            ByVal iYear as Integer) as Boolean
        

Modul ModuleControl

Funktionen und Subroutinen für die Modulkontrolle.

GetControlShape

' Gets the Shape of a Control( e. g. to reset the size or Position of the control

' Parameters:

' The 'oContainer' is the Document or a specific sheet of a Calc - Document

' 'CName' is the Name of the Control


            Function GetControlShape(
            oContainer as Object,
            CName as String)
        

getControlView

' Returns the View of a Control

' Parameters:

' The 'oContainer' is the Document or a specific sheet of a Calc - Document

' The 'oController' is always directly attached to the Document

' 'CName' is the Name of the Control


            Function getControlView(
            oContainer , 
            oController as Object, 
            CName as String) as Object
        

DisposeControl

' Parameters:

' The 'oContainer' is the Document or a specific sheet of a Calc - Document

' 'CName' is the Name of the Control


            Function DisposeControl(
            oContainer as Object, 
            CName as String) as Boolean
        

GetControlGroupModel

' Returns a sequence of a group of controls like option buttons or checkboxes

' The 'oContainer' is the Document or a specific sheet of a Calc - Document

' 'sGroupName' is the Name of the Controlgroup


            Function GetControlGroupModel(
            oContainer as Object, 
            sGroupName as String )
        

GetRefValue

' Returns the Referencevalue of a group of e.g. option buttons or check boxes

' 'oControlGroup' is a sequence of the Control objects


            Function GetRefValue(
            oControlGroup() as Object)
        

GetRefValueOfControlGroup


            Function GetRefValueOfControlGroup(
            oContainer as Object, 
            GroupName as String)
        

GetOptionGroupValue


            Function GetOptionGroupValue(
            oContainer as Object, 
            OptGroupName as String) as Boolean
        

WriteOptValueToCell


            Function WriteOptValueToCell(
            oSheet as Object, 
            OptGroupName as String, 
            iCol as Integer, 
            iRow as Integer) as Boolean
        

LoadDialog


            Function LoadDialog(
            Libname as String, 
            DialogName as String, 
            Optional oLibContainer)
        

Unter Öffnen eines Dialoges mit Basic finden Sie ein Beispiel für die Funktion LoadDialog.

GetFolderName


            Sub GetFolderName(oRefModel as Object)
        

GetFileName


            Sub GetFileName(
            oRefModel as Object, 
            Filternames())
        

StoreDocument


            Function StoreDocument(
            oDocument as Object, 
            FilterNames() as String, 
            DefaultName as String, 
            DisplayDirectory as String, 
            Optional iAddProcedure as Integer) as String
        

AddFiltersToDialog


            Sub AddFiltersToDialog(
            FilterNames() as String, 
            oDialog as Object)
        

SwitchMousePointer


            Sub SwitchMousePointer(
            oWindowPeer as Object, 
            bDoEnable as Boolean)
        

ShowOverwriteAllDialog


            Sub ShowOverwriteAllDialog(
            FilePath as String, 
            sTitle as String)
        

SetOVERWRITEToQuery


            Sub SetOVERWRITEToQuery()
        

SetOVERWRITEToAlways


            Sub SetOVERWRITEToAlways()
        

SetOVERWRITEToNever


            Sub SetOVERWRITEToNever()
        

Modul Strings

Erweiterte Funktionen und Subroutinen zur String-Manipulation.

ElimChar


            Function ElimChar(
            ByVal BigString as String, 
            ElimArray() as String)
        

DeleteStr

' Deletes out of a String 'BigString' a possible Partstring 'CompString'