Re: Opening the file in MS Word, linked images wrong size

Fernand Vanrie <[email protected]> Mon, 07 Feb 2011 09:19:19 +0100
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
cdfleischmann,

xProps.getPropertyValue("IsPixelContour") have no sence when using "linked" images, this property only works with embeded images. Maybe thats the reason for your problems.
When setting xProps.setPropertyValue("Width", width); to a percentage and not a fixed value, can also be the reason why you have different sizes in the Word Document.

Hope it helps a bit

Fernand
  


> Hello, I am hoping someone can help me... I am using OpenOffice SDK 3.3 with
> OpenOffice, (I also tried with LibreOffice), and find that after I insert an
> image using code like:
>
> Object newImage =
> xWriterFactory_dest.createInstance("com.sun.star.text.TextGraphicObject");
> XTextContent xNewTextContent = (XTextContent)
> UnoRuntime.queryInterface(XTextContent.class, newImage);
> XPropertySet xProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, newImage);
>
>
> xProps.setPropertyValue("GraphicURL", strImgFileName);
> xProps.setPropertyValue("AnchorType", TextContentAnchorType.AS_CHARACTER);
>
> xText.insertTextContent(xTextCursor, xNewTextContent, false);
>
> xProps.getPropertyValue("IsPixelContour");
>
> xProps.setPropertyValue("Width", width);
> xProps.setPropertyValue("Height", height);
>
> xProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
> xProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
> xProps.setPropertyValue("HoriOrientPosition", new Integer(x));
> xProps.setPropertyValue("VertOrientPosition", new Integer(y));
>
> to insert an image at a certain character position...
>
> After inserting, I then set the size which seems to work for OpenOffice. The
> images are sized correctly and linked accordingly. However when I try to
> save/export the document to it's MS Word format. I see that the picture
> frame (the frame prior to having its contents loaded/prior to fetching the
> URL), are set to the correct size, however after Word fetches the actual
> picture file, the image no longer fit within the image size I set and seems
> to reflect the images true file size (the actual image size) rather than the
> width and height that I set the image to open in.
>
> If you know of a way to set the actual image size once it has loaded/fetched
> for Word, I'd appreciate any assistance.
>
> Kind Regards,
>
> Chris