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="sc_ScIndexEnumeration_DataPilotFieldsEnumeration" script:language="StarBasic"> 4 5'************************************************************************* 6' 7' Licensed to the Apache Software Foundation (ASF) under one 8' or more contributor license agreements. See the NOTICE file 9' distributed with this work for additional information 10' regarding copyright ownership. The ASF licenses this file 11' to you under the Apache License, Version 2.0 (the 12' "License"); you may not use this file except in compliance 13' with the License. You may obtain a copy of the License at 14' 15' http://www.apache.org/licenses/LICENSE-2.0 16' 17' Unless required by applicable law or agreed to in writing, 18' software distributed under the License is distributed on an 19' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20' KIND, either express or implied. See the License for the 21' specific language governing permissions and limitations 22' under the License. 23' 24'************************************************************************* 25 26 27 28 29 30' Be sure that all variables are dimensioned: 31option explicit 32 33 34' REQUIRED VARIABLES for interface/service tests: 35 36 37Sub CreateObj() 38 39'************************************************************************* 40' COMPONENT: 41' sc.ScIndexEnumeration_DataPilotFieldsEnumeration 42'************************************************************************* 43On Error Goto ErrHndl 44 45 Dim bOK As Boolean 46 Dim i as Integer,j As Integer 47 Dim oSheet as Object, oDataPilotDescriptor As Object 48 Dim oFields as Variant, oDataPilotTable As Variant 49 Dim sCellRangeAddress As New com.sun.star.table.CellRangeAddress 50 Dim sCellAddress As New com.sun.star.table.CellAddress 51 52 bOK = true 53 oDoc = utils.createDocument("scalc", cObjectName) 54 oSheet = oDoc.Sheets.getByIndex(0) 55 56 for i = 1 to 5 57 for j = 1 to 5 58 oSheet.getCellByPosition(i, j).Value = 2.5 * j + i 59 next j 60 next i 61 62 sCellRangeAddress.Sheet = 0 63 sCellRangeAddress.StartColumn = 1 64 sCellRangeAddress.StartRow = 1 65 sCellRangeAddress.EndColumn = 5 66 sCellRangeAddress.EndRow = 5 67 68 sCellAddress.Sheet = 0 69 sCellAddress.Column = 7 70 sCellAddress.Row = 8 71 72 oDataPilotTable = oSheet.getDataPilotTables 73 oDataPilotDescriptor = oDataPilotTable.createDataPilotDescriptor() 74 oDataPilotDescriptor.setSourceRange(sCellRangeAddress) 75 76 oDataPilotTable.insertNewByName(cObjectName, sCellAddress, oDataPilotDescriptor) 77 78 oFields = oDataPilotDescriptor.getDataPilotFields 79 oObj = oFields.createEnumeration() 80 81Exit Sub 82ErrHndl: 83 Test.Exception() 84End Sub 85</script:module> 86