Jump to content

Development/Writer

From The Document Foundation Wiki

Adding a new feature

If you're adding a completely new feature, here is a checklist:

  • Document model: extend the relevant SwFoo class or SfxPoolItem, etc.
  • UNO API: start with (the document model and) this or with the UI, so that you can test the read/write of the document model
  • Layout: let the layout paint something according to the document model (you need to consider changes to the SwFrame-based layout and to the actual rendering)
  • Filters: at least update the ODF filter, if it makes sense, then updating DOCX/DOC/RTF/etc is also welcome
  • Tests: at least add a test to the odfexport testsuite, see here for details
  • UI: so that users can create a document taking advantage of your new feature just by clicking around (also consider undo/redo)
  • Documentation: update help.git, so when users hit F1 (on the new dialog on the UI, or so), the upcoming help page contains something relevant about your new feature
  • Specification: if you had to extend ODF, see here

Code pointers

Selection overlay

  • The selection overlay is a set of rectangles, SwSelPaintRects::Show() does the painting.
  • SwSelPaintRects is inheriting from an std::vector; SwRootFrm::CalcFrmRects() calculates that vector of rectangles. (For tables, it's SwShellTableCrsr::FillRects().)

Undo / Redo

  • SwUndoRenameBookmark is a small, self-contained example on how to add undo/redo support for something

InteropGrabBag

See here for rationale. Currently the following UNO objects support this property:

  • OfficeDocument (document-level props, used for docx theme.xml)
  • Shapes (used for docx smartart)
  • Writer characters (CharInteropGrabBag)
  • Writer paragraphs (ParaInteropGrabBag)
  • Writer textframes (FrameInteropGrabBag)
  • Writer styles: paragraph, character and list (StyleInteropGrabBag)

Partially implemented features

Document model, UNO API, filters (ODT and DOCX) are implemented for these features. UI, layout and documentation are needed.

gdb

Aliases to dump the last created document model (nodes) or layout:

alias ndump = print SwDoc::s_pLast->dumpAsXml(0)
alias ldump = print SwRootFrame::s_pLast->dumpAsXml(0)