1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE script:module PUBLIC
"-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:
script=
"http://openoffice.org/2000/script" script:
name=
"Property" script:
language=
"StarBasic">
4 REM =======================================================================================================================
5 REM === The Access2Base library is a part of the LibreOffice project. ===
6 REM === Full documentation is available on http://www.access2base.com ===
7 REM =======================================================================================================================
14 REM -----------------------------------------------------------------------------------------------------------------------
15 REM --- CLASS ROOT FIELDS ---
16 REM -----------------------------------------------------------------------------------------------------------------------
18 Private _Type As String
' Must be PROPERTY
19 Private _This As Object
' Workaround for absence of This builtin function
20 Private _Parent As Object
21 Private _Name As String
22 Private _Value As Variant
23 Private _ParentDatabase As Object
25 REM -----------------------------------------------------------------------------------------------------------------------
26 REM --- CONSTRUCTORS / DESTRUCTORS ---
27 REM -----------------------------------------------------------------------------------------------------------------------
28 Private Sub Class_Initialize()
34 End Sub
' Constructor
36 REM -----------------------------------------------------------------------------------------------------------------------
37 Private Sub Class_Terminate()
38 On Local Error Resume Next
39 Call Class_Initialize()
40 End Sub
' Destructor
42 REM -----------------------------------------------------------------------------------------------------------------------
44 Call Class_Terminate()
45 End Sub
' Explicit destructor
47 REM -----------------------------------------------------------------------------------------------------------------------
48 REM --- CLASS GET/LET/SET PROPERTIES ---
49 REM -----------------------------------------------------------------------------------------------------------------------
51 Property Get Name() As String
52 Name = _PropertyGet(
"Name
")
53 End Property
' Name (get)
55 Public Function pName() As String
' For compatibility with
< V0.9
.0
56 pName = _PropertyGet(
"Name
")
57 End Function
' pName (get)
59 REM -----------------------------------------------------------------------------------------------------------------------
60 Property Get ObjectType() As String
61 ObjectType = _PropertyGet(
"ObjectType
")
62 End Property
' ObjectType (get)
64 REM -----------------------------------------------------------------------------------------------------------------------
65 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
67 ' a Collection object if pvIndex absent
68 ' a Property object otherwise
70 Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
71 vPropertiesList = _PropertiesList()
72 sObject = Utils._PCase(_Type)
73 If IsMissing(pvIndex) Then
74 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList)
76 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList, pvIndex)
77 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
81 Set Properties = vProperty
83 End Function
' Properties
85 REM -----------------------------------------------------------------------------------------------------------------------
86 Property Get Value() As Variant
87 Value = _PropertyGet(
"Value
")
88 End Property
' Value (get)
90 REM -----------------------------------------------------------------------------------------------------------------------
91 REM --- CLASS METHODS ---
92 REM -----------------------------------------------------------------------------------------------------------------------
94 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
95 ' Return property value of psProperty property name
97 Utils._SetCalledSub(
"Property.getProperty
")
98 If IsMissing(pvProperty) Then Call _TraceArguments()
99 getProperty = _PropertyGet(pvProperty)
100 Utils._ResetCalledSub(
"Property.getProperty
")
102 End Function
' getProperty
104 REM -----------------------------------------------------------------------------------------------------------------------
105 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
106 ' Return True if object has a valid property called pvProperty (case-insensitive comparison !)
108 If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
111 End Function
' hasProperty
113 REM -----------------------------------------------------------------------------------------------------------------------
114 REM --- PRIVATE FUNCTIONS ---
115 REM -----------------------------------------------------------------------------------------------------------------------
116 Private Function _PropertiesList() As Variant
117 _PropertiesList = Array(
"Name
",
"ObjectType
",
"Value
")
118 End Function
' _PropertiesList
120 REM -----------------------------------------------------------------------------------------------------------------------
121 Private Function _PropertyGet(ByVal psProperty As String) As Variant
122 ' Return property value of the psProperty property name
124 If _ErrorHandler() Then On Local Error Goto Error_Function
125 Utils._SetCalledSub(
"Property.get
" & psProperty)
126 _PropertyGet = Nothing
128 Select Case UCase(psProperty)
129 Case UCase(
"Name
")
131 Case UCase(
"ObjectType
")
133 Case UCase(
"Value
")
134 _PropertyGet = _Value
140 Utils._ResetCalledSub(
"Property.get
" & psProperty)
143 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
144 _PropertyGet = Nothing
147 TraceError(TRACEABORT, Err,
"Property._PropertyGet
", Erl)
148 _PropertyGet = Nothing
150 End Function
' _PropertyGet