merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / document / _DocumentInfo.java
blob013cd7cf6c3b91e631da4f6bbc6d92eb17140c5e
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: _DocumentInfo.java,v $
10 * $Revision: 1.5 $
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.document;
33 import lib.MultiPropertyTest;
35 import com.sun.star.util.DateTime;
37 /**
38 * Testing <code>com.sun.star.document.DocumentInfo</code>
39 * service properties : <p>
40 * <ul>
41 * <li> <code> Author </code> </li>
42 * <li> <code> AutoloadEnabled </code> </li>
43 * <li> <code> AutoloadSecs </code> </li>
44 * <li> <code> AutoloadURL </code> </li>
45 * <li> <code> BlindCopiesTo </code> </li>
46 * <li> <code> CopyTo </code> </li>
47 * <li> <code> CreationDate </code> </li>
48 * <li> <code> DefaultTarget </code> </li>
49 * <li> <code> Description </code> </li>
50 * <li> <code> InReplyTo </code> </li>
51 * <li> <code> IsEncrypted </code> </li>
52 * <li> <code> Keywords </code> </li>
53 * <li> <code> MIMEType </code> </li>
54 * <li> <code> ModifiedBy </code> </li>
55 * <li> <code> ModifyDate </code> </li>
56 * <li> <code> Newsgroups </code> </li>
57 * <li> <code> Original </code> </li>
58 * <li> <code> PrintDate </code> </li>
59 * <li> <code> PrintedBy </code> </li>
60 * <li> <code> Priority </code> </li>
61 * <li> <code> Recipient </code> </li>
62 * <li> <code> References </code> </li>
63 * <li> <code> ReplyTo </code> </li>
64 * <li> <code> Template </code> </li>
65 * <li> <code> TemplateDate </code> </li>
66 * <li> <code> Theme </code> </li>
67 * <li> <code> Title </code> </li>
68 * </ul>
69 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
70 * @see com.sun.star.document.DocumentInfo
72 public class _DocumentInfo extends MultiPropertyTest {
74 /**
75 * Overrides compare method. Can compare <code>DateTime</code>
76 * structures.
78 protected boolean compare(Object ob1, Object ob2) {
79 if (ob1 instanceof DateTime && ob2 instanceof DateTime) {
80 DateTime dt1 = (DateTime)ob1;
81 DateTime dt2 = (DateTime)ob2;
83 return dt1.Year == dt2.Year
84 && dt1.Month == dt2.Month
85 && dt1.Day == dt2.Day
86 && dt1.Hours == dt2.Hours
87 && dt1.Minutes == dt2.Minutes
88 && dt1.Seconds == dt2.Seconds
89 && dt1.HundredthSeconds == dt2.HundredthSeconds;
90 } else {
91 return super.compare(ob1, ob2);
95 /**
96 * Prints DateTime.
98 protected String toString(Object obj) {
99 if (obj instanceof DateTime) {
100 DateTime dt = (DateTime)obj;
102 return dt.Year + ":" + dt.Month + ":" + dt.Day
103 + ":" + dt.Hours + ":" + dt.Minutes
104 + ":" + dt.Seconds + ":" + dt.HundredthSeconds;
105 } else {
106 return super.toString(obj);
111 * Tester for properties with <code>DateTime</code> type which
112 * creates new structure if old property value was null.
114 class DatePropertyTester extends PropertyTester {
115 protected Object getNewValue(String propName,
116 Object oldValue) {
117 if (oldValue == null || util.utils.isVoid(oldValue)) {
118 DateTime dt = new DateTime();
120 dt.Year = 2000;
121 dt.Month = 10;
122 dt.Day = 18;
123 dt.Hours = 19;
124 dt.Minutes = 41;
126 return dt;
127 } else {
128 return super.getNewValue(propName, oldValue);
134 * Can be void.
136 public void _PrintDate() {
137 testProperty("PrintDate", new DatePropertyTester());
141 * Can be void.
143 public void _TemplateDate() {
144 testProperty("TemplateDate", new DatePropertyTester());
148 * Can be void.
150 public void _ModifyDate() {
151 testProperty("ModifyDate", new DatePropertyTester());