<?xml version="1.0"?> | |
<!-- | |
$RCSfile: Writer.HowToCreateAFrameAtAnArbitraryLocationAndZOrderWithinATable.snip,v $ | |
last change: $Revision: 1.1 $ $Author: tomsontom $ $Date: 2006/07/06 11:41:17 $ | |
(c)2003 by the copyright holders listed with the author-tags. | |
If no explicit copyright holder is mentioned with a certain author, | |
the author him-/herself is the copyright holder. All rights reserved. | |
Public Documentation License Notice: | |
The contents of this Documentation are subject to the | |
Public Documentation License Version 1.0 (the "License"); | |
you may only use this Documentation if you comply with | |
the terms of this License. A copy of the License is | |
available at http://www.openoffice.org/licenses/PDL.html | |
The Original Documentation can be found in the CVS archives | |
of openoffice.org at the place specified by RCSfile: in this header. | |
The Initial Writer(s) of the Original Documentation are listed | |
with the author-tags below. | |
The Contributor(s) are listed with the author-tags below | |
without the marker for being an initial author. | |
All Rights Reserved. | |
--> | |
<snippet language="Java" application="Writer"> | |
<keywords> | |
<keyword>frame</keyword> | |
<keyword>table</keyword> | |
<keyword>ZOrder</keyword> | |
</keywords> | |
<authors> | |
<author id="" initial="true" email="kentgibson@yahoo.com">Kent Gibson</author> | |
</authors> | |
<question heading="How to create a frame at an arbitrary location and ZOrder within a table"> | |
</question> | |
<answer> | |
<listing> private void renderTextFrame() | |
{ | |
/* This snippet shows how to create a frame at an arbitrary location and ZOrder within a table. | |
* The Parameter IsFollowingTextFlow ensures that the | |
table "grows" | |
* The XText does not neccessarily have to be from a table. | |
* It also shows how to make the frame transparent | |
* | |
* */ | |
XMultiServiceFactory documentFactory = null; | |
XText currentXCellText = null; | |
Integer x = new Integer( 20 ); | |
Integer y = new Integer( 20 ); | |
int width = 50; | |
int height = 50; | |
Integer ZOrder = new Integer( 1 ); | |
try | |
{ | |
Object writerShape = documentFactory.createInstance( "com.sun.star.text.TextFrame" ); | |
XShape xWriterShape = ( XShape ) UnoRuntime.queryInterface( XShape.class, writerShape ); | |
xWriterShape.setSize( new Size( width, height ) ); | |
XTextContent xTextContentShape = ( XTextContent ) UnoRuntime.queryInterface( XTextContent.class, writerShape ); | |
// does not support XFastPropertySet | |
XPropertySet xTextContentPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, | |
xTextContentShape ); | |
xTextContentPropertySet.setPropertyValue( "FrameStyleName", "FrameStyle" ); | |
xTextContentPropertySet.setPropertyValue( "FrameIsAutomaticHeight", Boolean.TRUE ); | |
xTextContentPropertySet.setPropertyValue( "ZOrder", ZOrder ); | |
xTextContentPropertySet.setPropertyValue( "IsFollowingTextFlow", Boolean.TRUE ); | |
xTextContentPropertySet.setPropertyValue( "BackColor", new Integer( 0xffffffff ) ); | |
//$NON-NLS-1$ | |
xTextContentPropertySet.setPropertyValue( "BackColorTransparency", new Short( ( short ) 100 ) ); | |
//$NON-NLS-1$ | |
XPropertySet xShapeProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, writerShape ); | |
// Setting the vertical position | |
xShapeProps.setPropertyValue( "HoriOrientPosition", x ); | |
xShapeProps.setPropertyValue( "VertOrientPosition", y ); | |
// get the XText from the shape | |
XText xShapeText = ( XText ) UnoRuntime.queryInterface( XText.class, writerShape ); | |
currentXCellText.insertTextContent( this.currentXCellCursor, xTextContentShape, false ); | |
xShapeText.setString( "SOME TEXT " ); | |
} | |
catch ( Exception e ) | |
{ | |
e.printStackTrace(); | |
} | |
}</listing> | |
</answer> | |
<versions> | |
<version number="2.0.x" status="tested"/> | |
</versions> | |
<operating-systems> | |
<operating-system name="All"/> | |
</operating-systems> | |
<changelog> | |
</changelog> | |
</snippet> |