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">REM =======================================================================================================================
4 REM === The Access2Base library is a part of the LibreOffice project. ===
5 REM === Full documentation is available on http://www.access2base.com ===
6 REM =======================================================================================================================
13 REM -----------------------------------------------------------------------------------------------------------------------
14 REM --- CLASS ROOT FIELDS ---
15 REM -----------------------------------------------------------------------------------------------------------------------
17 Private _Type As String
' Must be PROPERTY
18 Private _Name As String
19 Private _Value As Variant
20 Private _ParentDatabase As Object
22 REM -----------------------------------------------------------------------------------------------------------------------
23 REM --- CONSTRUCTORS / DESTRUCTORS ---
24 REM -----------------------------------------------------------------------------------------------------------------------
25 Private Sub Class_Initialize()
29 End Sub
' Constructor
31 REM -----------------------------------------------------------------------------------------------------------------------
32 Private Sub Class_Terminate()
33 On Local Error Resume Next
34 Call Class_Initialize()
35 End Sub
' Destructor
37 REM -----------------------------------------------------------------------------------------------------------------------
39 Call Class_Terminate()
40 End Sub
' Explicit destructor
42 REM -----------------------------------------------------------------------------------------------------------------------
43 REM --- CLASS GET/LET/SET PROPERTIES ---
44 REM -----------------------------------------------------------------------------------------------------------------------
46 Property Get Name() As String
47 Name = _PropertyGet(
"Name
")
48 End Property
' Name (get)
50 Public Function pName() As String
' For compatibility with
< V0.9
.0
51 pName = _PropertyGet(
"Name
")
52 End Function
' pName (get)
54 REM -----------------------------------------------------------------------------------------------------------------------
55 Property Get ObjectType() As String
56 ObjectType = _PropertyGet(
"ObjectType
")
57 End Property
' ObjectType (get)
59 REM -----------------------------------------------------------------------------------------------------------------------
60 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
62 ' a Collection object if pvIndex absent
63 ' a Property object otherwise
65 Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
66 vPropertiesList = _PropertiesList()
67 sObject = Utils._PCase(_Type)
68 If IsMissing(pvIndex) Then
69 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList)
71 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList, pvIndex)
72 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
76 Set Properties = vProperty
78 End Function
' Properties
80 REM -----------------------------------------------------------------------------------------------------------------------
81 Property Get Value() As Variant
82 Value = _PropertyGet(
"Value
")
83 End Property
' Value (get)
85 REM -----------------------------------------------------------------------------------------------------------------------
86 REM --- CLASS METHODS ---
87 REM -----------------------------------------------------------------------------------------------------------------------
89 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
90 ' Return property value of psProperty property name
92 Utils._SetCalledSub(
"Property.getProperty
")
93 If IsMissing(pvProperty) Then Call _TraceArguments()
94 getProperty = _PropertyGet(pvProperty)
95 Utils._ResetCalledSub(
"Property.getProperty
")
97 End Function
' getProperty
99 REM -----------------------------------------------------------------------------------------------------------------------
100 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
101 ' Return True if object has a valid property called pvProperty (case-insensitive comparison !)
103 If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
106 End Function
' hasProperty
108 REM -----------------------------------------------------------------------------------------------------------------------
109 REM --- PRIVATE FUNCTIONS ---
110 REM -----------------------------------------------------------------------------------------------------------------------
111 Private Function _PropertiesList() As Variant
112 _PropertiesList = Array(
"Name
",
"ObjectType
",
"Value
")
113 End Function
' _PropertiesList
115 REM -----------------------------------------------------------------------------------------------------------------------
116 Private Function _PropertyGet(ByVal psProperty As String) As Variant
117 ' Return property value of the psProperty property name
119 If _ErrorHandler() Then On Local Error Goto Error_Function
120 Utils._SetCalledSub(
"Property.get
" & psProperty)
121 _PropertyGet = Nothing
123 Select Case UCase(psProperty)
124 Case UCase(
"Name
")
126 Case UCase(
"ObjectType
")
128 Case UCase(
"Value
")
129 _PropertyGet = _Value
135 Utils._ResetCalledSub(
"Property.get
" & psProperty)
138 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
139 _PropertyGet = Nothing
142 TraceError(TRACEABORT, Err,
"Property._PropertyGet
", Erl)
143 _PropertyGet = Nothing
145 End Function
' _PropertyGet