"Remove Codes" in LibreOffice also removes some styling

Hello and thanks again for Zotero!

I hope I can contribute myself a bit more pretty soon. In the meantime, this is a bug I encountered while using Zotero with LibreOffice:

Say I have a document in LibreOffice, which uses the style "Modern Humanities Research Association (note with bibliography)". With this style, book titles are displayed in italics. If I use the "Remove Codes" features, in order to send it to someone else who doesn't use Zotero, all italics are lost.

This seems to work correctly with Word, so it'd be great to have a fix for LibreOffice.

(I looked into the source, but didn't get very far. Some of the relevant code seems to be in Zotero itself (in chrome/content/zotero/xpcom/integration.js). I could find "removeCodes()", but I did not understand where to find the "removeCode()" function which it calls on each field. Nor do I get why it works with Word and not with LibreOffice if the code is shared.)
  • edited August 28, 2012
    It looks like this isn't properly implemented for LibreOffice at present, although I was apparently aware of this at a previous date and forgot to revisit it. The relevant code is here for LibreOffice, here for Word for Windows, and here for Word for Mac.

    For now, an easy workaround is to save as a Word doc (or any other non-ODF format) and then re-open the file to remove the codes, instead of using the button.
  • Okay, thank you very much for your answer and the workaround, which I'll use.

    As for your pointers to the code, I looked around quickly and it seems difficult. At the very least, while Word exposes a function for the user to unlink fields, there is no such thing in OOo/LibreOffice, as evinced by bug reports [1][2]. It probably doesn't mean it can't be achieved, though. But it'd be great if you could revisit the issue, since I know nothing about fields nor the OOo API and it will/would take me a while to learn.

    [1]: https://issues.apache.org/ooo/show_bug.cgi?id=41572
    [2]: https://bugs.freedesktop.org/show_bug.cgi?id=45946
  • Any progress on fixing this bug?
  • Hi,

    Sorry to re-up the subject. But this bug fix would be reaaally great, since the others feature of Zotero/LibreOffice integration are so convinient.
  • not fixed yet, but do note Simon's workaround:
    For now, an easy workaround is to save as a Word doc (or any other non-ODF format) and then re-open the file to remove the codes, instead of using the button.
  • I have brought this up as a feature request for Libreoffice, and had it accepted. If you wish to see this feature implemented in Libreoffice, please help out here: https://bugs.freedesktop.org/show_bug.cgi?id=80786

    Also, it was suggested as a workaround to cut->"paste special" (Crtl+shift+V) the entire document to remove field codes. If you use the RTF paste option this works OK: Field codes are removed, and formatting is preserved for e.g. ciations. But it does change up some of the heading styles in my test documents. In other words, not perfect, but an OK workaround. Easier and probably even better than the "save as word"-workaround suggested above.
  • Couple of questions related to this :
    I thought I had a work around using character styling : select the italicised citation, add the character style 'emphasis style' and I thought that would be OK, but it seems that removing field codes also removes all attribute styling.

    Backing up slightly, is there a reason why the citations aren't styled using the character style 'emphasis style', as opposed to italics ? and is there a reason why removing field codes also strips character styling ?

    Saving as a word file isn't an option as currently libreoffice kills picture links, which is a royal PITA - however the copy/paste-special works fine - I use templates for my styling so reloading them if the headings are wrong is not a problem.
  • If this is going to be a long-running problem in LibreOffice, it should be possible to do it with a plugin that post-processes an ODT file to make the necessary adjustments. A good starting point might be the code of the RTF/ODF Scan plugin, which has not-too-bad UI in place for selecting a file and saving to another name. Most of the plugin code (the regexp stuff) would be irrelevant, but I recently added a method that casts the content.xml portion of the ODT file as a DOM object, for final touch-up (of the document styles). I haven't looked at this problem myself, but it should be possible to remove the field code wrapper nodes under the DOM, without incidental damage to other parts of the document.
  • @fbennet

    I didn't understand much of your coding stuff, but I really thank you for suggesting a solution.
  • Come to think of it, we could probably implement this with a small tweak to add it as an option in the RTF/ODF Scan plugin itself. Not sure if others in the team would think that a good idea, or if so, when it would be likely to happen, but it should be possible.
  • edited November 1, 2014
    Actually, Simon's suggestion is simpler, and already works:
    For now, an easy workaround is to save as a Word doc (or any other non-ODF format) and then re-open the file to remove the codes, instead of using the button.
    The only advantage to my idea would be that it would not be vulnerable to formatting breakage from conversion to another format.
Sign In or Register to comment.