List Info

Thread: Snippet Request for Comments : TextFrame at Arbitrary Location




Snippet Request for Comments : TextFrame at Arbitrary Location
user name
2006-03-31 15:21:39
Before submitting this snippet with the snippet
creator , does anyone have any comments?

  private void renderTextFrame()
  {

/* This snippet shows how to create a frame at an
arbitrary location and ZOrder within a table.
 * Inorder for it run you need to define the following
objects.
 * 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();
}
  }

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection
around 
http://mail.yahoo.com 

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )