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