Ask Your Question
0

Why does my frame not center vertically?

asked 2017-05-22 18:23:39 +0200

ksten gravatar image

I'm generating a frame like so:

     XTextFrame frame = UnoRuntime.queryInterface(XTextFrame.class, serviceFactory.createInstance("com.sun.star.text.TextFrame"));
    text.insertTextContent(cursor, frame, false);
    XPropertySet properties = UnoRuntime.queryInterface(XPropertySet.class, frame);
    properties.setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);
    properties.setPropertyValue("VertOrient", VertOrientation.CENTER);
    properties.setPropertyValue("VertOrientRelation", RelOrientation.PRINT_AREA);
    properties.setPropertyValue("HoriOrient", HoriOrientation.CENTER);
    properties.setPropertyValue("HoriOrientRelation", RelOrientation.PRINT_AREA);
    properties.setPropertyValue("Width", 15000);

It draws the frame centered horizontally, but not vertically (the frame draws at the top of the printable are). If, after generating the content via code, I click inside the frame, hit enter, and then either backspace or CTRL-Z to undo, THEN it centers vertically, but unless I do that, it remains at the top, even after closing and reloading the document. Is there something else I need to do to get it centered vertically?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-05-24 05:47:58 +0200

Ratslinger gravatar image

updated 2017-05-24 06:43:06 +0200

I have no problems with this using Basic or Python. Text frame is centered vertically and horizontally. However I do not see where 'cursor' is created. Something such as (not sure of Java syntax - "XTextDocument document = getDocument();):

cursor = document.Text.createTextCursor() with that going before text.insertTextContent(cursor, frame, false); and move both lines to after all properties have been set.

Just noticed, don't see where "text" is created - sb something like "text = document.Text"

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-22 18:23:39 +0200

Seen: 58 times

Last updated: May 24 '17