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="sw_SwXTextFrame" 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: 36Global nGlobalLong As Long 37Global oCollection As Object 38Global oComponentInstance As Object 39 40Global oXTextContent as Object 41Global oXTextContentRange as Object 42 43 44Sub CreateObj() 45 46'************************************************************************* 47' COMPONENT: 48' sw.SwXTextFrame 49'************************************************************************* 50On Error Goto ErrHndl 51 Dim bOK As Boolean 52 Dim nHeight As Integer 53 Dim nWidth As Integer 54 Dim i As Integer 55 Dim oCursor As Object 56 Dim sSize As Object 57 Dim aFrame As Object 58 Dim oBookmark As Object 59 60 bOK = true 61 oDoc = utils.createDocument("swriter", cObjectName) 62 63 oCursor = oDoc.Text.createTextCursor() 64 65 nHeight = 10000 66 nWidth = 10000 67 nGlobalLong = 2 68 69 for i = 1 to nGlobalLong 70 ' create some frames on doc 71 oObj = oDoc.createInstance("com.sun.star.text.TextFrame") 72 sSize = createUNOStruct("com.sun.star.awt.Size") 73 sSize.Height = nHeight 74 sSize.Width = nWidth 75 oObj.Size = sSize 76 oObj.SizeType = 1 77 oObj.Name = cObjectName + i 78 oObj.HoriOrient = i 79 oObj.VertOrient = 1 80 81 ' AnchorTypes: 0 = paragraph, 1 = as char, 2 = page, 3 = frame/paragraph 4= at char 82 oObj.AnchorType = 2 83 oDoc.Text.insertTextContent(oCursor, oObj, false) 84 If i = 1 Then 85 oComponentInstance = oObj 86 End If 87 next i 88 89 ' the tested frame must be inside another frame to check the property AnchorType 90 ' (the value AT_FRAME can be set only in this case) 91 aFrame = oDoc.createInstance("com.sun.star.text.TextFrame") 92 oCursor = oObj.Text.createTextCursor() 93 oObj.Text.insertTextContent(oCursor, aFrame, false) 94 oObj = aFrame 95 96 oCollection = oDoc.TextFrames 97 98 oObj.String = "-Text" 99 100 oCursor = oObj.createTextCursor() 101 oObj.insertString(oCursor, "SwXTextFrame", false) 102 103 oBookmark = oDoc.createInstance("com.sun.star.text.Bookmark") 104 oCursor.gotoEnd(false) 105 oObj.insertTextContent(oCursor, oBookmark, false) 106 107 oXTextContent = oDoc.createInstance("com.sun.star.text.TextFrame") 108 oXTextContentRange = oDoc.Text.createTextCursor() 109 110 111Exit Sub 112ErrHndl: 113 Test.Exception() 114End Sub 115</script:module> 116