Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You may run the Sub charFormatEachSingleTextRangeOfCurrentSelection as given in the BASIC code below.

Sub charFormatEachSingleTextRangeOfCurrentSelection(Optional pWhat As String)
If IsMissing(pWhat) Then pWhat = "removeCharBorders"
doc    = ThisComponent
currC  = doc.CurrentController
oldSel = doc.CurrentSelection
If NOT oldSel.supportsService("com.sun.star.text.TextRanges") Then
 MsgBox("This Routine needs a TextRanges selection to work on.")
 Exit Sub
End If
uRgs = oldSel.Count - 1
For j = 0 To uRgs
 rg_j = oldSel(j)
 workOnTextPortionsOfCurrentTextRange(rg_j, pWhat)
Next j
currC.select(oldSel)
End Sub

Sub workOnTextPortionsOfCurrentTextRange(pRange As Object, pWhat As String)
hDoc  = ThisComponent
hCtrl = hDoc.CurrentController
Select Case pWhat
 Case "removeCharBorders"
  selOnEnter = hDoc.CurrentSelection
  hCtrl.select(pRange)
  nowSel = hDoc.CurrentSelection(0)
  Dim bH As New com.sun.star.table.BorderLine2
  nowSel.CharLeftBorder = bH 'cLB
  nowSel.CharBorderDistance = 0
  hCtrl.select(selOnEnter)
 Case Else
  MsgBox("Case """ & pWhat & """ not implemented!", 0, "Unknown Case")
End Select
End Sub

The code is also contained in this attached example, where you also find some additional explanations, and a gfew comments on strangenesses concerning text procesing.

You may run the Sub charFormatEachSingleTextRangeOfCurrentSelection as given in the BASIC code below.

Sub charFormatEachSingleTextRangeOfCurrentSelection(Optional pWhat As String)
If IsMissing(pWhat) Then pWhat = "removeCharBorders"
doc    = ThisComponent
currC  = doc.CurrentController
oldSel = doc.CurrentSelection
If NOT oldSel.supportsService("com.sun.star.text.TextRanges") Then
 MsgBox("This Routine needs a TextRanges selection to work on.")
 Exit Sub
End If
uRgs = oldSel.Count - 1
For j = 0 To uRgs
 rg_j = oldSel(j)
 workOnTextPortionsOfCurrentTextRange(rg_j, pWhat)
Next j
currC.select(oldSel)
End Sub

Sub workOnTextPortionsOfCurrentTextRange(pRange As Object, pWhat As String)
hDoc  = ThisComponent
hCtrl = hDoc.CurrentController
Select Case pWhat
 Case "removeCharBorders"
  selOnEnter = hDoc.CurrentSelection
  hCtrl.select(pRange)
  nowSel = hDoc.CurrentSelection(0)
  Dim bH As New com.sun.star.table.BorderLine2
  nowSel.CharLeftBorder = bH 'cLB
  nowSel.CharBorderDistance = 0
  hCtrl.select(selOnEnter)
 Case Else
  MsgBox("Case """ & pWhat & """ not implemented!", 0, "Unknown Case")
End Select
End Sub

The code is also contained in this attached example, where you also find some additional explanations, and a gfew few comments on strangenesses concerning text procesing. processing.

You may run the Sub charFormatEachSingleTextRangeOfCurrentSelection as given in the BASIC code below.

Sub charFormatEachSingleTextRangeOfCurrentSelection(Optional pWhat As String)
If IsMissing(pWhat) Then pWhat = "removeCharBorders"
doc    = ThisComponent
currC  = doc.CurrentController
oldSel = doc.CurrentSelection
If NOT oldSel.supportsService("com.sun.star.text.TextRanges") Then
 MsgBox("This Routine needs a TextRanges selection to work on.")
 Exit Sub
End If
uRgs = oldSel.Count - 1
For j = 0 To uRgs
 rg_j = oldSel(j)
 workOnTextPortionsOfCurrentTextRange(rg_j, workOnFormatOfTheSingleTextRange(rg_j, pWhat)
Next j
currC.select(oldSel)
End Sub

Sub workOnTextPortionsOfCurrentTextRange(pRange workOnFormatOfTheSingleTextRange(pRange As Object, pWhat As String)
hDoc  = ThisComponent
hCtrl = hDoc.CurrentController
Select Case pWhat
 Case "removeCharBorders"
  selOnEnter = hDoc.CurrentSelection
  hCtrl.select(pRange)
  nowSel = hDoc.CurrentSelection(0)
  Dim bH As New com.sun.star.table.BorderLine2
  nowSel.CharLeftBorder = bH 'cLB
  = bH
  nowSel.CharRightBorder  = bH
  nowSel.CharTopBorder    = bH
  nowSel.CharBottomBorder = bH
  nowSel.CharBorderDistance = 0
  hCtrl.select(selOnEnter)
 Case Else
  MsgBox("Case """ & pWhat & """ not implemented!", 0, "Unknown Case")
End Select
End Sub

The code is also contained in this attached example, where you also find some additional explanations, and a few comments on strangenesses concerning text processing.