Thanks for the help and comments.
I seem to have got it working, it needs more testing.
Surly there seems to be a bug here:
xShapeProps.setPropertyValue( "VertOrientPosition",
new Integer( 20000 ) );
xShapeProps.setPropertyValue( "HoriOrientPosition",
new Integer( 12000 ) );
These properties are defined to take longs. VertOrient
can take a long, but gives odd results and the other
one takes a long but then throws a
IllegalArgumentException.
Below is the method, I will post this somewhere on a
snippets page, after I wait to see if I get any
comments, or at least after I test it a bit more.
manipulateText() is taken directly out of the
handbook.
Code Follows
#################################
public void frameTest() throws java.lang.Exception
{
mxDoc = this.bean.getTextDocument();
// get its text
mxDocText = ( XText ) mxDoc.getText();
// Create a document cursor and remember it
mxDocCursor = mxDocText.createTextCursor();
// Access the text document's multi service factory
mxDocFactory = ( XMultiServiceFactory )
UnoRuntime.queryInterface( XMultiServiceFactory.class,
mxDoc );
// Use the document's factory to create a new text
frame and immediately access
// it's XTextFrame interface
Object objectTextFrame = mxDocFactory.createInstance(
"com.sun.star.text.TextFrame" );
XTextFrame xFrame = ( XTextFrame )
UnoRuntime.queryInterface( XTextFrame.class,
objectTextFrame );
XPropertySet xpropertyset = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class, xFrame
);
xpropertyset.setPropertyValue( "AnchorType",
TextContentAnchorType.AT_PAGE );
// insert RectangleShape and get shape text, then
manipulate text
Object writerShape = mxDocFactory.createInstance(
"com.sun.star.drawing.TextShape" );
XShape xWriterShape = ( XShape )
UnoRuntime.queryInterface( XShape.class, writerShape
);
xWriterShape.setSize( new Size( 50000, 5000 ) );
xWriterShape.setPosition(new Point(20000,12000));
XTextContent xTextContentShape = ( XTextContent )
UnoRuntime.queryInterface( XTextContent.class,
writerShape );
mxDocText.insertTextContent( mxDocText.getEnd(),
xTextContentShape, false );
XPropertySet xShapeProps = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class,
writerShape );
xShapeProps.setPropertyValue( "AnchorType",
TextContentAnchorType.AT_PAGE );
// Setting the vertical position
xShapeProps.setPropertyValue( "VertOrient", new Short(
VertOrientation.NONE ) );
xShapeProps.setPropertyValue( "HoriOrient", new Short(
HoriOrientation.NONE ) );
// Setting the vertical position
// these really should be able to take longs
xShapeProps.setPropertyValue( "VertOrientPosition",
new Integer( 20000 ) );
xShapeProps.setPropertyValue( "HoriOrientPosition",
new Long( 12000 ) );
XText xShapeText = ( XText )
UnoRuntime.queryInterface( XText.class, writerShape );
manipulateText( xShapeText );
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]