I almost NEVER use direct formatting in Writer—I use named styles for. almost everything. My body-text styles are 11pt. I have discovered that there are several places where the text is direct formatted to 12pt. I would like to be able to search for this condition and manually remove the direct formatting.
Unfortunately, there is no search function for direct formatting (nor for character styles either).
The only way I know is to select some block of text, say one or a couple of paragraphs, and Ctrl+M (clear direct formatting). Watch your screen for any apparent change. You can Ctrl+Z to revert to the previous formatting to carefully analyse the differences.
Another approach is to use the Style Inspector of the side style pane, but I’d use it after the previous method to have the exact direct formatting applied (although list numbering is reported as direct formatting even if a list style has been applied).
This works for text. Direct formatting on list, page and frame styles can’t be eliminated with Ctrl+M. My trick is to apply another style then re-apply the original style, effectively eliminating added direct formatting.
I wonder why nobody has ever written a macro for this. As far as I know the Writer API, it is possible to split a text body into equally formatted subsequent snippets of text. For each snippet it should be possible to determine which properties have a default value based on the underlying style. The other non-default properties would be the hard formatted ones.
Some users tend to think of a text document as one text.
In fact, you know, each cell of a TextTable in the document is (has; looping back) a text object. Same with any TextFrame. Even shapes are text objects, but the services are reduced in their case. (I put them aside.)
Thus you may need to pass and regard lots of parameters telling the needed routine first of all what texts it should parse and how to handle the different situations.
You may start with
doc = ThisComponent
textObjects = Array(doc.Text)
uTexts = 0
tTs = doc.TextTables
uTTs = tTs.Count - 1
For t = 0 To uTTs
t_T = tTs(t)
t_CellNames = t_T.CellNames
t_CNum = Ubound(t_CellNames)
For j = 0 To t_CNum
j_cell = t_T.getCellByName(t_CellNames(j))
uTexts = uTexts + 1
Redim Preserve textObjects(uTexts)
textObjects(uTexts) = j_cell
Next j
Next t
tFs = doc.TextFrames
uTFs = tFs.Count - 1
For f = 0 To uTFs
t_F = tFs(f)
uTexts = uTexts + 1
Redim Preserve textObjects(uTexts)
textObjects(uTexts) = t_F.Text
Next f
For k = 0 To uTexts
k_text = textObjects(k)
For Each level1Part
REM Skip TextTable here
REM and so on (second level)
Lots of fun.
Searching for specific character attributes not set with the help of a character style is supported using the options Attributes...
and Format...
of the F&R dialog and leaving the field Find:
empty.
There also recently was the topic Finding directly formatted text in specific type size where I presented related code for “macro addicts” in an example.
What @Villeroy suggested also can be done, of course, but in this topic the actual question again was about font heights, though the subject looked more general.
New edxample:
disask76298CharHeightAgain.odt (54.0 KB)
And for this question, you must check Font size. This will find only text whose size was set by direct formatting. In your example, it will find 12pt text in the body-text style of 11pt, but won’t find 12pt text if the style states that the size is 12pt.