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

Creating a macro - Writing a Script - Using the API

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

Postby rajibando » Sat Jul 29, 2017 5:51 am

[Solved at the link posted in the last post of this thread]
I am new to LibreOffice / OpenOffice Macro programming.
I posted the following thread to the LibreOffice forum:
I want to build a Specific Macro with Find-Replace
I received a partial response with codes, and also guidance to reach and download from OOoFBTools with a lot of codes, which I can't yet properly discern as I have just begun reading the APIs.
I want to build this macro:
  • I will have two String variables declared within the macro.
  • I use Find with Wild Characters to find out texts like [a-z,A-Z,0-9]$. (These are usually the Title for the Paragraph.)
  • For the first string my find encounters, I take this entire string into the string variable, including the ¶ mark.
  • I then count the length of the string. Suppose this is n.
  • I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
  • I replace the first string with this second string.
  • I do this from the top every time, till there are no other such entries I wish to replace.

Could I be helped with the Macro creation?
Last edited by rajibando on Sat Sep 02, 2017 3:34 am, edited 3 times in total.
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 robleyd » Sat Jul 29, 2017 7:04 am

You may find an issue with replacing ¶ (paragraph marker) with ↲ (new line) as AOO, and possibly LO, has a 64K limit on the size of a paragraph; paragraphs as you doubtless know are delimited by the ¶
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.2.0 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 944
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: A Specific Macro with Find-Replace?

Postby Zizi64 » Sat Jul 29, 2017 7:14 am

I want to build this macro:

I will have two String variables declared within the macro.
I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.)
For the first string my find encounters, I take this entire string into the string variable, including the ¶ mark.
I then count the length of the string. Suppose this is n.
I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
I replace the first string with this second string.
I do this from the top every time, till there are no other such entries I wish to replace.


Why you need a new macro for this task? It seems a normal "Find and replace" procedure. (Maybe you need install the Alternative F&R extension. As I remember, that extension can seach for the ¶ mark and can replace it with ↲ mark.)

Be careful with the changing ¶ marks to ↲ marks. (see robleyd's post).

https://extensions.openoffice.org/en/pr ... -altsearch
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 8:02 am

Thank you, Zizi64 and robleyd for posting so quickly!
I need the macro because I wish to (1) replace the ¶ with ↲ for strings satisfying `[a-z,A-Z,0-9]¶` and (2) keep ¶ for strings satisfying `[.]¶`

Had you kindly perused the Ask.LibreOffice link I had provided with my thread, you would see that I need to add "&"+"Ch(10)" and then remove the empty paragraphs with find "^$" with the complete code provided.
But the problem is: if I use the macro code, then the Find "^$" no longer works! Says, "Search key not found."
test.odt
You could test with this file
(11.27 KiB) Downloaded 31 times

Code Courtesy: Librebel
Code: Select all   Expand viewCollapse view
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
    Dim oReplace as Object
    oReplace = ThisComponent.createReplaceDescriptor()
    oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
    oReplace.setReplaceString( "&" + chr(10) )
    oReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
End Function
Last edited by rajibando on Sat Jul 29, 2017 7:22 pm, edited 2 times in total.
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 Zizi64 » Sat Jul 29, 2017 8:20 am

Please upload your sample ODF type Writer file with the embedded macros (with all of the related macro functions and procedures).
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 8:31 am

Posted above in the edited post while you were typing! Sorry! How does one embed macros with a file?

BTW, Alternative F&R extension is complicated, without visual examples.
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 Zizi64 » Sat Jul 29, 2017 9:47 am

Posted above in the edited post while you were typing!


OK thanks, I see the attachment now.



Sorry! How does one embed macros with a file?

Copy the macro code into a Module of the Standard Library of the document. (You need create a Module before)



BTW, Alternative F&R extension is complicated, without visual examples.

Alt_F&R.png
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby RoryOF » Sat Jul 29, 2017 9:54 am

AltSearch help file is at
http://mujweb.cz/macrojtb/HelpAltSearch_en.html?redirected=1501314727

Learn how to use AltSearch rather than reinvent the wheel.
Apache OpenOffice 4.1.4 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25077
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: A Specific Macro with Find-Replace?

Postby Zizi64 » Sat Jul 29, 2017 9:58 am

Alt_F&R_2.png
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby robleyd » Sat Jul 29, 2017 10:10 am

AltSearch help is also available from the question mark ? in the Altsearch window.
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.2.0 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 944
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: A Specific Macro with Find-Replace?

Postby Zizi64 » Sat Jul 29, 2017 10:15 am

Note:
Replacing ¶ (paragraph marker) with ↲ (new line) will convert your original Style-formatted text into ONE paragraph wich will have ONE paragraph style.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 10:40 am

RoryOF wrote: ... Learn how to use AltSearch rather than reinvent the wheel.

Very clumsily written! I had seen it earlier, but chose to avoid 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 » Sat Jul 29, 2017 10:44 am

Zizi64 wrote:Note:
Replacing ¶ (paragraph marker) with ↲ (new line) will convert your original Style-formatted text into ONE paragraph wich will have ONE paragraph style.

That was only a sample file for illustration!
And thanks for the snapshot!
I am irritated at the very thought of negotiating that clumsy help link of Alt-Search! Only if the creator could write a reader-friendly help file!
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 Zizi64 » Sat Jul 29, 2017 10:51 am

I am irritated at the very thought of negotiating that clumsy help link of Alt-Search! Only if the creator could write a reader-friendly help file!


The extensions usually are third-pary softwares. Please contact with the distributor.
http://mujweb.cz/macrojtb/HelpAltSearch_en.html
And the extensions usually are open source softwares. You can modify them as you want it.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 10:54 am

BTW, how did you Find-Replace for that file I uploaded? Thank you in advance!

Zizi64 wrote:The extensions usually are third-pary softwares. Please contact with the distributor.
Yes, I am aware of it!

Zizi64 wrote:And the extensions usually are open source softwares. You can modify them as you want it.
A considerable challenge! 1st, to understand the methods by reading the usage, then editing and modifying the content!
Moreover, the programmer doesn't even have a contact email-Id.!
Last edited by rajibando on Sat Jul 29, 2017 11:11 am, edited 1 time in total.
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 Zizi64 » Sat Jul 29, 2017 11:06 am

A considerable challenge! 1st, to understand the methods by reading the usage, then editing and modifying the content!


You wrote:
I want to build a Specific Macro with Find-Replace

I supposed you have some knowledge to create (write) macros...
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby Zizi64 » Sat Jul 29, 2017 11:09 am

BTW, how did you Find-Replace for that file I uploaded? Thank you in advance!


I just used the AltSearch extension as the attached pictures show you... Do not forget to check in the "Regular expressions" option.
Last edited by Zizi64 on Sat Jul 29, 2017 12:48 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 11:17 am

Zizi64 wrote:... I just used the AltSearch extension as the attached pictures show you...

I am so sorry! I only checked from the thumbnail image of this forum that ¶ (paragraph mark) was replaced by ↲ (new line) and so I knew one could do it with alt-search if one wanted to.
BTW, do you have the contact email-id of the developer? The page doesn't appear to have that!
Last edited by rajibando on Sat Jul 29, 2017 11:18 am, edited 1 time in total.
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 RoryOF » Sat Jul 29, 2017 11:18 am

rajibando wrote:I am irritated at the very thought of negotiating that clumsy help link of Alt-Search! Only if the creator could write a reader-friendly help file!


From memory, the author of the AltSearch extension is not a native English speaker. If you don't like it, don't use it; write something better if you wish.
Apache OpenOffice 4.1.4 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25077
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: A Specific Macro with Find-Replace?

Postby robleyd » Sat Jul 29, 2017 11:26 am

There is a link to the author both on the online help at the link Zizi64 posted, and also from the same help page available locally through the help on the Altsearch window. To save you looking it up, the link is http://mujweb.cz/macrojtb/?redirected=1501320128; it appears to be in the Czech language but there is an email address.
Cheers
David
OpenOffice 4.1.3 - Windows 7
OpenOffice 4.2.0 - Slackware 14.2 - 64 bit
User avatar
robleyd
Volunteer
 
Posts: 944
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 12:28 pm

robleyd wrote:There is a link to the author both on the online help at the link Zizi64 posted, and also from the same help page available locally through the help on the Altsearch window. To save you looking it up, the link is http://mujweb.cz/macrojtb/?redirected=1501320128; it appears to be in the Czech language but there is an email address.

And I thank you for your kindness!
I found the email-id once you said there was one.
My script blocker had blocked the javascript in the original Czsech page.
The code was here:
Code: Select all   Expand viewCollapse view
<p align="RIGHT">Tomáš Bílek -  <script language="JavaScript">mkemail('macrojtb','volny.cz','?subject=cs - ');</script></p></div>
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 » Sat Jul 29, 2017 3:48 pm

@Zizi64:
You used only `$` in the `find` textbox, while I used `[a-z,A-Z,0-9]$` and replaced those para with `\n`
After I have replaced the ¶ (paragraph marker) with ↲ (new line) with Alt-Search, I find that ↲ is immediately followed by an empty ¶.
Strangely, if I want now to replace the created `^$` with no character, Alt-Search can't find any empty paragraph!
I am attaching the modified file here:
test.odt
The modified Test file
(11.3 KiB) Downloaded 28 times

Maybe my version of LibreOffice has a bug. The version of AlternateSearching I used is 1.4.2 of 3/2017, file size 562.1 KiB (575,605 bytes)

[Later]
No, please check your snapshot with my requirement. Only the lines with `[a-z,A-Z,0-9]$` had to have the `$` (¶ i.e., paragraph marker) replaced by a ↲. Also, your first line and second line got joined!
Last edited by rajibando on Sat Jul 29, 2017 7:20 pm, edited 1 time in total.
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 Zizi64 » Sat Jul 29, 2017 4:26 pm

Maybe I not understood your task exactly. Please upload your document with BEFORE and AFTER state text. (make a copy of the text and modify it manually.)
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Sat Jul 29, 2017 6:11 pm

The earlier file I uploaded first.
The work I did:
to (1) replace the ¶ with ↲ for strings satisfying `[a-z,A-Z,0-9]$` and to (2) keep ¶ for strings satisfying `[.]¶`
The amended file after Alt-Search after find-replace operation, here.

After I have replaced the ¶ (paragraph marker) with ↲ (new line) with Alt-Search, I find that ↲ is immediately followed by an empty ¶. I also find that the character immediately preceding ¶ is also deleted.

But if I used `&\n` in Alt-search, the Replace option gives the following error message:
Code: Select all   Expand viewCollapse view
BASIC runtime error.
An exception occurred
Type: com.sun.star.resource.MissingResourceException
Message: StringResourceImpl: No entry for ResourceID: \n.
and halts at the macro code `seznam.addItem(neco,0)` of `sub pridejDoSeznamuA(seznam, neco, promene, pevne)`

Strangely, if I want now to replace the created `^$` with no character in the `Replace` box,, Alt-Search can't find any empty paragraph!

In normal LibreOffice Find-Replace, I would have needed `&\n` but it would again be an addition of `$` (i.e., visually, ¶ addition).

Only the macro-code I was provided with does some justice but with an addition of `$` (i.e., visually, ¶ addition)!

What I want is this file:
WhatIwant.odt
(11.31 KiB) Downloaded 22 times


If at all possible, will this indicated alteration to the original codes I was given, do?:
Code: Select all   Expand viewCollapse view
rem *****************************************
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
    Dim oReplace as Object
    oReplace = ThisComponent.createReplaceDescriptor()
    oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
    oReplace.setReplaceString( "&" + chr(10) )
    oReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
REM Reiteration to remove empty paras after above action
     Dim oDReplace as Object
    oDReplace = ThisComponent.createReplaceDescriptor()
    oDReplace.setSearchString( "^$" )
    oDReplace.setReplaceString( "" )
    oDReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oDReplace )
End Function
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 » Mon Jul 31, 2017 9:17 am

Okay, read and found a solution! But help me make it run as intended.
Created two functions and ran them, one after the other.

Code: Select all   Expand viewCollapse view
rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
    Dim oReplace as Object
    oReplace = ThisComponent.createReplaceDescriptor()
    oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
    oReplace.setReplaceString( "&" + chr(10) )
    oReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
    End Function

&
Code: Select all   Expand viewCollapse view
REM Reiteration to remove empty paras after above action
    Function Writer_ReplaceAll_Blank_Paras() As Long
    Dim bReplace as Object
    bReplace = ThisComponent.createReplaceDescriptor()
    bReplace.setSearchString( chr(10) + "^$" )
    bReplace.setReplaceString( chr(10)  )
    bReplace.SearchRegularExpression = True
    Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
   End Function

Then I run the first, then the second, The second one is not running as intended.
I have to have your help to catch the error.
Regards
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 Zizi64 » Mon Jul 31, 2017 9:50 pm

Code: Select all   Expand viewCollapse view
oReplace.setSearchString( "[a-z,A-Z,0-9]$" )

Do you want replace the "Paragraph End" mark to LineFeed mark, when the last letter of the paragraph IS a letter of the array A-Z OR a-z OR a 0-9 numeric character or a COMMA?
But you want not replace it, when the last letter of the paragraph IS a space OR dot OR exclamination mark OR a question mark OR all of other special characters?
Your first macro can to do this.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby Zizi64 » Mon Jul 31, 2017 10:05 pm

Fhjb iui ugigh ugg↲

The pilcrow in the second line of the attached rext IS NOT an empty paragraph, because the LineFeed mark IS NOT a paragraph end mark. Therefore the all of the characters and marks in this two lines mean ONE paragraph only. You will not recognise the pilcrow (¶) as an empty paragraph, because that is not an empty paragraph, but that is the END MARK of the only one paragraph.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Tue Aug 01, 2017 4:05 am

Zizi64 wrote:
Code: Select all   Expand viewCollapse view
oReplace.setSearchString( "[a-z,A-Z,0-9]$" )

Do you want replace the "Paragraph End" mark to LineFeed mark, when the last letter of the paragraph IS a letter of the array A-Z OR a-z OR a 0-9 numeric character or a COMMA?
But you want not replace it, when the last letter of the paragraph IS a space OR dot OR exclamination mark OR a question mark OR all of other special characters?
Your first macro can to do this.

Yes, but how? 'Comma', 'space', 'exclamation mark', 'question mark' I can add later with an escape char `\` before the marks.
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 Zizi64 » Tue Aug 01, 2017 7:01 am

Yes, but how? 'Comma', 'space', 'exclamation mark', 'question mark' I can add later with an escape char `\` before the marks.


If you will replace ALL of the paragraph marks from your document, you will be in truble. (Please read robleyd's first answer.)
In that case your text wil be tranfromed into only one pararaph, and that only one paragraph (maybe) will reach the limit of the charater numbers in a paragraph.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.6 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5909
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: A Specific Macro with Find-Replace?

Postby rajibando » Tue Aug 01, 2017 7:14 am

Zizi64 wrote:If you will replace ALL of the paragraph marks from your document...

change_from_this to_this.jpeg
Just changing from this to this

If you look at the code, you will notice that I am not removing all paragraph marks from my document.
So, please ...
Last edited by rajibando on Fri Aug 04, 2017 7:28 am, edited 1 time in total.
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

Next

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests