1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package ifc.form.validation; 24 25 import com.sun.star.form.validation.XValidatable; 26 import com.sun.star.form.validation.XValidator; 27 import com.sun.star.form.validation.XValidityConstraintListener; 28 import com.sun.star.uno.UnoRuntime; 29 30 import lib.MultiMethodTest; 31 32 33 public class _XValidityConstraintListener extends MultiMethodTest { 34 public XValidityConstraintListener oObj; 35 protected boolean ValidatorCalled = false; 36 _validityConstraintChanged()37 public void _validityConstraintChanged() { 38 boolean res = false; 39 try { 40 XValidatable xValidatable = (XValidatable) UnoRuntime.queryInterface( 41 XValidatable.class, 42 tEnv.getTestObject()); 43 44 log.println("adding Validator"); 45 XValidator xValidator = new MyValidator(); 46 xValidatable.setValidator(xValidator); 47 ValidatorCalled = false; 48 49 log.println("calling validityConstraintChanged()"); 50 oObj.validityConstraintChanged( 51 new com.sun.star.lang.EventObject()); 52 res = ValidatorCalled; 53 } catch (com.sun.star.util.VetoException e) { 54 e.printStackTrace(); 55 } 56 tRes.tested("validityConstraintChanged()",res); 57 } 58 59 /* 60 * The validator to add this Listener implementation 61 * 62 */ 63 public class MyValidator implements XValidator { addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)64 public void addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener) 65 throws com.sun.star.lang.NullPointerException { 66 log.println("\t Validator::addValidityConstraintListener called"); 67 } 68 explainInvalid(Object obj)69 public String explainInvalid(Object obj) { 70 log.println("\t Validator::explainInvalid() called"); 71 72 return "explainInvalid"; 73 } 74 isValid(Object obj)75 public boolean isValid(Object obj) { 76 log.println("\t Validator::isValid() called"); 77 ValidatorCalled = true; 78 return false; 79 } 80 removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)81 public void removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener) 82 throws com.sun.star.lang.NullPointerException { 83 log.println("\t Validator::removeValidityConstraintListener called"); 84 } 85 } 86 }