Apache OpenOffice (AOO) Bugzilla – Issue 80297
Cannot modify Chart title via Basic using old API because getTitle is ambiguous
Last modified: 2013-02-24 21:19:18 UTC
In a Basic Macro where you have an XChartDocument in oDoc the call oDoc.Title may call css::chart2::XTitled::getTitle instead of css::chart::XChartDocument::getTitle. So, the following fails: oDoc.Title.CharHeight = 12 oDoc.Title.String = "My Title" As a work-around, the following works: Dim oFormattedString As Object Dim oTitle As Object Dim aStrings(0) As Object Set oTitle = createUNOService( "com.sun.star.chart2.Title" ) Set oFormattedString = createUNOService( "com.sun.star.chart2.FormattedString" ) oFormattedString.String = "My Title" oFormattedString.CharHeight = 12 Set aStrings(0) = oFormattedString oTitle.Text = aStrings oDoc.Title = oTitle Although its is quite more complicated. The cleanest fix would be to rename chart::XChartDocument::getTitle to getMainTitle, that would be consistent to the "HasMainTitle" property and would solve the ambiguity, however this is published API, so not possible. The other getTitle() is a method from the interface XTitled, so the name of the method cannot be renamed to getMainTitle(). Maybe it can be renamed to getTitleContent or sth. like that?
Created attachment 47273 [details] Example document with macros for inserting a title with old and new API
Created attachment 47333 [details] Fixed version of the macro using getTitleObject for the new API
Fixed the new (unpublished) API methods XTitled::getTitle() and setTitle() to getTitleObject() and set TitleObject(). The new attachment works with the fixed version, there both macros work. Note that the problem with not having this fix is: the old method no longer works, as a work-around you have to change all places with the new API, but this will change when this issue is fixed, so you have to change the place again (either back to the old API or the changed name in the new API). So, I think it would be good to have this in OOo 2.3.
changing target to 2.3
added keyword regression
->CN: Please verify. The second attachment "TitleFixed" works with CWS chat12. There, for the old API the expression oDoc.Title is used to access css::chart::XChartDocument.getTitle(). The macro for the new API uses oDoc.TitleObject which calls the renamed method css::chart2::XTitled::getTitleObject. Note, that this issue only appeared with Basic, as on other systems you usually have direct access to the interface, i.e. in Java you have an XTitled object at which the call to getTitle() was different from from the call to getTitle() at an object of type XChartDocument. Implementation note: I changed the following in XTitled: getTitle() -> getTitleObject() setTitle() -> setTitleObject()
ok in cws => verified
Found fixed in OOG680.m2
verified fixed in SRC680_m229; closing.