1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package ifc.util; 29 30 import lib.MultiMethodTest; 31 32 import com.sun.star.beans.XPropertySet; 33 import com.sun.star.util.XNumberFormats; 34 import com.sun.star.util.XNumberFormatsSupplier; 35 36 /** 37 * Testing <code>com.sun.star.util.XNumberFormatsSupplier</code> 38 * interface methods : 39 * <ul> 40 * <li><code> getNumberFormatSettings()</code></li> 41 * <li><code> getNumberFormats()</code></li> 42 * </ul> <p> 43 * Test is <b> NOT </b> multithread compilant. <p> 44 * @see com.sun.star.util.XNumberFormatsSupplier 45 */ 46 public class _XNumberFormatsSupplier extends MultiMethodTest { 47 48 public XNumberFormatsSupplier oObj = null; 49 50 /** 51 * Get format settings and checks some properties for existence. <p> 52 * 53 * Has <b> OK </b> status if a number properties inherent to 54 * <code>NumberFormatSettings</code> service exist in the 55 * returned <code>XPropertySet</code>. <p> 56 * 57 * @see com.sun.star.util.NumberFormatSettings 58 */ 59 public void _getNumberFormatSettings() { 60 boolean result = true ; 61 XPropertySet props = oObj.getNumberFormatSettings(); 62 63 if (props != null) { 64 try { 65 result &= props.getPropertyValue("NullDate") != null && 66 props.getPropertyValue("StandardDecimals") != null && 67 props.getPropertyValue("NoZero") != null && 68 props.getPropertyValue("TwoDigitDateStart") != null ; 69 } catch (com.sun.star.beans.UnknownPropertyException e) { 70 log.println("Some property doesn't exist") ; 71 e.printStackTrace(log) ; 72 result = false ; 73 } catch (com.sun.star.lang.WrappedTargetException e) { 74 e.printStackTrace(log) ; 75 result = false ; 76 } 77 } else { 78 log.println("Method returns null") ; 79 result = false ; 80 } 81 82 tRes.tested("getNumberFormatSettings()", result) ; 83 } 84 85 /** 86 * Test calls the method. <p> 87 * Has <b> OK </b> status if the method returns not 88 * <code>null</code> value. 89 */ 90 public void _getNumberFormats() { 91 XNumberFormats formats = oObj.getNumberFormats(); 92 93 tRes.tested("getNumberFormats()", formats != null) ; 94 } 95 96 } 97 98 99