Hello All,

OpenOffice 3.1.1. Java SDK, MAC OS X 10.6.2, MS Word 2007/2008.

Firstly I am happily able to position my TextGraphicObject's where I need
them, ie., I use the following code to position the TextGrahicObject in
OpenOffice with a particular width and height:

        Object newImage =
xWriterFactory_dest.createInstance("com.sun.star.text.TextGraphicObject");

        XTextContent xNewTextContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, newImage);

        XTextCursor xTextCursor = xFrameText.createTextCursor();

        xTextCursor.gotoEnd(false);

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

        // helper-stuff to let OOo create an internal name of the graphic
        // that can be used later (internal name consists of various
checksums)
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(strImgFileName.getBytes(), 0, strImgFileName.length());

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

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

        xBitmapContainer.insertByName(internalName, strImgFileName);
        
        String internalURL =
(String)(xBitmapContainer.getByName(internalName));

        xProps.setPropertyValue("AnchorType",
TextContentAnchorType.AT_PARAGRAPH);
        
        xProps.setPropertyValue("Width", width);
        xProps.setPropertyValue("Height", height);

        if (centreImage == true) {
            int pos_x = (frame_size.Width / 2) - (width / 2);

            // update frame width with the new dimensions.
            xProps.setPropertyValue("HoriOrient", new
Short(HoriOrientation.NONE));
            xProps.setPropertyValue("HoriOrientPosition", new
Integer(pos_x));
        } else {
            int pos_x = 1000;
            int pos_y = 1000;

            xProps.setPropertyValue("HoriOrient", new
Short(HoriOrientation.NONE));
            xProps.setPropertyValue("HoriOrientPosition", new
Integer(pos_x));

            xProps.setPropertyValue("VertOrient", new
Short(HoriOrientation.NONE));
            xProps.setPropertyValue("VertOrientPosition", new
Integer(pos_y));
        }

        xtext.insertTextContent(xTextCursor, xNewTextContent, false);

        // remove unnecessary object reference
        xBitmapContainer.removeByName(internalName);

However when I open up the document in MS Word, the image, has been
left-aligned (lots its X position) and lots its Y position?

Is there a way to make sure the position is maintained in both OOo and MS
Word?

Thanks in advance,

Chris


-- 
View this message in context: 
http://old.nabble.com/Please-help%3A-saving-document-as-DOC-format%2C-then-opening%2C-losing-position-properties-for-TextGraphicObject-tp26989671p26989671.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