Hi, Yes, I am trying to calculate the height like so,
(i * page_size.Height) + 1000
The page_size.Height was calculated previously, ie.,
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class,
xTextDocument_dest);
// get the NameAccess interface from the Style family collection
XNameAccess xNameAccess = xSupplier.getStyleFamilies();
XNameContainer xPageStyleCollection = (XNameContainer)
UnoRuntime.queryInterface(XNameContainer.class,
xNameAccess.getByName(
"PageStyles"));
// create a PropertySet to set the properties for the new
Pagestyle
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
xPageStyleCollection.getByName("Default"));
// Flip the size
page_size = (Size) xPropertySet.getPropertyValue("Size");
int height = page_size.Height;
page_size.Height = page_size.Width;
page_size.Width = height;
I have also tried the following:
private void moveTextFrames() {
XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier)
UnoRuntime.queryInterface(XTextFramesSupplier.class,
xWriterComponent_dest);
XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames();
XIndexAccess xIndexAccess = (XIndexAccess)
UnoRuntime.queryInterface(
XIndexAccess.class, xNamedFrames);
XTextContent xFrameContent[] = new
XTextContent[xIndexAccess.getCount()];
XPropertySet xShapeProps[] = new
XPropertySet[xIndexAccess.getCount()];
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();
xFrameContent[i] = (XTextContent)textFrame;
xShapeProps[i] = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, textFrame);
xShapeProps[i].setPropertyValue("AnchorType",
TextContentAnchorType.AT_PAGE);
// Setting the vertical and horizontal position
long 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[i].setPropertyValue("VertOrientPosition",
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);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
Which doesn't seem to work either, see attached.
Is there a problem specifying a "long" for the vertical position, rather
than an "Integer", ie., the value when you get to page 3 or 4 is over 32768
pixels high.
Any thoughts, do I have to move the view cursor or something or somehow to
get the anchor on to the next page.. I notice when I try it manually, i need
to "cut" the text frame, move to the next page and paste the frame, I then
notice that the anchor is moved to the right page..
At present, it seems all of the textframes remain on page1 in top/left
corner.
I can happily move the textframes using the above technique around the first
page, but not on to the next page....
Your help is greatly appreciated.
Chris
Fernand Vanrie wrote:
>
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/I-have-five-text-frames-on-the-one-page%2C-can-I-move-each-frame-to-a-new-page--tp24146586p24162161.html
Sent from the openoffice - api dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]