Difference between revisions of "FAQ about Chart API Compatibility"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Using StarBasic Macros: renamed Star to OOo, seems more appropriate)
(Using OOo Basic Macros: added note about order of title creation and modification)
 
Line 7: Line 7:
 
'''Question:''' I can no longer set the main title using the Title property.
 
'''Question:''' I can no longer set the main title using the Title property.
  
<code>
+
<code>[starbasic]
 
   ' oMyChart is the XChartDocument (XModel)
 
   ' oMyChart is the XChartDocument (XModel)
 
   oMyChart.Title.String = "My Title"
 
   oMyChart.Title.String = "My Title"
 
</code>
 
</code>
  
'''Answer:''' Get a newer version. In OOG680.m2 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. (OOG680.m2 is a pre-release of OOo2.3)
+
'''Answer:''' There is no main title any longer per default, so you have to add it first.
 +
 
 +
<code>[starbasic]
 +
  ' oMyChart is the XChartDocument (XModel)
 +
  oMyChart.HasMainTitle = true
 +
  oMyChart.Title.String = "My Title"
 +
</code>
 +
 
 +
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.
 +
 
 +
<code>[starbasic]
 +
  ' oMyChart is the XChartDocument (XModel)
 +
  oMyChart.Diagram.YAxisTitle.String="My Y-Axis text"
 +
  oMyChart.Diagram.HasYAxisTitle=True
 +
</code>
 +
 
 +
'''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:
 +
 
 +
<code>[starbasic]
 +
  ' oMyChart is the XChartDocument (XModel)
 +
  oMyChart.Diagram.HasYAxisTitle=True
 +
  oMyChart.Diagram.YAxisTitle.String="My Y-Axis text"
 +
</code>
  
 
[[Category:FAQ]]
 
[[Category:FAQ]]

Latest revision as of 07:55, 12 September 2007

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