Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous endnotes in Writer

Miklos V
October 10, 2024
3

Continuous endnotes in Writer

Miklos V

October 10, 2024
Tweet

Transcript

  1. 2/18 About Miklos • From Hungary • More details: https://www.collaboraonline.com/about-us/

    • Google Summer of Code 2010 / 2011 • Rewrite of the Writer RTF import/export • Then a full-time LibreOffice developer for SUSE • Now a contractor at Collabora
  2. 6/18 Previous approach • Implemented in 2019 • Tries to

    map endnotes to footnotes on the last page • Grows from the bottom up, now from to the top to bottom after content • Native Writer behavior: separate endnote page • Collapses with large amount of endnotes • Especially if those are of multiple pages
  3. 7/18 The new approach • Introduce a special endnotes section

    • No backing section node, only exists at a layout level • At the end of the document • No actual content in the section’s body, just hosts a foot/endnote container • Can flow across pages, can handle many notes
  4. 8/18 Switch to a section-based layout • Works for simple

    cases, but the compat flag (to render Word-style endnotes, not Writer-style ones) is just used by DOC files, only in case they have 1 or 2 endnotes • Reverts the changes of the old approach • Creates the layout-level section for endnotes on demand • Handles moving the endnote to a previous or next page
  5. 9/18 Enable for all DOC files • See what ‘make

    check’ finds • What crashtesting has to say • Found problem: trouble if there is a section at the document end already • We tried to insert the section for the endnotes inside that last section from model, fixed
  6. 10/18 Enable for DOCX files • Didn’t find more issues

    instantly • Still had to fix: • Endnote container’s top margin • Endnote separator position • Endnote separator length • DOCX has a per-doc flag to collect endnotes at section end • Import / export of this • Endnote continuation separator length • Writer UI: conditionally hide widgets which won’t work for DOCX
  7. 12/18 Document model • sw::DocumentSettingManager stores compat flags • DocumentSettingId::CONTINUOUS_ENDNOTES

    is the relevant flag here • If true, then layout endnotes like Word does • Otherwise compatible with existing ODF documents
  8. 13/18 UNO API • The Writer’s document’s factory can create

    an instance of the com.sun.star.document.Settings service • Implements beans::XPropertySet • Can set the ContinuousEndnotes property there to true to have the Word behavior
  9. 14/18 Layout • The most interesting part • SwFootnoteBossFrame::AppendFootnote() is

    where the foot/endnote frames are created • A note can go to the end of the current section, to a note page, and now can go to the special new endnote section at the end of the document • The endnote section is created on demand • Moving to the next page works out of the box • Moving to the previous page needs explicit handling in SwFlowFrame::MoveBwd() • Similar to moving sections to the previous page is handled in SwFrame::GetPrevSctLeaf()
  10. 15/18 Filters • Remove the restriction to only have continuous

    endnotes for 1 or 2 endnotes from DOC, have it for all DOC • Also enable it for DOCX • DOCX <w:endnotePr> describes the position of the endnotes in a document • At document end vs at section end • Existing ODF documents stay unchanged
  11. 16/18 Tests • Search for stress-test documents in bugzilla •

    The old approach was reverted for DOCX in the past • It was also restricted to 1-2 endnotes for DOC in the past • Various provided documents to show the old layout was poor • Largest document is 72 endotes, over several pages at the document end • Automated testing: • CppunitTest_sw_core_layout for the actual layout • CppunitTest_sw_writerfilter_dmapper for the DOCX import • CppunitTest_sw_filter_ww8 for the DOCX export • bin/diff-pdf-page.py for the visual diff, based on Laszlo’s idea
  12. 18/18 Summary • Section-based endnotes are a new way to

    layout endnotes at the end of the document, as opposed to layout on a separate endnote page • Compatible with Word • Scales properly: • Many endnotes • Many footnotes • Available for everyone using LibreOffice Technology: LibreOffice desktop, Collabora Online, etc.