View is called layout, build from frames β also called FCM β’ One opened document β SwDoc β SwDoc::GetNodes() β SwNode array (has pretty-printer in gdb) β’ Inside that, building block: paragraphs β One paragraph β SwNode β’ Terminology: β Word has sections, paragraphs and runs β Writer has page styles, sections, paragraphs and text portions
text as a single OUString β’ Properties: β SfxPoolItem β Stored in an SfxItemSet β Think of it as a map<int, any> β’ βintβ is called a WhichId: β Writer specific ones are in sw/inc/hintids.hxx β’ SfxPoolItem is has many subclasses, examples: β Bold: SvxWeightItem (Sv: StarView) β Paragraph adjust: SvxAdjustItem
_pWhichRanges β Array of pointers: value βnβ: start of a range β Value βn+1β: end of a range β End of the list: 0 β’ Can have a parent: think of style inheritance β’ While debugging: _nCount contains the size β’ Items are pointers: _aItems β If a property is βsetβ, its pointer is non-zero
change to it comes with some cost β Still, not set in stone β Extensions use this, UNO-supported languages (C++, Java, Python etc) can connect to a running soffice using URP β’ If the document model is changed, the API has to be updated in most cases β We serialize everything to ODF, and that uses the UNO API as well β Bad: slower than necessary β Good: UNO API is kept up to date
if this is implemented, can read / write the document model β Other approach: implement the UI β’ Properties themselves: β Most SfxPoolItem has two methods to load / save: β QueryValue() + PutValue() β’ New frame, paragraph, character, list (etc.) property: β sw/source/core/unocore/ β Maps between UNO's string + any key-value and WhichIds + SfxPoolItems
to test automatically β Think of missing fonts on test machines β Document model has only paragraphs, not pages β’ One opened document β multiple layouts β Try it: Window β new window β’ Typically single layout: SwRootFrm (root frame) β Inside: pages β SwPageFrm β Paragraphs β SwTxtFrm
a server, e.g. SwTxtNode β’ SwClient: the client, e.g. SwTxtFrm β’ SwModify β SwClient is 1:N β’ SwModify has Modify(SfxPoolItem* pOld, SfxPoolItem *pNew) β So layout can react without building from scratch β SwClient can only be registered in one SwModify β But SwClient can have multiple SwDepend (which is an SwClient)
text frame β Can contain anything: tables, columns, fields, etc. β Does not support advanced drawing features β Like rounded corners β’ Drawinglayer (shared) takes care of all other drawings β Also has a rectangle, with all features one can ever wish β Rounded edges, rotations, etc. β Except it doesn't know about Writer layout, so can't contain fields, etc. β’ Problem for Word interop: β They don't have this code shared, so combining the above two feature list is possible there
has to be serialized / loaded back to every file format β Or you loose data β In practice: ODF should not loose data, the rest should be good enough β’ Important filters: β ODF (.odt) β OOXML (.docx) β WW8 (.doc) β RTF (.rtf) β Rest: HTML, plain text, etc.
this has to be updated before the change hits a release β So users have at least one format which don't loose data for sure β’ Mostly uses the UNO API: β Code under xmloff/ β’ Some Writer-specific bits are using the internal API: β sw/source/filter/xml/ β’ Is an open standard, proposals for new features can be submitted
code under writerfilter/ β Tokenizer: β Shared XML parser, model.xml β tokens β Domain mapper: β Handles the incoming stream of tokens and maps them to UNO API β Tokenizer β dmapper traffic is XML logged: β cd writerfilter; make -sr dbglevel=2, then /tmp/test.docx*.XML after load β’ Export: β Shared with RTF/WW8, uses internal API β sw/source/filter/ww8/docx*
even older, but it's removed β’ Import/export somewhat shared β’ Uses the internal API β’ Code under sw/source/filter/ww8/ β’ Shared (doc, xls, ppt) parts: β filter/source/msfilter/ β’ Using doc-dumper may help
Code under sw/source/filters/ww8/rtf* β’ Import is shared with DOCX: β Code under writerfilter/source/rtftok/ β Domain mapper is the same for RTF and DOCX β’ Math: β Import generates OOXML tokens (RTF-specific part is inside the normal RTF tokenizer) β Export is shared with DOCX: β Code under starmath/source/rtf*
/ export β Poke around with xray, then assert the UNO document model β’ The rest is more challenging β We have uwriter, which has access to private sw symbols β No UI tests β that's still to be figured out
sense β’ Doesn't use the UNO API β’ Input/output for the dialog is an SfxItemSet β’ Own toolkit: VCL β Newer dialogs use the GTK .ui format β Glade is a GUI to edit those β If have to touch an older dialog: best to convert it first β Doesn't take too much time
Typically every existing dialog has a related help page β’ If you add a new UI element, makes sense to spend a minute on updating the related help β Requires a --with-help build β’ XML based, also stored in git, just different repo β’ Offline / online help is generated from that
UNO API what we offer β Typically 1 UNO property β 1 XML attribute in ODF β’ If you extend the UNO API β Go ahead with updating the ODF filter β After implementation is ready: β See https://wiki.documentfoundation.org/Development/ODF_Imple menter_Notes#LibreOffice_ODF_extensions β Submit a proposal to OASIS, so it can be part of the next version of the standard