I have five text frames on the one page, can I move each frame to a new page?

View: New views
13 Messages — Rating Filter:   Alert me  

I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
               

Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

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
               

Re: I have five text frames on the one page, can I move each frame to a new page?

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...


Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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[i].setPropertyValue("VertOrientPosition", height);

                // 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.

test.odt

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: dev-unsubscribe@api.openoffice.org
For additional commands, e-mail: dev-help@api.openoffice.org

Re: I have five text frames on the one page, can I move each frame to a new page?

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris ,

Long is needed because integer is to small and there are different
properties who has to been set properly.

 Please find the basic code i uses to place Frames without any problem

 iPagenr = oViewCursor.page
    iHCpos = oViewCursor.getPosition().X
    iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
Vieuwcursor rekend steeds van begin van document
 
     oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
    oFrame.AnchorType = lAnchor
    oFrame.PositionProtected = False
    oFrame.SizeProtected = false
    oFrame.ContentProtected = false
     oFrame.HoriOrient = NONE
     oFrame.VertOrient = NONE
     oFrame.VertOrientRelation = PAGE_PRINT_AREA  
     oFrame.HoriOrientRelation = PAGE_PRINT_AREA

     oText.insertTextContent(oCursor(), oFrame, false)

hope i  helps

Fernand

> 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: dev-unsubscribe@...
>> For additional commands, e-mail: dev-help@...
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the tips... my method is now;

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();

        XController xController_targetDoc = xTextDocument_dest.getCurrentController();

        // the cursor for the source document
        XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
                (XTextViewCursorSupplier)
                UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                xController_targetDoc);

        //selecting the whole source document
        XTextViewCursor xTextViewCursor_sourceDoc =
                xViewCursorSupplier_targetDoc.getViewCursor();

        /*
        XPageCursor xPageCursor =
                (XPageCursor) UnoRuntime.queryInterface(
                XPageCursor.class,
                xTextViewCursor_sourceDoc);
        */

        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);

                // Setting the vertical and horizontal position
                long height = (i * page_size.Height) + 1000;

                System.out.println("height: " + height);

                // Setting the vertical and horizontal position

                xShapeProps[i].setPropertyValue("AnchorPageNo", new Short((short)(i + 1)));
               
                xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);

                xShapeProps[i].setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
                xShapeProps[i].setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
                xShapeProps[i].setPropertyValue("VertOrientPosition", new Long(height));
                xShapeProps[i].setPropertyValue("HoriOrientPosition", new Integer(1000));

                xShapeProps[i].setPropertyValue("HoriOrientRelation", (short)50);
                xShapeProps[i].setPropertyValue("VertOrientRelation", (short)50);

                // Set the width and height of the shape.
                xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width));
                xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height));

                xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
                xShapeProps[i].setPropertyValue("SizeType", new Short((short)1));

                xShapeProps[i].setPropertyValue("LeftBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("RightBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("TopBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("BottomBorderDistance", new Integer(200));

                // Insert a paragraph break into the document (not the frame)
                xText.insertControlCharacter(xTextViewCursor_sourceDoc, ControlCharacter.PARAGRAPH_BREAK, false);

                XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextViewCursor_sourceDoc);

                xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER);

                xText.insertControlCharacter(xTextViewCursor_sourceDoc, ControlCharacter.PARAGRAPH_BREAK, false);
                // xTextCursor.collapseToEnd();
               
            } catch (Exception e) {
                System.out.println(e.getMessage());
               
                e.printStackTrace();
            }
        }
    }



With your code, are you coming from the "bottom" of your document and working your way up?

I also don't believe I need;

PositionProtected = False
SizeProtected = false
ContentProtected = false

But still it doesn't work... :(

See attachment, text.odt

I als notice that there seems to be issues with the longs, ints, shorts etc... as also captured here: http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089

Any other thoughts?

Thanks in advance

Fernand Vanrie wrote:
Chris ,

Long is needed because integer is to small and there are different
properties who has to been set properly.

 Please find the basic code i uses to place Frames without any problem

 iPagenr = oViewCursor.page
    iHCpos = oViewCursor.getPosition().X
    iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
Vieuwcursor rekend steeds van begin van document
 
     oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
    oFrame.AnchorType = lAnchor
    oFrame.PositionProtected = False
    oFrame.SizeProtected = false
    oFrame.ContentProtected = false
     oFrame.HoriOrient = NONE
     oFrame.VertOrient = NONE
     oFrame.VertOrientRelation = PAGE_PRINT_AREA  
     oFrame.HoriOrientRelation = PAGE_PRINT_AREA

     oText.insertTextContent(oCursor(), oFrame, false)

hope i  helps

Fernand
> 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: dev-unsubscribe@api.openoffice.org
>> For additional commands, e-mail: dev-help@api.openoffice.org
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
For additional commands, e-mail: dev-help@api.openoffice.org

Re: I have five text frames on the one page, can I move each frame to a new page?

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris ,

Before you start placing Frames, you must been sure you have already
created the right number of pages.

anyhow: i placed some code in your documents  "standard basic libray
module1"
this code placed a 1000x1000 frame at the cusor position,you moves your
cursor to the right position, or you  gives  fixed coordinates to
replace the cursor position and translates to java :-)
Fernand

> Thanks for the tips... my method is now;
>
> 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();
>
>         XController xController_targetDoc =
> xTextDocument_dest.getCurrentController();
>
>         // the cursor for the source document
>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>                 (XTextViewCursorSupplier)
>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>                 xController_targetDoc);
>
>         //selecting the whole source document
>         XTextViewCursor xTextViewCursor_sourceDoc =
>                 xViewCursorSupplier_targetDoc.getViewCursor();
>
>         /*
>         XPageCursor xPageCursor =
>                 (XPageCursor) UnoRuntime.queryInterface(
>                 XPageCursor.class,
>                 xTextViewCursor_sourceDoc);
>         */
>
>         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);
>
>                 // Setting the vertical and horizontal position
>                 long height = (i * page_size.Height) + 1000;
>
>                 System.out.println("height: " + height);
>
>                 // Setting the vertical and horizontal position
>
>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
> Short((short)(i + 1)));
>                
>                 xShapeProps[i].setPropertyValue("AnchorType",
> TextContentAnchorType.AT_PAGE);
>
>                 xShapeProps[i].setPropertyValue("VertOrient", new
> Short(VertOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("HoriOrient", new
> Short(HoriOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("VertOrientPosition", new
> Long(height));
>                 xShapeProps[i].setPropertyValue("HoriOrientPosition", new
> Integer(1000));
>
>                 xShapeProps[i].setPropertyValue("HoriOrientRelation",
> (short)50);
>                 xShapeProps[i].setPropertyValue("VertOrientRelation",
> (short)50);
>
>                 // Set the width and height of the shape.
>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new
> Integer(frame_size.Width));
>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new
> Integer(frame_size.Height));
>
>                 xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
> new Boolean(false));
>                 xShapeProps[i].setPropertyValue("SizeType", new
> Short((short)1));
>
>                 xShapeProps[i].setPropertyValue("LeftBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("RightBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("BottomBorderDistance", new
> Integer(200));
>
>                 // Insert a paragraph break into the document (not the
> frame)
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>
>                 XPropertySet xCursorProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
> xTextViewCursor_sourceDoc);
>
>                 xCursorProps.setPropertyValue("BreakType",
> com.sun.star.style.BreakType.PAGE_AFTER);
>
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>                 // xTextCursor.collapseToEnd();
>                
>             } catch (Exception e) {
>                 System.out.println(e.getMessage());
>                
>                 e.printStackTrace();
>             }
>         }
>     }
>
>
> With your code, are you coming from the "bottom" of your document and
> working your way up?
>
> I also don't believe I need;
>
> PositionProtected = False
> SizeProtected = false
> ContentProtected = false
>
> But still it doesn't work... :(
>
> See attachment,  http://www.nabble.com/file/p24164747/text.odt text.odt
>
> I als notice that there seems to be issues with the longs, ints, shorts
> etc... as also captured here:
> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089
>
> Any other thoughts?
>
> Thanks in advance
>
>
> Fernand Vanrie wrote:
>  
>> Chris ,
>>
>> Long is needed because integer is to small and there are different
>> properties who has to been set properly.
>>
>>  Please find the basic code i uses to place Frames without any problem
>>
>>  iPagenr = oViewCursor.page
>>     iHCpos = oViewCursor.getPosition().X
>>     iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
>> Vieuwcursor rekend steeds van begin van document
>>  
>>      oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
>>     oFrame.AnchorType = lAnchor
>>     oFrame.PositionProtected = False
>>     oFrame.SizeProtected = false
>>     oFrame.ContentProtected = false
>>      oFrame.HoriOrient = NONE
>>      oFrame.VertOrient = NONE
>>      oFrame.VertOrientRelation = PAGE_PRINT_AREA  
>>      oFrame.HoriOrientRelation = PAGE_PRINT_AREA
>>
>>      oText.insertTextContent(oCursor(), oFrame, false)
>>
>> hope i  helps
>>
>> Fernand
>>    
>>> 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: dev-unsubscribe@...
>>>> For additional commands, e-mail: dev-help@...
>>>>
>>>>
>>>>
>>>>    
>>>>        
>>>  
>>>      
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@...
>> For additional commands, e-mail: dev-help@...
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm sorry but your last comment lost me...

Here is my Java method to create the necessary pages and to move the textframes (well trying to):

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();

        XController xController_targetDoc = xTextDocument_dest.getCurrentController();

        // the cursor for the source document
        XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
                (XTextViewCursorSupplier)
                UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                xController_targetDoc);

        //selecting the whole source document
        XTextViewCursor xTextViewCursor_targetDoc =
                xViewCursorSupplier_targetDoc.getViewCursor();

        XPageCursor xPageCursor =
                (XPageCursor) UnoRuntime.queryInterface(
                XPageCursor.class,
                xTextViewCursor_targetDoc);

        xPageCursor.jumpToFirstPage();
        xPageCursor.jumpToEndOfPage();

        for (int i = 0; i < xIndexAccess.getCount(); i++) {
            try {
                xPageCursor.jumpToLastPage();
                xPageCursor.jumpToEndOfPage();

                // Insert a paragraph break into the document (not the frame)
                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);

                XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextViewCursor_targetDoc);

                xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER);

                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);
            } catch (Exception e) {
                System.out.println(e.getMessage());

                e.printStackTrace();
            }
        }

        xPageCursor.jumpToFirstPage();
       
        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);

                int height = xTextViewCursor_targetDoc.getPosition().Y;

                xShapeProps[i].setPropertyValue("AnchorPageNo", new Short((short)(i + 1)));

                System.out.println("AnchorPageNo: " + xShapeProps[i].getPropertyValue("AnchorPageNo"));

                xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);

                System.out.println("AnchorType: " + xShapeProps[i].getPropertyValue("AnchorType"));

                xShapeProps[i].setPropertyValue("VertOrient", new Short(VertOrientation.NONE));

                System.out.println("VertOrient: " + xShapeProps[i].getPropertyValue("VertOrient"));

                xShapeProps[i].setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));

                System.out.println("HoriOrient: " + xShapeProps[i].getPropertyValue("HoriOrient"));
               
                xShapeProps[i].setPropertyValue("VertOrientPosition", new Integer(height));

                System.out.println("VertOrientPosition: " + xShapeProps[i].getPropertyValue("VertOrientPosition"));

                xShapeProps[i].setPropertyValue("HoriOrientPosition", new Integer(1000));

                System.out.println("HoriOrientPosition: " + xShapeProps[i].getPropertyValue("HoriOrientPosition"));

                xShapeProps[i].setPropertyValue("HoriOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA));

                System.out.println("HoriOrientRelation: " + xShapeProps[i].getPropertyValue("HoriOrientRelation"));

                xShapeProps[i].setPropertyValue("VertOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA));

                System.out.println("VertOrientRelation: " + xShapeProps[i].getPropertyValue("VertOrientRelation"));

                // Set the width and height of the shape.
                xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width));
                xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height));

                xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
                xShapeProps[i].setPropertyValue("SizeType", new Short((short)1));

                xShapeProps[i].setPropertyValue("LeftBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("RightBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("TopBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("BottomBorderDistance", new Integer(200));

                xPageCursor.jumpToNextPage();
               
            } catch (Exception e) {
                System.out.println(e.getMessage());
               
                e.printStackTrace();
            }
        }
    }


The pages are created without any issues... The output as per my println statements shows correct page and heights assuming the first page top, left is 0/0.

Basically, what I can do is move the text frame without any issues using the VertOrientPosition and HoriOrientPosition as long as the boundaries for the textframe don't go out of the first page... Meaning I can get the textframes to move around on page 1 no problem... but trying to anchor them on to subsequent pages at the same x/y coordinate on the page isn't working.

Again, see attached odt. test.odt

Fernand Vanrie wrote:
Chris ,

Before you start placing Frames, you must been sure you have already
created the right number of pages.

anyhow: i placed some code in your documents  "standard basic libray
module1"
this code placed a 1000x1000 frame at the cusor position,you moves your
cursor to the right position, or you  gives  fixed coordinates to
replace the cursor position and translates to java :-)
Fernand

> Thanks for the tips... my method is now;
>
> 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();
>
>         XController xController_targetDoc =
> xTextDocument_dest.getCurrentController();
>
>         // the cursor for the source document
>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>                 (XTextViewCursorSupplier)
>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>                 xController_targetDoc);
>
>         //selecting the whole source document
>         XTextViewCursor xTextViewCursor_sourceDoc =
>                 xViewCursorSupplier_targetDoc.getViewCursor();
>
>         /*
>         XPageCursor xPageCursor =
>                 (XPageCursor) UnoRuntime.queryInterface(
>                 XPageCursor.class,
>                 xTextViewCursor_sourceDoc);
>         */
>
>         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);
>
>                 // Setting the vertical and horizontal position
>                 long height = (i * page_size.Height) + 1000;
>
>                 System.out.println("height: " + height);
>
>                 // Setting the vertical and horizontal position
>
>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
> Short((short)(i + 1)));
>                
>                 xShapeProps[i].setPropertyValue("AnchorType",
> TextContentAnchorType.AT_PAGE);
>
>                 xShapeProps[i].setPropertyValue("VertOrient", new
> Short(VertOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("HoriOrient", new
> Short(HoriOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("VertOrientPosition", new
> Long(height));
>                 xShapeProps[i].setPropertyValue("HoriOrientPosition", new
> Integer(1000));
>
>                 xShapeProps[i].setPropertyValue("HoriOrientRelation",
> (short)50);
>                 xShapeProps[i].setPropertyValue("VertOrientRelation",
> (short)50);
>
>                 // Set the width and height of the shape.
>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new
> Integer(frame_size.Width));
>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new
> Integer(frame_size.Height));
>
>                 xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
> new Boolean(false));
>                 xShapeProps[i].setPropertyValue("SizeType", new
> Short((short)1));
>
>                 xShapeProps[i].setPropertyValue("LeftBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("RightBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("BottomBorderDistance", new
> Integer(200));
>
>                 // Insert a paragraph break into the document (not the
> frame)
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>
>                 XPropertySet xCursorProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
> xTextViewCursor_sourceDoc);
>
>                 xCursorProps.setPropertyValue("BreakType",
> com.sun.star.style.BreakType.PAGE_AFTER);
>
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>                 // xTextCursor.collapseToEnd();
>                
>             } catch (Exception e) {
>                 System.out.println(e.getMessage());
>                
>                 e.printStackTrace();
>             }
>         }
>     }
>
>
> With your code, are you coming from the "bottom" of your document and
> working your way up?
>
> I also don't believe I need;
>
> PositionProtected = False
> SizeProtected = false
> ContentProtected = false
>
> But still it doesn't work... :(
>
> See attachment,  http://www.nabble.com/file/p24164747/text.odt text.odt
>
> I als notice that there seems to be issues with the longs, ints, shorts
> etc... as also captured here:
> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089
>
> Any other thoughts?
>
> Thanks in advance
>
>
> Fernand Vanrie wrote:
>  
>> Chris ,
>>
>> Long is needed because integer is to small and there are different
>> properties who has to been set properly.
>>
>>  Please find the basic code i uses to place Frames without any problem
>>
>>  iPagenr = oViewCursor.page
>>     iHCpos = oViewCursor.getPosition().X
>>     iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
>> Vieuwcursor rekend steeds van begin van document
>>  
>>      oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
>>     oFrame.AnchorType = lAnchor
>>     oFrame.PositionProtected = False
>>     oFrame.SizeProtected = false
>>     oFrame.ContentProtected = false
>>      oFrame.HoriOrient = NONE
>>      oFrame.VertOrient = NONE
>>      oFrame.VertOrientRelation = PAGE_PRINT_AREA  
>>      oFrame.HoriOrientRelation = PAGE_PRINT_AREA
>>
>>      oText.insertTextContent(oCursor(), oFrame, false)
>>
>> hope i  helps
>>
>> Fernand
>>    
>>> 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: dev-unsubscribe@api.openoffice.org
>>>> For additional commands, e-mail: dev-help@api.openoffice.org
>>>>
>>>>
>>>>
>>>>    
>>>>        
>>>  
>>>      
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
>> For additional commands, e-mail: dev-help@api.openoffice.org
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
For additional commands, e-mail: dev-help@api.openoffice.org

Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is the output I capture from the println statements:

height: 0
AnchorPageNo: 1
AnchorType: com.sun.star.text.TextContentAnchorType@39060b
VertOrient: 0
HoriOrient: 0
VertOrientPosition: 0
HoriOrientPosition: 1000
HoriOrientRelation: 8
VertOrientRelation: 8
height: 21500
AnchorPageNo: 2
AnchorType: com.sun.star.text.TextContentAnchorType@39060b
VertOrient: 0
HoriOrient: 0
VertOrientPosition: 21500
HoriOrientPosition: 1000
HoriOrientRelation: 8
VertOrientRelation: 8
 
height: 43000
AnchorPageNo: 3
AnchorType: com.sun.star.text.TextContentAnchorType@39060b
VertOrient: 0
HoriOrient: 0
VertOrientPosition: 43000
HoriOrientPosition: 1000
HoriOrientRelation: 8
VertOrientRelation: 8




I'm sorry but your last comment lost me...

Here is my Java method to create the necessary pages and to move the textframes (well trying to):

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();

        XController xController_targetDoc = xTextDocument_dest.getCurrentController();

        // the cursor for the source document
        XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
                (XTextViewCursorSupplier)
                UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                xController_targetDoc);

        //selecting the whole source document
        XTextViewCursor xTextViewCursor_targetDoc =
                xViewCursorSupplier_targetDoc.getViewCursor();

        XPageCursor xPageCursor =
                (XPageCursor) UnoRuntime.queryInterface(
                XPageCursor.class,
                xTextViewCursor_targetDoc);

        xPageCursor.jumpToFirstPage();
        xPageCursor.jumpToEndOfPage();

        for (int i = 0; i < xIndexAccess.getCount(); i++) {
            try {
                xPageCursor.jumpToLastPage();
                xPageCursor.jumpToEndOfPage();

                // Insert a paragraph break into the document (not the frame)
                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);

                XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextViewCursor_targetDoc);

                xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER);

                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);
            } catch (Exception e) {
                System.out.println(e.getMessage());

                e.printStackTrace();
            }
        }

        xPageCursor.jumpToFirstPage();
       
        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);

                int height = xTextViewCursor_targetDoc.getPosition().Y;

                xShapeProps[i].setPropertyValue("AnchorPageNo", new Short((short)(i + 1)));

                System.out.println("AnchorPageNo: " + xShapeProps[i].getPropertyValue("AnchorPageNo"));

                xShapeProps[i].setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);

                System.out.println("AnchorType: " + xShapeProps[i].getPropertyValue("AnchorType"));

                xShapeProps[i].setPropertyValue("VertOrient", new Short(VertOrientation.NONE));

                System.out.println("VertOrient: " + xShapeProps[i].getPropertyValue("VertOrient"));

                xShapeProps[i].setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));

                System.out.println("HoriOrient: " + xShapeProps[i].getPropertyValue("HoriOrient"));
               
                xShapeProps[i].setPropertyValue("VertOrientPosition", new Integer(height));

                System.out.println("VertOrientPosition: " + xShapeProps[i].getPropertyValue("VertOrientPosition"));

                xShapeProps[i].setPropertyValue("HoriOrientPosition", new Integer(1000));

                System.out.println("HoriOrientPosition: " + xShapeProps[i].getPropertyValue("HoriOrientPosition"));

                xShapeProps[i].setPropertyValue("HoriOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA));

                System.out.println("HoriOrientRelation: " + xShapeProps[i].getPropertyValue("HoriOrientRelation"));

                xShapeProps[i].setPropertyValue("VertOrientRelation", new Short(RelOrientation.PAGE_PRINT_AREA));

                System.out.println("VertOrientRelation: " + xShapeProps[i].getPropertyValue("VertOrientRelation"));

                // Set the width and height of the shape.
                xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new Integer(frame_size.Width));
                xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new Integer(frame_size.Height));

                xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
                xShapeProps[i].setPropertyValue("SizeType", new Short((short)1));

                xShapeProps[i].setPropertyValue("LeftBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("RightBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("TopBorderDistance", new Integer(200));
                xShapeProps[i].setPropertyValue("BottomBorderDistance", new Integer(200));

                xPageCursor.jumpToNextPage();
               
            } catch (Exception e) {
                System.out.println(e.getMessage());
               
                e.printStackTrace();
            }
        }
    }


The pages are created without any issues... The output as per my println statements shows correct page and heights assuming the first page top, left is 0/0.

Basically, what I can do is move the text frame without any issues using the VertOrientPosition and HoriOrientPosition as long as the boundaries for the textframe don't go out of the first page... Meaning I can get the textframes to move around on page 1 no problem... but trying to anchor them on to subsequent pages at the same x/y coordinate on the page isn't working.

Again, see attached odt. test.odt

Fernand Vanrie wrote:
Chris ,

Before you start placing Frames, you must been sure you have already
created the right number of pages.

anyhow: i placed some code in your documents  "standard basic libray
module1"
this code placed a 1000x1000 frame at the cusor position,you moves your
cursor to the right position, or you  gives  fixed coordinates to
replace the cursor position and translates to java :-)
Fernand

> Thanks for the tips... my method is now;
>
> 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();
>
>         XController xController_targetDoc =
> xTextDocument_dest.getCurrentController();
>
>         // the cursor for the source document
>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>                 (XTextViewCursorSupplier)
>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>                 xController_targetDoc);
>
>         //selecting the whole source document
>         XTextViewCursor xTextViewCursor_sourceDoc =
>                 xViewCursorSupplier_targetDoc.getViewCursor();
>
>         /*
>         XPageCursor xPageCursor =
>                 (XPageCursor) UnoRuntime.queryInterface(
>                 XPageCursor.class,
>                 xTextViewCursor_sourceDoc);
>         */
>
>         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);
>
>                 // Setting the vertical and horizontal position
>                 long height = (i * page_size.Height) + 1000;
>
>                 System.out.println("height: " + height);
>
>                 // Setting the vertical and horizontal position
>
>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
> Short((short)(i + 1)));
>                
>                 xShapeProps[i].setPropertyValue("AnchorType",
> TextContentAnchorType.AT_PAGE);
>
>                 xShapeProps[i].setPropertyValue("VertOrient", new
> Short(VertOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("HoriOrient", new
> Short(HoriOrientation.NONE));
>                 xShapeProps[i].setPropertyValue("VertOrientPosition", new
> Long(height));
>                 xShapeProps[i].setPropertyValue("HoriOrientPosition", new
> Integer(1000));
>
>                 xShapeProps[i].setPropertyValue("HoriOrientRelation",
> (short)50);
>                 xShapeProps[i].setPropertyValue("VertOrientRelation",
> (short)50);
>
>                 // Set the width and height of the shape.
>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new
> Integer(frame_size.Width));
>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new
> Integer(frame_size.Height));
>
>                 xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
> new Boolean(false));
>                 xShapeProps[i].setPropertyValue("SizeType", new
> Short((short)1));
>
>                 xShapeProps[i].setPropertyValue("LeftBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("RightBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
> Integer(200));
>                 xShapeProps[i].setPropertyValue("BottomBorderDistance", new
> Integer(200));
>
>                 // Insert a paragraph break into the document (not the
> frame)
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>
>                 XPropertySet xCursorProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
> xTextViewCursor_sourceDoc);
>
>                 xCursorProps.setPropertyValue("BreakType",
> com.sun.star.style.BreakType.PAGE_AFTER);
>
>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
> ControlCharacter.PARAGRAPH_BREAK, false);
>                 // xTextCursor.collapseToEnd();
>                
>             } catch (Exception e) {
>                 System.out.println(e.getMessage());
>                
>                 e.printStackTrace();
>             }
>         }
>     }
>
>
> With your code, are you coming from the "bottom" of your document and
> working your way up?
>
> I also don't believe I need;
>
> PositionProtected = False
> SizeProtected = false
> ContentProtected = false
>
> But still it doesn't work... :(
>
> See attachment,  http://www.nabble.com/file/p24164747/text.odt text.odt
>
> I als notice that there seems to be issues with the longs, ints, shorts
> etc... as also captured here:
> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089
>
> Any other thoughts?
>
> Thanks in advance
>
>
> Fernand Vanrie wrote:
>  
>> Chris ,
>>
>> Long is needed because integer is to small and there are different
>> properties who has to been set properly.
>>
>>  Please find the basic code i uses to place Frames without any problem
>>
>>  iPagenr = oViewCursor.page
>>     iHCpos = oViewCursor.getPosition().X
>>     iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
>> Vieuwcursor rekend steeds van begin van document
>>  
>>      oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
>>     oFrame.AnchorType = lAnchor
>>     oFrame.PositionProtected = False
>>     oFrame.SizeProtected = false
>>     oFrame.ContentProtected = false
>>      oFrame.HoriOrient = NONE
>>      oFrame.VertOrient = NONE
>>      oFrame.VertOrientRelation = PAGE_PRINT_AREA  
>>      oFrame.HoriOrientRelation = PAGE_PRINT_AREA
>>
>>      oText.insertTextContent(oCursor(), oFrame, false)
>>
>> hope i  helps
>>
>> Fernand
>>    
>>> 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: dev-unsubscribe@api.openoffice.org
>>>> For additional commands, e-mail: dev-help@api.openoffice.org
>>>>
>>>>
>>>>
>>>>    
>>>>        
>>>  
>>>      
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
>> For additional commands, e-mail: dev-help@api.openoffice.org
>>
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
For additional commands, e-mail: dev-help@api.openoffice.org


Re: I have five text frames on the one page, can I move each frame to a new page?

by Ariel Constenla-Haile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Chris,

On Monday 22 June 2009, 09:46, Chris Fleischmann wrote:
> Hello folks, I have TextFrames, that are created like so (at the beginning
> of the process):
...
> 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:
...
> 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?

you can "move" each text frame to a new page by inserting a page break at the
frame's anchor (IIRC the frame will have an anchor as long as it is not
anchored at the page).
See the Java code attached.

Regards
--
Ariel Constenla-Haile
La Plata, Argentina

[TextFramePageBreak.java]

/*
 * TextFramePageBreak.java
 *
 */
package org.openoffice.sdk;

import com.sun.star.awt.Size;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.uno.XComponentContext;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.drawing.XShape;
import com.sun.star.frame.FrameSearchFlag;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.style.BreakType;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.SizeType;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.text.XText;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.text.XTextRange;
import com.sun.star.uno.UnoRuntime;

/**
 *
 * @author ariel
 */
public class TextFramePageBreak {

    private static final int FRAMES_COUNT = 5;
    XComponentContext m_xContext;

    /** Creates a new instance of TextFramePageBreak */
    public TextFramePageBreak(XComponentContext xContext) {
        m_xContext = xContext;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int nRet = 0;
        try {
            // get the remote office component context
            XComponentContext xContext = Bootstrap.bootstrap();
            if (xContext == null) {
                System.err.println("ERROR: Could not bootstrap default Office.");
                nRet = -1;
            }

            TextFramePageBreak demo = new TextFramePageBreak(xContext);
            demo.firstInsertThenAccess();

        } catch (java.lang.Exception e) {
            e.printStackTrace();
        } finally {
            System.exit(nRet);
        }
    }

    protected void firstInsertThenAccess(){
        try {
            XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(
                    XTextDocument.class, newDocComponent(m_xContext, "swriter"));

            // this simulates a situation where we want to access already inserted
            // objects in order to set a page break after them
            insertTextFrames(xTextDocument);
            accessTextFrames(xTextDocument);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
   
    private void insertTextFrames(XTextDocument xTextDocument){
        try {
            XMultiServiceFactory xDocFactory =
                    (XMultiServiceFactory) UnoRuntime.queryInterface(
                    XMultiServiceFactory.class, xTextDocument);

            XText xText = xTextDocument.getText();
            XTextCursor xTextCursor = xText.createTextCursorByRange(xText.getStart());
           
            // first insert the text frames
            for (int i = 0; i < FRAMES_COUNT; i++) {
                insertTextFrame(xDocFactory, xTextCursor);
                insertParaBreak(xTextCursor);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
   
    private void accessTextFrames(XTextDocument xTextDocument){        
        try {
            // access them and insert a page break
            XTextFramesSupplier xTextFramesSupplier = (XTextFramesSupplier)
                    UnoRuntime.queryInterface(XTextFramesSupplier.class, xTextDocument);

            XNameAccess xNamedTextFrames = xTextFramesSupplier.getTextFrames();
            XIndexAccess xIndexedTextFrames = (XIndexAccess) UnoRuntime.queryInterface(
                    XIndexAccess.class, xNamedTextFrames);

            for (int i = 0; i < xIndexedTextFrames.getCount(); i++) {
                XTextFrame xTextFrame = (XTextFrame) UnoRuntime.queryInterface(
                        XTextFrame.class, xIndexedTextFrames.getByIndex(i));
                XTextRange xAnchor = xTextFrame.getAnchor();
                // IIRC when anchored at the page, there is no anchor (sic.)
                // (and of course, the text content CAN NOT be a text table)
                if ( xAnchor != null ){
                    try {
                        XPropertySet xAnchorProps = (XPropertySet) UnoRuntime.queryInterface(
                                XPropertySet.class, xAnchor);
                        xAnchorProps.setPropertyValue("PageDescName", "Default");

                        // this also works, but results in an extra page
                        //xAnchorProps.setPropertyValue("BreakType", BreakType.PAGE_AFTER);
                    } catch (Exception e) {
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //=========================================================================
    //=========================================================================

    private void insertText(XTextRange xTextRange, String sStr) {
        xTextRange.getText().insertString(xTextRange, sStr, false);
    }

    private void insertParaBreak(XTextRange xTextRange) {
        try {
            xTextRange.getText().insertControlCharacter(
                    xTextRange, ControlCharacter.PARAGRAPH_BREAK, false);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void insertTextContent(XTextRange xTextRange, XTextContent xContent) {
        try {
            xTextRange.getText().insertTextContent(xTextRange, xContent, false);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void insertTextFrame(XMultiServiceFactory xDocFactory, XTextRange xTextRange) {

        try {
            XTextFrame xTextFrame = createTextFrame(xDocFactory,
                    12000, 4000, TextContentAnchorType.AT_PARAGRAPH, SizeType.MIN);
            insertTextContent(xTextRange, xTextFrame);

            XText xFrameText = xTextFrame.getText();
            insertText(xFrameText.getEnd(), "Some text inside the frame.");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private XTextFrame createTextFrame(
            XMultiServiceFactory xDocFactory,
            int nWidth, int nHeight, TextContentAnchorType aAnchorType, short nSizeType){
        XTextFrame xTextFrame = null;
        try {
            xTextFrame = (XTextFrame) UnoRuntime.queryInterface(
                    XTextFrame.class, xDocFactory.createInstance(
                        "com.sun.star.text.TextFrame"));

            XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame);
            xShape.setSize(new Size(nWidth, nHeight));

            XPropertySet xFrameProps = (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class, xTextFrame);
            xFrameProps.setPropertyValue("AnchorType", aAnchorType);
            xFrameProps.setPropertyValue("SizeType", new Short(nSizeType));
           
        } catch (Exception ex){
            ex.printStackTrace();
        } finally {
            return xTextFrame;
        }
    }

    private XComponent newDocComponent(XComponentContext xContext, String sDocType){
        XComponent xComponent = null;
        try {
            XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(
                    XComponentLoader.class,
                    xContext.getServiceManager().createInstanceWithContext(
                    "com.sun.star.frame.Desktop", xContext));
            xComponent = xComponentLoader.loadComponentFromURL(
                    "private:factory/" + sDocType,
                    "_blank", FrameSearchFlag.ALL, new PropertyValue[0]);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return xComponent;
        }
    }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

Re: I have five text frames on the one page, can I move each frame to a new page?

by Fernand Vanrie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris Fleischmann wrote:
> Here is the output I capture from the println statements:
>
> height: 0
>  
= invisible frame

> AnchorPageNo: 1
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
> HoriOrient: 0
> VertOrientPosition: 0
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
> VertOrientRelation: 8
> height: 21500
> AnchorPageNo: 2
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
>  
supposed to be "NONE" ?
> HoriOrient: 0
> VertOrientPosition: 21500
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
>  
supposed to be "PAGE_PRINT_AREA"
> VertOrientRelation: 8
>  
> height: 43000
>  
= frame with height off 43 cm , can not been placed

> AnchorPageNo: 3
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
> HoriOrient: 0
> VertOrientPosition: 43000
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
> VertOrientRelation: 8
>
>
>
> Chris Fleischmann wrote:
>  
>> I'm sorry but your last comment lost me...
>>
>> Here is my Java method to create the necessary pages and to move the
>> textframes (well trying to):
>>
>> 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();
>>
>>         XController xController_targetDoc =
>> xTextDocument_dest.getCurrentController();
>>
>>         // the cursor for the source document
>>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>>                 (XTextViewCursorSupplier)
>>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>>                 xController_targetDoc);
>>
>>         //selecting the whole source document
>>         XTextViewCursor xTextViewCursor_targetDoc =
>>                 xViewCursorSupplier_targetDoc.getViewCursor();
>>
>>         XPageCursor xPageCursor =
>>                 (XPageCursor) UnoRuntime.queryInterface(
>>                 XPageCursor.class,
>>                 xTextViewCursor_targetDoc);
>>
>>         xPageCursor.jumpToFirstPage();
>>         xPageCursor.jumpToEndOfPage();
>>
>>         for (int i = 0; i < xIndexAccess.getCount(); i++) {
>>             try {
>>                 xPageCursor.jumpToLastPage();
>>                 xPageCursor.jumpToEndOfPage();
>>
>>                 // Insert a paragraph break into the document (not the
>> frame)
>>                 xText.insertControlCharacter(xTextViewCursor_targetDoc,
>> ControlCharacter.PARAGRAPH_BREAK, false);
>>
>>                 XPropertySet xCursorProps =
>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
>> xTextViewCursor_targetDoc);
>>
>>                 xCursorProps.setPropertyValue("BreakType",
>> com.sun.star.style.BreakType.PAGE_AFTER);
>>
>>                 xText.insertControlCharacter(xTextViewCursor_targetDoc,
>> ControlCharacter.PARAGRAPH_BREAK, false);
>>             } catch (Exception e) {
>>                 System.out.println(e.getMessage());
>>
>>                 e.printStackTrace();
>>             }
>>         }
>>
>>         xPageCursor.jumpToFirstPage();
>>        
>>         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);
>>
>>                 int height = xTextViewCursor_targetDoc.getPosition().Y;
>>
>>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
>> Short((short)(i + 1)));
>>
>>                 System.out.println("AnchorPageNo: " +
>> xShapeProps[i].getPropertyValue("AnchorPageNo"));
>>
>>                 xShapeProps[i].setPropertyValue("AnchorType",
>> TextContentAnchorType.AT_PAGE);
>>
>>                 System.out.println("AnchorType: " +
>> xShapeProps[i].getPropertyValue("AnchorType"));
>>
>>                 xShapeProps[i].setPropertyValue("VertOrient", new
>> Short(VertOrientation.NONE));
>>
>>                 System.out.println("VertOrient: " +
>> xShapeProps[i].getPropertyValue("VertOrient"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrient", new
>> Short(HoriOrientation.NONE));
>>
>>                 System.out.println("HoriOrient: " +
>> xShapeProps[i].getPropertyValue("HoriOrient"));
>>                
>>                 xShapeProps[i].setPropertyValue("VertOrientPosition", new
>> Integer(height));
>>
>>                 System.out.println("VertOrientPosition: " +
>> xShapeProps[i].getPropertyValue("VertOrientPosition"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrientPosition", new
>> Integer(1000));
>>
>>                 System.out.println("HoriOrientPosition: " +
>> xShapeProps[i].getPropertyValue("HoriOrientPosition"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrientRelation", new
>> Short(RelOrientation.PAGE_PRINT_AREA));
>>
>>                 System.out.println("HoriOrientRelation: " +
>> xShapeProps[i].getPropertyValue("HoriOrientRelation"));
>>
>>                 xShapeProps[i].setPropertyValue("VertOrientRelation", new
>> Short(RelOrientation.PAGE_PRINT_AREA));
>>
>>                 System.out.println("VertOrientRelation: " +
>> xShapeProps[i].getPropertyValue("VertOrientRelation"));
>>
>>                 // Set the width and height of the shape.
>>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new
>> Integer(frame_size.Width));
>>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new
>> Integer(frame_size.Height));
>>
>>                 xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
>> new Boolean(false));
>>                 xShapeProps[i].setPropertyValue("SizeType", new
>> Short((short)1));
>>
>>                 xShapeProps[i].setPropertyValue("LeftBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("RightBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("BottomBorderDistance",
>> new Integer(200));
>>
>>                 xPageCursor.jumpToNextPage();
>>                
>>             } catch (Exception e) {
>>                 System.out.println(e.getMessage());
>>                
>>                 e.printStackTrace();
>>             }
>>         }
>>     }
>>
>> The pages are created without any issues... The output as per my println
>> statements shows correct page and heights assuming the first page top,
>> left is 0/0.
>>
>> Basically, what I can do is move the text frame without any issues using
>> the VertOrientPosition and HoriOrientPosition as long as the boundaries
>> for the textframe don't go out of the first page... Meaning I can get the
>> textframes to move around on page 1 no problem... but trying to anchor
>> them on to subsequent pages at the same x/y coordinate on the page isn't
>> working.
>>
>> Again, see attached odt.  http://www.nabble.com/file/p24177299/test.odt
>> test.odt
>>
>>
>> Fernand Vanrie wrote:
>>    
>>> Chris ,
>>>
>>> Before you start placing Frames, you must been sure you have already
>>> created the right number of pages.
>>>
>>> anyhow: i placed some code in your documents  "standard basic libray
>>> module1"
>>> this code placed a 1000x1000 frame at the cusor position,you moves your
>>> cursor to the right position, or you  gives  fixed coordinates to
>>> replace the cursor position and translates to java :-)
>>> Fernand
>>>
>>>      
>>>> Thanks for the tips... my method is now;
>>>>
>>>> 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();
>>>>
>>>>         XController xController_targetDoc =
>>>> xTextDocument_dest.getCurrentController();
>>>>
>>>>         // the cursor for the source document
>>>>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>>>>                 (XTextViewCursorSupplier)
>>>>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>>>>                 xController_targetDoc);
>>>>
>>>>         //selecting the whole source document
>>>>         XTextViewCursor xTextViewCursor_sourceDoc =
>>>>                 xViewCursorSupplier_targetDoc.getViewCursor();
>>>>
>>>>         /*
>>>>         XPageCursor xPageCursor =
>>>>                 (XPageCursor) UnoRuntime.queryInterface(
>>>>                 XPageCursor.class,
>>>>                 xTextViewCursor_sourceDoc);
>>>>         */
>>>>
>>>>         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);
>>>>
>>>>                 // Setting the vertical and horizontal position
>>>>                 long height = (i * page_size.Height) + 1000;
>>>>
>>>>                 System.out.println("height: " + height);
>>>>
>>>>                 // Setting the vertical and horizontal position
>>>>
>>>>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
>>>> Short((short)(i + 1)));
>>>>                
>>>>                 xShapeProps[i].setPropertyValue("AnchorType",
>>>> TextContentAnchorType.AT_PAGE);
>>>>
>>>>                 xShapeProps[i].setPropertyValue("VertOrient", new
>>>> Short(VertOrientation.NONE));
>>>>                 xShapeProps[i].setPropertyValue("HoriOrient", new
>>>> Short(HoriOrientation.NONE));
>>>>                 xShapeProps[i].setPropertyValue("VertOrientPosition",
>>>> new
>>>> Long(height));
>>>>                 xShapeProps[i].setPropertyValue("HoriOrientPosition",
>>>> new
>>>> Integer(1000));
>>>>
>>>>                 xShapeProps[i].setPropertyValue("HoriOrientRelation",
>>>> (short)50);
>>>>                 xShapeProps[i].setPropertyValue("VertOrientRelation",
>>>> (short)50);
>>>>
>>>>                 // Set the width and height of the shape.
>>>>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute",
>>>> new
>>>> Integer(frame_size.Width));
>>>>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute",
>>>> new
>>>> Integer(frame_size.Height));
>>>>
>>>>                
>>>> xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
>>>> new Boolean(false));
>>>>                 xShapeProps[i].setPropertyValue("SizeType", new
>>>> Short((short)1));
>>>>
>>>>                 xShapeProps[i].setPropertyValue("LeftBorderDistance",
>>>> new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("RightBorderDistance",
>>>> new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("BottomBorderDistance",
>>>> new
>>>> Integer(200));
>>>>
>>>>                 // Insert a paragraph break into the document (not the
>>>> frame)
>>>>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
>>>> ControlCharacter.PARAGRAPH_BREAK, false);
>>>>
>>>>                 XPropertySet xCursorProps =
>>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
>>>> xTextViewCursor_sourceDoc);
>>>>
>>>>                 xCursorProps.setPropertyValue("BreakType",
>>>> com.sun.star.style.BreakType.PAGE_AFTER);
>>>>
>>>>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
>>>> ControlCharacter.PARAGRAPH_BREAK, false);
>>>>                 // xTextCursor.collapseToEnd();
>>>>                
>>>>             } catch (Exception e) {
>>>>                 System.out.println(e.getMessage());
>>>>                
>>>>                 e.printStackTrace();
>>>>             }
>>>>         }
>>>>     }
>>>>
>>>>
>>>> With your code, are you coming from the "bottom" of your document and
>>>> working your way up?
>>>>
>>>> I also don't believe I need;
>>>>
>>>> PositionProtected = False
>>>> SizeProtected = false
>>>> ContentProtected = false
>>>>
>>>> But still it doesn't work... :(
>>>>
>>>> See attachment,  http://www.nabble.com/file/p24164747/text.odt text.odt
>>>>
>>>> I als notice that there seems to be issues with the longs, ints, shorts
>>>> etc... as also captured here:
>>>> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089
>>>>
>>>> Any other thoughts?
>>>>
>>>> Thanks in advance
>>>>
>>>>
>>>> Fernand Vanrie wrote:
>>>>  
>>>>        
>>>>> Chris ,
>>>>>
>>>>> Long is needed because integer is to small and there are different
>>>>> properties who has to been set properly.
>>>>>
>>>>>  Please find the basic code i uses to place Frames without any problem
>>>>>
>>>>>  iPagenr = oViewCursor.page
>>>>>     iHCpos = oViewCursor.getPosition().X
>>>>>     iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
>>>>> Vieuwcursor rekend steeds van begin van document
>>>>>  
>>>>>      oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
>>>>>     oFrame.AnchorType = lAnchor
>>>>>     oFrame.PositionProtected = False
>>>>>     oFrame.SizeProtected = false
>>>>>     oFrame.ContentProtected = false
>>>>>      oFrame.HoriOrient = NONE
>>>>>      oFrame.VertOrient = NONE
>>>>>      oFrame.VertOrientRelation = PAGE_PRINT_AREA  
>>>>>      oFrame.HoriOrientRelation = PAGE_PRINT_AREA
>>>>>
>>>>>      oText.insertTextContent(oCursor(), oFrame, false)
>>>>>
>>>>> hope i  helps
>>>>>
>>>>> Fernand
>>>>>    
>>>>>          
>>>>>> 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: dev-unsubscribe@...
>>>>>>> For additional commands, e-mail: dev-help@...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    
>>>>>>>        
>>>>>>>              
>>>>>>  
>>>>>>      
>>>>>>            
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@...
>>>>> For additional commands, e-mail: dev-help@...
>>>>>
>>>>>
>>>>>
>>>>>    
>>>>>          
>>>>  
>>>>        
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@...
>>> For additional commands, e-mail: dev-help@...
>>>
>>>
>>>
>>>      
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


SOLVED Re: I have five text frames on the one page, can I move each frame to a new page?

by Chris Fleischmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for all of your help Fernand, I ended up solving it with the following code/method:

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();

        XController xController_targetDoc = xTextDocument_dest.getCurrentController();

        // the cursor for the source document
        XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
                (XTextViewCursorSupplier)
                UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
                xController_targetDoc);

        //selecting the whole source document
        XTextViewCursor xTextViewCursor_targetDoc =
                xViewCursorSupplier_targetDoc.getViewCursor();

        XPageCursor xPageCursor =
                (XPageCursor) UnoRuntime.queryInterface(
                XPageCursor.class,
                xTextViewCursor_targetDoc);

        XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
                UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument_dest);

        // get the NameAccess interface from the Style family collection
        XNameAccess xNameAccess = xSupplier.getStyleFamilies();

        try {
            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"));

            // retrieve the page size
            page_size = (Size) xPropertySet.getPropertyValue("Size");
        } catch (Exception e) {
            System.out.println(e.getMessage());

            e.printStackTrace();
        }

        xPageCursor.jumpToFirstPage();
        xPageCursor.jumpToEndOfPage();

        for (int i = 1; i < xIndexAccess.getCount(); i++) {
            try {
                xPageCursor.jumpToLastPage();
                xPageCursor.jumpToEndOfPage();

                // Insert a paragraph break into the document (not the frame)
                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);

                XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextViewCursor_targetDoc);

                xCursorProps.setPropertyValue("BreakType", com.sun.star.style.BreakType.PAGE_AFTER);

                xText.insertControlCharacter(xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);
            } catch (Exception e) {
                System.out.println(e.getMessage());

                e.printStackTrace();
            }
        }

        xPageCursor.jumpToFirstPage();

        for (int i = 0; i < xIndexAccess.getCount(); i++) {
            try {
                Any xImageAny = (Any) xIndexAccess.getByIndex(i);
                Object textFrame = xImageAny.getObject();

                XTextFrame xTextFrame = (XTextFrame)textFrame;

                XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);

                xShapeProps.setPropertyValue("AnchorPageNo", xPageCursor.getPage());
                xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);

                xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
                xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));

                // Setting the vertical and horizontal position
                xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(1000));
                xShapeProps.setPropertyValue("VertOrientPosition", new Integer(1000));

                xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
               
                xShapeProps.setPropertyValue("LeftBorderDistance", new Integer(200));
                xShapeProps.setPropertyValue("RightBorderDistance", new Integer(200));
                xShapeProps.setPropertyValue("TopBorderDistance", new Integer(200));
                xShapeProps.setPropertyValue("BottomBorderDistance", new Integer(200));
               
                xPageCursor.jumpToNextPage();
                xPageCursor.jumpToStartOfPage();
            } catch (Exception e) {
                System.out.println(e.getMessage());
               
                e.printStackTrace();
            }
        }
    }


Fernand Vanrie wrote:
Chris Fleischmann wrote:
> Here is the output I capture from the println statements:
>
> height: 0
>  
= invisible frame
> AnchorPageNo: 1
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
> HoriOrient: 0
> VertOrientPosition: 0
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
> VertOrientRelation: 8
> height: 21500
> AnchorPageNo: 2
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
>  
supposed to be "NONE" ?
> HoriOrient: 0
> VertOrientPosition: 21500
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
>  
supposed to be "PAGE_PRINT_AREA"
> VertOrientRelation: 8
>  
> height: 43000
>  
= frame with height off 43 cm , can not been placed
> AnchorPageNo: 3
> AnchorType: com.sun.star.text.TextContentAnchorType@39060b
> VertOrient: 0
> HoriOrient: 0
> VertOrientPosition: 43000
> HoriOrientPosition: 1000
> HoriOrientRelation: 8
> VertOrientRelation: 8
>
>
>
> Chris Fleischmann wrote:
>  
>> I'm sorry but your last comment lost me...
>>
>> Here is my Java method to create the necessary pages and to move the
>> textframes (well trying to):
>>
>> 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();
>>
>>         XController xController_targetDoc =
>> xTextDocument_dest.getCurrentController();
>>
>>         // the cursor for the source document
>>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>>                 (XTextViewCursorSupplier)
>>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>>                 xController_targetDoc);
>>
>>         //selecting the whole source document
>>         XTextViewCursor xTextViewCursor_targetDoc =
>>                 xViewCursorSupplier_targetDoc.getViewCursor();
>>
>>         XPageCursor xPageCursor =
>>                 (XPageCursor) UnoRuntime.queryInterface(
>>                 XPageCursor.class,
>>                 xTextViewCursor_targetDoc);
>>
>>         xPageCursor.jumpToFirstPage();
>>         xPageCursor.jumpToEndOfPage();
>>
>>         for (int i = 0; i < xIndexAccess.getCount(); i++) {
>>             try {
>>                 xPageCursor.jumpToLastPage();
>>                 xPageCursor.jumpToEndOfPage();
>>
>>                 // Insert a paragraph break into the document (not the
>> frame)
>>                 xText.insertControlCharacter(xTextViewCursor_targetDoc,
>> ControlCharacter.PARAGRAPH_BREAK, false);
>>
>>                 XPropertySet xCursorProps =
>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
>> xTextViewCursor_targetDoc);
>>
>>                 xCursorProps.setPropertyValue("BreakType",
>> com.sun.star.style.BreakType.PAGE_AFTER);
>>
>>                 xText.insertControlCharacter(xTextViewCursor_targetDoc,
>> ControlCharacter.PARAGRAPH_BREAK, false);
>>             } catch (Exception e) {
>>                 System.out.println(e.getMessage());
>>
>>                 e.printStackTrace();
>>             }
>>         }
>>
>>         xPageCursor.jumpToFirstPage();
>>        
>>         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);
>>
>>                 int height = xTextViewCursor_targetDoc.getPosition().Y;
>>
>>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
>> Short((short)(i + 1)));
>>
>>                 System.out.println("AnchorPageNo: " +
>> xShapeProps[i].getPropertyValue("AnchorPageNo"));
>>
>>                 xShapeProps[i].setPropertyValue("AnchorType",
>> TextContentAnchorType.AT_PAGE);
>>
>>                 System.out.println("AnchorType: " +
>> xShapeProps[i].getPropertyValue("AnchorType"));
>>
>>                 xShapeProps[i].setPropertyValue("VertOrient", new
>> Short(VertOrientation.NONE));
>>
>>                 System.out.println("VertOrient: " +
>> xShapeProps[i].getPropertyValue("VertOrient"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrient", new
>> Short(HoriOrientation.NONE));
>>
>>                 System.out.println("HoriOrient: " +
>> xShapeProps[i].getPropertyValue("HoriOrient"));
>>                
>>                 xShapeProps[i].setPropertyValue("VertOrientPosition", new
>> Integer(height));
>>
>>                 System.out.println("VertOrientPosition: " +
>> xShapeProps[i].getPropertyValue("VertOrientPosition"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrientPosition", new
>> Integer(1000));
>>
>>                 System.out.println("HoriOrientPosition: " +
>> xShapeProps[i].getPropertyValue("HoriOrientPosition"));
>>
>>                 xShapeProps[i].setPropertyValue("HoriOrientRelation", new
>> Short(RelOrientation.PAGE_PRINT_AREA));
>>
>>                 System.out.println("HoriOrientRelation: " +
>> xShapeProps[i].getPropertyValue("HoriOrientRelation"));
>>
>>                 xShapeProps[i].setPropertyValue("VertOrientRelation", new
>> Short(RelOrientation.PAGE_PRINT_AREA));
>>
>>                 System.out.println("VertOrientRelation: " +
>> xShapeProps[i].getPropertyValue("VertOrientRelation"));
>>
>>                 // Set the width and height of the shape.
>>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute", new
>> Integer(frame_size.Width));
>>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute", new
>> Integer(frame_size.Height));
>>
>>                 xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
>> new Boolean(false));
>>                 xShapeProps[i].setPropertyValue("SizeType", new
>> Short((short)1));
>>
>>                 xShapeProps[i].setPropertyValue("LeftBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("RightBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
>> Integer(200));
>>                 xShapeProps[i].setPropertyValue("BottomBorderDistance",
>> new Integer(200));
>>
>>                 xPageCursor.jumpToNextPage();
>>                
>>             } catch (Exception e) {
>>                 System.out.println(e.getMessage());
>>                
>>                 e.printStackTrace();
>>             }
>>         }
>>     }
>>
>> The pages are created without any issues... The output as per my println
>> statements shows correct page and heights assuming the first page top,
>> left is 0/0.
>>
>> Basically, what I can do is move the text frame without any issues using
>> the VertOrientPosition and HoriOrientPosition as long as the boundaries
>> for the textframe don't go out of the first page... Meaning I can get the
>> textframes to move around on page 1 no problem... but trying to anchor
>> them on to subsequent pages at the same x/y coordinate on the page isn't
>> working.
>>
>> Again, see attached odt.  http://www.nabble.com/file/p24177299/test.odt
>> test.odt
>>
>>
>> Fernand Vanrie wrote:
>>    
>>> Chris ,
>>>
>>> Before you start placing Frames, you must been sure you have already
>>> created the right number of pages.
>>>
>>> anyhow: i placed some code in your documents  "standard basic libray
>>> module1"
>>> this code placed a 1000x1000 frame at the cusor position,you moves your
>>> cursor to the right position, or you  gives  fixed coordinates to
>>> replace the cursor position and translates to java :-)
>>> Fernand
>>>
>>>      
>>>> Thanks for the tips... my method is now;
>>>>
>>>> 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();
>>>>
>>>>         XController xController_targetDoc =
>>>> xTextDocument_dest.getCurrentController();
>>>>
>>>>         // the cursor for the source document
>>>>         XTextViewCursorSupplier xViewCursorSupplier_targetDoc =
>>>>                 (XTextViewCursorSupplier)
>>>>                 UnoRuntime.queryInterface(XTextViewCursorSupplier.class,
>>>>                 xController_targetDoc);
>>>>
>>>>         //selecting the whole source document
>>>>         XTextViewCursor xTextViewCursor_sourceDoc =
>>>>                 xViewCursorSupplier_targetDoc.getViewCursor();
>>>>
>>>>         /*
>>>>         XPageCursor xPageCursor =
>>>>                 (XPageCursor) UnoRuntime.queryInterface(
>>>>                 XPageCursor.class,
>>>>                 xTextViewCursor_sourceDoc);
>>>>         */
>>>>
>>>>         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);
>>>>
>>>>                 // Setting the vertical and horizontal position
>>>>                 long height = (i * page_size.Height) + 1000;
>>>>
>>>>                 System.out.println("height: " + height);
>>>>
>>>>                 // Setting the vertical and horizontal position
>>>>
>>>>                 xShapeProps[i].setPropertyValue("AnchorPageNo", new
>>>> Short((short)(i + 1)));
>>>>                
>>>>                 xShapeProps[i].setPropertyValue("AnchorType",
>>>> TextContentAnchorType.AT_PAGE);
>>>>
>>>>                 xShapeProps[i].setPropertyValue("VertOrient", new
>>>> Short(VertOrientation.NONE));
>>>>                 xShapeProps[i].setPropertyValue("HoriOrient", new
>>>> Short(HoriOrientation.NONE));
>>>>                 xShapeProps[i].setPropertyValue("VertOrientPosition",
>>>> new
>>>> Long(height));
>>>>                 xShapeProps[i].setPropertyValue("HoriOrientPosition",
>>>> new
>>>> Integer(1000));
>>>>
>>>>                 xShapeProps[i].setPropertyValue("HoriOrientRelation",
>>>> (short)50);
>>>>                 xShapeProps[i].setPropertyValue("VertOrientRelation",
>>>> (short)50);
>>>>
>>>>                 // Set the width and height of the shape.
>>>>                 xShapeProps[i].setPropertyValue("FrameWidthAbsolute",
>>>> new
>>>> Integer(frame_size.Width));
>>>>                 xShapeProps[i].setPropertyValue("FrameHeightAbsolute",
>>>> new
>>>> Integer(frame_size.Height));
>>>>
>>>>                
>>>> xShapeProps[i].setPropertyValue("FrameIsAutomaticHeight",
>>>> new Boolean(false));
>>>>                 xShapeProps[i].setPropertyValue("SizeType", new
>>>> Short((short)1));
>>>>
>>>>                 xShapeProps[i].setPropertyValue("LeftBorderDistance",
>>>> new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("RightBorderDistance",
>>>> new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("TopBorderDistance", new
>>>> Integer(200));
>>>>                 xShapeProps[i].setPropertyValue("BottomBorderDistance",
>>>> new
>>>> Integer(200));
>>>>
>>>>                 // Insert a paragraph break into the document (not the
>>>> frame)
>>>>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
>>>> ControlCharacter.PARAGRAPH_BREAK, false);
>>>>
>>>>                 XPropertySet xCursorProps =
>>>> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,
>>>> xTextViewCursor_sourceDoc);
>>>>
>>>>                 xCursorProps.setPropertyValue("BreakType",
>>>> com.sun.star.style.BreakType.PAGE_AFTER);
>>>>
>>>>                 xText.insertControlCharacter(xTextViewCursor_sourceDoc,
>>>> ControlCharacter.PARAGRAPH_BREAK, false);
>>>>                 // xTextCursor.collapseToEnd();
>>>>                
>>>>             } catch (Exception e) {
>>>>                 System.out.println(e.getMessage());
>>>>                
>>>>                 e.printStackTrace();
>>>>             }
>>>>         }
>>>>     }
>>>>
>>>>
>>>> With your code, are you coming from the "bottom" of your document and
>>>> working your way up?
>>>>
>>>> I also don't believe I need;
>>>>
>>>> PositionProtected = False
>>>> SizeProtected = false
>>>> ContentProtected = false
>>>>
>>>> But still it doesn't work... :(
>>>>
>>>> See attachment,  http://www.nabble.com/file/p24164747/text.odt text.odt
>>>>
>>>> I als notice that there seems to be issues with the longs, ints, shorts
>>>> etc... as also captured here:
>>>> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16089
>>>>
>>>> Any other thoughts?
>>>>
>>>> Thanks in advance
>>>>
>>>>
>>>> Fernand Vanrie wrote:
>>>>  
>>>>        
>>>>> Chris ,
>>>>>
>>>>> Long is needed because integer is to small and there are different
>>>>> properties who has to been set properly.
>>>>>
>>>>>  Please find the basic code i uses to place Frames without any problem
>>>>>
>>>>>  iPagenr = oViewCursor.page
>>>>>     iHCpos = oViewCursor.getPosition().X
>>>>>     iVCpos = oViewCursor.getPosition().Y  - (30700 * (iPagenr -1)) '
>>>>> Vieuwcursor rekend steeds van begin van document
>>>>>  
>>>>>      oFrame.SetPropertyValue("AnchorPageNo", iPagenr)
>>>>>     oFrame.AnchorType = lAnchor
>>>>>     oFrame.PositionProtected = False
>>>>>     oFrame.SizeProtected = false
>>>>>     oFrame.ContentProtected = false
>>>>>      oFrame.HoriOrient = NONE
>>>>>      oFrame.VertOrient = NONE
>>>>>      oFrame.VertOrientRelation = PAGE_PRINT_AREA  
>>>>>      oFrame.HoriOrientRelation = PAGE_PRINT_AREA
>>>>>
>>>>>      oText.insertTextContent(oCursor(), oFrame, false)
>>>>>
>>>>> hope i  helps
>>>>>
>>>>> Fernand
>>>>>    
>>>>>          
>>>>>> 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: dev-unsubscribe@api.openoffice.org
>>>>>>> For additional commands, e-mail: dev-help@api.openoffice.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    
>>>>>>>        
>>>>>>>              
>>>>>>  
>>>>>>      
>>>>>>            
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
>>>>> For additional commands, e-mail: dev-help@api.openoffice.org
>>>>>
>>>>>
>>>>>
>>>>>    
>>>>>          
>>>>  
>>>>        
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
>>> For additional commands, e-mail: dev-help@api.openoffice.org
>>>
>>>
>>>
>>>      
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@api.openoffice.org
For additional commands, e-mail: dev-help@api.openoffice.org

Parent Message unknown Re: I have five text frames on the one page, can I move each frame to a new page?

by Ariel Constenla-Haile :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Chris,

On Wednesday 24 June 2009, 03:06, chris.fleischmann@... wrote:
> Hello.... Hrm, I have read through your example... Thank you very much... I
> am still stuck... Just a newbie... I'm sure its a simple solution.. Just
> cant find it :-(

the problem with your code is that the document with the text frames has only
*one* paragraph, so there is no change to have page breaks == different pages
(a page break is a paragraph property, you only have one paragraph ==> then,
all text frames are anchored to the very same paragraph; then, when you get
the anchor and insert a page break, you only have one page because it is the
very same and only paragraph you are modifying).

The solution is to insert a new paragraph right after you insert a text frame,
like in my code:

    private void insertTextFrames(XTextDocument xTextDocument){
        try {
            XMultiServiceFactory xDocFactory =
                    (XMultiServiceFactory) UnoRuntime.queryInterface(
                    XMultiServiceFactory.class, xTextDocument);

            XText xText = xTextDocument.getText();
            XTextCursor xTextCursor =
                      xText.createTextCursorByRange(xText.getStart());
           
            // first insert the text frames
            for (int i = 0; i < FRAMES_COUNT; i++) {
                insertTextFrame(xDocFactory, xTextCursor);
                insertParaBreak(xTextCursor);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


> Please see my code here below:

see the change I've made to your code (look at the /*=======>*/ in line 241).
The change only answers the subject of this thread (Re: I have five text frames
on the one page, can I move each frame to a new page?): now every frame is in
its own page. You will have to fix other things to achieve what you're looking
for.

Regards
--
Ariel Constenla-Haile
La Plata, Argentina

[TextDocumentStructure.java]

package org.openoffice.sdk;

import com.sun.star.awt.Size;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.datatransfer.XTransferable;
import com.sun.star.datatransfer.XTransferableSupplier;
import com.sun.star.drawing.XShape;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XController;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.HoriOrientation;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.text.VertOrientation;
import com.sun.star.text.XPageCursor;
import com.sun.star.text.XText;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.text.XTextRange;
import com.sun.star.text.XTextViewCursor;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;

public class TextDocumentStructure {

    private XTextDocument xTextDocument_src;
    private XTextDocument xTextDocument_dest;
    private XMultiServiceFactory xWriterFactory;
    private XComponent xWriterComponent_src;
    private XComponent xWriterComponent_dest;
    private Size page_size;
    private Size frame_size;

    public static void main(String args[]) {
        TextDocumentStructure tds = new TextDocumentStructure();

        tds.copyContents();

        tds.moveTextFrames();

        // tds.saveFile();

        System.exit(1);
    }

    public TextDocumentStructure() {
        try {
            // get the remote office component context
            XComponentContext xRemoteContext = Bootstrap.bootstrap();

            if (xRemoteContext == null) {
                System.err.println("ERROR: Could not bootstrap default Office.");
            }

            XMultiComponentFactory xRemoteServiceManager =
                    xRemoteContext.getServiceManager();

            Object desktop =
                    xRemoteServiceManager.createInstanceWithContext(
                    "com.sun.star.frame.Desktop", xRemoteContext);

            XComponentLoader xComponentLoader =
                    (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);

            PropertyValue[] loadProps = new PropertyValue[0];

            xWriterComponent_src =
                    xComponentLoader.loadComponentFromURL("private:factory/swriter",
                    "_blank", 0, loadProps);

            xWriterComponent_dest =
                    xComponentLoader.loadComponentFromURL("private:factory/swriter",
                    "_blank", 0, loadProps);

            xTextDocument_src =
                    (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,
                    xWriterComponent_src);

            xTextDocument_dest =
                    (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,
                    xWriterComponent_dest);

            // get internal service factory of the document
            xWriterFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
                    XMultiServiceFactory.class, xWriterComponent_src);

            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;

            xPropertySet.setPropertyValue("Size", page_size);

            // Switch the orientation
            xPropertySet.setPropertyValue("IsLandscape", new Boolean(true));
            xPropertySet.setPropertyValue("LeftMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("RightMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("TopMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("BottomMargin", new Short((short) 0));

            xSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(
                    XStyleFamiliesSupplier.class, xTextDocument_src);

            // get the NameAccess interface from the Style family collection
            xNameAccess = xSupplier.getStyleFamilies();

            xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(
                    XNameContainer.class, xNameAccess.getByName(
                    "PageStyles"));

            // create a PropertySet to set the properties for the new Pagestyle
            xPropertySet = (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class,
                    xPageStyleCollection.getByName("Default"));

            xPropertySet.setPropertyValue("LeftMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("RightMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("TopMargin", new Short((short) 0));
            xPropertySet.setPropertyValue("BottomMargin", new Short((short) 0));

            frame_size = new Size();

            frame_size.Height = page_size.Height - 2000;
            frame_size.Width = (page_size.Width / 2) - 2000;

            // create some example data
            XText xText = xTextDocument_src.getText();

            createExampleData(xText);

            XTextCursor xTextCursor = xText.createTextCursor();
            xTextCursor.gotoEnd(false);

            xText.insertControlCharacter(
                    xTextCursor,
                    com.sun.star.text.ControlCharacter.APPEND_PARAGRAPH,
                    false);

            //loadJpgImage(xText, "file:///Users/chrisf/Pictures/orthohedron1600.jpg", 4000, 4000);
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    private void moveTextFrames() {
        XTextFramesSupplier xTextFramesSupplier =
                (XTextFramesSupplier) UnoRuntime.queryInterface(
                XTextFramesSupplier.class, xWriterComponent_dest);

        XNameAccess xNamedFrames = xTextFramesSupplier.getTextFrames();

        XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
                XIndexAccess.class, xNamedFrames);

        XTextFrame xTextFrame;

        for (int i = 0; i < xIndexAccess.getCount(); i++) {
            try {
                xTextFrame = (XTextFrame) UnoRuntime.queryInterface(
                        XTextFrame.class, xIndexAccess.getByIndex(i));

                XTextRange xAnchor = xTextFrame.getAnchor();
                if (xAnchor != null) {
                    XPropertySet xAnchorProps = (XPropertySet) UnoRuntime.queryInterface(
                            XPropertySet.class, xAnchor);

                    xAnchorProps.setPropertyValue("PageDescName", "Default");
                    //xAnchorProps.setPropertyValue("BreakType", BreakType.PAGE_AFTER);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private XText getTextFrame(XText xText, int x, int y) {
        try {
            Object textFrame = xWriterFactory.createInstance("com.sun.star.text.TextFrame");

            XTextFrame xTextFrame = (XTextFrame) UnoRuntime.queryInterface(
                    XTextFrame.class, textFrame);

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

            xShape.setSize(new Size(frame_size.Width, frame_size.Height));

            XPropertySet xShapeProps = (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class, xTextFrame);

            xShapeProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH);

            // Setting the vertical and horizontal position
            xShapeProps.setPropertyValue("FrameIsAutomaticHeight", new Boolean(false));
            xShapeProps.setPropertyValue("SizeType", new Short((short) 1));

            xShapeProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
            xShapeProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));

            xShapeProps.setPropertyValue("VertOrientPosition", new Integer(1000));
            xShapeProps.setPropertyValue("HoriOrientPosition", new Integer(1000));

            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(), xTextFrame, false);
/*=======>*/xText.insertControlCharacter(xText.getEnd(), ControlCharacter.PARAGRAPH_BREAK, false);

            XText xFrameText = (XText) UnoRuntime.queryInterface(XText.class, textFrame);

            return xFrameText;
        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    private void copyContents() {
        try {
            //the controllers
            XController xController_sourceDoc = xTextDocument_src.getCurrentController();
            XController xController_targetDoc = xTextDocument_dest.getCurrentController();

            // the cursor for the source document
            XTextViewCursorSupplier xViewCursorSupplier_sourceDoc =
                    (XTextViewCursorSupplier) UnoRuntime.queryInterface(
                    XTextViewCursorSupplier.class,
                    xController_sourceDoc);

            //selecting the whole source document
            XTextViewCursor xTextViewCursor_sourceDoc =
                    xViewCursorSupplier_sourceDoc.getViewCursor();

            XPageCursor xPageCursor =
                    (XPageCursor) UnoRuntime.queryInterface(
                    XPageCursor.class,
                    xTextViewCursor_sourceDoc);

            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(
                    "ParagraphStyles"));

            // create a PropertySet to set the properties for the new Pagestyle
            XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class,
                    xPageStyleCollection.getByName("Default"));

            Float charHeight = (Float) xPropertySet.getPropertyValue("CharHeight");
            Integer paraTopMargin = (Integer) xPropertySet.getPropertyValue("ParaTopMargin");
            Integer paraBottomMargin = (Integer) xPropertySet.getPropertyValue("ParaBottomMargin");

            int page_height = page_size.Width;
            int page_width = page_size.Height;

            int frame_height = frame_size.Height;
            int frame_width = frame_size.Width;

            float ratio_x = (float) frame_height / (float) page_height;
            float ratio_y = (float) frame_width / (float) page_width;
            float ratio = 1;

            if (ratio_x < ratio_y) {
                ratio = ratio_x;
            } else {
                ratio = ratio_y;
            }

            // Switch the orientation
            short charHeight2 = (short) (charHeight.floatValue() * ratio);
            short paraTopMargin2 = (short) (paraTopMargin.floatValue() * ratio);
            short paraBottomMargin2 = (short) (paraBottomMargin.floatValue() * ratio);

            xPropertySet.setPropertyValue("CharHeight", new Short(charHeight2));
            xPropertySet.setPropertyValue("ParaTopMargin", new Short(paraTopMargin2));
            xPropertySet.setPropertyValue("ParaBottomMargin", new Short(paraBottomMargin2));

            // select the current page of document with the cursor
            xPageCursor.jumpToLastPage();
            xPageCursor.jumpToEndOfPage();

            int currentPage = xPageCursor.getPage();

            //getting the data supplier of our source doc
            XTransferableSupplier xTransferableSupplier_sourceDoc;
            XTransferableSupplier xTransferableSupplier_targetDoc;
            XTextViewCursorSupplier xViewCursorSupplier_targetDoc;
            XTextViewCursor xTextViewCursor_targetDoc;
            XTransferable xTransferable;

            do {
                while (xPageCursor.getPage() == currentPage) {
                    if (!xTextViewCursor_sourceDoc.goLeft((short) 1, true)) {
                        break;
                    }
                }

                //getting the data supplier of our source doc
                xTransferableSupplier_sourceDoc =
                        (XTransferableSupplier) UnoRuntime.queryInterface(
                        XTransferableSupplier.class,
                        xController_sourceDoc);

                //saving the selected contents
                xTransferable =
                        xTransferableSupplier_sourceDoc.getTransferable();

                // Create the TextFrame
                XText xText = xTextDocument_dest.getText();
                xText = getTextFrame(xText, 1000, 1000);

                //getting the data supplier of our target doc
                xTransferableSupplier_targetDoc =
                        (XTransferableSupplier) UnoRuntime.queryInterface(
                        XTransferableSupplier.class,
                        xController_targetDoc);

                //the cursor for the target document
                xViewCursorSupplier_targetDoc =
                        (XTextViewCursorSupplier) UnoRuntime.queryInterface(
                        XTextViewCursorSupplier.class,
                        xController_targetDoc);

                //going to the end of the source document
                xTextViewCursor_targetDoc =
                        xViewCursorSupplier_targetDoc.getViewCursor();

                xTextViewCursor_targetDoc.gotoRange(xText.getEnd(), false);

                // inserting the source document there
                xTransferableSupplier_targetDoc.insertTransferable(xTransferable);

                // Insert a paragraph break.
                xTextViewCursor_targetDoc.getText().insertControlCharacter(
                        xTextViewCursor_targetDoc, ControlCharacter.PARAGRAPH_BREAK, false);

                // RESET cursor and page.
                xTextViewCursor_sourceDoc.goRight((short) 1, false);

                xPageCursor.jumpToPreviousPage();
                xPageCursor.jumpToEndOfPage();
            } while (--currentPage > 0);

        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    private void saveFile() {
        try {
            XStorable xStorable =
                    (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument_dest);

            PropertyValue[] storeProps = new PropertyValue[1];
            storeProps[0] = new PropertyValue();
            storeProps[0].Name = "FilterName";
            storeProps[0].Value = "MS Word 97";

            xStorable.storeAsURL("file:///Users/chrisf/Documents/test.doc", storeProps);

        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }
    }

    protected void createExampleData(com.sun.star.text.XText xText) {
        try {
            for (int i = 0; i < 3000; i++) {
                xText.insertString(xText.getEnd(), String.valueOf(i) + " ", false);
            }

            com.sun.star.text.XWordCursor xWordCursor =
                    (com.sun.star.text.XWordCursor) UnoRuntime.queryInterface(
                    com.sun.star.text.XWordCursor.class, xText.getStart());

            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoNextWord(false);
            xWordCursor.gotoEndOfWord(true);

            com.sun.star.beans.XPropertySet xPropertySet =
                    (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
                    com.sun.star.beans.XPropertySet.class, xWordCursor);

            xPropertySet.setPropertyValue("CharWeight",
                    new Float(com.sun.star.awt.FontWeight.BOLD));
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    protected void loadJpgImage(XText xText, String strImgFileName, int width, int height) {
        XNameContainer xBitmapContainer = null;
        XTextContent xImage = null;
        String internalURL = null;

        try {
            xBitmapContainer = (XNameContainer) UnoRuntime.queryInterface(
                    XNameContainer.class, xWriterFactory.createInstance(
                    "com.sun.star.drawing.BitmapTable"));

            xImage = (XTextContent) UnoRuntime.queryInterface(
                    XTextContent.class, xWriterFactory.createInstance(
                    "com.sun.star.text.TextGraphicObject"));

            XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(
                    XPropertySet.class, xImage);

            // helper-stuff to let OOo create an internal name of the graphic
            // that can be used later (internal name consists of various checksums)
            xBitmapContainer.insertByName("someID", strImgFileName);
            internalURL = AnyConverter.toString(xBitmapContainer.getByName("someID"));

            int page_height = page_size.Width;
            int page_width = page_size.Height;

            int frame_height = frame_size.Height;
            int frame_width = frame_size.Width;

            float ratio_x = (float) frame_height / (float) page_height;
            float ratio_y = (float) frame_width / (float) page_width;
            float ratio = 1;

            if (ratio_x < ratio_y) {
                ratio = ratio_x;
            } else {
                ratio = ratio_y;
            }

            xProps.setPropertyValue("AnchorType",
                    com.sun.star.text.TextContentAnchorType.AS_CHARACTER);

            xProps.setPropertyValue("GraphicURL", internalURL);
            xProps.setPropertyValue("Width", (int) (width * ratio));
            xProps.setPropertyValue("Height", (int) (height * ratio));

            // inser the graphic at the cursor position
            xText.insertTextContent(xText.getEnd(), xImage, false);

            // remove the helper-entry
            xBitmapContainer.removeByName("someID");
        } catch (Exception e) {
            System.out.println("Failed to insert Graphic");
        }
    }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...