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="sheet_XNamedRange" 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.sheet.XNamedRange
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim oldContent, newContent As String
45    Dim position, oldPosition As Object
46    Dim newPosition As New com.sun.star.table.CellAddress
47    Dim oldType, newType As Long
48
49    Test.StartMethod("getContent()")
50    bOK = true
51    bOK = bOK AND NOT isNULL(oObj.getContent())
52    Test.MethodTested("getContent()", bOK)
53
54    Test.StartMethod("setContent()")
55    bOK = true
56    oldContent = oObj.getContent
57    newContent = cIfcShortName
58    oObj.setContent(newContent)
59    bOK = bOK AND (oldContent &lt;&gt; oObj.getContent)
60    oObj.setContent(oldContent)
61    Test.MethodTested("setContent()", bOK)
62
63    Test.StartMethod("getReferencePosition()")
64    bOK = true
65    bOK = bOK AND NOT isNULL(oObj.getReferencePosition())
66    Test.MethodTested("getReferencePosition()", bOK)
67
68    Test.StartMethod("setReferencePosition()")
69    bOK = true
70    oldPosition = oObj.getReferencePosition()
71
72    newPosition.sheet = oldPosition.sheet
73    newPosition.row = oldPosition.row + 1
74    newPosition.column = oldPosition.column + 1
75    oObj.setReferencePosition(newPosition)
76    position = oObj.getReferencePosition()
77
78    bOK = bOK AND NOT isNULL(position)
79    bOK = bOK AND position.Row &lt;&gt; oldPosition.row
80    bOK = bOK AND position.Column &lt;&gt; oldPosition.Column
81
82    oObj.setReferencePosition(oldPosition)
83    Test.MethodTested("setReferencePosition()", bOK)
84
85    Test.StartMethod("getType()")
86    bOK = true
87    bOK = bOK AND NOT isNULL(oObj.getType)
88    Test.MethodTested("getType()", bOK)
89
90    Test.StartMethod("setType()")
91    bOK = true
92    oldType = oObj.getType()
93    newType = oldType XOR com.sun.star.sheet.NamedRangeFlag.PRINT_AREA
94    oObj.setType(newType)
95    bOK = bOK AND (oldType &lt;&gt; oObj.getType())
96    oObj.setType(oldType)
97    Test.MethodTested("setType()", bOK)
98
99Exit Sub
100ErrHndl:
101    Test.Exception()
102    bOK = false
103    resume next
104End Sub
105</script:module>
106