Altsearch slow in replacing

i have a file that have lot of footnotes, every footnote is written between twoo brackets manually, i want to remove all those brackets but there are other texts that are between brackets
so i think of using AltSearch
i tried: ([::Footnote::]) but it finds nothing
so i tried:
1- replaced every [::Footnote::] with: “-footnote-”
and after that:
2- i replace every (- with empty and every -) with empty

in the first replace it is slow and every time it takes me to the page of the footnote and replace it. why it takes me to the footnotes and generate the page? i think this may make it slower, it should replace it directly to be more fast. is there a way to make it faster in such replacing actions?

-----system info
OS: Manjaro
save format: odt
LO: Version: 24.2.2.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 4; OS: Linux 6.9; UI render: default; VCL: kf6 (cairo+wayland)
Locale: ar-DZ (en_US.UTF-8); UI: en-US
24.2.2-3
Calc: threaded

Please share one or two sample files containing the problem and the expected result of one’s proceeding. - Thank you.

test file.odt (37.0 KB)

if i have a file with about 900 footnotes the task will be slower

but the second replace: (- with empty: this is made it with the original libreoffice search and replace and it is fast

Do you want to only remove the brackets (which include the footnote anchor) or do you want to remove the two brackets and the footnote anchor?

To remove the two brackets and the footnote anchor you could use FIND&REPLACE (regular expressions activated):


SEARCH: \(.{1}\) which means that there is only one figure between the brackets (so from 1 up to 9). If there are 10 or more you could use \(.{1,2}\)


To only delete the brackets and not to delete the footnote anchor I did not find a solution. - Cheers

1 Like

i want to only remove the brackets (which include the footnote anchor)

Hallo

def remove_braces_around_footnotes(*_):
    doc = XSCRIPTCONTEXT.getDocument()
    cursor = doc.Text.createTextCursor()
    footnotes = doc.Footnotes
    un_do = doc.UndoManager
    un_do.enterUndoContext("remove_braces")
    for footnote in footnotes:
        cursor.gotoRange(footnote.Anchor.Start, False)
        cursor.goLeft(1,True)
        if cursor.String == '(':
            cursor.String = ''
        cursor.gotoRange(footnote.Anchor.End, False)
        cursor.goRight(1,True)
        if cursor.String == ')':
            cursor.String = ''
    un_do.leaveUndoContext()

its python, maybe you need apso.oxt to manage python_scripts

1 Like

@karolus
Couldn’t you write an extension (.oxt) for adding and deleting characters before and after footnote anchors? This could be helpful for some authors…
Cheers

1 Like