Re: [dev] Programmatic XTextFrame Control with Java

2006-02-08 Thread Steffen Grund

Hi again,

I took your code and just added some lines. Here you are:

 XInterface xTextFrameInterface = (XInterface)
mxDocFactory.createInstance(com.sun.star.text.TextFrame);

XTextContent xFrameContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class,
xTextFrameInterface);

XTextRange xDocRange =
(XTextRange)UnoRuntime.queryInterface(XTextRange.class,
mxDocFactory);

XText xText = xDocRange.getText();
xText.insertTextContent(xDocRange, xFrameContent, false);

XPropertySet xFramePropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
xTextFrameInterface);
xFramePropSet.setPropertyValue( FrameHeightAbsolute,
new Long(5000));
xFramePropSet.setPropertyValue(
FrameIsAutomaticHeight, Boolean.FALSE);
xFramePropSet.setPropertyValue( SizeType, new
Short((short)1));


This should do the trick. Note that the text frame is inserted at the 
end of your document. See the description of insertTextContent.


Regards, Steffen

Kent Gibson wrote:

please an example in java would be grand, this has
been a two day struggle.

kind regards,

kent



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [dev] Programmatic XTextFrame Control with Java

2006-02-08 Thread Kent Gibson
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( 2 ) );
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( 5, 5000 ) );
xWriterShape.setPosition(new Point(2,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( 2 ) );
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]



Re: [dev] Programmatic XTextFrame Control with Java

2006-02-07 Thread Christian Junker
Hi Kent Gibson,

this is a pure API topic, so discussion should rather go on over there
(dev@api.openoffice.org). Thus I am forwarding your message.

2006/2/6, Kent Gibson [EMAIL PROTECTED]:
 Hi-ya,

 I would like to create XTextFrames of a fixed
 arbitrary height and width and place them at arbitrary
 x and y coordinates.

 I can manage to get the frame, but I can't seem to
 size it or place it arbitrarily. I have based my code
 on the TextFrameExample() in TextDocuments.java.

 These properties seem to have no effect:

 XInterface xTextFrameInterface = (XInterface)
 mxDocFactory.createInstance(com.sun.star.text.TextFrame);


 XPropertySet xFramePropSet = (XPropertySet)
 UnoRuntime.queryInterface(XPropertySet.class,
 xTextFrameInterface);
 xFramePropSet.setPropertyValue( FrameHeightAbsolute,
 new Long(5000));
 xFramePropSet.setPropertyValue(
 FrameIsAutomaticHeight, new Boolean(false));
 xFramePropSet.setPropertyValue( SizeType, new
 Short((short)1));

 Also when I use xShape to define height and width, it
 doesn't seem to work either. The textframe is only as
 big as the text inside it.

 XShape xShape = ( XShape ) UnoRuntime.queryInterface(
 XShape.class, xFrame );

 // Access the XPropertySet interface of the TextFrame
 XPropertySet xFrameProps = ( XPropertySet )
 UnoRuntime.queryInterface( XPropertySet.class, xFrame
 );

 // Set the size of the new Text Frame using the
 XShape's 'setSize' method
 Size aSize = new Size();
 // this is probably (1/100 mm)
 aSize.Height = 400;
 aSize.Width = 15000;
 xShape.setSize(aSize);

 If anyone has any pointers that would be grand.



--
Best Regards
Christian Junker

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [dev] Programmatic XTextFrame Control with Java

2006-02-07 Thread Kent Gibson
thanks, I am now signed up to the api list. I don't
suppose in the interim my question was answered?

We would really like to integrate openoffice but we
need to able to place text with x,y coords and so far
I can't get it to work. Does anyone even know if this
is possible?

Whenever I set any of these properties on a XTextFrame
they are either ignored or I get
IllegalArgumentException:

HoriOrientPosition
VertOrientPosition
Width
Height
FrameHeightAbsolute
FrameWidthAbsolute
FrameWidthAbsolute
FrameIsAutomaticHeight
SizeType


--- Christian Junker [EMAIL PROTECTED]
wrote:

 Hi Kent Gibson,
 
 this is a pure API topic, so discussion should
 rather go on over there
 (dev@api.openoffice.org). Thus I am forwarding your
 message.
 
 2006/2/6, Kent Gibson [EMAIL PROTECTED]:
  Hi-ya,
 
  I would like to create XTextFrames of a fixed
  arbitrary height and width and place them at
 arbitrary
  x and y coordinates.
 
  I can manage to get the frame, but I can't seem to
  size it or place it arbitrarily. I have based my
 code
  on the TextFrameExample() in TextDocuments.java.
 
  These properties seem to have no effect:
 
  XInterface xTextFrameInterface = (XInterface)
 

mxDocFactory.createInstance(com.sun.star.text.TextFrame);
 
 
  XPropertySet xFramePropSet = (XPropertySet)
  UnoRuntime.queryInterface(XPropertySet.class,
  xTextFrameInterface);
  xFramePropSet.setPropertyValue(
 FrameHeightAbsolute,
  new Long(5000));
  xFramePropSet.setPropertyValue(
  FrameIsAutomaticHeight, new Boolean(false));
  xFramePropSet.setPropertyValue( SizeType, new
  Short((short)1));
 
  Also when I use xShape to define height and width,
 it
  doesn't seem to work either. The textframe is only
 as
  big as the text inside it.
 
  XShape xShape = ( XShape )
 UnoRuntime.queryInterface(
  XShape.class, xFrame );
 
  // Access the XPropertySet interface of the
 TextFrame
  XPropertySet xFrameProps = ( XPropertySet )
  UnoRuntime.queryInterface( XPropertySet.class,
 xFrame
  );
 
  // Set the size of the new Text Frame using the
  XShape's 'setSize' method
  Size aSize = new Size();
  // this is probably (1/100 mm)
  aSize.Height = 400;
  aSize.Width = 15000;
  xShape.setSize(aSize);
 
  If anyone has any pointers that would be grand.
 
 
 
 --
 Best Regards
 Christian Junker
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 


__
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]



Re: [dev] Programmatic XTextFrame Control with Java

2006-02-07 Thread Steffen Grund

Hi Kent,

the text frame is only really valid after you've inserted it in the 
document.
See 
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextFrame.html
for a Basic example on how to insert the frame. If you need one in Java, 
let me know.


Regards, Steffen


Kent Gibson wrote:

Hi-ya,

I would like to create XTextFrames of a fixed
arbitrary height and width and place them at arbitrary
x and y coordinates. 


I can manage to get the frame, but I can't seem to
size it or place it arbitrarily. I have based my code
on the TextFrameExample() in TextDocuments.java.

These properties seem to have no effect:

XInterface xTextFrameInterface = (XInterface)
mxDocFactory.createInstance(com.sun.star.text.TextFrame);


XPropertySet xFramePropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
xTextFrameInterface); 
xFramePropSet.setPropertyValue( FrameHeightAbsolute,

new Long(5000));
xFramePropSet.setPropertyValue(
FrameIsAutomaticHeight, new Boolean(false));
xFramePropSet.setPropertyValue( SizeType, new
Short((short)1));

Also when I use xShape to define height and width, it
doesn't seem to work either. The textframe is only as
big as the text inside it.

XShape xShape = ( XShape ) UnoRuntime.queryInterface(
XShape.class, xFrame );
  
// Access the XPropertySet interface of the TextFrame

XPropertySet xFrameProps = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class, xFrame
);

// Set the size of the new Text Frame using the
XShape's 'setSize' method
Size aSize = new Size();
// this is probably (1/100 mm)
aSize.Height = 400;
aSize.Width = 15000;
xShape.setSize(aSize);

If anyone has any pointers that would be grand.

kent

__
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]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [dev] Programmatic XTextFrame Control with Java

2006-02-07 Thread Kent Gibson
please an example in java would be grand, this has
been a two day struggle.

kind regards,

kent

--- Steffen Grund [EMAIL PROTECTED] wrote:

 Hi Kent,
 
 the text frame is only really valid after you've
 inserted it in the 
 document.
 See 

http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextFrame.html
 for a Basic example on how to insert the frame. If
 you need one in Java, 
 let me know.
 
 Regards, Steffen
 
 
 Kent Gibson wrote:
  Hi-ya,
  
  I would like to create XTextFrames of a fixed
  arbitrary height and width and place them at
 arbitrary
  x and y coordinates. 
  
  I can manage to get the frame, but I can't seem to
  size it or place it arbitrarily. I have based my
 code
  on the TextFrameExample() in TextDocuments.java.
  
  These properties seem to have no effect:
  
  XInterface xTextFrameInterface = (XInterface)
 

mxDocFactory.createInstance(com.sun.star.text.TextFrame);
  
  
  XPropertySet xFramePropSet = (XPropertySet)
  UnoRuntime.queryInterface(XPropertySet.class,
  xTextFrameInterface); 
  xFramePropSet.setPropertyValue(
 FrameHeightAbsolute,
  new Long(5000));
  xFramePropSet.setPropertyValue(
  FrameIsAutomaticHeight, new Boolean(false));
  xFramePropSet.setPropertyValue( SizeType, new
  Short((short)1));
  
  Also when I use xShape to define height and width,
 it
  doesn't seem to work either. The textframe is only
 as
  big as the text inside it.
  
  XShape xShape = ( XShape )
 UnoRuntime.queryInterface(
  XShape.class, xFrame );

  // Access the XPropertySet interface of the
 TextFrame
  XPropertySet xFrameProps = ( XPropertySet )
  UnoRuntime.queryInterface( XPropertySet.class,
 xFrame
  );
  
  // Set the size of the new Text Frame using the
  XShape's 'setSize' method
  Size aSize = new Size();
  // this is probably (1/100 mm)
  aSize.Height = 400;
  aSize.Width = 15000;
  xShape.setSize(aSize);
  
  If anyone has any pointers that would be grand.
  
  kent
  
  __
  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]
  
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 


__
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]