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 37' Be sure that all variables are dimensioned: 38option explicit 39 40 41 42Sub RunTest() 43 44'************************************************************************* 45' SERVICE: 46' com.sun.star.document.DocumentInfo 47'************************************************************************* 48On Error Goto ErrHndl 49 Dim bOK As Boolean 50 Dim pval As Variant, resVal As Variant 51 52 PropertyTester.TestProperty("Author") 53 54 PropertyTester.TestProperty("BlindCopiesTo") 55 56 PropertyTester.TestProperty("CopyTo") 57 58 testDateTime("CreationDate") 59 60 PropertyTester.TestProperty("Description") 61 62 PropertyTester.TestProperty("InReplyTo") 63 64 PropertyTester.TestProperty("Keywords") 65 66 PropertyTester.TestProperty("MIMEType") 67 68 testDateTime("ModifyDate") 69 70 PropertyTester.TestProperty("ModifiedBy") 71 72 PropertyTester.TestProperty("Newsgroups") 73 74 PropertyTester.TestProperty("Original") 75 76 Test.StartMethod("Priority") 77 78 bOK =true 79 80 pval = oObj.Priority 81 Out.Log("Was:" + pval) 82 oObj.Priority = pval + 1 83 resVal = oObj.Priority 84 Out.Log("Res:" + resVal) 85 bOK = bOK AND (pval + 1 = resVal) 86 87 Test.MethodTested("Priority", bOK) 88 89 PropertyTester.TestProperty("Recipient") 90 91 PropertyTester.TestProperty("References") 92 93 PropertyTester.TestProperty("ReplyTo") 94 95 PropertyTester.TestProperty("Theme") 96 97 PropertyTester.TestProperty("Title") 98 99 PropertyTester.TestProperty("Template") 100 101 testDateTime("TemplateDate") 102 103 PropertyTester.TestProperty("IsEncrypted") 104 105 testDateTime("PrintDate") 106 107 PropertyTester.TestProperty("PrintedBy") 108 109 PropertyTester.TestProperty("AutoloadEnabled") 110 111 PropertyTester.TestProperty("AutoloadURL") 112 113 Test.StartMethod("AutoloadSecs") 114 115 bOK =true 116 117 pval = oObj.AutoloadSecs 118 Out.Log("Was:" + pval) 119 oObj.AutoloadSecs = pval + 10 120 resVal = oObj.AutoloadSecs 121 Out.Log("Res:" + resval) 122 bOK = bOK AND (pval + 10 = resVal) 123 124 Test.MethodTested("AutoloadSecs", bOK) 125 126 PropertyTester.TestProperty("DefaultTarget") 127 128 PropertyTester.TestProperty("Generator") 129 130 PropertyTester.TestProperty("CreationDate") 131 132 PropertyTester.TestProperty("Subject") 133 134 PropertyTester.TestProperty("Language") 135 136 PropertyTester.TestProperty("ModifyDate") 137 138 PropertyTester.TestProperty("PrintDate") 139 140 PropertyTester.TestProperty("TemplateDate") 141 142Exit Sub 143ErrHndl: 144 Test.Exception() 145 resume next 146End Sub 147 148Sub testDateTime(propName As String) 149 Dim oldVal As Variant, resVal As Variant 150 Dim newVal As New com.sun.star.util.DateTime 151 Dim bOK As Boolean 152 bOK = true 153 154 Test.StartMethod(propName) 155 156 oldVal = oObj.getPropertyValue(propName) 157 Out.Log("OldVal :" + dateTime2String(oldVal)) 158 if isNull(oldVal) then 159 newVal.Year = 2001 160 newVal.Month = 11 161 newVal.Day = 12 162 newVal.Hours = 16 163 newVal.Minutes = 14 164 newVal.Seconds = 48 165 newVal.HundredthSeconds = 0 166 else 167 newVal.Year = oldVal.Year 168 newVal.Month = oldVal.Month 169 newVal.Day = oldVal.Day 170 newVal.Hours = oldVal.Hours 171 newVal.Minutes = oldVal.Minutes 172 newVal.HundredthSeconds = oldVal.HundredthSeconds 173 newVal.Seconds = oldVal.Seconds + 1 174 if (newVal.Seconds > 59) then newVal.Seconds = 0 175 end if 176 177 Out.Log("NewVal :" + dateTime2String(newVal)) 178 oObj.setPropertyValue(propName, newVal) 179 resVal = oObj.getPropertyValue(propName) 180 Out.Log("ResVal :" + dateTime2String(resVal)) 181 182 bOK = bOK AND (newVal.Year = resVal.Year) 183 bOK = bOK AND (newVal.Month = resVal.Month) 184 bOK = bOK AND (newVal.Day = resVal.Day) 185 bOK = bOK AND (newVal.Hours = resVal.Hours) 186 bOK = bOK AND (newVal.Minutes = resVal.Minutes) 187 bOK = bOK AND (newVal.Seconds = resVal.Seconds) 188 bOK = bOK AND (newVal.HundredthSeconds = resVal.HundredthSeconds) 189 190' ### The following property was not found in correspond IDL file! ### 191 Test.MethodTested(propName, bOK) 192 193 Exit Sub 194ErrHndl: 195 Test.Exception() 196 bOK = false 197 resume next 198End Sub 199 200Function dateTime2String (dT As Variant) As String 201 202 dateTime2String = "" + dT.Day + "." + dT.Month + "." + dT.Year + _ 203 " " + dT.Hours + ":" + dT.Minutes + ":" + dT.Seconds + "." + _ 204 dT.HundredthSeconds 205 206End Function 207</script:module> 208