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_XSheetPageBreak" 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' Be sure that all variables are dimensioned: 37option explicit 38 39 40 41Sub RunTest() 42 43'************************************************************************* 44' INTERFACE: 45' com.sun.star.sheet.XSheetPageBreak 46'************************************************************************* 47On Error Goto ErrHndl 48 Dim bOK As Boolean 49 Dim nColsBreaks As Integer 50 Dim nRowsBreaks As Integer 51 Dim oColumn As Object 52 Dim oRow As Object 53 Dim oPBs As Variant 54 Dim iRowsBefore As Integer 55 Dim iColsBefore As Integer 56 57 iColsBefore = ubound(oObj.getColumnPageBreaks()) - 1 58 iRowsBefore = ubound(oObj.getRowPageBreaks()) - 1 59 60 Out.Log("Before test: colBreaks: " & iColsBefore & _ 61 " rowBreaks: " & iRowsBefore) 62 63 Out.Log("Inserting new PageBreaks.") 64 oColumn = oObj.Columns.getByIndex(5) 65 oColumn.SetPropertyValue("IsStartOfNewPage", true) 66 oRow = oObj.Rows.getByIndex(15) 67 oRow.SetPropertyValue("IsStartOfNewPage", true) 68 69 Test.StartMethod("getColumnPageBreaks()") 70 bOK = true 71 oPBs = oObj.getColumnPageBreaks() 72 nColsBreaks = uBound(oPBs) 73 Out.Log("There are " & nColsBreaks & " column breaks.") 74 bOK = bOK AND nColsBreaks > 0 75 bOK = bOK AND oPBs(0).Position >= 0 76 Test.MethodTested("getColumnPageBreaks()", bOK) 77 78 Test.StartMethod("getRowPageBreaks()") 79 bOK = true 80 oPBs = oObj.getRowPageBreaks() 81 nRowsBreaks = uBound(oPBs) 82 Out.Log("There are " & nRowsBreaks & " row breaks.") 83 bOK = bOK AND nRowsBreaks > 0 84 bOK = bOK AND oPBs(0).Position >= 0 85 Test.MethodTested("getRowPageBreaks()", bOK) 86 87 Test.StartMethod("removeAllManualPageBreaks()") 88 bOK = true 89 oObj.removeAllManualPageBreaks() 90 Out.Log("After test: colBreaks: " & ubound(oObj.getColumnPageBreaks()) - 1 & _ 91 " rowBreaks: " & ubound(oObj.getRowPageBreaks()) - 1) 92 93 bOK = bOK AND ubound(oObj.getRowPageBreaks()) - 1 = iRowsBefore 94 bOK = bOK AND ubound(oObj.getColumnPageBreaks()) - 1= iColsBefore 95 Test.MethodTested("removeAllManualPageBreaks()", bOK) 96 97Exit Sub 98ErrHndl: 99 Test.Exception() 100 bOK = false 101 resume next 102End Sub 103</script:module> 104