Hello,

I am using the API and python to create a Writer document (OOo 2.3.1) with 
a simple text table in it. After I create the table and populate it with 
strings I use the dispatcher to execute setOptimalColumnWidth. I can 
select the last n columns in a table and set the optimal column width. 
That works. But when I try to select a single column that is not the last 
column in the table, that does not work.

This is the code that works for multiple columns:

        cell = table.getCellByPosition(2,0)
        doc.getCurrentController().select(cell)

        vCursor = doc.getCurrentController().getViewCursor()
        vCursor.gotoEnd(True)
        vCursor.gotoEnd(True)

        frame = doc.CurrentController.getFrame()
        dispHelper = 
smgr.createInstance("com.sun.star.frame.DispatchHelper")
        dispHelper.executeDispatch(frame, ".uno:SetOptimalColumnWidth", 
"", 0, ())

This is the code that does not work for selecting a single column:

        cell = table.getCellByPosition(1,0)
        doc.getCurrentController().select(cell) 

        vCursor = doc.getCurrentController().getViewCursor()
        vCursor.gotoEnd(True)
        vCursor.goDown(numRows-1,True)

        frame = doc.CurrentController.getFrame()
        dispHelper = 
smgr.createInstance("com.sun.star.frame.DispatchHelper")
        dispHelper.executeDispatch(frame, ".uno:SetOptimalColumnWidth", 
"", 0, ())


The vCursor.goDown command does not seem to work as I expected. I see the 
text in the first cell highlighted but none of the other cells in the 
column are highlighted and the column width is unchanged. It seems like 
the vCursor.goDown command was ignored.

I also thought about using:

        cellRange = table.getCellRangeByPosition(1,0,1,numRows-1)
        doc.getCurrentController().select(cellRange)

but then I can't figure out how to get the cell range into the view 
cursor.

Can somebody point me to a solution for selecting a single column of a 
simple text table so I can use setOptimalColumnWidth?



Thanks,

Mike Wazlowski

Reply via email to