Peter Eberlein wrote:

Hi,

in a former StarOffice version the following worked properly:

oTableCursor = oTable.createCursorByCellName(oTable.CellNames(0))
oTableCursor.ParaStyleName = "MyStyle"

Contrary to a "normal" XTextCursor this does not work in 2.0 anymore.

According to the api the service css.text.TextTableCursor includes the service css.style.ParagraphProperties with the missing property "ParaStyleName".

Any hints?

Regards

Peter

If you need to modify ALL of the paragraphs, I have macros that do this sort of thing. I am making updates to my macro document that descirbe how to work with text tables. I think that the version on my web site (which is not really the latest) has something that formats a table to match the OOo Authors format. In case it is too old, here is the macro

REM  *****  BASIC  *****
Option Explicit

Sub Main
 FormatTable()
End Sub

Sub FormatTable(Optional oUseTable)
 Dim oTable
 Dim oCell
 Dim nRow As Long
 Dim nCol As Long

 If IsMissing(oUseTable) Then
   oTable = ThisComponent.CurrentController.getViewCursor().TextTable
 Else
   oTable = oUseTable
 End If
 If IsNull(oTable) OR IsEmpty(oTable) Then
   Print "FormatTable: No table specified"
   Exit Sub
 End If

 Dim v
 Dim x
 v = oTable.TableBorder
 x = v.TopLine
 x.OuterLineWidth = 2
 v.TopLine = x

 x = v.LeftLine
 x.OuterLineWidth = 2
 v.LeftLine = x

 x = v.RightLine
 x.OuterLineWidth = 2
 v.RightLine = x

 x = v.TopLine
 x.OuterLineWidth = 2
 v.TopLine = x

 x = v.VerticalLine
 x.OuterLineWidth = 2
 v.VerticalLine = x

 x = v.HorizontalLine
 x.OuterLineWidth = 0
 v.HorizontalLine = x

 x = v.BottomLine
 x.OuterLineWidth = 2
 v.BottomLine = x

 'v.Distance = 51

 oTable.TableBorder = v

 For nRow = 0 To oTable.getRows().getCount() - 1
   For nCol = 0 To oTable.getColumns().getCount() - 1
     oCell = oTable.getCellByPosition(nCol, nRow)
     If nRow = 0 Then
       oCell.BackColor = 128
       SetParStyle(oCell.getText(), "OOoTableHeader")
     Else
       SetParStyle(oCell.getText(), "OOoTableText")
       If nRow MOD 2 = 1 Then
         oCell.BackColor = -1
       Else
         REM color is (230, 230, 230)
         oCell.BackColor = 15132390
       End If
     End If
   Next
 Next
'  Inspect(oTable)
'  Inspect(oCell)
End Sub

Sub SetParStyle(oText, sParStyle As String)
 Dim oEnum
 Dim oPar
 oEnum = oText.createEnumeration()
 Do While oEnum.hasMoreElements()
   oPar = oEnum.nextElement()
   If opar.supportsService("com.sun.star.text.Paragraph") Then
     'oPar.ParaConditionalStyleName = sParStyle
     oPar.ParaStyleName = sParStyle
   End If
 Loop
End Sub


Be warned that this macro will ONLY work for a simple text table because of the way that it enumerates all of the cells.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to