Craig Johnson wrote:
Andrew Douglas Pitonyak wrote:


I had never written a staroffice macro until ~ 3 weeks ago. For a complete newcomer like me I found you book to be an invaluable reference.

Is it time for a second edition? 8^)

I created the text for the second edition a long time ago, but there was limited call for it at the time. Not much changed in the text, it was mostly "yeah, I was right about ...."

Probably about time for another revision, however, but even now, most of the information is right on the money, because Sun works hard to not change their API.
First, let me say that charts are in a strong state of change at the moment, and I have had trouble understanding them. That said, you need

Any pointers to where one might find info about known chart problems and work arounds? Or what's changing and when it will be available?

From my perspective as a newcomer understanding anything about OpenOffice and particularly access to things via macros has been troublesome.

Because things are not yet documented in this area and will likely change, your best bet is to:

1. Ask directly on [EMAIL PROTECTED], and the developers will frequently answer your questions. Not always, but sometimes.

2. Download and read the code and IDL directly to get a feel for what it can do. This is MUCH more difficult, by the way. Much of what is in the first chapters of my book, I found by reading the code to see what the functions really do.

to get the embedded object and look at that. For example:

Sub DisplayData()
   CR = Chr$(13)
   SPC = " "

   Dim Sheet as Object
   Sheet = getNamedSheet("Sheet1")

   Dim Charts as Object
   Dim Chart as Object

   Charts = Sheet.getCharts()
   Chart = Charts.getByIndex(0)
   ChartRanges = Chart.getRanges()
   Dim x, i%, j%, y, s$
   x = Chart.getEmbeddedObject().getData().getData()
   For i = LBound(x) To UBound(x)
     y = x(i)
     For j = LBound(y) To UBound(y)
       s = s & y(j) & "  "
     Next
     s = s & CHR$(10)
   Next
   MsgBox s
End Sub

The reason the lower bound on the other is -1, is because calling getRanges returns an empty array. This may be because of the chart type, but that is a wild guess.

Yes, -1 indicates an empty array but it should *not* be empty as
Format-Data Ranges shows there is a valid chart range.

My example only dealt with one chart type but I have seen this on several different chart types (e.g. bars, stacked bars, stacked bars with lines).

What I have learned since yesterday is that if I select the chart and look at Format->Data Ranges through the GUI then do the Chart.getRanges I get an array with the expected elements in it. In fact all that's really necessary is to select/deselect the chart in the GUI and the getRanges works as expected.

Ummm. Really? OK, now that is strange! I would mention that specifically on the dev list...

Do you know of a way to do a select/deselect of a chart from a macro?

I just might. The following might work:

ThisComponent.CurrentController.select(Chart)

The second problem is that after updating the ranges with setRanges to add a new row the X-axis tick labeling is incorrect and if you save, exit and re-open the doc the chart range displayed by Format->Data Ranges is incorrect.


The embedded object supports the com.sun.star.chart2.ChartDocument service.

You want to see the ranges?

   x = Chart.getEmbeddedObject().getUsedRangeRepresentations()
   MsgBox Join(x, CHR$(10))

I did find some old code here, that may be of interest

http://lxr.go-oo.org/source/graphics/chart2/qa/TestCaseOldAPI.java

Thanks for your timely reply and the additional examples and info!

What is your opinion on filing this as an issue at the api.openoffice.org site? (at least I think that's where bugs should be filed)

I would post on [EMAIL PROTECTED] first, because the API is changing, and then, I would open a bug :-)

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to