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 .
21 import com
.sun
.star
.container
.XNameContainer
;
22 import com
.sun
.star
.uno
.AnyConverter
;
23 import com
.sun
.star
.uno
.Type
;
24 import com
.sun
.star
.xml
.AttributeData
;
25 import lib
.MultiPropertyTest
;
28 * Test page properties.
29 * Testing is done by lib.MultiPropertyTest, except for properties
31 * <li>PrinterPaperTray</li>
32 * <li>UserDefinedAttribures</li>
35 public class _PageProperties
extends MultiPropertyTest
{
38 * Switch on Header and Footer properties
39 * so all props can be tested.
41 protected void before() {
43 oObj
.setPropertyValue("HeaderIsOn", Boolean
.TRUE
);
44 oObj
.setPropertyValue("FooterIsOn", Boolean
.TRUE
);
45 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
46 log
.println("Don't know the Property 'HeaderIsOn' or 'FooterIsOn'");
47 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
48 log
.println("WrappedTargetException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
49 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
50 log
.println("IllegalArgumentException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
51 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
52 log
.println("PropertyVetoException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
57 * This property is system dependent and printer dependent.
58 * So only reading it does make sense, since it cannot be determined, if
59 * it is set to a allowed value.
61 public void _PrinterPaperTray() {
63 String setting
= null;
65 setting
= (String
)oObj
.getPropertyValue("PrinterPaperTray");
66 log
.println("Property 'PrinterPaperTray' is set to '" + setting
+ "'.");
67 res
= setting
!= null;
69 catch(com
.sun
.star
.beans
.UnknownPropertyException e
) {
70 log
.println("Don't know the Property 'PrinterPaperTray'");
71 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
72 log
.println("WrappedTargetException while getting Property 'PrinterPaperTray'");
74 tRes
.tested("PrinterPaperTray", res
);
78 * Create some valid user defined attributes
80 public void _UserDefinedAttributes() {
81 XNameContainer uda
= null;
84 uda
= (XNameContainer
) AnyConverter
.toObject(
85 new Type(XNameContainer
.class),
86 oObj
.getPropertyValue("UserDefinedAttributes"));
87 AttributeData attr
= new AttributeData();
88 attr
.Namespace
= "http://www.sun.com/staroffice/apitest/Cellprop";
91 uda
.insertByName("Cellprop:has-first-alien-attribute",attr
);
92 uda
.getElementNames();
93 oObj
.setPropertyValue("UserDefinedAttributes",uda
);
94 uda
= (XNameContainer
) AnyConverter
.toObject(
95 new Type(XNameContainer
.class),
96 oObj
.getPropertyValue("UserDefinedAttributes"));
97 uda
.getElementNames();
98 uda
.getByName("Cellprop:has-first-alien-attribute");
100 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
101 log
.println("Don't know the Property 'UserDefinedAttributes'");
102 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
103 log
.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
104 } catch (com
.sun
.star
.container
.NoSuchElementException nee
) {
105 log
.println("added Element isn't part of the NameContainer");
106 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
107 log
.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
108 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
109 log
.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
110 } catch (com
.sun
.star
.container
.ElementExistException eee
) {
111 log
.println("ElementExistException while getting Property 'UserDefinedAttributes'");
113 tRes
.tested("UserDefinedAttributes",res
);