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