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.
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:
ChartModel ( service: cssc2::ChartDocument and class: ChartModel )
- DataProvider (optionally internal data) ( service: cssc2::data::DataProvider and class: InternalDataProvider for charts own data (calc and writer implement their own DataProvider) )
- Maintitle ( service: cssc2::Title and class: Title )
Diagram ( service: cssc2::Diagram and class: Diagram )
- Subtitle ( service: cssc2::Title and class: Title )
- Legend ( service: cssc2::Legend and class: Legend )
- Wall and Floor ( class: Wall )
a list of Coordinatesystems (restricted to 1 currently)
( service: cssc2::CoordinateSystem and base class: BaseCoordinateSystem and several classes: CartesianCoordinateSystem and PolarCoordinateSystem )
the Axes ( service: cssc2::Axis and class: Axis )
- the Grids ( service: cssc2::Grid and class: Grid )
a list of Charttypes ( service: cssc2::ChartType and base class: ChartType and
several classes: AreaChartType, ColumnChartType, etc. )
- a list of Data Series ( service: cssc2::DataSeries and class: DataSeries )
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'.
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'.
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.
Loading and saving of the chart is implemented in module xmloff/source/chart.