Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _CellProperties.java
blobe3fac6674aacd5030c57906e7d6ebb98798a6410
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.table;
21 import lib.MultiPropertyTest;
23 import com.sun.star.container.XNameContainer;
24 import com.sun.star.uno.AnyConverter;
25 import com.sun.star.uno.Type;
26 import com.sun.star.xml.AttributeData;
28 /**
29 * Testing <code>com.sun.star.table.CellProperties</code>
30 * service properties :
31 * <ul>
32 * <li><code> CellStyle</code></li>
33 * <li><code> CellBackColor</code></li>
34 * <li><code> IsCellBackgroundTransparent</code></li>
35 * <li><code> NumberFormat</code></li>
36 * <li><code> ShadowFormat</code></li>
37 * <li><code> HoriJustify</code></li>
38 * <li><code> VertJustify</code></li>
39 * <li><code> Orientation</code></li>
40 * <li><code> CellProtection</code></li>
41 * <li><code> TableBorder</code></li>
42 * <li><code> IsTextWrapped</code></li>
43 * <li><code> RotateAngle</code></li>
44 * <li><code> RotateReference</code></li>
45 * </ul> <p>
46 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
47 * @see com.sun.star.table.CellProperties
49 public class _CellProperties extends MultiPropertyTest {
52 /**
53 * This property is tested with custom property tester which
54 * switches between 'Default' and 'Result' style names.
56 public void _CellStyle() {
57 testProperty("CellStyle", new PropertyTester() {
58 @Override
59 protected Object getNewValue(String name, Object old) {
60 return "Default".equals(old) ? "Result" : "Default" ;
62 }) ;
65 public void _UserDefinedAttributes() {
66 XNameContainer uda = null;
67 boolean res = false;
68 try {
69 uda = (XNameContainer) AnyConverter.toObject(
70 new Type(XNameContainer.class),
71 oObj.getPropertyValue("UserDefinedAttributes"));
72 AttributeData attr = new AttributeData();
73 attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop";
74 attr.Type="CDATA";
75 attr.Value="true";
76 uda.insertByName("Cellprop:has-first-alien-attribute",attr);
77 uda.getElementNames();
78 oObj.setPropertyValue("UserDefinedAttributes",uda);
79 uda = (XNameContainer) AnyConverter.toObject(
80 new Type(XNameContainer.class),
81 oObj.getPropertyValue("UserDefinedAttributes"));
82 uda.getElementNames();
83 uda.getByName("Cellprop:has-first-alien-attribute");
84 res = true;
85 } catch (com.sun.star.beans.UnknownPropertyException upe) {
86 log.println("Don't know the Property 'UserDefinedAttributes'");
87 } catch (com.sun.star.lang.WrappedTargetException wte) {
88 log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
89 } catch (com.sun.star.container.NoSuchElementException nee) {
90 log.println("added Element isn't part of the NameContainer");
91 } catch (com.sun.star.lang.IllegalArgumentException iae) {
92 log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
93 } catch (com.sun.star.beans.PropertyVetoException pve) {
94 log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
95 } catch (com.sun.star.container.ElementExistException eee) {
96 log.println("ElementExistException while getting Property 'UserDefinedAttributes'");
98 tRes.tested("UserDefinedAttributes",res);
101 } // finish class _CellProperties