1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="document_DocumentInfo" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36' Be sure that all variables are dimensioned:
37option explicit
38
39
40
41Sub RunTest()
42
43'*************************************************************************
44' SERVICE:
45' com.sun.star.document.DocumentInfo
46'*************************************************************************
47On Error Goto ErrHndl
48    Dim bOK As Boolean
49    Dim pval As Variant, resVal As Variant
50
51    PropertyTester.TestProperty("Author")
52
53    PropertyTester.TestProperty("BlindCopiesTo")
54
55    PropertyTester.TestProperty("CopyTo")
56
57    testDateTime("CreationDate")
58
59    PropertyTester.TestProperty("Description")
60
61    PropertyTester.TestProperty("InReplyTo")
62
63    PropertyTester.TestProperty("Keywords")
64
65    PropertyTester.TestProperty("MIMEType")
66
67    testDateTime("ModifyDate")
68
69    PropertyTester.TestProperty("ModifiedBy")
70
71    PropertyTester.TestProperty("Newsgroups")
72
73    PropertyTester.TestProperty("Original")
74
75    Test.StartMethod("Priority")
76
77    bOK =true
78
79    pval = oObj.Priority
80    Out.Log("Was:" + pval)
81    oObj.Priority = pval + 1
82    resVal = oObj.Priority
83    Out.Log("Res:" + resVal)
84    bOK = bOK AND (pval + 1 = resVal)
85
86    Test.MethodTested("Priority", bOK)
87
88    PropertyTester.TestProperty("Recipient")
89
90    PropertyTester.TestProperty("References")
91
92    PropertyTester.TestProperty("ReplyTo")
93
94    PropertyTester.TestProperty("Theme")
95
96    PropertyTester.TestProperty("Title")
97
98    PropertyTester.TestProperty("Template")
99
100    testDateTime("TemplateDate")
101
102    PropertyTester.TestProperty("IsEncrypted")
103
104    testDateTime("PrintDate")
105
106    PropertyTester.TestProperty("PrintedBy")
107
108    PropertyTester.TestProperty("AutoloadEnabled")
109
110    PropertyTester.TestProperty("AutoloadURL")
111
112    Test.StartMethod("AutoloadSecs")
113
114    bOK =true
115
116    pval = oObj.AutoloadSecs
117    Out.Log("Was:" + pval)
118    oObj.AutoloadSecs = pval + 10
119    resVal = oObj.AutoloadSecs
120    Out.Log("Res:" + resval)
121    bOK = bOK AND (pval + 10 = resVal)
122
123    Test.MethodTested("AutoloadSecs", bOK)
124
125    PropertyTester.TestProperty("DefaultTarget")
126
127    PropertyTester.TestProperty("Generator")
128
129    PropertyTester.TestProperty("CreationDate")
130
131    PropertyTester.TestProperty("Subject")
132
133    PropertyTester.TestProperty("Language")
134
135    PropertyTester.TestProperty("ModifyDate")
136
137    PropertyTester.TestProperty("PrintDate")
138
139    PropertyTester.TestProperty("TemplateDate")
140
141Exit Sub
142ErrHndl:
143    Test.Exception()
144    resume next
145End Sub
146
147Sub testDateTime(propName As String)
148    Dim oldVal As Variant, resVal As Variant
149    Dim newVal As New com.sun.star.util.DateTime
150    Dim bOK As Boolean
151    bOK = true
152
153    Test.StartMethod(propName)
154
155    oldVal = oObj.getPropertyValue(propName)
156    Out.Log("OldVal :" + dateTime2String(oldVal))
157    if isNull(oldVal) then
158        newVal.Year = 2001
159        newVal.Month = 11
160        newVal.Day = 12
161        newVal.Hours = 16
162        newVal.Minutes = 14
163        newVal.Seconds = 48
164        newVal.HundredthSeconds = 0
165    else
166        newVal.Year = oldVal.Year
167        newVal.Month = oldVal.Month
168        newVal.Day = oldVal.Day
169        newVal.Hours = oldVal.Hours
170        newVal.Minutes = oldVal.Minutes
171        newVal.HundredthSeconds = oldVal.HundredthSeconds
172        newVal.Seconds = oldVal.Seconds + 1
173        if (newVal.Seconds > 59) then newVal.Seconds = 0
174    end if
175
176    Out.Log("NewVal :" + dateTime2String(newVal))
177    oObj.setPropertyValue(propName, newVal)
178    resVal = oObj.getPropertyValue(propName)
179    Out.Log("ResVal :" + dateTime2String(resVal))
180
181    bOK = bOK AND (newVal.Year = resVal.Year)
182    bOK = bOK AND (newVal.Month = resVal.Month)
183    bOK = bOK AND (newVal.Day = resVal.Day)
184    bOK = bOK AND (newVal.Hours = resVal.Hours)
185    bOK = bOK AND (newVal.Minutes = resVal.Minutes)
186    bOK = bOK AND (newVal.Seconds = resVal.Seconds)
187    bOK = bOK AND (newVal.HundredthSeconds = resVal.HundredthSeconds)
188
189' ### The following property was not found in correspond IDL file! ###
190    Test.MethodTested(propName, bOK)
191
192    Exit Sub
193ErrHndl:
194    Test.Exception()
195    bOK = false
196    resume next
197End Sub
198
199Function dateTime2String (dT As Variant) As String
200
201    dateTime2String = "" + dT.Day + "." + dT.Month + "." + dT.Year + _
202        " " + dT.Hours + ":" + dT.Minutes + ":" + dT.Seconds + "." + _
203        dT.HundredthSeconds
204
205End Function
206</script:module>
207