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="text_XTextSection" 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
36Sub RunTest()
37
38'*************************************************************************
39' INTERFACE:
40' com.sun.star.text.XTextSection
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim oPS As Variant, oCS As Variant
45    Dim i As Integer
46    Dim bChild As Boolean
47
48    Test.StartMethod("getParentSection()")
49    bOK = true
50    oPS = oObj.getParentSection()
51    if (NOT isNULL(oPS)) then
52        bOK = bOK AND hasUnoInterfaces(oPS, "com.sun.star.text.XTextSection")
53        if bOK then
54            Out.Log("Checking the names of parent's children ...")
55            oCS = oPS.getChildSections()
56            bChild = false
57            for i = 0 to ubound(oCS)
58                if oCS(i).Name = oObj.Name then bChild = true
59            next i
60            if NOT bChild then
61                Out.Log("The tested section was not found among its parent's child sections.")
62                bOK = false
63            endif
64        else
65            Out.Log("Wrong object returned.")
66            bOK = false
67        endif
68    else
69        Out.Log("!!! Not really tested. Parent not found !!!")
70    end if
71    Test.MethodTested("getParentSection()", bOK)
72
73    Test.StartMethod("getChildSections()")
74    bOK = true
75    oCS = oObj.getChildSections()
76    bOK = bOK AND isArray(oCS)
77    if (ubound(oCS) &gt;= 0) then
78        bOK = bOK AND hasUnoInterfaces(oCS(0), "com.sun.star.text.XTextSection")
79        if bOK then
80            Out.Log("Checking the name of child's parent ...")
81            oPS = oCS(0).getParentSection()
82            bOK = bOK AND oPS.Name = oObj.Name
83            if NOT bOK then
84                Out.Log("Child's parent name isn't match to the object name: '" + oPS.Name + "', '" + oObj.Name + "'")
85            endif
86        else
87            Out.Log("Wrong object returned.")
88        endif
89    else
90        Out.Log("!!! Not really tested. There are no section's children !!!")
91        bOK = false
92    end if
93    Test.MethodTested("getChildSections()", bOK)
94
95Exit Sub
96ErrHndl:
97    Test.Exception()
98    bOK = false
99    resume next
100End Sub
101</script:module>
102