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_ScDataPilotFieldsObj" 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' REQUIRED VARIABLES for interface/service tests: 36 37Global nGlobalLong As Long 38 39 40Sub CreateObj() 41 42'************************************************************************* 43' COMPONENT: 44' sc.ScDataPilotFieldsObj 45'************************************************************************* 46On Error Goto ErrHndl 47 Dim bOK As Boolean 48 Dim i as Integer,j As Integer 49 Dim oSheet as Object, oDataPilotDescriptor As Object 50 Dim oFields as Variant , oDataPilotTable As Variant 51 Dim sCellRangeAddress As New com.sun.star.table.CellRangeAddress 52 Dim sCellAddress As New com.sun.star.table.CellAddress 53 54 bOK = true 55 oDoc = utils.createDocument("scalc", cObjectName) 56 oSheet = oDoc.Sheets.getByIndex(0) 57 58 for i = 1 to 5 59 for j = 1 to 5 60 oSheet.getCellByPosition(i, j).Value = 2.5 * j + i 61 next j 62 next i 63 64 sCellRangeAddress.Sheet = 0 65 sCellRangeAddress.StartColumn = 1 66 sCellRangeAddress.StartRow = 1 67 sCellRangeAddress.EndColumn = 5 68 sCellRangeAddress.EndRow = 5 69 70 sCellAddress.Sheet = 0 71 sCellAddress.Column = 7 72 sCellAddress.Row = 8 73 74 oDataPilotTable = oSheet.getDataPilotTables 75 oDataPilotDescriptor = oDataPilotTable.createDataPilotDescriptor() 76 oDataPilotDescriptor.setSourceRange(sCellRangeAddress) 77 78 oDataPilotTable.insertNewByName(cObjectName, sCellAddress, oDataPilotDescriptor) 79 80 oFields = oDataPilotDescriptor.getDataPilotFields 81 oObj = oFields 82 nGlobalLong = oObj.Count 83 84 85Exit Sub 86ErrHndl: 87 Test.Exception() 88End Sub 89</script:module> 90