/usr/lib/libreoffice/share/basic/Access2Base/UtilProperty.xba is in libreoffice-base 1:5.1.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | <?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="UtilProperty" script:language="StarBasic">REM =======================================================================================================================
REM === The Access2Base library is a part of the LibreOffice project. ===
REM === Full documentation is available on http://www.access2base.com ===
REM =======================================================================================================================
'**********************************************************************
' UtilProperty module
'
' Module of utilities to manipulate arrays of PropertyValue's.
'**********************************************************************
'**********************************************************************
' Copyright (c) 2003-2004 Danny Brewer
' d29583@groovegarden.com
'**********************************************************************
'**********************************************************************
' If you make changes, please append to the change log below.
'
' Change Log
' Danny Brewer Revised 2004-02-25-01
' Jean-Pierre Ledure Adapted to Access2Base coding conventions
'**********************************************************************
REM =======================================================================================================================
Public Function _MakePropertyValue(ByVal Optional psName As String, Optional pvValue As Variant) As com.sun.star.beans.PropertyValue
' Create and return a new com.sun.star.beans.PropertyValue.
Dim oPropertyValue As Object
Set oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
If Not IsMissing(psName) Then oPropertyValue.Name = psName
If Not IsMissing(pvValue) Then oPropertyValue.Value = pvValue
_MakePropertyValue() = oPropertyValue
End Function ' _MakePropertyValue V1.3.0
REM =======================================================================================================================
Public Function _NumPropertyValues(pvPropertyValuesArray As Variant) As Integer
' Return the number of PropertyValue's in an array.
' Parameters:
' pvPropertyValuesArray - an array of PropertyValue's, that is an array of com.sun.star.beans.PropertyValue.
' Returns zero if the array contains no elements.
Dim iNumProperties As Integer
If Not IsArray(pvPropertyValuesArray) Then iNumProperties = 0 Else iNumProperties = UBound(pvPropertyValuesArray) + 1
_NumPropertyValues() = iNumProperties
End Function ' _NumPropertyValues V1.3.0
REM =======================================================================================================================
Public Function _FindPropertyIndex(pvPropertyValuesArray, ByVal psPropName As String ) As Integer
' Find a particular named property from an array of PropertyValue's.
' Finds the index in the array of PropertyValue's and returns it, or returns -1 if it was not found.
Dim iNumProperties As Integer, i As Integer, vProp As Variant
iNumProperties = _NumPropertyValues(pvPropertyValuesArray)
For i = 0 To iNumProperties - 1
vProp = pvPropertyValuesArray(i)
If UCase(vProp.Name) = UCase(psPropName) Then
_FindPropertyIndex() = i
Exit Function
EndIf
Next i
_FindPropertyIndex() = -1
End Function ' _FindPropertyIndex V1.3.0
REM =======================================================================================================================
Public Function _FindProperty(pvPropertyValuesArray, ByVal psPropName As String) As com.sun.star.beans.PropertyValue
' Find a particular named property from an array of PropertyValue's.
' Finds the PropertyValue and returns it, or returns Null if not found.
Dim iPropIndex As Integer
iPropIndex = _FindPropertyIndex(pvPropertyValuesArray, psPropName)
If iPropIndex >= 0 Then
vProp = pvPropertyValuesArray(iPropIndex) ' access array subscript
_FindProperty() = vProp
EndIf
End Function ' _FindProperty V1.3.0
REM =======================================================================================================================
Function _GetPropertyValue(pvPropertyValuesArray, ByVal psPropName As String, Optional pvDefaultValue) As Variant
' Get the value of a particular named property from an array of PropertyValue's.
' vDefaultValue - This value is returned if the property is not found in the array.
Dim iPropIndex As Integer, vProp As Variant, vValue As Variant
iPropIndex = _FindPropertyIndex(pvPropertyValuesArray, psPropName)
If iPropIndex >= 0 Then
vProp = pvPropertyValuesArray(iPropIndex) ' access array subscript
vValue = vProp.Value ' get the value from the PropertyValue
_GetPropertyValue() = vValue
Else
If IsMissing(pvDefaultValue) Then pvDefaultValue = Null
_GetPropertyValue() = pvDefaultValue
EndIf
End Function ' _GetPropertyValue V1.3.0
REM =======================================================================================================================
Sub _SetPropertyValue(pvPropertyValuesArray, ByVal psPropName As String, ByVal pvValue)
' Set the value of a particular named property from an array of PropertyValue's.
Dim iPropIndex As Integer, vProp As Variant, iNumProperties As Integer
iPropIndex = _FindPropertyIndex(pvPropertyValuesArray, psPropName)
' Did we find it?
If iPropIndex >= 0 Then
' Found, the PropertyValue is already in the array. Just modify its value.
vProp = pvPropertyValuesArray(iPropIndex) ' access array subscript
vProp.Value = pvValue ' set the property value.
pvPropertyValuesArray(iPropIndex) = vProp ' put it back into array
Else
' Not found, the array contains no PropertyValue with this name. Append new element to array.
iNumProperties = _NumPropertyValues(pvPropertyValuesArray)
If iNumProperties = 0 Then
pvPropertyValuesArray = Array(_MakePropertyValue(psPropName, pvValue))
Else
' Make array larger.
Redim Preserve pvPropertyValuesArray(iNumProperties)
' Assign new PropertyValue
pvPropertyValuesArray(iNumProperties) = _MakePropertyValue(psPropName, pvValue)
EndIf
EndIf
End Sub ' _SetPropertyValue V1.3.0
REM =======================================================================================================================
Sub _DeleteProperty(pvPropertyValuesArray, ByVal psPropName As String)
' Delete a particular named property from an array of PropertyValue's.
Dim iPropIndex As Integer
iPropIndex = _FindPropertyIndex(pvPropertyValuesArray, psPropName)
_DeleteIndexedProperty(pvPropertyValuesArray, iPropIndex)
End Sub ' _DeletePropertyValue V1.3.0
REM =======================================================================================================================
Public Sub _DeleteIndexedProperty(pvPropertyValuesArray, ByVal piPropIndex As Integer)
' Delete a particular indexed property from an array of PropertyValue's.
Dim iNumProperties As Integer, i As Integer
iNumProperties = _NumPropertyValues(pvPropertyValuesArray)
' Did we find it?
If piPropIndex < 0 Then
' Do nothing
ElseIf iNumProperties = 1 Then
' Just return a new empty array
pvPropertyValuesArray = Array()
Else
' If it is NOT the last item in the array, then shift other elements down into it's position.
If piPropIndex < iNumProperties - 1 Then
' Bump items down lower in the array.
For i = piPropIndex To iNumProperties - 2
pvPropertyValuesArray(i) = pvPropertyValuesArray(i + 1)
Next i
EndIf
' Redimension the array to have one fewer element.
Redim Preserve pvPropertyValuesArray(iNumProperties - 2)
EndIf
End Sub ' _DeleteIndexedProperty V1.3.0
REM =======================================================================================================================
Public Function _PropValuesToStr(pvPropertyValuesArray) As String
' Convenience function to return a string which explains what PropertyValue's are in the array of PropertyValue's.
Dim iNumProperties As Integer, sResult As String, i As Integer, vProp As Variant
Dim sName As String, vValue As Variant
iNumProperties = _NumPropertyValues(pvPropertyValuesArray)
sResult = Cstr(iNumProperties) & " Properties:"
For i = 0 To iNumProperties - 1
vProp = pvPropertyValuesArray(i)
sName = vProp.Name
vValue = vProp.Value
sResult = sResult & Chr(13) & " " & sName & " = " & _CStr(vValue)
Next i
_PropValuesToStr() = sResult
End Function ' _PropValuesToStr V1.3.0
</script:module>
|