Ask Your Question

selectively clear direct formatting [closed]

asked 2013-05-06 11:06:47 +0200

Aegluin gravatar image

updated 2013-05-06 11:55:54 +0200

I have to insert text from MS-Word documents into Writer that have a lot of direct formatting (fonts, font sizes etc.). However, superscript and subscript have here a semantic meaning (formulars, units) and need to be preserved.

When I do Format > Clear direct formatting it removes all formatting and I have to do a lot manual work restoring the superscript/subscript formatting. Is there a more efficient way?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-19 06:10:11.654885


Are you sure, that there is not a character style applied?

m.a.riosv gravatar imagem.a.riosv ( 2014-02-02 02:20:57 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2013-05-06 13:33:52 +0200

mahfiaz gravatar image

updated 2018-09-17 06:25:26 +0200


There is a much easier way to achieve this, answered by @pierre-yves-samyn:

Original answer

I have used the following workaround:

  1. Search with regular expressions for (.*) with desired style, e.g for bold (see formatting button on lower right corner).

  2. Replace it with e.g <b>$1</b>

  3. Repeat with all other formatting you need, e.g italics and super- or subscript.

  4. Select all, Clear all Formatting. Now your document looks something like "This <b> was bold,</b>, this was <i>italic</i>."

  5. Do it the other way around. Search for <b>([^<]*)</b> and replace it with $1 and let the replace box have the desired formatting.

And you are done.

BTW, formatting applies to "search for" or "replace with" boxes, depending on which one is selected. So does the "No formatting" button.

edit flag offensive delete link more


Thank you for your reply! Actually I will test another versions, like EuroOffice or something. In OO I was able to assign a shortcut to this function, and have it at one click. And so my colleagues. Compare this to your kind recipe. Looks like someone manages LO development in the way to make it less, and less usable for an average user.

frankaen gravatar imagefrankaen ( 2014-02-11 10:00:53 +0200 )edit

@frankaen, true. But hey, why not write an extension?

mahfiaz gravatar imagemahfiaz ( 2014-03-20 00:47:08 +0200 )edit

Very confusing mistake in the explanation at step 2: you need to use $0, not $1 or the output will be empty. The method is very effective though!

darioshanghai gravatar imagedarioshanghai ( 2014-11-01 19:09:48 +0200 )edit

@darioshanghai, no not a mistake at all. $0 returns the whole match, while $1 is just the first group, which means anything inside first pair of parenthesis (). So if your search is (.*) not .*, then it will work just fine. Although for this case using .* and $0 would be 2 characters shorter.

mahfiaz gravatar imagemahfiaz ( 2016-08-13 19:22:14 +0200 )edit

answered 2014-02-01 23:36:54 +0200

frankaen gravatar image

Interesting that in your case Clear Direct Formatting works, because I have some characters formatted more than bold, italic and so on, and CDF removes only this simple formatting, but not advanced, like changed intercharacter space, underline, colour.

edit flag offensive delete link more

Question Tools


Asked: 2013-05-06 11:06:47 +0200

Seen: 1,178 times

Last updated: Sep 17 '18