1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir package ifc.style; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue; 30*cdf0e10cSrcweir import com.sun.star.beans.UnknownPropertyException; 31*cdf0e10cSrcweir import com.sun.star.container.XIndexReplace; 32*cdf0e10cSrcweir import com.sun.star.container.XNameContainer; 33*cdf0e10cSrcweir import com.sun.star.lang.WrappedTargetException; 34*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 35*cdf0e10cSrcweir import com.sun.star.uno.Type; 36*cdf0e10cSrcweir import com.sun.star.xml.AttributeData; 37*cdf0e10cSrcweir import ifc.text._NumberingLevel; 38*cdf0e10cSrcweir import java.util.Enumeration; 39*cdf0e10cSrcweir import java.util.Hashtable; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir import lib.MultiPropertyTest; 42*cdf0e10cSrcweir import lib.Status; 43*cdf0e10cSrcweir import share.LogWriter; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir import util.utils; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir /** 50*cdf0e10cSrcweir * Testing <code>com.sun.star.style.ParagraphProperties</code> 51*cdf0e10cSrcweir * service properties : 52*cdf0e10cSrcweir * <ul> 53*cdf0e10cSrcweir * <li><code> ParaAdjust</code></li> 54*cdf0e10cSrcweir * <li><code> ParaLineSpacing</code></li> 55*cdf0e10cSrcweir * <li><code> ParaBackColor</code></li> 56*cdf0e10cSrcweir * <li><code> ParaBackTransparent</code></li> 57*cdf0e10cSrcweir * <li><code> ParaBackGraphicURL</code></li> 58*cdf0e10cSrcweir * <li><code> ParaBackGraphicFilter</code></li> 59*cdf0e10cSrcweir * <li><code> ParaBackGraphicLocation</code></li> 60*cdf0e10cSrcweir * <li><code> ParaLastLineAdjust</code></li> 61*cdf0e10cSrcweir * <li><code> ParaExpandSingleWord</code></li> 62*cdf0e10cSrcweir * <li><code> ParaLeftMargin</code></li> 63*cdf0e10cSrcweir * <li><code> ParaRightMargin</code></li> 64*cdf0e10cSrcweir * <li><code> ParaTopMargin</code></li> 65*cdf0e10cSrcweir * <li><code> ParaBottomMargin</code></li> 66*cdf0e10cSrcweir * <li><code> ParaLineNumberCount</code></li> 67*cdf0e10cSrcweir * <li><code> ParaLineNumberStartValue</code></li> 68*cdf0e10cSrcweir * <li><code> ParaIsHyphenation</code></li> 69*cdf0e10cSrcweir * <li><code> PageDescName</code></li> 70*cdf0e10cSrcweir * <li><code> PageNumberOffset</code></li> 71*cdf0e10cSrcweir * <li><code> ParaRegisterModeActive</code></li> 72*cdf0e10cSrcweir * <li><code> ParaTabStops</code></li> 73*cdf0e10cSrcweir * <li><code> ParaStyleName</code></li> 74*cdf0e10cSrcweir * <li><code> DropCapFormat</code></li> 75*cdf0e10cSrcweir * <li><code> DropCapWholeWord</code></li> 76*cdf0e10cSrcweir * <li><code> ParaKeepTogether</code></li> 77*cdf0e10cSrcweir * <li><code> ParaSplit</code></li> 78*cdf0e10cSrcweir * <li><code> NumberingLevel</code></li> 79*cdf0e10cSrcweir * <li><code> NumberingRules</code></li> 80*cdf0e10cSrcweir * <li><code> NumberingStartValue</code></li> 81*cdf0e10cSrcweir * <li><code> ParaIsNumberingRestart</code></li> 82*cdf0e10cSrcweir * <li><code> NumberingStyleName</code></li> 83*cdf0e10cSrcweir * <li><code> ParaOrphans</code></li> 84*cdf0e10cSrcweir * <li><code> ParaWidows</code></li> 85*cdf0e10cSrcweir * <li><code> ParaShadowFormat</code></li> 86*cdf0e10cSrcweir * <li><code> IsHangingPunctuation</code></li> 87*cdf0e10cSrcweir * <li><code> IsCharacterDistance</code></li> 88*cdf0e10cSrcweir * <li><code> IsForbiddenRules</code></li> 89*cdf0e10cSrcweir * <li><code> LeftBorder</code></li> 90*cdf0e10cSrcweir * <li><code> RightBorder</code></li> 91*cdf0e10cSrcweir * <li><code> TopBorder</code></li> 92*cdf0e10cSrcweir * <li><code> BottomBorder</code></li> 93*cdf0e10cSrcweir * <li><code> BorderDistance</code></li> 94*cdf0e10cSrcweir * <li><code> LeftBorderDistance</code></li> 95*cdf0e10cSrcweir * <li><code> RightBorderDistance</code></li> 96*cdf0e10cSrcweir * <li><code> TopBorderDistance</code></li> 97*cdf0e10cSrcweir * <li><code> BottomBorderDistance</code></li> 98*cdf0e10cSrcweir * </ul> <p> 99*cdf0e10cSrcweir * This test needs the following object relations : 100*cdf0e10cSrcweir * <ul> 101*cdf0e10cSrcweir * <li> <code>'NRULES'</code> : <b>optional</b> 102*cdf0e10cSrcweir * (service <code>com.sun.star.text.NumberingRules</code>): 103*cdf0e10cSrcweir * instance of the service which can be set as 'NumberingRules' 104*cdf0e10cSrcweir * property new value. If the relation doesn't then two 105*cdf0e10cSrcweir * different <code>NumberingRules</code> objects are tried 106*cdf0e10cSrcweir * to be obtained by setting different 'NumberingStyleName' 107*cdf0e10cSrcweir * property styles and getting 'NumberingRules' property values.</li> 108*cdf0e10cSrcweir * <ul> <p> 109*cdf0e10cSrcweir * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 110*cdf0e10cSrcweir * @see com.sun.star.style.ParagraphProperties 111*cdf0e10cSrcweir */ 112*cdf0e10cSrcweir public class _ParagraphProperties extends MultiPropertyTest { 113*cdf0e10cSrcweir /** 114*cdf0e10cSrcweir * Custom tester for numbering style properties. Switches between 115*cdf0e10cSrcweir * 'Numbering 1' and 'Numbering 2' styles. 116*cdf0e10cSrcweir */ 117*cdf0e10cSrcweir protected PropertyTester NumberingStyleTester = new PropertyTester() { 118*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) 119*cdf0e10cSrcweir throws java.lang.IllegalArgumentException { 120*cdf0e10cSrcweir if ((oldValue != null) && (oldValue.equals("Numbering 1"))) { 121*cdf0e10cSrcweir return "Numbering 2"; 122*cdf0e10cSrcweir } else { 123*cdf0e10cSrcweir return "Numbering 1"; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir /** 129*cdf0e10cSrcweir * Custom tester for paragraph style properties. Switches between 130*cdf0e10cSrcweir * 'Salutation' and 'Heading' styles. 131*cdf0e10cSrcweir */ 132*cdf0e10cSrcweir protected PropertyTester charStyleTester = new PropertyTester() { 133*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 134*cdf0e10cSrcweir if (!utils.isVoid(oldValue) && (oldValue.equals("Example"))) { 135*cdf0e10cSrcweir return "Emphasis"; 136*cdf0e10cSrcweir } else { 137*cdf0e10cSrcweir return "Example"; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir }; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /** 143*cdf0e10cSrcweir * Custom tester for paragraph style properties. Switches between 144*cdf0e10cSrcweir * 'Salutation' and 'Heading' styles. 145*cdf0e10cSrcweir */ 146*cdf0e10cSrcweir protected PropertyTester ParaStyleTester = new PropertyTester() { 147*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 148*cdf0e10cSrcweir if (!utils.isVoid(oldValue) && (oldValue.equals("Heading"))) { 149*cdf0e10cSrcweir return "Salutation"; 150*cdf0e10cSrcweir } else { 151*cdf0e10cSrcweir return "Heading"; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir }; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /** 157*cdf0e10cSrcweir * Custom tester for PageDescName properties. Switches between 158*cdf0e10cSrcweir * 'HTML' and 'Standard' descriptor names. 159*cdf0e10cSrcweir */ 160*cdf0e10cSrcweir protected PropertyTester PageDescTester = new PropertyTester() { 161*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 162*cdf0e10cSrcweir if (!util.utils.isVoid(oldValue) && 163*cdf0e10cSrcweir (oldValue.equals("Default"))) { 164*cdf0e10cSrcweir return "HTML"; 165*cdf0e10cSrcweir } else { 166*cdf0e10cSrcweir return "Default"; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir }; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /** 172*cdf0e10cSrcweir * Custom tester for properties which have <code>short</code> type 173*cdf0e10cSrcweir * and can be void, so if they have void value, the new value must 174*cdf0e10cSrcweir * be specified. Switches between two different values. 175*cdf0e10cSrcweir */ 176*cdf0e10cSrcweir protected PropertyTester ShortTester = new PropertyTester() { 177*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 178*cdf0e10cSrcweir if ((oldValue != null) && 179*cdf0e10cSrcweir (oldValue.equals(new Short((short) 0)))) { 180*cdf0e10cSrcweir return new Short((short) 2); 181*cdf0e10cSrcweir } else { 182*cdf0e10cSrcweir return new Short((short) 0); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir }; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /** 188*cdf0e10cSrcweir * Custom tester for properties which have <code>boolean</code> type 189*cdf0e10cSrcweir * and can be void, so if they have void value, the new value must 190*cdf0e10cSrcweir * be specified. Switches between true and false. 191*cdf0e10cSrcweir */ 192*cdf0e10cSrcweir protected PropertyTester BooleanTester = new PropertyTester() { 193*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 194*cdf0e10cSrcweir if ((oldValue != null) && 195*cdf0e10cSrcweir (oldValue.equals(new Boolean((boolean) false)))) { 196*cdf0e10cSrcweir return new Boolean((boolean) true); 197*cdf0e10cSrcweir } else { 198*cdf0e10cSrcweir return new Boolean((boolean) false); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir }; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir /** 204*cdf0e10cSrcweir * Custom tester for properties which contains image URLs. 205*cdf0e10cSrcweir * Switches between two JPG images' URLs. 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir protected PropertyTester URLTester = new PropertyTester() { 208*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 209*cdf0e10cSrcweir if (oldValue.equals(util.utils.getFullTestURL("space-metal.jpg"))) { 210*cdf0e10cSrcweir return util.utils.getFullTestURL("crazy-blue.jpg"); 211*cdf0e10cSrcweir } else { 212*cdf0e10cSrcweir return util.utils.getFullTestURL("space-metal.jpg"); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir }; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir protected PropertyTester rules = null; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir /** 220*cdf0e10cSrcweir * Creates tester for 'NumberingRules' depending on relation. 221*cdf0e10cSrcweir */ 222*cdf0e10cSrcweir public void before() { 223*cdf0e10cSrcweir final Object nRules = tEnv.getObjRelation("NRULES"); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir if (nRules != null) { 226*cdf0e10cSrcweir rules = new PropertyTester() { 227*cdf0e10cSrcweir protected Object getNewValue(String propName, Object oldValue) { 228*cdf0e10cSrcweir return nRules; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir }; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir } else { 233*cdf0e10cSrcweir Object rules1 = null; 234*cdf0e10cSrcweir Object rules2 = null; 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir try { 237*cdf0e10cSrcweir oObj.setPropertyValue("NumberingStyleName", "Numbering 1"); 238*cdf0e10cSrcweir rules1 = oObj.getPropertyValue("NumberingRules"); 239*cdf0e10cSrcweir oObj.setPropertyValue("NumberingStyleName", "Numbering 2"); 240*cdf0e10cSrcweir rules2 = oObj.getPropertyValue("NumberingRules"); 241*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 242*cdf0e10cSrcweir log.println("WARNING !!! Exception getting numbering rules :"); 243*cdf0e10cSrcweir e.printStackTrace(log); 244*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 245*cdf0e10cSrcweir log.println("WARNING !!! Exception getting numbering rules :"); 246*cdf0e10cSrcweir e.printStackTrace(log); 247*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 248*cdf0e10cSrcweir log.println("WARNING !!! Exception getting numbering rules :"); 249*cdf0e10cSrcweir e.printStackTrace(log); 250*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 251*cdf0e10cSrcweir log.println("Property 'NumberingStyleName' is not supported."); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir rules = new PropertyValueSwitcher(rules1, rules2); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir /** 259*cdf0e10cSrcweir * Tested with custom property tester. 260*cdf0e10cSrcweir */ 261*cdf0e10cSrcweir public void _NumberingStyleName() { 262*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 263*cdf0e10cSrcweir testProperty("NumberingStyleName", NumberingStyleTester); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir /** 267*cdf0e10cSrcweir * Tested with custom property tester. 268*cdf0e10cSrcweir */ 269*cdf0e10cSrcweir public void _DropCapCharStyleName() { 270*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 271*cdf0e10cSrcweir testProperty("DropCapCharStyleName", charStyleTester); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir /** 275*cdf0e10cSrcweir * Tested with custom property tester. 276*cdf0e10cSrcweir */ 277*cdf0e10cSrcweir public void _ParaStyleName() { 278*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 279*cdf0e10cSrcweir testProperty("ParaStyleName", ParaStyleTester); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir /** 283*cdf0e10cSrcweir * Tested with custom property tester. 284*cdf0e10cSrcweir */ 285*cdf0e10cSrcweir public void _PageDescName() { 286*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 287*cdf0e10cSrcweir testProperty("PageDescName", PageDescTester); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir /** 291*cdf0e10cSrcweir * Tested with custom property tester. Before testing property 292*cdf0e10cSrcweir * <code>ParaAdjust</code> is setting to value <code>BLOCK</code> 293*cdf0e10cSrcweir * because setting the property <code>ParaLastLineAdjust</code> 294*cdf0e10cSrcweir * makes sense only in this case. 295*cdf0e10cSrcweir */ 296*cdf0e10cSrcweir public void _ParaLastLineAdjust() { 297*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir try { 300*cdf0e10cSrcweir oObj.setPropertyValue("ParaAdjust", 301*cdf0e10cSrcweir com.sun.star.style.ParagraphAdjust.BLOCK); 302*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException e) { 303*cdf0e10cSrcweir log.println("Exception occured setting property 'ParagraphAdjust'" + e); 304*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 305*cdf0e10cSrcweir log.println("Exception occured setting property 'ParagraphAdjust'" + e); 306*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 307*cdf0e10cSrcweir log.println("Exception occured setting property 'ParagraphAdjust'" + e); 308*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException e) { 309*cdf0e10cSrcweir log.println("Exception occured setting property 'ParagraphAdjust'" + e); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir testProperty("ParaLastLineAdjust", ShortTester); 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir /** 316*cdf0e10cSrcweir * Tested with custom property tester. 317*cdf0e10cSrcweir */ 318*cdf0e10cSrcweir public void _ParaBackGraphicURL() { 319*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 320*cdf0e10cSrcweir testProperty("ParaBackGraphicURL", URLTester); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir /** 324*cdf0e10cSrcweir * Tested with custom property tester. <p> 325*cdf0e10cSrcweir * The following property tests are to be completed successfully before : 326*cdf0e10cSrcweir * <ul> 327*cdf0e10cSrcweir * <li> <code> NumberingStyleName </code> : a numbering style must 328*cdf0e10cSrcweir * be set before testing this property </li> 329*cdf0e10cSrcweir * </ul> 330*cdf0e10cSrcweir */ 331*cdf0e10cSrcweir public void _NumberingLevel() { 332*cdf0e10cSrcweir requiredMethod("NumberingStyleName"); 333*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 334*cdf0e10cSrcweir testProperty("NumberingLevel", ShortTester); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir /** 338*cdf0e10cSrcweir * Tested with custom property tester. <p> 339*cdf0e10cSrcweir */ 340*cdf0e10cSrcweir public void _ParaIsConnectBorder() { 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 343*cdf0e10cSrcweir testProperty("ParaIsConnectBorder", BooleanTester); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir /** 347*cdf0e10cSrcweir * Tested with custom property tester. 348*cdf0e10cSrcweir */ 349*cdf0e10cSrcweir public void _ParaVertAlignment() { 350*cdf0e10cSrcweir log.println("Testing with custom Property tester"); 351*cdf0e10cSrcweir testProperty("ParaVertAlignment", ShortTester); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir /** 355*cdf0e10cSrcweir * Tested with com.sun.star.text.NumberingLevel <p> 356*cdf0e10cSrcweir * The value of this property is a com.sun.star.container.XIndexReplace which is represneted by 357*cdf0e10cSrcweir * com.sun.star.text.NumberingLevel. 358*cdf0e10cSrcweir * The following property tests are to be completed successfully before : 359*cdf0e10cSrcweir * <ul> 360*cdf0e10cSrcweir * <li> <code> NumberingStyleName </code> : a numbering style must 361*cdf0e10cSrcweir * be set before testing this property </li> 362*cdf0e10cSrcweir * </ul> 363*cdf0e10cSrcweir * @see com.sun.star.text.NumberlingLevel 364*cdf0e10cSrcweir * @see com.sun.star.container.XIndexReplace 365*cdf0e10cSrcweir * @see ifc.text._NumberingLevel 366*cdf0e10cSrcweir */ 367*cdf0e10cSrcweir public void _NumberingRules() { 368*cdf0e10cSrcweir requiredMethod("NumberingStyleName"); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir XIndexReplace NumberingRules = null; 371*cdf0e10cSrcweir PropertyValue[] propertyValues = null; 372*cdf0e10cSrcweir try { 373*cdf0e10cSrcweir NumberingRules = (XIndexReplace) AnyConverter.toObject( 374*cdf0e10cSrcweir new Type(XIndexReplace.class), oObj.getPropertyValue("NumberingRules")); 375*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException ex) { 376*cdf0e10cSrcweir Status.failed( "could not get NumberingRuels: "+ ex.toString() ); 377*cdf0e10cSrcweir return; 378*cdf0e10cSrcweir } catch (UnknownPropertyException ex) { 379*cdf0e10cSrcweir Status.failed( "could not get NumberingRuels: "+ ex.toString() ); 380*cdf0e10cSrcweir return; 381*cdf0e10cSrcweir } catch (WrappedTargetException ex) { 382*cdf0e10cSrcweir Status.failed( "could not get NumberingRuels: "+ ex.toString() ); 383*cdf0e10cSrcweir return; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir try { 386*cdf0e10cSrcweir propertyValues = (PropertyValue[]) NumberingRules.getByIndex(0); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { 389*cdf0e10cSrcweir Status.failed( "could not get NumberlingLevel-Array from NumberingRuels: "+ ex.toString() ); 390*cdf0e10cSrcweir return; 391*cdf0e10cSrcweir } catch (WrappedTargetException ex) { 392*cdf0e10cSrcweir Status.failed( "could not get NumberlingLevel-Array from NumberingRuels: "+ ex.toString() ); 393*cdf0e10cSrcweir return; 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir _NumberingLevel numb = new _NumberingLevel((LogWriter)log, tParam, propertyValues); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir boolean result = numb.testPropertieArray(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir tRes.tested("NumberingRules", result); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir public void _ParaUserDefinedAttributes() { 404*cdf0e10cSrcweir XNameContainer uda = null; 405*cdf0e10cSrcweir boolean res = false; 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir try { 408*cdf0e10cSrcweir try{ 409*cdf0e10cSrcweir uda = (XNameContainer) AnyConverter.toObject( 410*cdf0e10cSrcweir new Type(XNameContainer.class), 411*cdf0e10cSrcweir oObj.getPropertyValue("ParaUserDefinedAttributes")); 412*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e){ 413*cdf0e10cSrcweir log.println("ParaUserDefinedAttributes is empty."); 414*cdf0e10cSrcweir uda = new _ParagraphProperties.OwnUserDefinedAttributes(); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir AttributeData attr = new AttributeData(); 417*cdf0e10cSrcweir attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop"; 418*cdf0e10cSrcweir attr.Type = "CDATA"; 419*cdf0e10cSrcweir attr.Value = "true"; 420*cdf0e10cSrcweir uda.insertByName("Cellprop:has-first-alien-attribute", attr); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir String[] els = uda.getElementNames(); 423*cdf0e10cSrcweir oObj.setPropertyValue("ParaUserDefinedAttributes", uda); 424*cdf0e10cSrcweir uda = (XNameContainer) AnyConverter.toObject( 425*cdf0e10cSrcweir new Type(XNameContainer.class), 426*cdf0e10cSrcweir oObj.getPropertyValue("ParaUserDefinedAttributes")); 427*cdf0e10cSrcweir els = uda.getElementNames(); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir Object obj = uda.getByName("Cellprop:has-first-alien-attribute"); 430*cdf0e10cSrcweir res = true; 431*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException upe) { 432*cdf0e10cSrcweir if (isOptional("ParaUserDefinedAttributes")) { 433*cdf0e10cSrcweir log.println("Property is optional and not supported"); 434*cdf0e10cSrcweir res = true; 435*cdf0e10cSrcweir } else { 436*cdf0e10cSrcweir log.println("Don't know the Property 'ParaUserDefinedAttributes'"); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } catch (com.sun.star.lang.WrappedTargetException wte) { 439*cdf0e10cSrcweir log.println( 440*cdf0e10cSrcweir "WrappedTargetException while getting Property 'ParaUserDefinedAttributes'"); 441*cdf0e10cSrcweir } catch (com.sun.star.container.NoSuchElementException nee) { 442*cdf0e10cSrcweir log.println("added Element isn't part of the NameContainer"); 443*cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException iae) { 444*cdf0e10cSrcweir log.println( 445*cdf0e10cSrcweir "IllegalArgumentException while getting Property 'ParaUserDefinedAttributes'"); 446*cdf0e10cSrcweir } catch (com.sun.star.beans.PropertyVetoException pve) { 447*cdf0e10cSrcweir log.println( 448*cdf0e10cSrcweir "PropertyVetoException while getting Property 'ParaUserDefinedAttributes'"); 449*cdf0e10cSrcweir } catch (com.sun.star.container.ElementExistException eee) { 450*cdf0e10cSrcweir log.println( 451*cdf0e10cSrcweir "ElementExistException while getting Property 'ParaUserDefinedAttributes'"); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir tRes.tested("ParaUserDefinedAttributes", res); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir private class OwnUserDefinedAttributes implements XNameContainer{ 458*cdf0e10cSrcweir Hashtable members = null; 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir public OwnUserDefinedAttributes() { 462*cdf0e10cSrcweir members = new Hashtable(); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir public Object getByName(String str) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException { 466*cdf0e10cSrcweir return members.get(str); 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir public String[] getElementNames() { 470*cdf0e10cSrcweir Enumeration oEnum = members.keys(); 471*cdf0e10cSrcweir int count = members.size(); 472*cdf0e10cSrcweir String[] res = new String[count]; 473*cdf0e10cSrcweir int i=0; 474*cdf0e10cSrcweir while(oEnum.hasMoreElements()) 475*cdf0e10cSrcweir res[i] = (String)oEnum.nextElement(); 476*cdf0e10cSrcweir return res; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir public com.sun.star.uno.Type getElementType() { 480*cdf0e10cSrcweir Enumeration oEnum = members.keys(); 481*cdf0e10cSrcweir String key = (String)oEnum.nextElement(); 482*cdf0e10cSrcweir Object o = members.get(key); 483*cdf0e10cSrcweir return new Type(o.getClass()); 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir public boolean hasByName(String str) { 487*cdf0e10cSrcweir return members.get(str) != null; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir public boolean hasElements() { 491*cdf0e10cSrcweir return members.size() > 0; 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir public void insertByName(String str, Object obj) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.ElementExistException, com.sun.star.lang.WrappedTargetException { 495*cdf0e10cSrcweir members.put(str, obj); 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir public void removeByName(String str) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException { 499*cdf0e10cSrcweir members.remove(str); 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir public void replaceByName(String str, Object obj) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException { 503*cdf0e10cSrcweir members.put(str, obj); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir } // finish class _ParagraphProperties 508