List Info

Thread: text table cells with multiple columns?




text table cells with multiple columns?
user name
2007-04-16 13:01:40
Hi, I am working with an XTextTable and I'm able to create
all the cells
individually.  But I would like to do is to create cells
that multiple
column spans.  Is this possible? I looked through as many
mailings as I
could but could not find an answer.

 

Here is my code snippet.

 

       //getting the text object

        XText xText = myDoc.getText();

 

        //create a cursor object

        XTextCursor xTCursor = xText.createTextCursor();

 

        //getting MSF of the document

        XMultiServiceFactory xDocMSF =
(XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class,

                myDoc);

 

        //create instance of a text table

        XTextTable xTT = null;

 

        try {

            Object oInt =
xDocMSF.createInstance("com.sun.star.text.TextTable&quo
t;);

            xTT = (XTextTable)
UnoRuntime.queryInterface(XTextTable.class,
oInt);

        } catch (Exception e) {

            System.err.println("Couldn't create
instance " + e);

            e.printStackTrace(System.err);

        }

 

        //initialize the text table with 2 rows x 9 columns

        xTT.initialize(2, 9);

 

        XPropertySet xTTRowPS = null;

 

        //insert the table

        try {

            xText.insertTextContent(xTCursor, xTT, false);

 

            // get first Row

            com.sun.star.container.XIndexAccess xTTRows =
xTT.getRows();

            xTTRowPS = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,

                    xTTRows.getByIndex(0));

        } catch (Exception e) {

            System.err.println("Couldn't insert the
table " + e);

            e.printStackTrace(System.err);

        }

 

        // write Text in the Table headers

        System.out.println("Write text in the table
headers");

 

        insertIntoCell("A1", "Org /
Reviewer", xTT);

        insertIntoCell("B1", "Page #",
xTT);

 

************************************************************
****************
******************

   public static void insertIntoCell(String CellName, String
theText,

        XTextTable xTTbl) {

        XText xTableText = (XText)
UnoRuntime.queryInterface(XText.class,

                xTTbl.getCellByName(CellName));

 

        //create a cursor object

        com.sun.star.text.XTextCursor xTC =
xTableText.createTextCursor();

 

        com.sun.star.beans.XPropertySet xTPS =
(com.sun.star.beans.XPropertySet)
UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.cl
ass,

                xTC);

 

        try {

            xTPS.setPropertyValue("CharHeight",
new Float(8));

        } catch (Exception e) {

            System.err.println(" Exception " +
e);

            e.printStackTrace(System.err);

        }

 

        //inserting some Text

        xTableText.setString(theText);

    }

 

_______________________
Anh-Tuan Le
FCI
703.961.1818 x162 

 

Re: text table cells with multiple columns?
user name
2007-04-16 13:13:53
Anh-Tuan Le wrote:
> Hi, I am working with an XTextTable and I'm able to
create all the cells
> individually.  But I would like to do is to create
cells that multiple
> column spans.  Is this possible? I looked through as
many mailings as I
> could but could not find an answer.
>
>   
Hi,
what you need is a com::sun::star::text::XTextTableCursor.
see 
http://api.openoffice.org/docs/
common/ref/com/sun/star/text/XTextTableCursor.html

Regards,

Oliver

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )