1:The first three lines are XML header. You should pay attention with script name 2:<?xml version="1.0" encoding="UTF-8"?> 3:<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 4:<script:module xmlns:script="http://openoffice.org/2000/script" script:name="frame_XController" script:language="StarBasic"> 5: 6:The GNU header 7:'************************************************************************* 8:'* CSV-Tags 9:'* $RCSfile: frame_XController.html,v $ 10:'* 11:'* $Revision: 1.1 $ 12:'* 13:'* last change:$Date: 2004/03/10 16:29:49 $ 14:'* 15:'* The Contents of this file are made available subject to the terms of 16:'* either of the following licenses 17:'* 18:'* - GNU Lesser General Public License Version 2.1 19:'* - Sun Industry Standards Source License Version 1.1 20:'* 21:'* Sun Microsystems Inc., October, 2000 22:'* 23:'* GNU Lesser General Public License Version 2.1 24:'* ============================================= 25:'* Copyright 2000 by Sun Microsystems, Inc. 26:'* 901 San Antonio Road, Palo Alto, CA 94303, USA 27:'* 28:'* This library is free software; you can redistribute it and/or 29:'* modify it under the terms of the GNU Lesser General Public 30:'* License version 2.1, as published by the Free Software Foundation. 31:'* 32:'* This library is distributed in the hope that it will be useful, 33:'* but WITHOUT ANY WARRANTY; without even the implied warranty of 34:'* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35:'* Lesser General Public License for more details. 36:'* 37:'* You should have received a copy of the GNU Lesser General Public 38:'* License along with this library; if not, write to the Free Software 39:'* Foundation, Inc., 59 Temple Place, Suite 330, Boston, 40:'* MA 02111-1307 USA 41:'* 42:'* 43:'* Sun Industry Standards Source License Version 1.1 44:'* ================================================= 45:'* The contents of this file are subject to the Sun Industry Standards 46:'* Source License Version 1.1 (the "License"); You may not use this file 47:'* except in compliance with the License. You may obtain a copy of the 48:'* License at http://www.openoffice.org/license.html. 49:'* 50:'* Software provided under this License is provided on an "AS IS" basis, 51:'* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, 52:'* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, 53:'* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. 54:'* See the License for the specific provisions governing your rights and 55:'* obligations concerning the Software. 56:'* 57:'* The Initial Developer of the Original Code is: Sun Microsystems, Inc. 58:'* 59:'* Copyright: 2000 by Sun Microsystems, Inc. 60:'* 61:'* All Rights Reserved. 62:'* 63:'* Contributor(s): _______________________________________ 64:'* 65:'* 66:'************************************************************************* 67:'************************************************************************* 68: 69:use "option explicit" to define all local variables 70:option explicit 71: 72:'************************************************************************* 73:' This Interface/Service test depends on the following GLOBAL variables, 74:' which must be specified in the object creation: 75:This interface test depends on some variables which must created and 76:filled at the object creation 77:' - Global oFrameToAttach As Object 78:' - Global oModelToAttach As Object 79:' - Global bHasNoViewData As Boolean 80:' - Global oObjToSuspend As Object 81:' - Global bHasNoModel As Boolean 82: 83:'************************************************************************* 84: 85:Sub RunTest() 86: 87:'************************************************************************* 88:' INTERFACE: 89:' com.sun.star.frame.XController 90:'************************************************************************* 91:On Error Goto ErrHndl 92: Dim bOK As Boolean 93:start testof a method 94: Test.StartMethod("getViewData()") 95: bOK = true 96:usage of a global variable 97: if (bHasNoViewData) then 98: Out.Log("This object has no ViewData - nothing to test") 99: else 100: oViewData = oObj.getViewData() 101: bOK = bOK AND NOT isNULL(oViewData) 102: end if 103:finished test of a method 104: Test.MethodTested("getViewData()", bOK) 105: 106: Test.StartMethod("restoreViewData()") 107: bOK = true 108: if (bHasNoViewData) then 109: Out.Log("This object has no ViewData - nothing to test") 110: else 111: oObj.restoreViewData(oViewData) 112: end if 113: Test.MethodTested("restoreViewData()", bOK) 114: 115: Test.StartMethod("getFrame()") 116: bOK = true 117: oFrame = oObj.getFrame() 118: bOK = bOK AND hasUnoInterfaces(oFrame, "com.sun.star.frame.XFrame") 119: Test.MethodTested("getFrame()", bOK) 120: 121: Test.StartMethod("getModel()") 122: bOK = true 123: oModel = oObj.getModel() 124: if (bHasNoModel) then 125: bOK = bOK AND isNull(oModel) 126: Out.Log("The object has no Model. Retunrned value must be NULL") 127: else 128: bOK = bOK AND NOT isNull(oModel) AND hasUnoInterfaces(oModel, "com.sun.star.frame.XModel") 129: end if 130: Test.MethodTested("getModel()", bOK) 131: 132: Test.StartMethod("attachFrame()") 133: bOK = true 134: Dim attachedFrame As Object 135: attachedFrame = oObj.getFrame() 136: oFrameToAttach.Name = "XController" 137: oObj.attachFrame(oFrameToAttach) 138: bOK = bOK AND oObj.getFrame.Name = oFrameToAttach.Name 139: ' return previous frame. 140: oObj.attachFrame(attachedFrame) 141: Test.MethodTested("attachFrame()", bOK) 142: 143: Test.StartMethod("attachModel()") 144: bOK = true 145: if bHasNoModel then 146: Out.Log("The object has no Model. Nothing to test.") 147: else 148: oObj.attachModel(oModelToAttach) 149: if isNull(oObj.getModel()) then 150: Out.Log("The model is NULL after setModel() call") 151: bOK = false 152: else 153: bOK = bOK AND oModelToAttach.location = oObj.getModel.location 154: end if 155: end if 156: Test.MethodTested("attachModel()", bOK) 157: 158: Test.StartMethod("suspend()") 159: bOK = true 160: bOK = bOK AND oObjToSuspend.suspend(true) 161: Test.MethodTested("suspend()", bOK) 162: 163:Exit Sub 164:ErrHndl: 165: Test.Exception() 166: bOK = false 167: resume next 168:End Sub 169:</script:module>