zotero / zotero-libreoffice-integration

Zotero LibreOffice integration
https://www.zotero.org/support/libreoffice_writer_plugin_usage
Other
67 stars 31 forks source link

Use fields in odt files for Word compatibility #39

Open tstenner opened 6 years ago

tstenner commented 6 years ago

The odt format also allows fields, as the following experiment confirms:

What does not work:

The extension currently doesn't recognize the citation fields, but libreoffice loads and writes them correctly in both formats. If they could be either loaded natively or converted on loading / saving the document, interoperability with Word users would be much improved.

adomasven commented 6 years ago

LibreOffice has incomplete support for Word fields. It clearly recognises and avoids erasing them, but there is no UI to edit the field contents within LibreOffice, nor programming API to interface with them from the plugin.

tstenner commented 6 years ago

Editing the contents of a field works for me (Libreoffice 6.0) and the changes are shown correctly in Word.

Creating fields also works (insert the citation, create a com.sun.star.text.Fieldmark, set the type (i.e. the citation data) and attach the field to the citation text) but I haven't found a way to find the fields again to edit them. Would you accept a PR to either convert citations on loading / saving or support them natively?

adomasven commented 6 years ago

Ok, I've done some more research on Fieldmarks and while, as noted above, LibreOffice clearly has some internal support for them. I am not sure it is complete and the programming API doesn't seem to be documented, which means that we would avoid using it for now since it is likely to change and break the plugin.

Once the API is stable and documented, we would definitely accept a PR, although we would move to just using Fields in LibreOffice to simplify interoperability with Word, and convert old-style fields on document open or interaction.

tstenner commented 6 years ago

I've done some preliminary testing on inserting fieldmarks and asked on StackOverflow about finding Fieldmarks. JIM k's solution works (not sure about citations in footnotes though), but it might be a lot slower than Reference Marks. Still, "This document contains Fieldmarks, do you want to convert them to edit/insert citations" is a lot better than "This document uses fields and you need Word installed to change anything about it"

adomasven commented 6 years ago

"This document contains Fieldmarks, do you want to convert them to edit/insert citations" is a lot better than "This document uses fields and you need Word installed to change anything about it"

We receive a lot of user feedback via the Zotero forums and I don't remember a single instance over the past couple of years of users being confused regarding collaboration between Word and LibreOffice.

Either way, in the case of collaborative work across LO and Word we already support Bookmarks. Conversion from Fieldmarks to Reference Marks wouldn't help in this case, since the Word user would not be able to continue working on the document. If collaboration is expected Zotero already supports conversion to Bookmarks via the document preferences.

We could suggest converting Fieldmarks to Bookmarks, but Bookmarks increase the risk of accidentally corrupting the fields or the document itself. Given that users often tend to click "Yes" in dialogs without reading them this could cause more problems than solve.

Furthermore, having code based on unstable API makes it vulnerable to breaking with updates from LO, which means increased additional maintenance over the long run.

Once the API is stable and there is a way to access Fieldmarks in the document, we will move to using Fieldmarks and remove the need for Bookmarks and Reference Marks completely. That is desirable, because it will simplify all plugin architecture significantly.

tstenner commented 6 years ago

We receive a lot of user feedback via the Zotero forums and I don't remember a single instance over the past couple of years of users being confused regarding collaboration between Word and LibreOffice.

The problem is not the confusion, but the irritating extra steps for everyone (e.g. here).

Either way, in the case of collaborative work across LO and Word we already support Bookmarks. Conversion from Fieldmarks to Reference Marks wouldn't help in this case, since the Word user would not be able to continue working on the document.

That's right, but the other way (Refmarks->Fieldmarks) will be needed for older documents even after the change to Fieldmarks. This could be done in LO Basic so the Java component can get simplified. Also, converting to Fieldmarks means collaborators won't have to use the more fragile bookmarks.

I've created a bug report to get the ball rolling.

adomasven commented 6 years ago

I've created a bug report to get the ball rolling.

Thanks for the interest and for creating the bug report. Another venue worth asking on is the LibreOffice developer mailing list since they may want to discuss this in more detail and you may be able to get this included into one of their weekly meeting's agenda.

ilDon commented 5 years ago

Any update on this? I have lots of documents with "fields" citations and that is forcing me to stick with Word. Having the ability to edit "fields" citations in LibreOffice would be great!

MatthiasSiewert commented 5 years ago

This would be really nice. Libreoffice and MS compatibility is a major issue for me running Linux.

adomasven commented 1 year ago

I have not looked into this in more detail, but we may be able to support Word fields/fieldmarks in LibreOffice 7.6 and later. See

adomasven commented 1 year ago

After testing LibreOffice 7.6 and talking with LibreOffice developers I have discovered the following:

  1. Writer functionality has not been changed regarding Word fields. That is, Word fields are still not editable in Writer, i.e. the content is marked read-only.
  2. The APIs documented above are only available using LibreOfficeKit, which is a different API which seems to be developed by Collabora to be used with C++, so not useful to us.
  3. However, there may actually be an undocumented way to access and edit Word Fields with the current Java API. More investigation of LibreOffice source code is required (which is not very accessible without figuring out the full architecture of the software).

Regarding (1), we could consider adding a patch to LibreOffice which would make Word Field text editable. Assuming LibreOffice developers would be willing to accept it, we could move forwards with Field support. We generally wouldn't be as interested in this, but with the development of the new Word JS plugin, we would rather not support Bookmark citations given their various problems. On the other hand, with support for transferring Zotero citations via the transfer format, we could just slash Bookmark support for the time being without adding Field support to LibreOffice.

raffaem commented 4 weeks ago

I guess still nothing about this?