[Writer] Set font color to all matching regex ?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

[Writer] Set font color to all matching regex ?

Post by BubikolRamios »

should be something/or not along createReplaceDescriptor , but can't find anything ...
OPen office 4.1.5/ win 7
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro - set font color to all matching regex ?

Post by JeJe »

There's an example of setting the search attributes in Useful Macro Information For OpenOffice By Andrew Pitonyak

Edit:
And replace attributes.
You could also use the macro record to get a solution.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: macro - set font color to all matching regex ?

Post by Villeroy »

menu:Edit>FInd&Replace...
do the regex search and hit [Find All]
Apply a prepared character style or some formatting attribute.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: macro - set font color to all matching regex ?

Post by eeigor »

Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: macro - set font color to all matching regex ?

Post by BubikolRamios »

Villeroy wrote:menu:Edit>FInd&Replace...
do the regex search and hit [Find All]
Apply a prepared character style or some formatting attribute.
How to undo 'find all', I mean text stays selected, don't want that.

Click somewhere does it, but this is part of macro so it should be automatic. There is no edit/'unselect all'.
OPen office 4.1.5/ win 7
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro - set font color to all matching regex ?

Post by JeJe »

Store the selection before you do whatever operation than select it again afterwards.

Code: Select all


vc = Thiscomponent.currentcontroller.viewcursor
tc = vc.text.createtextcursorbyrange(vc)
'... do whatever
thiscomponent.currentcontroller.select(tc)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply