FAQ about Chart API Compatibility

From Apache OpenOffice Wiki
Jump to: navigation, search

If you have written StarBasic Macros or other Code that uses the API in com.sun.star.chart and want to be able to still run it with the new chart here is some help in case you encounter problems. If you have problems not listed here feel free to add them here.

Note, that the new API is not published yet, so you should not use the new API extensively before it is published!

Using OOo Basic Macros

Question: I can no longer set the main title using the Title property.

[starbasic]

 ' oMyChart is the XChartDocument (XModel)
 oMyChart.Title.String = "My Title"

Answer: There is no main title any longer per default, so you have to add it first.

[starbasic]

 ' oMyChart is the XChartDocument (XModel)
 oMyChart.HasMainTitle = true
 oMyChart.Title.String = "My Title"

If this does not fix your problem, get a newer version. From OOG680.m2 on, the new API has changed. The interface XTitled now has the methods getTitleObject and setTitleObject. Thus the name-clash that lead to this problem no longer exists from that version on.

Question: Adding a sub-title or axis-title no longer works.

[starbasic]

 ' oMyChart is the XChartDocument (XModel)
 oMyChart.Diagram.YAxisTitle.String="My Y-Axis text"
 oMyChart.Diagram.HasYAxisTitle=True

Answer: Titles are object now, that are created with the API-function behind the "Has" properties. Thus, you can set the title content only after you added the title. Change the order:

[starbasic]

 ' oMyChart is the XChartDocument (XModel)
 oMyChart.Diagram.HasYAxisTitle=True
 oMyChart.Diagram.YAxisTitle.String="My Y-Axis text"

Personal tools