[Solved] Writer macro: Action based on paragraph style.

The Application Programming Interface and the OASIS Open Document Format

[Solved] Writer macro: Action based on paragraph style.

Postby kocj » Mon Aug 20, 2018 9:12 am

Hello community, I am new here, hopefully I have done everything right.

I am looking for help to create a macro that adds some bits of text, of a defined style, just before and after all paragraph of an other style. Lets assume that I have a paragraph style called mystyle. Now the macro should add @@.ta just before and @@ just after the paragraph, those bits of text should use myothersyle. The result should look like this.

Whitespace (Myothersyle)
@@.ta (Myothersyle)
Mstyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle
@@ (Myothersyle)
whitespace (Myothersyle)

To my understanding it should be possible to have a macro handling that. Till now I use two recoded macros and apply one before the paragraph and one after the paragraph. I works, but it is an error prone approach.

I am quite new to macros and do not have experience in programming at all. I would really appreciate that someone cold help me out with an example, that could adjust to my meeds later on. I tried to get some knowledge of the document from Andrews Pitonyaks BASIC-Makros für OpenOffice und LibreOffice. That did not really help me to go on with the macro.

Thanks

Kocj
Last edited by kocj on Thu Aug 23, 2018 9:52 am, edited 2 times in total.
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am

Re: Writer macro: Action based on paragraph style.

Postby RoryOF » Mon Aug 20, 2018 9:21 am

Why use a macro?

Extension AltSearch
will do this.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29294
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer macro: Action based on paragraph style.

Postby kocj » Mon Aug 20, 2018 9:36 am

Thank you, I will try it out.
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am

Re: Writer macro: Action based on paragraph style.

Postby kocj » Mon Aug 20, 2018 4:58 pm

@ RoryOF

I have tried AltSearch now for a wile, I am very happy as it also solves an other solutions I was looking for. Thank you.

I did not find an option to group paragraphs of the same style. The reality i face looks more like:

Paragraph> Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle <Paragraph
Paragraph> Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle <Paragraph
Paragraph> Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mysty Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle <Paragraph
Paragraph> Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle Mystyle <Paragraph

Paragraph> OtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyle <Paragraph
Paragraph> OtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyleOtherstyle <Paragraph

I would like to markup a bundle of the same paragraph style only once. A lot of sentences are quite short, that makes it difficult to to do minor edits that might be needed once marked up. Is there any other way to achieve that.

The marked up documents will be displayed in a https://tiddlywiki.com later.
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am

Re: Writer macro: Action based on paragraph style.

Postby RoryOF » Mon Aug 20, 2018 5:06 pm

My immediate thought is that I would mark up the string of paragraphs this way
<beginmark>
Mystyle para
<endmark>
<beginmark>
Mystyle para
<endmark>
<beginmark>
Mystyle para
<endmark>

Now search and delete the sequence
<endmark>
<beginmark>

This will leave the above sequence as
<beginmark>
Mystyle para
Mystyle para
Mystyle para
<endmark>

which is I think what you require.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29294
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer macro: Action based on paragraph style.

Postby kocj » Tue Aug 21, 2018 6:02 pm

@ RoryOF

sorry,I am not able to catch the sequence <endmark><beginmark>, not even if I try it on the example you provided. What do i do wrong? How to delete the mark and the paragraph too?
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am

Re: Writer macro: Action based on paragraph style.

Postby RoryOF » Tue Aug 21, 2018 6:14 pm

The Help file can be downloaded from [url](http://www.volny.cz/macrojtb/HelpAltSearch_en.html)p[/url]

I think you will have to read through this carefully and experiment with sequences to sort out your problem, if it is sortable.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29294
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer macro: Action based on paragraph style.

Postby kocj » Tue Aug 21, 2018 6:45 pm

Yes, it's the same help page that comes up if pressed the ? in the extension. I have been studding for 8 hours the last tow days, to come that far. ;)

Just to get me running, a solution for this example would be enough.

My immediate thought is that I would mark up the string of paragraphs this way
<beginmark>
Mystyle para
<endmark>
<beginmark>
Mystyle para
<endmark>
<beginmark>
Mystyle para
<endmark>

Now search and delete the sequence
<endmark>
<beginmark>

This will leave the above sequence as
<beginmark>
Mystyle para
Mystyle para
Mystyle para
<endmark>

which is I think what you require


What to put in the search box, witch option to choose. Thanks
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am

Re: Writer macro: Action based on paragraph style.

Postby RoryOF » Tue Aug 21, 2018 7:31 pm

The AltSearch Help file says
List box 'Extended'

[::BigBlock::] - searches for a block of paragraphs (of unlimited length) delimited by some known text:

start[::BigBlock::]end – first, start is searched for, and when it is found, end is searched for. If both are found, the whole block between them is selected.

In the replace string you can use the parameters \b, & or \e for inserting the contents of start, found block of paragraphs, or end, respectively.

Limitation: In the initial and final strings you cannot use the || sign for multiple searching and replacing; see below.



This is probably the search construct you need.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29294
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Writer macro: Action based on paragraph style.

Postby kocj » Tue Aug 21, 2018 8:02 pm

Found the solution, this will mark the sequenze.

Code: Select all   Expand viewCollapse view
<endmark>\p<beginmark>


Thank you very much for your help.
Libreoffice 5.3 and 6.1 on Debian Stretch 9.5
kocj
 
Posts: 13
Joined: Mon Aug 20, 2018 8:19 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest