"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.)
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.)
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.
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
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.
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.
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.
I didn't understand much of your coding stuff, but I really thank you for suggesting a solution.