# Find and replace or remove character border

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 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.

( 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!

( 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.

( 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".

( 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.

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

Sort by » oldest newest most voted

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)
workOnFormatOfTheSingleTextRange(rg_j, pWhat)
Next j
currC.select(oldSel)
End Sub

Sub 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
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.

more

Thanks! Thanks! Thanks!

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

Did I thank you enough? Thanks, once more!

( 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.

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

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!

more

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

( 2019-11-04 13:42:52 +0100 )edit

## Stats

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

Seen: 61 times

Last updated: Nov 04