https://bugs.documentfoundation.org/show_bug.cgi?id=173130
Bug ID: 173130
Summary: Unprotected path to "illegally" editing the "No
Character Style" character style results in possible
XML style code corruption
Product: LibreOffice
Version: 26.2.4.2 release
Hardware: x86-64 (AMD64)
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Writer
Assignee: [email protected]
Reporter: [email protected]
Description:
EXECUTIVE SUMMARY
If you're short on time, energy, and motivation, skip down to LIKELY BUG AND
POSSIBLE SOURCE OF XML CORRUPTION. Then, if you're interested in the details,
or if your reaction is "So what?", read the preliminary background stuff
immediately below.
PRELIMINARY BACKGROUND STUFF
It is currently not possible for a character style to inherit the character
attributes of a parent paragraph style, only from another character style (not
including "No Character Style", which, if it could be inherited from, would
effectively base the child character style on the character attributes of
whatever style of paragraph the character style is applied in). SEE ATTACHMENT
1.
Both of these would be VERY USEFUL FEATURES, especially the ability to inherit
from "No Character Style", as it would in some cases eliminate even MORE
"duplicative" iterations of a given type of character style than being able to
inherit from paragraph styles would.
In the meantime, a partial workaround is to create dummy character styles that
recapitulate the character attributes of the various paragraph styles the
character styles may be used in. That way, if a decision is made to change
something about a paragraph style's character attributes (font, font size,
spacing, etc.), the change need be made only TWICE — once in the paragraph
style and once in its paired dummy character style — instead of having to be
replicated in EVERY SINGLE CHARACTER STYLE that might be used in a paragraph
with the newly modified style. Generally speaking this seems to work, but I
recently encountered one bizarre, annoying, time-wasting, possibly
idiosyncratic bug:
If the font size in a child character style was set as a percentage of the font
size in a parent dummy character style — whether or not the dummy character
style was actually applied to any text in the document — whenever the document
was opened, the font size in the child style was based on some OTHER font size
not in found in any relevant applied style, including in the default paragraph
style, and did not get properly updated (did not get based on the font size in
the parent dummy style) until the Font tab of the child character style was
re-opened for editing and re-saved (without changes). I'm attaching examples of
one of my parent dummy character style / child character pairings, copied from
their XML entries in an *.fodt version of my document. SEE ATTACHMENTS 2 AND 3.
THIS WAS UNEXPECTED BEHAVIOR. The only category I had set to 12 pt in Options >
LibreOffice Writer > Basic Fonts (Western) was "Index". It uses a different
font than my "Default" Western font (which is set to 22 points). Moreover, the
only APPLIED styles in my document that use a 12 pt font are for the index and
the footers, and none of the relevant paragraph styles use my default paragraph
style's font, nor do any of them have a corresponding "dummy character style"
for now. I have some UNAPPLIED styles that are in 12pt type, but I haven't
manually updated any of them to my new "Default Paragraph Style" font, which I
switched to relatively recently. (I switched from Times New Roman to Linux
Libertine G with a number of optional Graphite features turned on.)
This is why I was surprised to find two 12 pt ≈"Linux Libertine G" entries in
the XML code of the *.fodt version of the document that I opened in a text
editor. (I'm typing "≈" because LibreOffice APPEARS to have corrupted four
instances [out of over 200] of "Linux Libertine G" by storing them as "Linux
LibertineG" with a missing space between "Libertine" and "G". Using "Linux
LibertineG" in Writer's font name interfaces triggers warnings that a close
substitution will be attempted. I have a hunch that its presence in XML may
well have affected parent-child style operations, even in the absence of those
interface warnings.)
At any rate, the four instances with the corrupted font name were found in
three XML entries, the last two of which had the font-size set to a fishy
(suspect) "12 pt". I'm attaching the three XML snippets in that order. SEE
ATTACHMENTS 4, 5, AND 6.
The last two corrupted entries, in ATTACHMENTS 5 AND 6, are the ones where the
12 pt font-size setting struck me as fishy. I manually changed the font size in
those entries from 12 pt to 22 pt (the current size for the document's default
paragraph size), and I used Find and Replace to change all four instances of
"Linux LibertineG" to "Linux Libertine G". I then saved the edited *.fodt file
from my text editor, opened it in LibreOffice Writer, saved it as an *.odt
file, and closed and reopened it in Writer. All of my child character styles
with font sizes based on a percentage of a parent dummy character style LOADED
WITH THE CORRECT INITIAL FONT SIZE, with no manual tweaking required.
LIKELY BUG AND POSSIBLE SOURCE OF XML CORRUPTION
At some point recently — it may have been in this document or the one I
imported updated styles from, but I think it was this one — I was trying to
make more extensive use of parent and child styles to reduce future
style-editing work. I quickly found out that you could NOT save "No Character
Style" as a parent style in a character style. But the character style's
"General" tab DID allow you to SELECT "No Character Style" as the parent style
(without being able to save it), and the usual "EDIT STYLE" BUTTON appeared to
the right of the parent-style field. To my surprise, the "Edit Style" button
WORKED and it brought up an Edit Character Style dialog window for "No
Character Style"! SEE ATTACHMENT 7. To my even GREATER surprise, you could MAKE
AND SAVE EDITS to it, and it REMEMBERED the edits the next time you brought it
up for editing! I think I changed the font size and saved it to see if anything
changed in my document. (It's highly likely the font name was my default "Linux
Libertine G" font with all the features, and it's quite possible the font size
I temporarily changed to was "12 pt", to help me spot a pronounced visual
contrst.) I didn't notice any obvious changes, so I edited the "style" back to
its original font size and went about my work.
I have a SNEAKING SUSPICION that my "ILLEGAL" (but possible) EDIT to "No
Character Style" was what CORRUPTED the font name and set the wrong font size
in a small number of critical XML entries. I have ZERO CODING CHOPS and an
EXTREMELY LIMITED UNDERSTANDING of how LibreOffice works under the hood, so
it's only a guess.
But if I'm right, it's probably important to GET RID OF THAT "EDIT STYLE"
BUTTON when "No Character Style" is selected as a parent style.
I still think it would be a terrific idea to make it possible for character
styles to inherit the character attributes of any paragraph style as well as
from the variable, current-paragraph-style-dependent "No Character Style". For
people who make heavy use of character styles, it could cut down on the
proliferation of largely duplicative styles and reduce the amount of (again
largely duplicative) style-editing work down the line.
Sorry for being so verbose, but it seemed useful to document what I had done.
Regardless, that unprotected path to editing the "No Character Style" character
style almost certainly needs to be closed, even if the rest of my report seems
like "an awful lot of effort" to read!
Steps to Reproduce:
NB: Use a DISPOSABLE COPY of an original document for this test.
1. In a LibreOffice text document, start editing a character style.
2. Go to the "General" tab, then to the "Inherit from" field, and select "No
Character Style" from the dropdown list.
3. Click on the "Edit Style" button to the right of the "Inherit from" field.
4. Go to the "Font" tab, make a note the original font name and original font
size, change the font size to a size not used in any style in the document,
make a note of the new size, and save the changes, exiting the "Edit Character
Style" dialog".
5. Repeat steps 3 and 4, but in step 4, change the "No Character Style" font
size back to what it was originally.
6. Exit the initial "Edit Character Style" dialog.
7. Save the document as an Flat XML ODF Text Document (.fodt).
8. Open the *.fodt file with a text editor.
9. Search for an XML style entry that specifies both the font name and the
temporarily changed font size you made a note of.
10. If you found such an entry and/or if the font name is corrupted, editing
the "No Character Style" may have corrupted the hidden XML style in your
document.
Actual Results:
In my document, I had set the font size of several character styles to a
PERCENTAGE of the font size in a parent character style that recapitulated the
font attributes of my Default Paragraph Style. After doing the foregoing "Steps
to Reproduce" (out of curiosity), every time I opened my document, those
"percent-sized" styles would load as a percentage of the temporarily changed
font size rather than the old/restored font size. Manually correcting
corrupted font names and manually replacing "temporary" font sizes with
old/restored ones in in XML fixed the problem.
Expected Results:
First, the "Edit Style" button should not have been displayed when "No
Character Style" was selected as a parent style (to "inherit from"). Second,
the "Edit Style" button should not have loaded an "Edit Character Style" dialog
window for "No Character Style" when clicked. Third, the "Edit Character Style"
dialog window should not have been able to SAVE any changes to "No Character
Style".
Reproducible: Always
User Profile Reset: No
Additional Info:
I'll be adding some attachments after filing this report. I referenced them in
the "Description". With luck, I got the attachment numbers right.
--
You are receiving this mail because:
You are the assignee for the bug.