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="frame_XFramesSupplier" 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' Be sure that all variables are dimensioned: 32option explicit 33 34 35 36 37Sub RunTest() 38 39'************************************************************************* 40' INTERFACE: 41' com.sun.star.frame.XFramesSupplier 42'************************************************************************* 43On Error Goto ErrHndl 44 Dim bOK As Boolean 45 46 Test.StartMethod("getFrames()") 47 bOK = true 48 Dim frames As Object 49 frames = oObj.getFrames() 50 Dim cnt As Integer 51 if (Not isNull(frames) ) then 52 cnt = frames.getCount() 53 bOK = cnt <> 0 54 Out.log("There are " + cnt + " frames.") 55 else 56 Out.log("getFrames() returned null !!!") 57 bOK = false 58 end if 59 Dim i As Integer 60 for i = 0 to (cnt - 1) 61 Dim fr As Object 62 fr = frames.getByIndex(i) 63 if (isNull(fr)) then 64 Out.log("Frame(" + i + ") == null") 65 bOK = false 66 end if 67 next i 68 Test.MethodTested("getFrames()", bOK) 69 70 Test.StartMethod("getActiveFrame()") 71 bOK = true 72 Dim active As Object 73 active = oObj.getActiveFrame() 74 active.setName("ActiveFrame") 75 Dim hasActiveFrame As Boolean 76 Dim activeIndex As Integer 77 if (isNull(active)) then 78 bOK = false 79 Out.log("getActiveFrame() returned null") 80 else 81 hasActiveFrame = false 82 for i = 0 to (cnt - 1) 83 fr = frames.getByIndex(i) 84 if (fr.getName() = "ActiveFrame") then 85 hasActiveFrame = true 86 activeIndex = i 87 end if 88 next i 89 if (Not hasActiveFrame) then 90 Out.log("getActiveFrame() isn't contained in getFrames() collection") 91 bOK = false 92 end if 93 end if 94 Test.MethodTested("getActiveFrame()", bOK) 95 96 Test.StartMethod("setActiveFrame()") 97 bOK = true 98 Dim sFrame As Object 99 if (cnt > 1) then 100 if (activeIndex <> 0) then 101 sFrame = frames.getByIndex(0) 102 else 103 sFrame = frame.getByIndex(1) 104 end if 105 else 106 sFrame = active 107 end if 108 sFrame.setName("Frame for set") 109 oObj.setActiveFrame(sFrame) 110 Dim gFrame As Object 111 gFrame = oObj.getActiveFrame() 112 if (gFrame.getName() <> "Frame for set") then 113 bOK = false 114 Out.log("Active frame set is not equal frame get: FAILED") 115 end if 116 Test.MethodTested("setActiveFrame()", bOK) 117 118Exit Sub 119ErrHndl: 120 Test.Exception() 121 bOK = false 122 resume next 123End Sub 124</script:module> 125