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' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31 32 33Sub RunTest() 34 35'************************************************************************* 36' INTERFACE: 37' com.sun.star.beans.XFastPropertySet 38'************************************************************************* 39On Error Goto ErrHndl 40 41 Dim bOK As Boolean 42 Dim oPropertySetInfo As Object 43 Dim oProperties As Variant 44 Dim nIndex As Long, nHanlde As Long 45 Dim nCount As Integer 46 Dim vMemVal As Variant, vNewVal As Variant 47 Dim bBoolean As Boolean 48 Dim nInteger As Integer 49 Dim nLong As Long 50 Dim nSingle As Single 51 Dim nDouble As Double 52 53 oPropertySetInfo = oObj.GetPropertySetInfo() 54 oProperties = oPropertySetInfo.Properties 55 nCount = uBound(oProperties) 56 57 nIndex = 0 58 nMem = nIndex 59 'find at first a Boolean Value, if not available a String Property 60 While (NOT bFound) AND (nCount >= nIndex) 61 If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 11 Then ' it is a Boolean Proerty 62 bFound = true 63 nMem = nIndex 64 else 65 If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 8 Then ' it is a String Property 66 nMem = nIndex 67 end if 68 end if 69 nIndex = nIndex + 1 70 Wend 71 nIndex = nMem 72 Out.Log("Property selected: '" + oProperties(nIndex).Name + "'") 73 74 'memory the old Value 75 vMemVal = oObj.getFastPropertyValue(oProperties(nIndex).Handle) 76 ' change the Value 77 select case VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle) 78 case 11 'boolean 79 bBoolean = NOT oObj.getFastPropertyValue(oProperties(nIndex).Handle) 80 vNewVal = bBoolean 81 case 2 'integer 82 nInteger = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 83 vNewVal = nInteger 84 case 3 'long 85 nLong = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 86 vNewVal = nLong 87 case 4 'single 88 nSingle = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 89 vNewVal = nSingle 90 case 5 'double 91 nDouble = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 92 vNewVal = nDouble 93 case 8 'string 94 vNewVal = oObj.getPropertyValue(oProperties(nIndex).Name) + cIfcShortName 95 end select 96 97 nHandle = oProperties(nIndex).Handle 98 99 Test.StartMethod("getFastPropertyValue()") 100 bOK = true 101 bOK = bOK AND (vMemVal = oObj.getFastPropertyValue(nHandle)) 102 Test.MethodTested("getFastPropertyValue()", bOK) 103 104 Test.StartMethod("setFastPropertyValue()") 105 bOK = true 106 oObj.setFastPropertyValue(nHandle, vNewVal) 107 bOK = bOK AND (vMemVal <> oObj.getFastPropertyValue(nHandle)) 108 Test.MethodTested("setFastPropertyValue()", bOK) 109 110 111Exit Sub 112ErrHndl: 113 Test.Exception() 114 bOK = false 115 resume next 116End Sub 117</script:module> 118