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_XSortedDynamicResultSetFactory" 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.ucb.XSortedDynamicResultSetFactory 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 45 46 Test.StartMethod("createSortedDynamicResultSet()") 47 48 Dim oUCB As Object 49 oUCB = createUnoService("com.sun.star.ucb.UniversalContentBroker") 50 Dim args As Variant 51 args = Array("Local", "Office") 52 oUCB.initialize(args()) 53 54 Dim sURL, sCntURL As String 55 sURL = utils.Path2URL(cTestDocsDir & "solibrary.jar") 56 sURL = utils.utils.StrReplace(sURL, "/", "%2F") 57 sCntURL = "vnd.sun.star.pkg://" & sURL & "/" 58 59 Dim oCI, oContent As Object 60 oCI = oUCB.createContentIdentifier(sCntUrl) 61 oContent = oUCB.queryContent(oCI) 62 63 Dim props(0) As new com.sun.star.beans.Property 64 Dim cmd As new com.sun.star.ucb.Command 65 Dim ocArg As new com.sun.star.ucb.OpenCommandArgument2 66 Dim sortInfo(0) As new com.sun.star.ucb.NumberedSortingInfo 67 Dim oDynResSet As Object 68 69 props(0).Name = "Title" 70 71 ocArg.Mode = com.sun.star.ucb.OpenMode.ALL 72 ocArg.Priority = 10000 73 ocArg.Properties = props() 74 ocArg.SortingInfo = sortInfo() 75 76 cmd.Name = "open" 77 cmd.Handle = -1 78 cmd.Argument = ocArg 79 80 oDynResSet = oContent.execute(cmd, 0, NULL_OBJECT) 81 82 Dim oSortedSet As Object 83 oSortedSet = oObj.createSortedDynamicResultSet(oDynResSet, sortInfo(), NULL_OBJECT) 84 85 If IsNULL(oSortedSet) Then 86 out.log("returns null") 87 bOK = False 88 Else 89 Dim oSet As Object 90 oSet = oSortedSet.getStaticResultSet() 91 oSet.last() 92 Dim rowCount As Integer 93 rowCount = oSet.getRow() 94 out.log("number of row : " + rowCount) 95 bOK = rowCount > 0 96 EndIf 97 98 Test.MethodTested("createSortedDynamicResultSet()", bOK) 99 100Exit Sub 101ErrHndl: 102 Test.Exception() 103 bOK = false 104 resume next 105End Sub 106</script:module> 107