I've also noticed that if I open up the saved word document in Word, and
right mouse click to see options for the picture... I see that it is
"anchored" as, "AS CHARACTER", I then reselect "AT PARAGRAPH" and save it...
What I notice is that I am now able to open up the document in M$
Word...?????

My code for the "embedding" of an image is as follows:

You will see from the code below that I retrieve the URL from the image
loaded in the document, and then use queryGraphics to reload the "embedded"
image.

------------------

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;
                   
                    xProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PARAGRAPH);

                    XGraphic xGraphic =
xGraphicProvider.queryGraphic(aMediaProperties);

                    xProps.setPropertyValue("GraphicURL", null);
                    xProps.setPropertyValue("Graphic", xGraphic);
                   
                    XPropertySetInfo xPropertySetInfo =
xProps.getPropertySetInfo();
                    Property property[] = xPropertySetInfo.getProperties();

                    for (int j = 0; j < property.length; j++) {
                        System.out.println(property[j].Name + " = " +
xProps.getPropertyValue(property[j].Name));
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }




Chris Fleischmann wrote:
> 
> 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-tp24296829p24305618.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


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

Reply via email to