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