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="text_XPagePrintable" 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.text.XPagePrintable 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 Dim aPrintSettings As Variant 45 Dim aNewSettings As Variant 46 47 Test.StartMethod("getPagePrintSettings()") 48 bOK = true 49 aPrintSettings = oObj.getPagePrintSettings() 50 Out.Log("PrintSettings have " & (ubound(aPrintSettings) + 1) & " elements") 51 bOK = bOK AND (ubound(aPrintSettings) > 0) 52 Test.MethodTested("getPagePrintSettings()", bOK) 53 54 Test.StartMethod("setPagePrintSettings()") 55 bOK = true 56 Dim bOldLandscape As Boolean 57 ' Changing Landscape property... 58 bOldLandscape = aPrintSettings(8).Value 59 aPrintSettings(8).Value = NOT bOldLandscape 60 61 oObj.setPagePrintSettings(aPrintSettings()) 62 aNewSettings = oObj.getPagePrintSettings() 63 bOK = bOK AND (aNewSettings(8).Value = NOT bOldLandscape) 64 65 Test.MethodTested("setPagePrintSettings()", bOK) 66 67 Test.StartMethod("printPages()") 68 bOK = true 69 Dim aPrintingOptions(0) As New com.sun.star.beans.PropertyValue 70 Dim sFileName As String 71 sFileName = utils.Path2URL(cTestDocsDir & "/temp/XPagePrintable.prt") 72 73 if (FileExists(sFileName)) then 74 kill(sFileName) 75 end if 76 77 aPrintingOptions(0).Name = "FileName" 78 aPrintingOptions(0).Value = sFileName 79 aPrintingOptions(0).State = com.sun.star.beans.PropertyState.DEFAULT_VALUE 80 81 Out.Log("Printing to " & sFileName) 82 oObj.printPages(aPrintingOptions()) 83 84 bOK = bOK AND FileExists(sFileName) 85 Test.MethodTested("printPages()", bOK) 86 87Exit Sub 88ErrHndl: 89 Test.Exception() 90 bOK = false 91 resume next 92End Sub 93</script:module> 94