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="frame_XStorable" 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' INTERFACE: 40' com.sun.star.frame.XStorable 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 Dim cLocation, cLocation1 As String 45 Dim i As Integer 46 Dim oDoc1 As Object 47 48 bOK = true 49 cLocation = utils.getTempFileURL(cObjectName & "." & "XStorable.tmp") 50 if (FileExists(cLocation)) then 51 Kill(cLocation) 52 end if 53 54 if (FileExists(cLocation & ".bak")) then 55 Kill(cLocation & ".bak") 56 end if 57 58 Out.Log("cLocation: "+cLocation) 59 60 Test.StartMethod("storeAsURL()") 61 bOK = true 62 oObj.storeAsURL(cLocation, DimArray()) 63 bOK = bOK AND oObj.hasLocation() 64 Test.MethodTested("storeAsURL()", bOK) 65 66 Test.StartMethod("hasLocation()") 67 bOK = true 68 bOK = bOK AND oObj.hasLocation() 69 Test.MethodTested("hasLocation()", bOK) 70 71 Test.StartMethod("isReadonly()") 72 bOK = true 73 bOK = bOK AND NOT oObj.isReadOnly() 74 Test.MethodTested("isReadonly()", bOK) 75 76 Test.StartMethod("getLocation()") 77 bOK = true 78 bOK = bOK AND (oObj.getLocation = cLocation) 79 Out.Log("Location is: " & oObj.getLocation & " It should be: " & cLocation) 80 Test.MethodTested("getLocation()", bOK) 81 82 Test.StartMethod("storeToURL()") 83 bOK = true 84 cLocation1 = cLocation + ".bak" 85 Out.Log("New Location: " + cLocation1) 86 oDoc.getDocumentInfo().setPropertyValue("Title", "frame_XStorable") 87 oObj.storeToURL(cLocation1, DimArray()) 88 oDoc1 = StarDesktop.loadComponentFromUrl(cLocation1, "sc.ScModelObj.XStorable.tmp.bak", 40, DimArray() ) 89 bOK = bOK AND (oDoc1.getDocumentInfo().getPropertyValue("Title") = "frame_XStorable") 90 if bOK then Out.Log("Document titles are equal") 91 oDoc1.dispose() 92 Test.MethodTested("storeToURL()", bOK) 93 94 Test.StartMethod("store()") 95 bOK = true 96 oObj.storeAsURL(cLocation1, DimArray()) 97 oDoc.getDocumentInfo().setPropertyValue("Title", "frame_XStorable12345") 98 oObj.store() 99 oDoc1 = StarDesktop.loadComponentFromUrl(cLocation1, "sc.ScModelObj.XStorable.tmp.bak", 40, DimArray() ) 100 bOK = bOK AND (oDoc1.getDocumentInfo().getPropertyValue("Title") = "frame_XStorable12345") 101 if bOK then Out.Log("Document titles are equal") 102 oDoc1.dispose() 103 Test.MethodTested("store()", bOK) 104 105Exit Sub 106ErrHndl: 107 Test.Exception() 108 bOK = false 109 resume next 110End Sub 111</script:module> 112