1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _PageProperties.java,v $
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 ************************************************************************/
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
;
40 * Test page properties.
41 * Testing is done by lib.MultiPropertyTest, except for properties
43 * <li>PrinterPaperTray</li>
44 * <li>UserDefinedAttribures</li>
47 public class _PageProperties
extends MultiPropertyTest
{
50 * Switch on Header and Footer properties
51 * so all props can be tested.
53 protected void before() {
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'");
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() {
75 String setting
= null;
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
);
90 * Create some valid user defined attributes
92 public void _UserDefinedAttributes() {
93 XNameContainer uda
= null;
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";
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");
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
);