 | OO-Snippets: change table column widthCommons| Keywords | width, column width, change table column width |
|---|
| Language | ooRexx |
|---|
| Application | Writer |
|---|
| Authors | Nicole Scholz
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question | How can I change the width of a table column
|
|---|
| Answer | In this example the column width of a table is changed. |
|---|
oDesktop = UNO.createDesktop()
xComponentLoader = oDesktop~XDesktop~XComponentLoader
url = "private:factory/swriter"
xWriterComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)
xDocumentFactory = xWriterComponent~XMultiServiceFactory
xTextDocument = xWriterComponent~XTextDocument
xText = xTextDocument~getText()
xTextCursor = xText~createTextCursor()
xPropertySet = xTextCursor~xPropertySet
xDMsf = xTextDocument~XMultiServiceFactory
xTextTable = xDMsf~createInstance("com.sun.star.text.TextTable")~XTextTable
xTextTable~initialize(1, 2)
xText~insertTextContent(xTextCursor, xTextTable, .false)
call setCellText "A1", "table width", xTextTable
call setColumnWidth "A1", xTextTable
::requires UNO.cls
::routine setCellText
use arg cell, text, xTextTable
xCellText = xTextTable~getCellByName(cell)~XText
xCellCursor = xCellText~createTextCursor()
cursorProps = xCellCursor~XPropertySet
xCellText~setString(text)
return
::routine setColumnWidth
use arg cell, xTextTable
xTextTableCursor = xTextTable~createCursorByCellName(cell)
xTableProps=xTextTable~xPropertySet
colRelSum=xTableProps~getPropertyValue("TableColumnRelativeSum")
colSeparators=xTableProps~getPropertyValue("TableColumnSeparators")
colSeparators[1]~position=trunc(colRelSum*0.70)
xTableProps~setPropertyValue("TableColumnSeparators", colSeparators)
return
|
|