merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / style / _PageProperties.java
blob54c9662def5f31c9442a0873a0ffc23900ff17be
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _PageProperties.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.style;
33 import com.sun.star.container.XNameContainer;
34 import com.sun.star.uno.AnyConverter;
35 import com.sun.star.uno.Type;
36 import com.sun.star.xml.AttributeData;
37 import lib.MultiPropertyTest;
39 /**
40 * Test page properties.
41 * Testing is done by lib.MultiPropertyTest, except for properties
42 * <ul>
43 * <li>PrinterPaperTray</li>
44 * <li>UserDefinedAttribures</li>
45 * </ul>
47 public class _PageProperties extends MultiPropertyTest {
49 /**
50 * Switch on Header and Footer properties
51 * so all props can be tested.
52 */
53 protected void before() {
54 try {
55 oObj.setPropertyValue("HeaderIsOn", Boolean.TRUE);
56 oObj.setPropertyValue("FooterIsOn", Boolean.TRUE);
57 } catch (com.sun.star.beans.UnknownPropertyException upe) {
58 log.println("Don't know the Property 'HeaderIsOn' or 'FooterIsOn'");
59 } catch (com.sun.star.lang.WrappedTargetException wte) {
60 log.println("WrappedTargetException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
61 } catch (com.sun.star.lang.IllegalArgumentException iae) {
62 log.println("IllegalArgumentException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
63 } catch (com.sun.star.beans.PropertyVetoException pve) {
64 log.println("PropertyVetoException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
68 /**
69 * This property is system dependent and printer dependent.
70 * So only reading it does make sense, since it cannot be determined, if
71 * it is set to a allowed value.
73 public void _PrinterPaperTray() {
74 boolean res = false;
75 String setting = null;
76 try {
77 setting = (String)oObj.getPropertyValue("PrinterPaperTray");
78 log.println("Property 'PrinterPaperTray' is set to '" + setting + "'.");
79 res = setting != null;
81 catch(com.sun.star.beans.UnknownPropertyException e) {
82 log.println("Don't know the Property 'PrinterPaperTray'");
83 } catch (com.sun.star.lang.WrappedTargetException wte) {
84 log.println("WrappedTargetException while getting Property 'PrinterPaperTray'");
86 tRes.tested("PrinterPaperTray", res);
89 /**
90 * Create some valid user defined attributes
91 */
92 public void _UserDefinedAttributes() {
93 XNameContainer uda = null;
94 boolean res = false;
95 try {
96 uda = (XNameContainer) AnyConverter.toObject(
97 new Type(XNameContainer.class),
98 oObj.getPropertyValue("UserDefinedAttributes"));
99 AttributeData attr = new AttributeData();
100 attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop";
101 attr.Type="CDATA";
102 attr.Value="true";
103 uda.insertByName("Cellprop:has-first-alien-attribute",attr);
104 String[] els = uda.getElementNames();
105 oObj.setPropertyValue("UserDefinedAttributes",uda);
106 uda = (XNameContainer) AnyConverter.toObject(
107 new Type(XNameContainer.class),
108 oObj.getPropertyValue("UserDefinedAttributes"));
109 els = uda.getElementNames();
110 Object obj = uda.getByName("Cellprop:has-first-alien-attribute");
111 res = true;
112 } catch (com.sun.star.beans.UnknownPropertyException upe) {
113 log.println("Don't know the Property 'UserDefinedAttributes'");
114 } catch (com.sun.star.lang.WrappedTargetException wte) {
115 log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
116 } catch (com.sun.star.container.NoSuchElementException nee) {
117 log.println("added Element isn't part of the NameContainer");
118 } catch (com.sun.star.lang.IllegalArgumentException iae) {
119 log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
120 } catch (com.sun.star.beans.PropertyVetoException pve) {
121 log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
122 } catch (com.sun.star.container.ElementExistException eee) {
123 log.println("ElementExistException while getting Property 'UserDefinedAttributes'");
125 tRes.tested("UserDefinedAttributes",res);