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

Ho do you Hide the Legend?

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


Joined: 25 Apr 2005
Posts: 32

PostPosted: Tue Dec 27, 2005 7:56 pm    Post subject: Ho do you Hide the Legend? Reply with quote

Does anyone have any idea whether the Legend can be hide programmatically?

I am using OO to generate the chart. However, the default always comes with a legend. Is there anyway I can get rid of it?
Back to top
View user's profile Send private message
uros
Super User
Super User


Joined: 22 May 2003
Posts: 601
Location: Slovenia

PostPosted: Tue Dec 27, 2005 11:21 pm    Post subject: Reply with quote

Hi rospcc!
Code:
...
oCharts = oSheet.getCharts
sName = "z12"
oChart = oCharts.getByName(sName)
oCh = oChart.getEmbeddedObject

oCh.hasLegend = False
...

Bernard Marcelly's X-Ray is a very useful tool to get answers on such questions:
http://www.ooomacros.org/dev.php#101416
Uros
Back to top
View user's profile Send private message
rospcc
General User
General User


Joined: 25 Apr 2005
Posts: 32

PostPosted: Wed Dec 28, 2005 6:53 pm    Post subject: Reply with quote

Thanx for the reply uros.

I tried to invoke the HasLegend property but I am still getting the Legend box. This is what I did:

Code:

// Create the chart
XTableChart xtablechart = OO.getChart(xSpreadsheet, column, column+1, row, startChart-1, divName, 15000, 10000, row, column);

// Show/Hide the Legend
OO.showLegend(xtablechart, false);


This is the showLegend method:
Code:

public void showLegend(XTableChart xtablechart, boolean bHasLegend) throws Exception
{
      XEmbeddedObjectSupplier xembeddedobjectsupplier = (XEmbeddedObjectSupplier)
           UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
 
      XInterface xinterface = xembeddedobjectsupplier.getEmbeddedObject();

      XChartDocument xchartdocument = (XChartDocument)UnoRuntime.queryInterface(
           XChartDocument.class, xinterface);
}


I tried to invoke the HasLegend properties "xchartdocument.HasLegend" but no such method found. May I know what did I did wrong?
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: Thu Dec 29, 2005 7:59 am    Post subject: Reply with quote

See :
http://api.openoffice.org/docs/common/ref/com/sun/star/chart/ChartDocument.html#HasLegend
where HasLegend is described as a property.
_________________
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
rospcc
General User
General User


Joined: 25 Apr 2005
Posts: 32

PostPosted: Thu Dec 29, 2005 11:31 pm    Post subject: Reply with quote

I tried to modify the original code but couln't find out the service that I should use:

Code:

public void showLegend(XTableChart xtablechart, boolean bHasLegend) throws Exception
{
      XEmbeddedObjectSupplier xembeddedobjectsupplier = (XEmbeddedObjectSupplier)
           UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xtablechart);
 
      XInterface xinterface = xembeddedobjectsupplier.getEmbeddedObject();

      XChartDocument xchartdocument = (XChartDocument)UnoRuntime.queryInterface(
           XChartDocument.class, xinterface);

     // What should be in the "__________" ?
     Object object = xmultiservicefactory.createInstance("com.sun.star.__________");

     XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, object);

    xPropSet.setPropertyValue("HasLegend", new Boolean(bHasLegend));
}
Back to top
View user's profile Send private message
mikepb78
General User
General User


Joined: 22 Jun 2005
Posts: 37

PostPosted: Thu Jun 08, 2006 1:44 am    Post subject: A Solution Reply with quote

This works for me

Code:
   public void showLegend(XTableChart xTableChart, boolean bHasLegend) throws Exception {
      XEmbeddedObjectSupplier xEmbeddedObjectSupplier = (XEmbeddedObjectSupplier)UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, xTableChart);
      XInterface xInterface = xEmbeddedObjectSupplier.getEmbeddedObject();
      XChartDocument xChartDoc = (XChartDocument) UnoRuntime.queryInterface(XChartDocument.class, xInterface);
      XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xChartDoc);
      xPropSet.setPropertyValue("HasLegend", new Boolean(bHasLegend));
   }
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