Chris Fleischmann wrote:
> I have gotten so far as;
>
> private void moveTextFrames() {
> XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier)
> UnoRuntime.queryInterface(XTextFramesSupplier.class,
> xWriterComponent_dest);
>
> XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames();
>
> XIndexAccess xIndexAccess = (XIndexAccess)
> UnoRuntime.queryInterface(
> XIndexAccess.class, xNamedFrames);
>
> XText xText = xTextDocument_dest.getText();
>
> XTextCursor xTextCursor = xText.createTextCursor();
>
> for (int i = 0; i < xIndexAccess.getCount(); i++) {
> try {
> Any xImageAny = (Any) xIndexAccess.getByIndex(i);
> Object textFrame = xImageAny.getObject();
>
> XTextContent xFrameContent = (XTextContent)textFrame;
>
> XPropertySet xShapeProps = (XPropertySet)
> UnoRuntime.queryInterface(XPropertySet.class, textFrame);
>
> xShapeProps.setPropertyValue("AnchorType",
> TextContentAnchorType.AT_PAGE);
>
> // Setting the vertical and horizontal position
> int height = (i * page_size.Height) + 1000;
>
> xShapeProps.setPropertyValue("VertOrient", new
> Short(VertOrientation.NONE));
> xShapeProps.setPropertyValue("HoriOrient", new
> Short(HoriOrientation.NONE));
> xShapeProps.setPropertyValue("HoriOrientPosition", new
> Integer(1000));
> xShapeProps.setPropertyValue("VertOrientPosition", new
> Integer(height));
>
> // 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));
>
> // Insert a paragraph break into the document (not the
> frame)
> xText.insertControlCharacter (xTextCursor,
> ControlCharacter.PARAGRAPH_BREAK, false);
>
> XPropertySet xCursorProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
>
> xCursorProps.setPropertyValue("BreakType",
> com.sun.star.style.BreakType.PAGE_AFTER);
>
> xText.insertControlCharacter(xTextCursor,
> ControlCharacter.PARAGRAPH_BREAK, false);
>
> xTextCursor.gotoEnd(false);
> } catch (Exception e) {
> System.out.println(e.getMessage());
>
> e.printStackTrace();
> }
> }
> }
>
>
> Which allows me to grab the existing textfram. I then attempt to change the
> verticial position based on the page size, and once moved add a new page to
> the document and updating the height value for the next frame's
> translation...
>
> This doesn't seem to work, ie., the textframe(s) do not move to the next
> page, they don't translate, the seem to move down the page by increments of
> 1000? Shouldn't the Anchor, AT_PAGE move to the "second", "third" or etc.
> etc. page, rather than stick to page 1?
>
Chris,
AT_PAGE is the only option, but the vertical position is calqulated from
the begining off the document, so for every Page you have to ad the
hight off every page .
And i think a viewCursor gives you information about the pagenr wher
the frame is located.
Hope it helps
Fernand
> thanks for any help you may be able to shed.
>
>
>
> 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
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
dev-unsubscribe@...
For additional commands, e-mail:
dev-help@...