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
38
39Sub RunTest()
40
41'*************************************************************************
42' INTERFACE:
43' com.sun.star.beans.XFastPropertySet
44'*************************************************************************
45On Error Goto ErrHndl
46
47    Dim bOK As Boolean
48    Dim oPropertySetInfo As Object
49    Dim oProperties As Variant
50    Dim nIndex As Long, nHanlde As Long
51    Dim nCount As Integer
52    Dim vMemVal As Variant, vNewVal As Variant
53    Dim bBoolean As Boolean
54    Dim nInteger As Integer
55    Dim nLong As Long
56    Dim nSingle As Single
57    Dim nDouble As Double
58
59    oPropertySetInfo = oObj.GetPropertySetInfo()
60    oProperties = oPropertySetInfo.Properties
61    nCount = uBound(oProperties)
62
63    nIndex = 0
64    nMem = nIndex
65    'find at first a Boolean Value, if not available a String Property
66    While (NOT bFound) AND (nCount &gt;= nIndex)
67        If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 11 Then ' it is a Boolean Proerty
68            bFound = true
69            nMem = nIndex
70        else
71            If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 8 Then ' it is a String Property
72                nMem = nIndex
73            end if
74        end if
75        nIndex = nIndex + 1
76    Wend
77    nIndex = nMem
78    Out.Log("Property selected: '" + oProperties(nIndex).Name + "'")
79
80    'memory the old Value
81    vMemVal = oObj.getFastPropertyValue(oProperties(nIndex).Handle)
82    ' change the Value
83    select case VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)
84        case 11 'boolean
85            bBoolean = NOT oObj.getFastPropertyValue(oProperties(nIndex).Handle)
86            vNewVal = bBoolean
87        case 2 'integer
88            nInteger = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
89            vNewVal = nInteger
90        case 3 'long
91            nLong = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
92            vNewVal = nLong
93        case 4 'single
94            nSingle = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
95            vNewVal = nSingle
96        case 5 'double
97            nDouble = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1
98            vNewVal = nDouble
99        case 8 'string
100          vNewVal = oObj.getPropertyValue(oProperties(nIndex).Name) + cIfcShortName
101    end select
102
103    nHandle = oProperties(nIndex).Handle
104
105    Test.StartMethod("getFastPropertyValue()")
106    bOK = true
107    bOK = bOK AND (vMemVal = oObj.getFastPropertyValue(nHandle))
108    Test.MethodTested("getFastPropertyValue()", bOK)
109
110    Test.StartMethod("setFastPropertyValue()")
111    bOK = true
112    oObj.setFastPropertyValue(nHandle, vNewVal)
113    bOK = bOK AND (vMemVal &lt;&gt; oObj.getFastPropertyValue(nHandle))
114    Test.MethodTested("setFastPropertyValue()", bOK)
115
116
117Exit Sub
118ErrHndl:
119    Test.Exception()
120    bOK = false
121    resume next
122End Sub
123</script:module>
124