Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / style / _PageProperties.java
blob9a7f7312ba909af31e157c3fae78eb1955401ac6
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.style;
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;
27 /**
28 * Test page properties.
29 * Testing is done by lib.MultiPropertyTest, except for properties
30 * <ul>
31 * <li>PrinterPaperTray</li>
32 * <li>UserDefinedAttribures</li>
33 * </ul>
35 public class _PageProperties extends MultiPropertyTest {
37 /**
38 * Switch on Header and Footer properties
39 * so all props can be tested.
41 @Override
42 protected void before() {
43 try {
44 oObj.setPropertyValue("HeaderIsOn", Boolean.TRUE);
45 oObj.setPropertyValue("FooterIsOn", Boolean.TRUE);
46 } catch (com.sun.star.beans.UnknownPropertyException upe) {
47 log.println("Don't know the Property 'HeaderIsOn' or 'FooterIsOn'");
48 } catch (com.sun.star.lang.WrappedTargetException wte) {
49 log.println("WrappedTargetException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
50 } catch (com.sun.star.lang.IllegalArgumentException iae) {
51 log.println("IllegalArgumentException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
52 } catch (com.sun.star.beans.PropertyVetoException pve) {
53 log.println("PropertyVetoException while setting Property 'HeaderIsOn' or 'FooterIsOn'");
57 /**
58 * This property is system dependent and printer dependent.
59 * So only reading it does make sense, since it cannot be determined, if
60 * it is set to a allowed value.
62 public void _PrinterPaperTray() {
63 boolean res = false;
64 String setting = null;
65 try {
66 setting = (String)oObj.getPropertyValue("PrinterPaperTray");
67 log.println("Property 'PrinterPaperTray' is set to '" + setting + "'.");
68 res = setting != null;
70 catch(com.sun.star.beans.UnknownPropertyException e) {
71 log.println("Don't know the Property 'PrinterPaperTray'");
72 } catch (com.sun.star.lang.WrappedTargetException wte) {
73 log.println("WrappedTargetException while getting Property 'PrinterPaperTray'");
75 tRes.tested("PrinterPaperTray", res);
78 /**
79 * Create some valid user defined attributes
81 public void _UserDefinedAttributes() {
82 XNameContainer uda = null;
83 boolean res = false;
84 try {
85 uda = (XNameContainer) AnyConverter.toObject(
86 new Type(XNameContainer.class),
87 oObj.getPropertyValue("UserDefinedAttributes"));
88 AttributeData attr = new AttributeData();
89 attr.Namespace = "http://www.sun.com/staroffice/apitest/Cellprop";
90 attr.Type="CDATA";
91 attr.Value="true";
92 uda.insertByName("Cellprop:has-first-alien-attribute",attr);
93 uda.getElementNames();
94 oObj.setPropertyValue("UserDefinedAttributes",uda);
95 uda = (XNameContainer) AnyConverter.toObject(
96 new Type(XNameContainer.class),
97 oObj.getPropertyValue("UserDefinedAttributes"));
98 uda.getElementNames();
99 uda.getByName("Cellprop:has-first-alien-attribute");
100 res = true;
101 } catch (com.sun.star.beans.UnknownPropertyException upe) {
102 log.println("Don't know the Property 'UserDefinedAttributes'");
103 } catch (com.sun.star.lang.WrappedTargetException wte) {
104 log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
105 } catch (com.sun.star.container.NoSuchElementException nee) {
106 log.println("added Element isn't part of the NameContainer");
107 } catch (com.sun.star.lang.IllegalArgumentException iae) {
108 log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
109 } catch (com.sun.star.beans.PropertyVetoException pve) {
110 log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
111 } catch (com.sun.star.container.ElementExistException eee) {
112 log.println("ElementExistException while getting Property 'UserDefinedAttributes'");
114 tRes.tested("UserDefinedAttributes",res);