Page 2 of 2

Re: A Specific Macro with Find-Replace?

PostPosted: Tue Aug 01, 2017 11:07 am
by robleyd
So there is no duplication of effort, this same question is asked on the Ask LibO site under a different username.

Re: A Specific Macro with Find-Replace?

PostPosted: Tue Aug 01, 2017 4:45 pm
by rajibando
Roblyed took all the troubles to post the above info post to ask.libreoffice also.
As an aside, the contribution of Librebel was acknowledged in the very first post here: A Specific Macro with Find-Replace? None has yet solved the case. So duplication doesn't yet occur. Everyone has been duly informed, as far as possible, that Zizi was also working on it.

Re: A Specific Macro with Find-Replace?

PostPosted: Fri Aug 04, 2017 7:42 am
by rajibando
I found that I can catch the "↲¶" combination with the normal Find-Replace (Ctrl+H) using the string "\n$". But when I use the same string in the macro, like "\n" + "$", or "\n$" and try to replace it with `ch(10)` I can't.
Why?

Re: A Specific Macro with Find-Replace?

PostPosted: Thu Aug 17, 2017 10:07 am
by hubert lambert
Hello,

Perhaps something like this would do the trick:
Code: Select all   Expand viewCollapse view
sub main
    doc = thiscomponent
    rajibando_find_and_remplace(doc.Text)
end sub

sub rajibando_find_and_remplace(T)
    do
        for each para in T
            if T.compareRegionEnds(T, para) = 0 then
                exit sub
            end if
            c = T.createTextCursorByRange(para.End)
            c.goRight(2, True)
            firstchar = mid(c.String, 3, 1)
            if not isnumeric(firstchar) then
                c.String = chr(10) & firstchar
                exit for
            end if
        next para
    loop
end sub

On linux amend this way:
Code: Select all   Expand viewCollapse view
            firstchar = mid(c.String, 2, 1)


 Edit: More simple, to stay plateform independant:
Code: Select all   Expand viewCollapse view
            firstchar = mid(c.String, len(c.String), 1)
 

[Solved]Re: A Specific Macro with Find-Replace?

PostPosted: Fri Aug 25, 2017 6:36 pm
by rajibando
This problem was totally solved here: A Specific Macro with Find-Replace? by Hubert Lambert.