| View previous topic :: View next topic |
| Author |
Message |
JeromeC General User

Joined: 13 Oct 2005 Posts: 37 Location: France - Nantes
|
Posted: Wed Jul 30, 2008 5:10 am Post subject: chartrangeaddress in a writer document |
|
|
Hello,
I work with a 2.4 Ooo version and something doesn't work anymore (in 2.0 version, it works).
in a writer document, I insert a chart with data based on values in a texttable.
In the 2.0 version, I could find the range address of the chart with this code :
| Code: | | sRangeAddress = oChart.ChartRangeAddress |
In the 2.0 version, it returns the address of the texttable values (A1:C6 for example)
but the ChartRangeAddress property doesn't work in the 2.4 version (not available anymore).
My question is: how can I retrieve the range address values of a chart ?
Thanks,
Jerome. |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
JeromeC General User

Joined: 13 Oct 2005 Posts: 37 Location: France - Nantes
|
Posted: Wed Jul 30, 2008 7:19 am Post subject: |
|
|
Thank you for the reply,
I test with your suggestion :
| Code: | | ochart.getChartRangeAddress |
and it still doesn't work  |
|
| Back to top |
|
 |
JeromeC General User

Joined: 13 Oct 2005 Posts: 37 Location: France - Nantes
|
Posted: Thu Jul 31, 2008 4:02 am Post subject: |
|
|
| To go further, it's the same problem in Calc version 2.4.0, not only in writer. With a chart inserted in a sheet, I can't get the range address of the chart with the code above. The property doesn't exist anymore but exists in the 2.0 version. |
|
| Back to top |
|
 |
JeromeC General User

Joined: 13 Oct 2005 Posts: 37 Location: France - Nantes
|
Posted: Thu Jul 31, 2008 7:21 am Post subject: |
|
|
I found the solution, so here is the code and some explanations.
the ChartRangeAddress property in the 2.4 version doesn't exist anymore. With the new version, a new implementation of charting diagram has been created by the com.sun.star.chart2 module with new interfaces managing data providers, data values and sequences.
So, in a chart, you can get the data source of the chart with the XDataSource interface and retrieve some informations of the chart by detecting arguments of its provider (XDataprovider interface).
All this following code made in VB and with Calc :
| Code: | set oDiagram=oDoc.getSheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject
set oDataSource = oDiagram.getUsedData
tArgs = oDiagram.DataProvider.detectArguments(oDataSource) |
and tArgs is a Property Value array of the TabularDataProviderArguments service. There are several arguments we can retrieve. So :
| Code: | for i=0 to ubound(tArgs)
set oProperty = tArgs(i)
if oProperty.Name = "CellRangeRepresentation" then
sAddressRange = oProperty.Value
exit for
end if
next |
and sAddressRange = "$Sheet1.$A$1:$G$8", the range of the diagram.
For Writer, it's the same code, the chart is defined by :
| Code: | | Set oDiagram = oDoc.EmbeddedObjects.getByIndex(0).Model |
Hope it will be useful for others,
Jérôme. |
|
| Back to top |
|
 |
|