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="beans_XFastPropertySet" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36
37
38Sub RunTest()
39
40'*************************************************************************
41' INTERFACE:
42' com.sun.star.beans.XFastPropertySet
43'*************************************************************************
44On Error Goto ErrHndl
45
46    Dim bOK As Boolean
47    Dim oPropertySetInfo As Object
48    Dim oProperties As Variant
49    Dim nIndex As Long, nHanlde As Long
50    Dim nCount As Integer
51    Dim vMemVal As Variant, vNewVal As Variant
52    Dim bBoolean As Boolean
53    Dim nInteger As Integer
54    Dim nLong As Long
55    Dim nSingle As Single
56    Dim nDouble As Double
57
58    oPropertySetInfo = oObj.GetPropertySetInfo()
59    oProperties = oPropertySetInfo.Properties
60    nCount = uBound(oProperties)
61
62    nIndex = 0
63    nMem = nIndex
64    'find at first a Boolean Value, if not available a String Property
65    While (NOT bFound) AND (nCount &gt;= nIndex)
66        If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 11 Then ' it is a Boolean Proerty
67            bFound = true
68            nMem = nIndex
69        else
70            If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 8 Then ' it is a String Property
71                nMem = nIndex
72            end if
73        end if
74        nIndex = nIndex + 1
75    Wend
76    nIndex = nMem
77    Out.Log("Property selected: '" + oProperties(nIndex).Name + "'")
78
79    'memory the old Value
80    vMemVal = oObj.getFastPropertyValue(oProperties(nIndex).Handle)
81    ' change the Value
82    select case VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)
83        case 11 'boolean
84            bBoolean = NOT oObj.getFastPropertyValue(oProperties(nIndex).Handle)
85            vNewVal = bBoolean
86        case 2 'integer
87            nInteger = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
88            vNewVal = nInteger
89        case 3 'long
90            nLong = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
91            vNewVal = nLong
92        case 4 'single
93            nSingle = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
94            vNewVal = nSingle
95        case 5 'double
96            nDouble = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
97            vNewVal = nDouble
98        case 8 'string
99          vNewVal = oObj.getPropertyValue(oProperties(nIndex).Name) + cIfcShortName
100    end select
101
102    nHandle = oProperties(nIndex).Handle
103
104    Test.StartMethod("getFastPropertyValue()")
105    bOK = true
106    bOK = bOK AND (vMemVal = oObj.getFastPropertyValue(nHandle))
107    Test.MethodTested("getFastPropertyValue()", bOK)
108
109    Test.StartMethod("setFastPropertyValue()")
110    bOK = true
111    oObj.setFastPropertyValue(nHandle, vNewVal)
112    bOK = bOK AND (vMemVal &lt;&gt; oObj.getFastPropertyValue(nHandle))
113    Test.MethodTested("setFastPropertyValue()", bOK)
114
115
116Exit Sub
117ErrHndl:
118    Test.Exception()
119    bOK = false
120    resume next
121End Sub
122</script:module>
123