Zebra Striping

Creating a macro - Writing a Script - Using the API

Zebra Striping

Postby php_penguin » Sat Dec 08, 2007 6:06 am

Hi there

I'm not much of a scripter... well I do PHP and so on, but BASIC is too boring and annoyingly documented!

Anyway, I am wondering if anyone has done a Zebra Striping macro? I'm sure its possible, but the docs are too much of a mess for me to figure it out for myself!

Thanks in advance!
Posts: 1
Joined: Sat Dec 08, 2007 6:02 am

Re: Zebra Striping

Postby probe1 » Tue Dec 25, 2007 12:35 pm

php_penguin wrote:if anyone has done a Zebra Striping macro?

I can only guess here.... Are you looking for a macro solution to alternate colors in tables?

for Calc:
Sets alternating colours to the cell selection, multiple selection possible

Sets alternating colours the used cell range, to actual or all sheets in document, respects header formats

for Writer:
Sets colours to text tables
Definition of two background colors which are applied alternatively to the rows of a text table.

Does this help?

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: Zebra Striping

Postby pitonyak » Sun Jan 13, 2008 4:46 pm

Looks like Sun is working on some items related to this... I use a macro such as the following:

Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****
Option Explicit

Sub Main
End Sub

sub ScreenUpdatingOn
end sub

public sub ScreenUpdatingOff
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
    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")
        SetParStyle(oCell.getText(), "OOoTableText")
        If nRow MOD 2 = 1 Then
          oCell.BackColor = -1
          REM color is (230, 230, 230)
          oCell.BackColor = 15132390
        End If
      End If
'  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
End Sub

If you look at any of my OOo documentation, you can see how it looks in my text tables.
Andrew Pitonyak
LO and AOO on Fedora
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests