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