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