OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

chartrangeaddress in a writer document

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
JeromeC
General User
General User


Joined: 13 Oct 2005
Posts: 37
Location: France - Nantes

PostPosted: Wed Jul 30, 2008 5:10 am    Post subject: chartrangeaddress in a writer document Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Jul 30, 2008 6:23 am    Post subject: Reply with quote

and what happens with
Code:

sRangeAddress = oChart.getChartRangeAddress

?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
JeromeC
General User
General User


Joined: 13 Oct 2005
Posts: 37
Location: France - Nantes

PostPosted: Wed Jul 30, 2008 7:19 am    Post subject: Reply with quote

Thank you for the reply,

I test with your suggestion :

Code:
ochart.getChartRangeAddress


and it still doesn't work Sad
Back to top
View user's profile Send private message
JeromeC
General User
General User


Joined: 13 Oct 2005
Posts: 37
Location: France - Nantes

PostPosted: Thu Jul 31, 2008 4:02 am    Post subject: Reply with quote

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
View user's profile Send private message
JeromeC
General User
General User


Joined: 13 Oct 2005
Posts: 37
Location: France - Nantes

PostPosted: Thu Jul 31, 2008 7:21 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group