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: _DocumentInfo.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 lib
.MultiPropertyTest
;
35 import com
.sun
.star
.util
.DateTime
;
38 * Testing <code>com.sun.star.document.DocumentInfo</code>
39 * service properties : <p>
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>
69 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
70 * @see com.sun.star.document.DocumentInfo
72 public class _DocumentInfo
extends MultiPropertyTest
{
75 * Overrides compare method. Can compare <code>DateTime</code>
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
86 && dt1
.Hours
== dt2
.Hours
87 && dt1
.Minutes
== dt2
.Minutes
88 && dt1
.Seconds
== dt2
.Seconds
89 && dt1
.HundredthSeconds
== dt2
.HundredthSeconds
;
91 return super.compare(ob1
, ob2
);
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
;
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
,
117 if (oldValue
== null || util
.utils
.isVoid(oldValue
)) {
118 DateTime dt
= new DateTime();
128 return super.getNewValue(propName
, oldValue
);
136 public void _PrintDate() {
137 testProperty("PrintDate", new DatePropertyTester());
143 public void _TemplateDate() {
144 testProperty("TemplateDate", new DatePropertyTester());
150 public void _ModifyDate() {
151 testProperty("ModifyDate", new DatePropertyTester());