Page 1 of 1

[C#] OOoDraw XText not writing text

Posted: Thu May 21, 2015 8:22 am
by scottadamson
trying to write text in an open office draw document (open office 4.1.1 and sdk 4.1.1) and no text is written, included my code
the objects are being created but no text is written.

i can see the elipse in the document and if i drag select all i also see the empty text shape.

please help, im coverting over a set of powerpoint generators from being coupled to ms office powerpoint to openoffice impress, so far boot times and interaction times are far quicker than with powerpoint.

Code: Select all

        public void DrawOnDrawing(XComponent document)
        {
            XDrawPages xp = ((XDrawPagesSupplier) document).getDrawPages();
            XDrawPage xpage1 = xp.insertNewByIndex(0);
            XDrawPage xpage0 = (XDrawPage)xp.getByIndex(0).Value;
            xp.remove(xpage0);
            XMultiServiceFactory xDocMSF = (XMultiServiceFactory)document;
            XShape shape = (XShape)xDocMSF.createInstance("com.sun.star.drawing.EllipseShape");
            shape.setPosition(new unoidl.com.sun.star.awt.Point(100, 100));
            shape.setSize(new unoidl.com.sun.star.awt.Size(5000, 5000));
            XShape txtshape = (XShape)xDocMSF.createInstance("com.sun.star.drawing.TextShape");
            txtshape.setPosition(new unoidl.com.sun.star.awt.Point(6000, 6000));
            txtshape.setSize(new unoidl.com.sun.star.awt.Size(5000, 5000));
            ((XText)txtshape).setString("test text");
            ((XText)shape).setString("another test");
            xpage1.add(txtshape);
            xpage1.add(shape);
        }

Re: [C#] OOoDraw XText not writing text

Posted: Mon May 25, 2015 9:28 am
by scottadamson
can anyone tell me if I am correct with the assumption that in C# I need to cast the shape as XText and use setString?

Code: Select all

  ((XText)txtshape).setString("test text");
any one see anything that I'm missing?

has anyone tried to produce presentations or drawings by code using Open Office and C#?