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

Joined: 25 Apr 2005 Posts: 32
|
Posted: Tue Dec 27, 2005 7:56 pm Post subject: Ho do you Hide the Legend? |
|
|
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 |
|
 |
uros Super User


Joined: 22 May 2003 Posts: 601 Location: Slovenia
|
Posted: Tue Dec 27, 2005 11:21 pm Post subject: |
|
|
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 |
|
 |
rospcc General User

Joined: 25 Apr 2005 Posts: 32
|
Posted: Wed Dec 28, 2005 6:53 pm Post subject: |
|
|
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 |
|
 |
SergeM Super User

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

Joined: 25 Apr 2005 Posts: 32
|
Posted: Thu Dec 29, 2005 11:31 pm Post subject: |
|
|
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 |
|
 |
mikepb78 General User


Joined: 22 Jun 2005 Posts: 37
|
Posted: Thu Jun 08, 2006 1:44 am Post subject: A Solution |
|
|
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 |
|
 |
|