1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="document_DocumentInfo" script:language="StarBasic">
4cdf0e10cSrcweir
5cdf0e10cSrcweir
6cdf0e10cSrcweir'*************************************************************************
7cdf0e10cSrcweir'
8*f94e042dSAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
9*f94e042dSAndrew Rist'  or more contributor license agreements.  See the NOTICE file
10*f94e042dSAndrew Rist'  distributed with this work for additional information
11*f94e042dSAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
12*f94e042dSAndrew Rist'  to you under the Apache License, Version 2.0 (the
13*f94e042dSAndrew Rist'  "License"); you may not use this file except in compliance
14*f94e042dSAndrew Rist'  with the License.  You may obtain a copy of the License at
15*f94e042dSAndrew Rist'
16*f94e042dSAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
17*f94e042dSAndrew Rist'
18*f94e042dSAndrew Rist'  Unless required by applicable law or agreed to in writing,
19*f94e042dSAndrew Rist'  software distributed under the License is distributed on an
20*f94e042dSAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*f94e042dSAndrew Rist'  KIND, either express or implied.  See the License for the
22*f94e042dSAndrew Rist'  specific language governing permissions and limitations
23*f94e042dSAndrew Rist'  under the License.
24cdf0e10cSrcweir'
25cdf0e10cSrcweir'*************************************************************************
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29*f94e042dSAndrew Rist
30*f94e042dSAndrew Rist
31cdf0e10cSrcweir' Be sure that all variables are dimensioned:
32cdf0e10cSrcweiroption explicit
33cdf0e10cSrcweir
34cdf0e10cSrcweir
35cdf0e10cSrcweir
36cdf0e10cSrcweirSub RunTest()
37cdf0e10cSrcweir
38cdf0e10cSrcweir'*************************************************************************
39cdf0e10cSrcweir' SERVICE:
40cdf0e10cSrcweir' com.sun.star.document.DocumentInfo
41cdf0e10cSrcweir'*************************************************************************
42cdf0e10cSrcweirOn Error Goto ErrHndl
43cdf0e10cSrcweir    Dim bOK As Boolean
44cdf0e10cSrcweir    Dim pval As Variant, resVal As Variant
45cdf0e10cSrcweir
46cdf0e10cSrcweir    PropertyTester.TestProperty("Author")
47cdf0e10cSrcweir
48cdf0e10cSrcweir    PropertyTester.TestProperty("BlindCopiesTo")
49cdf0e10cSrcweir
50cdf0e10cSrcweir    PropertyTester.TestProperty("CopyTo")
51cdf0e10cSrcweir
52cdf0e10cSrcweir    testDateTime("CreationDate")
53cdf0e10cSrcweir
54cdf0e10cSrcweir    PropertyTester.TestProperty("Description")
55cdf0e10cSrcweir
56cdf0e10cSrcweir    PropertyTester.TestProperty("InReplyTo")
57cdf0e10cSrcweir
58cdf0e10cSrcweir    PropertyTester.TestProperty("Keywords")
59cdf0e10cSrcweir
60cdf0e10cSrcweir    PropertyTester.TestProperty("MIMEType")
61cdf0e10cSrcweir
62cdf0e10cSrcweir    testDateTime("ModifyDate")
63cdf0e10cSrcweir
64cdf0e10cSrcweir    PropertyTester.TestProperty("ModifiedBy")
65cdf0e10cSrcweir
66cdf0e10cSrcweir    PropertyTester.TestProperty("Newsgroups")
67cdf0e10cSrcweir
68cdf0e10cSrcweir    PropertyTester.TestProperty("Original")
69cdf0e10cSrcweir
70cdf0e10cSrcweir    Test.StartMethod("Priority")
71cdf0e10cSrcweir
72cdf0e10cSrcweir    bOK =true
73cdf0e10cSrcweir
74cdf0e10cSrcweir    pval = oObj.Priority
75cdf0e10cSrcweir    Out.Log("Was:" + pval)
76cdf0e10cSrcweir    oObj.Priority = pval + 1
77cdf0e10cSrcweir    resVal = oObj.Priority
78cdf0e10cSrcweir    Out.Log("Res:" + resVal)
79cdf0e10cSrcweir    bOK = bOK AND (pval + 1 = resVal)
80cdf0e10cSrcweir
81cdf0e10cSrcweir    Test.MethodTested("Priority", bOK)
82cdf0e10cSrcweir
83cdf0e10cSrcweir    PropertyTester.TestProperty("Recipient")
84cdf0e10cSrcweir
85cdf0e10cSrcweir    PropertyTester.TestProperty("References")
86cdf0e10cSrcweir
87cdf0e10cSrcweir    PropertyTester.TestProperty("ReplyTo")
88cdf0e10cSrcweir
89cdf0e10cSrcweir    PropertyTester.TestProperty("Theme")
90cdf0e10cSrcweir
91cdf0e10cSrcweir    PropertyTester.TestProperty("Title")
92cdf0e10cSrcweir
93cdf0e10cSrcweir    PropertyTester.TestProperty("Template")
94cdf0e10cSrcweir
95cdf0e10cSrcweir    testDateTime("TemplateDate")
96cdf0e10cSrcweir
97cdf0e10cSrcweir    PropertyTester.TestProperty("IsEncrypted")
98cdf0e10cSrcweir
99cdf0e10cSrcweir    testDateTime("PrintDate")
100cdf0e10cSrcweir
101cdf0e10cSrcweir    PropertyTester.TestProperty("PrintedBy")
102cdf0e10cSrcweir
103cdf0e10cSrcweir    PropertyTester.TestProperty("AutoloadEnabled")
104cdf0e10cSrcweir
105cdf0e10cSrcweir    PropertyTester.TestProperty("AutoloadURL")
106cdf0e10cSrcweir
107cdf0e10cSrcweir    Test.StartMethod("AutoloadSecs")
108cdf0e10cSrcweir
109cdf0e10cSrcweir    bOK =true
110cdf0e10cSrcweir
111cdf0e10cSrcweir    pval = oObj.AutoloadSecs
112cdf0e10cSrcweir    Out.Log("Was:" + pval)
113cdf0e10cSrcweir    oObj.AutoloadSecs = pval + 10
114cdf0e10cSrcweir    resVal = oObj.AutoloadSecs
115cdf0e10cSrcweir    Out.Log("Res:" + resval)
116cdf0e10cSrcweir    bOK = bOK AND (pval + 10 = resVal)
117cdf0e10cSrcweir
118cdf0e10cSrcweir    Test.MethodTested("AutoloadSecs", bOK)
119cdf0e10cSrcweir
120cdf0e10cSrcweir    PropertyTester.TestProperty("DefaultTarget")
121cdf0e10cSrcweir
122cdf0e10cSrcweir    PropertyTester.TestProperty("Generator")
123cdf0e10cSrcweir
124cdf0e10cSrcweir    PropertyTester.TestProperty("CreationDate")
125cdf0e10cSrcweir
126cdf0e10cSrcweir    PropertyTester.TestProperty("Subject")
127cdf0e10cSrcweir
128cdf0e10cSrcweir    PropertyTester.TestProperty("Language")
129cdf0e10cSrcweir
130cdf0e10cSrcweir    PropertyTester.TestProperty("ModifyDate")
131cdf0e10cSrcweir
132cdf0e10cSrcweir    PropertyTester.TestProperty("PrintDate")
133cdf0e10cSrcweir
134cdf0e10cSrcweir    PropertyTester.TestProperty("TemplateDate")
135cdf0e10cSrcweir
136cdf0e10cSrcweirExit Sub
137cdf0e10cSrcweirErrHndl:
138cdf0e10cSrcweir    Test.Exception()
139cdf0e10cSrcweir    resume next
140cdf0e10cSrcweirEnd Sub
141cdf0e10cSrcweir
142cdf0e10cSrcweirSub testDateTime(propName As String)
143cdf0e10cSrcweir    Dim oldVal As Variant, resVal As Variant
144cdf0e10cSrcweir    Dim newVal As New com.sun.star.util.DateTime
145cdf0e10cSrcweir    Dim bOK As Boolean
146cdf0e10cSrcweir    bOK = true
147cdf0e10cSrcweir
148cdf0e10cSrcweir    Test.StartMethod(propName)
149cdf0e10cSrcweir
150cdf0e10cSrcweir    oldVal = oObj.getPropertyValue(propName)
151cdf0e10cSrcweir    Out.Log("OldVal :" + dateTime2String(oldVal))
152cdf0e10cSrcweir    if isNull(oldVal) then
153cdf0e10cSrcweir        newVal.Year = 2001
154cdf0e10cSrcweir        newVal.Month = 11
155cdf0e10cSrcweir        newVal.Day = 12
156cdf0e10cSrcweir        newVal.Hours = 16
157cdf0e10cSrcweir        newVal.Minutes = 14
158cdf0e10cSrcweir        newVal.Seconds = 48
159cdf0e10cSrcweir        newVal.HundredthSeconds = 0
160cdf0e10cSrcweir    else
161cdf0e10cSrcweir        newVal.Year = oldVal.Year
162cdf0e10cSrcweir        newVal.Month = oldVal.Month
163cdf0e10cSrcweir        newVal.Day = oldVal.Day
164cdf0e10cSrcweir        newVal.Hours = oldVal.Hours
165cdf0e10cSrcweir        newVal.Minutes = oldVal.Minutes
166cdf0e10cSrcweir        newVal.HundredthSeconds = oldVal.HundredthSeconds
167cdf0e10cSrcweir        newVal.Seconds = oldVal.Seconds + 1
168cdf0e10cSrcweir        if (newVal.Seconds > 59) then newVal.Seconds = 0
169cdf0e10cSrcweir    end if
170cdf0e10cSrcweir
171cdf0e10cSrcweir    Out.Log("NewVal :" + dateTime2String(newVal))
172cdf0e10cSrcweir    oObj.setPropertyValue(propName, newVal)
173cdf0e10cSrcweir    resVal = oObj.getPropertyValue(propName)
174cdf0e10cSrcweir    Out.Log("ResVal :" + dateTime2String(resVal))
175cdf0e10cSrcweir
176cdf0e10cSrcweir    bOK = bOK AND (newVal.Year = resVal.Year)
177cdf0e10cSrcweir    bOK = bOK AND (newVal.Month = resVal.Month)
178cdf0e10cSrcweir    bOK = bOK AND (newVal.Day = resVal.Day)
179cdf0e10cSrcweir    bOK = bOK AND (newVal.Hours = resVal.Hours)
180cdf0e10cSrcweir    bOK = bOK AND (newVal.Minutes = resVal.Minutes)
181cdf0e10cSrcweir    bOK = bOK AND (newVal.Seconds = resVal.Seconds)
182cdf0e10cSrcweir    bOK = bOK AND (newVal.HundredthSeconds = resVal.HundredthSeconds)
183cdf0e10cSrcweir
184cdf0e10cSrcweir' ### The following property was not found in correspond IDL file! ###
185cdf0e10cSrcweir    Test.MethodTested(propName, bOK)
186cdf0e10cSrcweir
187cdf0e10cSrcweir    Exit Sub
188cdf0e10cSrcweirErrHndl:
189cdf0e10cSrcweir    Test.Exception()
190cdf0e10cSrcweir    bOK = false
191cdf0e10cSrcweir    resume next
192cdf0e10cSrcweirEnd Sub
193cdf0e10cSrcweir
194cdf0e10cSrcweirFunction dateTime2String (dT As Variant) As String
195cdf0e10cSrcweir
196cdf0e10cSrcweir    dateTime2String = "" + dT.Day + "." + dT.Month + "." + dT.Year + _
197cdf0e10cSrcweir        " " + dT.Hours + ":" + dT.Minutes + ":" + dT.Seconds + "." + _
198cdf0e10cSrcweir        dT.HundredthSeconds
199cdf0e10cSrcweir
200cdf0e10cSrcweirEnd Function
201cdf0e10cSrcweir</script:module>
202