Documentation/Fields

    From The Document Foundation Wiki

    Interoperability discussion:

    There is one huge, glaring difference in Fields between LO and MS Word. Word does not automatically update the content of a field when the variable changes, but LO does.

    NOTE: This is a work in progress. I'm trying to learn about fields and am noting my observations as I go along.


    Fields in MS Word:

    • do not automatically update when the variable changes.
      • exception: PRINTDATE
      • exception: SAVEDATE updates ONLY at FILEOPEN (yet LASTSAVEDBY never auto-updates)
      • updated manually when the user selects a field and presses F9
      • to update all fields, the Internet suggests Ctrl-A to select all, and then press F9
    • can be edited by hand
    • generally do not have the UI option to be "fixed" or unchangeable (although Ctrl-F11 will set fldLock'd for any field I expect)
      • fldLocked fields can be updated by editing them and pressing OK


    Fields in LO:

    • always update automatically (unless FIXED)
      • LO probably needs to be extended to allow the field an option to manually updated. So a bit like "fixed"
    • cannot be edited by hand when tied to a variable
    • FIXED date format must be recognized as a valid date in order to work
    • always can be marked as "fixed"
      • this is a way to preserve/import a field whose displayString doesn't match the variableValue
        • doing this will interfere with fldLock - which is rarely used since it is not easily UI accessible.


    Why not just import as plain text instead of a field?

    • data loss in MS Word primarily


    Things to watch out for during import:

    • always make sure export also works (for all formats). DOCX export in particular is just bad/wrong, while RTF just seems to always work.
    • import only works if the variableValue matches the displayString. If not, either mark as fixed, or treat as plain text instead.
      • there are lots of reasons why it might not match. MS Word allows a lot of special formatting (upper, lower, title, sentence-case), or the user could have just typed something else.


    Things to watch out for during export:

    • make sure the MS Format doesn't support "locked" for that field type. If it does, then import has to handle that carefully.
      • Date/Time are there for sure. See Read_F_DateTime.


    Things to figure out:

    • what is it with special characters like extra nulls etc. For example
       lcl_GetExpandedField(const SwField &rField) {
           //replace LF 0x0A with VT 0x0B
           return rField.ExpandField(true, nullptr).replace(0x0A, 0x0B);