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