Folks, perhaps this has already been answered, or perhaps cannot be done, but
I am attempting to add content to a Writer / XText... adding content that is
either an image or normal text (with different font attributes; bold,
italics, underline etc)... Once the page is created, I would then like to be
able to extract all of the contents from the newly created pages, and with a
new blank document, transfer each page in to a textframe that I
programmatically create shrinking the "page content" to fit the text
frame...

Does any one know how I would go about that/this?

So far I have simple functions like;

protected void createExampleData(com.sun.star.text.XText xText) {

        try {
            xText.setString("This is an example sentence");

            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)
            throws Exception, java.lang.Exception {
        // insert RectangleShape and get shape text, then manipulate text
        Object textGraphicObject =
xWriterFactory.createInstance("com.sun.star.text.TextGraphicObject");

        XTextContent xTextContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, textGraphicObject);

        XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, textGraphicObject);

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

        xText.insertTextContent(xText.getEnd(), xTextContent, false);

        // Setting the vertical and horizontal position
        //xPropertySet.setPropertyValue("HoriOrientPosition", new
Integer(x));
        //xPropertySet.setPropertyValue("VertOrientPosition", new
Integer(y));
        xPropertySet.setPropertyValue("Width", new Integer(width));
        xPropertySet.setPropertyValue("Height", new Integer(height));

        xPropertySet.setPropertyValue("GraphicURL", strImgFileName);

        Object xBitmapContainerObject =
xWriterFactory.createInstance("com.sun.star.drawing.BitmapTable");

        XNameContainer xBitmapContainer = (XNameContainer)
                UnoRuntime.queryInterface(XNameContainer.class,
xBitmapContainerObject);

        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(strImgFileName.getBytes(), 0, strImgFileName.length());

        String internalName = new BigInteger(1, md.digest()).toString(16);

        xBitmapContainer.insertByName(internalName, strImgFileName);

        String internalURL =
(String)(xBitmapContainer.getByName(internalName));

        xPropertySet.setPropertyValue("GraphicURL", internalURL);

        xBitmapContainer.removeByName(internalName);
    }

To create sample text, and to load images in to the document...

And now I would like to be able to extract such content/the page, to then
insert the content in to a textFrame of another document. Is this possible?


-- 
View this message in context: 
http://www.nabble.com/Extract-all-content-from-a-page-of-a-document-and-add-to-a-textframe-in-another-document-tp24124814p24124814.html
Sent from the openoffice - api dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to