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="ucb_XContentProviderManager" 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
38
39Sub RunTest()
40
41'*************************************************************************
42' INTERFACE:
43' com.sun.star.ucb.XContentProviderManager
44'*************************************************************************
45On Error Goto ErrHndl
46    Dim bOK As Boolean
47
48    Dim Provider As Object
49    Dim Scheme As String
50    Dim ReplaceExisting As Boolean
51    Dim ContentProvider As Object
52    Dim queryInfo As Variant
53    Dim bFound As Boolean
54
55    Test.StartMethod("queryContentProviders()")
56    bOK = true
57    queryInfo = oObj.queryContentProviders()
58    Out.Log("queryContentProviders() returned " &amp; ubound(queryInfo) &amp; " elements.")
59    for i = 0 to ubound(queryInfo)
60        Out.Log(queryInfo(i).Scheme)
61    next i
62    Test.MethodTested("queryContentProviders()", bOK)
63
64    Test.StartMethod("registerContentProvider()")
65    bOK = true
66    ReplaceExisting = true
67    Scheme = "XContentProviderManager"
68    Provider = createUNOService("com.sun.star.ucb.FileContentProvider")
69    Out.Log("Registering Scheme = '" &amp; Scheme &amp; "'")
70    ContentProvider = oObj.registerContentProvider(Provider, Scheme, ReplaceExisting)
71    bOK = bOK AND hasUnoInterfaces(ContentProvider, "com.sun.star.ucb.XContentProvider")
72    Out.Log("ContentProvider is XContentProvider - " &amp; bOK)
73    if bOK then
74        bFound = false
75        queryInfo = oObj.queryContentProviders()
76        for i = 0 to ubound(queryInfo)
77            bFound = bFound OR queryInfo(i).Scheme = Scheme
78        next i
79        if NOT bFound then
80            Out.Log("Can't find registered ContentProvider in query!")
81            bOK = false
82        end if
83    end if
84    Test.MethodTested("registerContentProvider()", bOK)
85
86    Test.StartMethod("deregisterContentProvider()")
87    if bOK then
88        oObj.deregisterContentProvider(ContentProvider, Scheme)
89        bFound = false
90        queryInfo = oObj.queryContentProviders()
91        for i = 0 to ubound(queryInfo)
92            bFound = bFound OR queryInfo(i).Scheme = Scheme
93        next i
94        if bFound then
95            Out.Log("ContentProvider was found in query! It was not DeRegistered!")
96            bOK = false
97        end if
98    else
99        Out.Log("Can't deregister ContentProvider without registering!")
100    end if
101
102    Test.MethodTested("deregisterContentProvider()", bOK)
103
104    Test.StartMethod("queryContentProvider()")
105    bOK = true
106    ContentProvider = oObj.queryContentProvider(queryInfo(0).Scheme)
107    bOK = bOK AND hasUnoInterfaces(ContentProvider, "com.sun.star.ucb.XContentProvider")
108    Test.MethodTested("queryContentProvider()", bOK)
109
110Exit Sub
111ErrHndl:
112    Test.Exception()
113    bOK = false
114    resume next
115End Sub
116</script:module>
117