libreoffice-code-highlighter icon indicating copy to clipboard operation
libreoffice-code-highlighter copied to clipboard

inheritance of character styles

Open Bantoniof opened this issue 11 months ago • 11 comments

  • When the ch2_ styles are created, they do not inherit from the character style indicated in the dialog, although they acquire other properties, they do not appear as childrens of the parent style in the SideBar when Hierarchical. is selected.

  • Also if you indicate a parent character style name that is not in the document, a style with that name is created. Would it be possible to have a notice warning that it is going to be created?

    • CodeHiglighter2 v2.7.4
    • LibreOffice v24.8.3
    • Windows 10

Bantoniof avatar Dec 17 '24 19:12 Bantoniof

Hi,

Thank you for your report.

When the ch2_ styles are created, they do not inherit from the character style indicated in the dialog, although they acquire other properties, they do not appear as childrens of the parent style in the SideBar when Hierarchical. is selected.

I can't reproduce within the same context. Do the newly created character styles (beginning with ch2_) appear somewhere else ?

Also if you indicate a parent character style name that is not in the document, a style with that name is created. Would it be possible to have a notice warning that it is going to be created?

This is implicit, but I can make it explicit if you prefer. What about a precision in the infotip text (when hoovering over the control) ?

jmzambon avatar Dec 18 '24 10:12 jmzambon

  • I have a character style called "Code".
  • I go to Format > Colorize Code and indicate that they are based on the "Code" character style
  • The ch2_ character styles are created without any problems.

But if you look at the properties of any ch2_ style, they do not have any style inheritance.

In the sidebar you can see the styles classified by hierarchy using the listbox at the end of the sidebar Ch2_ styles are not depending on the "Code" character style

Bantoniof avatar Dec 18 '24 13:12 Bantoniof

@Bantoniof Check the minimum accepted version in the LO docs. Fairly sure that version of this extension worked as you expect. At the time I unzipped the LO writer docs and checked the code.

Edit: https://community.documentfoundation.org/t/how-to-for-syntax-highlighting-code/6749/10

Release v2.4.0 · jmzambon/libreoffice-code-highlighter is fit-for-purpose for LO guides.

flywire avatar Dec 18 '24 14:12 flywire

@flywire This version of Codehighlighter works in my system. I've the last version of LibreOffice as I said in the my first message. But the creation of ch2_ styles don't work as expected

Bantoniof avatar Dec 18 '24 14:12 Bantoniof

Sorry, I didn't try the right LibreOffice version. Your issue is a regression introduced with LibO 24.2.6.1. I'll try to fix this as soon as possible.

Edit I've sent a bug report: https://bugs.documentfoundation.org/show_bug.cgi?id=164370.

jmzambon avatar Dec 18 '24 16:12 jmzambon

Perhaps an internal improvement would be to check if a style has children before deleting it, and delete styles starting with the lowest hierarchy.

It may not be a bug. When styles are to be deleted from the sidebar, a notice may appear indicating if it is in use. Perhaps deleting styles with macros may force the style to be removed

Some additional test (LibreOffice 24..8.4 now) ~When deleting intermediate styles with the Sidebar, the child styles inherit the properties of the style before the deleted style~ . ~When deleting intermediate styles, they appear to be in the hierarchy as children of the previous style, but in the style properties they do not have an parent style.

  • Character styles are not updated automatically (you have to reload the document)

When you reload the document, the properties of the deleted intermediate style are lost and the text to which the child style was applied no longer has that style. - I think there may be some logic to it. CodeHiglighter.odt

Bantoniof avatar Dec 20 '24 18:12 Bantoniof

Checking for existing child would be the best solution. Unfortunately this is not possible. There is a method "isInUse" (checked before deletion) and a method "setParentChild" used to place the created style at its right place in the hierarchy. But there is no method or property like "hasChild" or "isParent".

Two things make me think it is a bug: the problem didn't exist until recently and, while retrieving by macro the "ParentStyle" of a child style after deleting its parent, you get an c++ error, instead of a empty string (as expected when there is no parent).

The only workaround I see by now is not deleting the unused character styles. Hierarchy will be preserved, but the style library may become quickly cluttered. What's your opinion?

jmzambon avatar Dec 21 '24 09:12 jmzambon

I don' kow how the styles are created on CodeHighlighter , my python knowledge is practically zero.

  • I think that the hierachy must be all styles children of the style indicated on the dialogbox without intermediate parents. (may be this is not possible).
  • If not is possible create a hierachy without intermediate parent styles, I think the delection of styles is the better option.

I have tested the actual version of CodeHighlighter on L.O. 7.5.9.2 and the creation of styles work as expected. all styles are in correct hierarchy and children of the style indicated on the dialogbox.

  • May be the bug is in the creation of styles, not in delection.

Bantoniof avatar Dec 21 '24 18:12 Bantoniof

@jmzambon I agree it seems clearly a LibreOffice bug so it should be fixed there. This extension is important for LibreOffice documentation so I added Olivier Hallot to the bug CC List to encourage a fix.

@Bantoniof Can you confirm the bug in Bugzilla, set importance to critical and add a few words of support?

The only workaround I see by now is not deleting the unused character styles. Hierarchy will be preserved, but the style library may become quickly cluttered.

In the interim, I agree.

flywire avatar Dec 21 '24 19:12 flywire

I'm not a programmer. I have several versions of L.O. installed in parallel. and I think that it could also be the python libraries. I find many differences in the python version files included with L.O.

  • in version ~24.2.5.2~ 24.8.2.1 there are python directories 3.8.17, 3.8.18, 3.8.19 and 3.8.20 (CodeHighlighter NOT working properly)
  • in version 24.2.6.1 there is only one python 3.8.19 directory (CodeHighlighter NOT working properly)
  • in version 24.2.5.2 there also there is only one python directories 3.8.19 but the files are different (CodeHighlighter works properly)

I'm sorry for the previous confusion with the versions.

Bantoniof avatar Dec 22 '24 00:12 Bantoniof

Finally I opt for the most robust option (IMO): checking each used style for existing parent style, and add them in a "to-be-kept" list. A new version of the oxt is available, if you want to test... Thanks both of you for your help and suggestions.

jmzambon avatar Dec 22 '24 12:12 jmzambon