« Return to Thread: I have five text frames on the one page, can I move each frame to a new page?
Chris Fleischmann wrote:Hello folks, I have TextFrames, that are created like so (at the beginning of the process):
private XText getTextFrame(XText xText, int x, int y) {
try {
Object textFrame = xWriterFactory.createInstance("com.sun.star.text.TextFrame");
XTextContent xTextContentFrame = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, textFrame);
XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textFrame);
xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH);
// Setting the vertical and horizontal position
xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
xShapeProps.setPropertyValue("VertOrientPosition", new Integer(x));
xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(y));
// Set the width and height of the shape.
xShapeProps.setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width));
xShapeProps.setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height));
xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
xShapeProps.setPropertyValue("SizeType", new Short((short)1));
xShapeProps.setPropertyValue("LeftBorderDistance", new Integer(200));
xShapeProps.setPropertyValue("RightBorderDistance", new Integer(200));
xShapeProps.setPropertyValue("TopBorderDistance", new Integer(200));
xShapeProps.setPropertyValue("BottomBorderDistance", new Integer(200));
xText.insertTextContent(xText.getEnd(), xTextContentFrame, false);
XText xFrameText = (XText) UnoRuntime.queryInterface(XText.class, textFrame);
return xFrameText;
} catch (java.lang.Exception e) {
e.printStackTrace();
}
return null;
}
This method seems to work, it creates the textframe with a specific size, at a specific x/y location.
I am now attempting to iterate over the "said" textframes like so:
XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier)
UnoRuntime.queryInterface(XTextFramesSupplier.class, xWriterComponent_dest);
XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames();
String[] textframes = xNamedFrames.getElementNames();
for (int i = 0; i < textframes.length; i++) {
XTextFrame textframe = null;
try {
textframe = (XTextFrame)xNamedFrames.getByName(textframes[i]);
XTextContent xFrameContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, textframe);
XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, textframe);
Which seems to work, ie., i can iterate over the above "said" frames.... I have tried doing:
xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH);
// Setting the vertical and horizontal position
xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
xShapeProps.setPropertyValue("VertOrientPosition", new Integer(1000 + (i * 1000)));
xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(1000));
so as to move the frames slowly but sure down the page....
That doesn't seem to work?
Secondly, is there a way to create a new page between each cycle so that I can move the textframe to the new page with the same, x/y origin?
Thanks in advance for any help you can shed on the issue,
Chris
« Return to Thread: I have five text frames on the one page, can I move each frame to a new page?
| Free embeddable forum powered by Nabble | Forum Help |