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