Hello Folks... I am using the XTransferable Object to copy sections of a
source document over to a destination document (that was opened as blank)..
This seems to work, copying images, text, text styles etc.

In terms of the source document I am loading images like so:


protected void loadJpgImage(XText xText, String strImgFileName, int width,
int height) {
        try {
            Object newImage =
xWriterFactory_src.createInstance("com.sun.star.text.TextGraphicObject" );
            XTextContent xNewTextContent = ( XTextContent )
UnoRuntime.queryInterface(XTextContent.class, newImage);

            XTextCursor xTextCursor = xText.createTextCursor();

            xTextCursor.gotoEnd(false);

            xText.insertTextContent( xTextCursor, xNewTextContent, false);

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

            xProps.setPropertyValue( "GraphicURL", strImgFileName);

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

            xProps.setPropertyValue("Width", new Integer((int)(width)));
            xProps.setPropertyValue("Height", new Integer((int)(height)));
        } catch (Exception e) {
            e.printStackTrace();

            System.out.println("Failed to insert Graphic");
        }
    }

Then as the images loaded in to the source document and then copied over to
the destination object by XTransferable as "linked" image(s). Moving the
destination file over to another system/PC, the file wouldn't be found
(AFAIK). So I attempt to perform the following, on the destination document:

xText = xTextDocument_dest.getText();

        try {
            XTextGraphicObjectsSupplier os =
                (XTextGraphicObjectsSupplier) UnoRuntime.queryInterface(
                XTextGraphicObjectsSupplier.class, xTextDocument_dest);

            XNameAccess as = os.getGraphicObjects();

            if ((as != null) && (as.hasElements())) {
                String names[] = as.getElementNames();

                for (int i = 0; i < names.length; i++) {
                    Object o = (Object) as.getByName(names[i]);

                    XTextContent xImage = (XTextContent)
UnoRuntime.queryInterface(
                            XTextContent.class, o);

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

                    String url =
(String)xProps.getPropertyValue("GraphicURL");
                    
                    PropertyValue aMediaProperties[] = new PropertyValue[1];

                    aMediaProperties[0] = new PropertyValue();
                    aMediaProperties[0].Name = "URL";
                    aMediaProperties[0].Value = url;

                    // Create new XGraphic object
                    XGraphic xNewGraphic =
xGraphicProvider.queryGraphic(aMediaProperties);

                    xProps.setPropertyValue("Graphic", xNewGraphic);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

The resultant destination file can happily be saved and reopened in ODT
format, but if I choose to Save AS a word doc, re-opening the file in office
2007 or mac office 2008, I get the following error/dialog:

"There is not enough memory or disk space to display or print the picture"

Although I have over 45GB spare with 4Gig of RAM... The Word Doc size is
only 2.4MB in size.

I have also tried iWork Pages, the images show, but the program also shows a
warning saying, Type, "Missing File", Value, "Image".

The Full Java code is here: 
http://www.nabble.com/file/p24296829/TextDocumentStructure3.java
TextDocumentStructure3.java 

Any thoughts, ideas or how-to's? I've been trying to solve this for 3 days
now. :(

Its been driving me crazy. Thanks in advance,

-- 
View this message in context: 
http://www.nabble.com/TextGraphicObject%2C-XTransferable-and-Save-As%2C-Microsoft-Word%2C-out-of-memory-errors-tp24296829p24296829.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org

Reply via email to