Chapter 7. Study of the "open document" workflow

In this chapter, we are going to see what happens when the user opens an xml document. This "open document" workflow can be triggered by doing file -> open or by hitting the "open" button in the application toolbar. The actual entry point of this workflow is the MlViewEditor::open_local_xml_document_interactive() method. This method basically pops up a file chooser to let the user choose the path of the document she wants to use. If the document is already loaded in the editor, the user is asked if she wants to reload it. Eventually, the MlViewEditor::load_xml_file() method is called to load the actual document in the editor.

The MlViewEditor::load_xml_file() method first parses the xml document into an in memory tree (using the excellent xml capabilities offered by the Libxml2 library). That in memory xml tree is an instance of the MlViewXMLDocument class. Afterwards, an instance of MlViewTreeView (the default editing view) is built and added to the current instance of MlViewEditor. The user can now edit the document using the editing capabilities offered by that editing view.

As you have noticed, the default view used when loading documents into the editor is the "tree-view" (MlViewTreeView). However, the user can at any time create a new view on the document being edited and then choose to instanciate another type view. Of course, the editor must have been compiled with the support of other views but the "tree-view".