[Solved Elsewhere] A Specific Macro with Find-Replace?

Creating a macro - Writing a Script - Using the API

Re: A Specific Macro with Find-Replace?

Postby robleyd » Tue Aug 01, 2017 11:07 am

So there is no duplication of effort, this same question is asked on the Ask LibO site under a different username.
Cheers
David
Apache OpenOffice 4.1.4 - Windows 7
Apache OpenOffice 4.1.4 - Slackware 14.2 - 64 bit
User avatar
robleyd
Moderator
 
Posts: 1087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: A Specific Macro with Find-Replace?

Postby rajibando » Tue Aug 01, 2017 4:45 pm

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.
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Re: A Specific Macro with Find-Replace?

Postby rajibando » Fri Aug 04, 2017 7:42 am

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?
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Re: A Specific Macro with Find-Replace?

Postby hubert lambert » Thu Aug 17, 2017 10:07 am

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)
 
Attachments
rajibando (linux).odt
(16.26 KiB) Downloaded 15 times
rajibando.odt
(16.28 KiB) Downloaded 19 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 59
Joined: Mon Jun 13, 2016 10:50 am

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

Postby rajibando » Fri Aug 25, 2017 6:36 pm

This problem was totally solved here: A Specific Macro with Find-Replace? by Hubert Lambert.
LibreOffice 4.0.3.3 (Build ID: 400m0(Build:3)) in Knoppix 7.2.0
rajibando
 
Posts: 52
Joined: Sat Jul 29, 2017 4:59 am

Previous

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests