Rough Overview of the Code Structure in Module chart2

The chart2 module produces 4 libraries:

The libraries are created in the respective directories:

Model, View and Controller are named according to the classic design pattern.

Model

The model contains the basic content of the chart. Access on the model objects is only possible via UNO interfaces. The model uses an unpublished new UNO API which is subject to futther changes. You can find that API in module offapi ( com::sun::star::chart2 ). The central class is 'ChartModel'(implementing the service ChartDocument). It represents the chart document which contains all further chart elements. While describing interfaces or services I use 'cssc2::' instead of writing the long namespace '::com::sun::star::chart2::' again and again here. The hierarchy looks like this:

View

The View is the creator of the visual screen representation. The chart view creates Shapes as offered by Draw and Impress ( see API com::sun::star::drawing service 'Shape'). There are some c++ exports from this library (see chart2/source/inc/chartview) offered for use in the controller. These are candidates for UNO interfaces in future.

The central class here is 'ChartView'. The place where the shapes are created is method 'createShapes()'. Roughly there is a view class for each type of chart element for creating the shapes. They are often named with a leading 'V' to indicate that this is the according view class. For an example you have the class 'Legend' in the chart model and the class 'VLegend' that creates the shapes for the view.

For having an interactive view where the user can select objects and perform some actions on it it is necessary to match the drawing shapes to the related chart model objects. This is done by identifiers. When the view does create a shape it sets an according identifier to the shapes Name property. The class that handles the creation and parsing of these identifiers is 'ObjectIdentifier'.

Controller

The controller is the connection to the framework and the user input via menu, mouse and keyboard. Here you will find dialogs and execution of chart changing methods.

The central class here is 'ChartController'. The method where commands from the menues arrive and are executed is 'dispatch()'. Events coming from the window like mousclicks or key inputs are directed to the controller for execution by the interface 'WindowController'.

Tools

The tools library contains some helping classes - for example to ease the access to the UNO interfaces. There are several exports (see chart2/source/inc (exclusive chartview)) which can be used in all other chart libs.

Load/Save

Loading and saving of the chart is implemented in module xmloff/source/chart.