Ask Your Question

Find and replace or remove character border

asked 2019-11-03 14:55:51 +0100

Dogbertus gravatar image

updated 2020-08-16 12:18:30 +0100

Alex Kemp gravatar image

How do I find and replace multiple instances of text with a box around it, which was applied using Character>border? There are multiple instances of roman numerals I, IV, IX and so on all over my document. Some have additional characters e.g, Ⅱ ➊ c .
I want to find and remove all borders. I cannot find an option to isolate character borders in "Find and Replace" or in Alt-Search. Thanks!

edit retag flag offensive close merge delete


Find & Replace` offers only a limited choice of attributes. Notably "border" is not possible, probably because it would involve a complex criterion (a border is drawn around a sequence of characters/pargraph, not basically around an individual character -- though this ia a limit case). It cannot also find a character style.

In your question, what is the relation with Roman numerals and "additional characters"? Are they exclusively included in your "bordered" sequences? This could be another angle of attack.

Either, edit your question (not an answer) or add a comment.

ajlittoz gravatar imageajlittoz ( 2019-11-04 10:03:16 +0100 )edit

Thanks for the response. The borders are used to highlight chapter numbers I to IX, which are (thankfully) in a different font using a single glyph (I and III are both single glyphs). I could have run a search for each glyph and changed them manually but in most cases the glyph is followed by a sub-chapter and sometimes by a paragraph reference in the following format: "IV4b" without the double-quotes. IV4b has a border around it. This is the pain. "Find all" does catch the glyph, but then I have to manually select the 4b to remove the borders. Another bother is that sometimes there is a gap between the chapter glyph (IV) and the sub-chapter (4) while at other times there is no gap. Any ideas? Regular expressions? Thanks for your help!

Dogbertus gravatar imageDogbertus ( 2019-11-04 10:20:14 +0100 )edit

If your use case is a special formatting of the number in the chapter/subchapter/… headings (and not in a reference to the heading), a better solution is to use the standard Heading n styles with a customised chapter numbering (no space between level elements) and a specific character style for the numbering. This character could be decorated or not with a border. Thus you have a single location to control your chapter numbering formatting.

ajlittoz gravatar imageajlittoz ( 2019-11-04 11:54:08 +0100 )edit

I've already changed the headings... It's the in-paragraph references that are killing me. All of them use the same paragraph style ("text body"). Looks like this one has to be done manually. Thanks. I'll mark this as closed with a note that it cannot be done using "Find and Replace".

Dogbertus gravatar imageDogbertus ( 2019-11-04 12:39:22 +0100 )edit

By the way: LibO only started to support that hokum (character bordering) with V 4.2 and Apache OpenOffice still doesn't support it at all. If not there are other LibO features you actually need, you may open your document in AOO, and save it again. AOO will not have interpreted the CharBorder thing, and will therefore also not write it to the file.

Lupp gravatar imageLupp ( 2019-11-04 18:08:58 +0100 )edit

2 Answers

Sort by » oldest newest most voted

answered 2019-11-04 17:15:14 +0100

Lupp gravatar image

updated 2019-11-04 17:30:01 +0100

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("") 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)
 workOnFormatOfTheSingleTextRange(rg_j, pWhat)
Next j
End Sub

Sub workOnFormatOfTheSingleTextRange(pRange As Object, pWhat As String)
hDoc  = ThisComponent
hCtrl = hDoc.CurrentController
Select Case pWhat
 Case "removeCharBorders"
  selOnEnter = hDoc.CurrentSelection
  nowSel = hDoc.CurrentSelection(0)
  Dim bH As New
  nowSel.CharLeftBorder   = bH
  nowSel.CharRightBorder  = bH
  nowSel.CharTopBorder    = bH
  nowSel.CharBottomBorder = bH
  nowSel.CharBorderDistance = 0
 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.

edit flag offensive delete link more


Thanks! Thanks! Thanks!

Dogbertus gravatar imageDogbertus ( 2019-11-04 21:39:37 +0100 )edit

Did I thank you enough? Thanks, once more!

Dogbertus gravatar imageDogbertus ( 2019-11-04 21:40:57 +0100 )edit

Sorry. As I just notice the code contains relics of premature states.
It should work as expected nonetheless.

Lupp gravatar imageLupp ( 2019-11-04 22:11:19 +0100 )edit

answered 2019-11-04 12:41:45 +0100

Dogbertus gravatar image

updated 2019-11-04 21:39:11 +0100

Thanks to ajlittoz for your suggestions. All hail Lupp the Guru!! It worked. You just saved me a day of work. Thank you! Thank you!

edit flag offensive delete link more


Please use the comments as you have done before, or edit the question to add more information.

m.a.riosv gravatar imagem.a.riosv ( 2019-11-04 13:42:52 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-11-03 14:55:51 +0100

Seen: 175 times

Last updated: Nov 04 '19