Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-27 Thread Doan Nguyen Van
Ingrid,

Thank you very much for your helps.

Kind regards,
Doan Nguyen Van


Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-27 Thread Ingrid Halama

Hi Doan Nguyen Van,

On 05/27/10 13:18, Doan Nguyen Van wrote:


I have more one question: Is chart name unique in the spreadsheet document?



As the PersistName is used to save the OLE object, it must be unique, yes.

Kind regards,
Ingrid

-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-27 Thread Ingrid Halama

Hi Doan Nguyen Van,

On 05/27/10 09:50, Doan Nguyen Van wrote:
 > Do you know how to receive XSpreadsheet from XChartDocument or XTableChart?




Query XChartDocument for interface com.sun.star.container.XChild.
The parent then should be a XSpreadsheetDocument.

Kind regards,
Ingrid

-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Doan Nguyen Van
Ingrid,

 

> If your first method gives you the wanted result, why not using it?

 

Because the shapes (of draw page of the sheet) don't have any references to
TableChart or ChartDocument, so it is not possible to understand which
TableChart some shape is related to.

 

> The second method cannot lead to the wanted result as the chart itself
does not know anything about a surrounding spreadsheet page.

 

There is no way to get position of a chart?

 

Thanks and best regards,

 

Doan Nguyen Van



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Ingrid Halama

Hi Doan Nguyen Van,

Am 26.05.10 17:20, Doan Nguyen Van schrieb:

Ingrid,

 


If your first method gives you the wanted result, why not using it?


 

Because the shapes (of draw page of the sheet) don't have any references 
to TableChart or ChartDocument, so it is not possible to understand 
which TableChart some shape is related to.


 

 The second method cannot lead to the wanted result as the chart itself 

does not know anything about a surrounding spreadsheet page.

 


The is no way to get position of a chart?



Not directly from the chart itself.
What you can do is to remind the name of the chart and then get the shape via 
that name from the spreadsheet.
To get the correct shape search through all shapes. If XShapeDescriptor::getShapeType equals 
"com.sun.star.drawing.OLE2Shape" check the property 'PersistName'.


Hope that helps,
Ingrid

-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Doan Nguyen Van
Ingrid,

 

> If your first method gives you the wanted result, why not using it?

 

Because the shapes (of draw page of the sheet) don't have any references to
TableChart or ChartDocument, so it is not possible to understand which
TableChart some shape is related to.

 

> The second method cannot lead to the wanted result as the chart itself
does not know anything about a surrounding spreadsheet page.

 

The is no way to get position of a chart?

 

Thanks and best regards,

 

Doan Nguyen Van



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Ingrid Halama

Am 26.05.10 16:11, Doan Nguyen Van schrieb:

Thanks so much for your helps! Now I could resolve the problem.


Nice to hear that!
 


Now I have another problem concerning getting position of a chart within a
sheet. With draw page of the sheet, we could get position of the shape using
following code:

 


Object shapeAsObject = drawPage.getByIndex(0);

XShape chartShape = (XShape) UnoRuntime.queryInterface(XShape.class,
shapeAsObject);

com.sun.star.awt.Point oopos = chartShape.getPosition();

 


But with draw page of the chart document, the position of the shape always
is (0, 0). May be we should update whatever before getting the position of
the chart? (I've already updated the view before getting the position, but
it doesn't help)



If your first method gives you the wanted result, why not using it?
The second method cannot lead to the wanted result as the chart itself does not know anything about a surrounding 
spreadsheet page.

Each shape that you get from the charts draw page has a position relative to 
the chart.

Kind regards,
Ingrid

-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Doan Nguyen Van
 

> Hm, there are different possibilities how to trigger the generation of the


shapes within the given draw page.

I think the best one is to directly request the view to update:

. . .

This is not standard API code, but I don't expect this part of the chart2
API 
to change in the next years.
 
Hope that helps,
Ingrid

 

 

Hi Ingrid,

 

Thanks so much for your helps! Now I could resolve the problem.

 

Now I have another problem concerning getting position of a chart within a
sheet. With draw page of the sheet, we could get position of the shape using
following code:

 

Object shapeAsObject = drawPage.getByIndex(0);

XShape chartShape = (XShape) UnoRuntime.queryInterface(XShape.class,
shapeAsObject);

com.sun.star.awt.Point oopos = chartShape.getPosition();

 

But with draw page of the chart document, the position of the shape always
is (0, 0). May be we should update whatever before getting the position of
the chart? (I've already updated the view before getting the position, but
it doesn't help)

 

Thanks and best regards,

Doan Nguyen Van



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Ingrid Halama

Am 26.05.10 12:34, Doan Nguyen Van schrieb:


The draw page of the chart has only one shape (drawPage.getCount()returns
1).  I've tried to use the draw page for exporting but It was failed, no
image has been exported.


Ah, I see. Then this is a different problem. The shapes representing the chart are still not generated at the moment of 
export. So the result is empty.

I guess if you double click your chart first and then run the exporting code 
you will get the wanted result.

Hm, there are different possibilities how to trigger the generation of the 
shapes within the given draw page.
I think the best one is to directly request the view to update:
//get the view from the model (there is one view for one model):
XMultiServiceFactory aChartFactory = 
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, 
aChartDoc);
XUpdatable aChartView = (XUpdatable)UnoRuntime.queryInterface(XUpdatable.class, 
aChartFactory.createInstance("com.sun.star.chart2.ChartView"));

//and use interface com.sun.star.util.XUpdatable to trigger the generation of 
the shapes
aChartView.update();

Do this before using the exporter.

This is not standard API code, but I don't expect this part of the chart2 API 
to change in the next years.

Hope that helps,
Ingrid

-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Doan Nguyen Van
On 02/26/10 02:59, Ingrid Halama wrote:

> Hi,

 

> In case the draw page from spreadsheet is used it is ok to export only the
first shape from that page (as this first shape is the chart as it seems in
this scenario). But different if you use the draw page of the chart. In that
case it is wrong to only export the first shape. Try to use the draw page
itself for export instead. 

 

Hope that helps,

Ingrid

 

Hi Ingrid,

 

The draw page of the chart has only one shape (drawPage.getCount()returns
1). I've tried to use the draw page for exporting but It was failed, no
image has been exported. The exporting code is:

 

XDrawPageSupplier drawPageSupplier =

  UnoRuntime.queryInterface(XDrawPageSupplier.class,
aChartDoc);

XDrawPage drawPage = drawPageSupplier.getDrawPage();



XComponent xDrawPageComp = (XComponent)
UnoRuntime.queryInterface(XComponent.class, 

 drawPage);

  

//Create an exporter

XExporter exporter = (XExporter)UnoRuntime.queryInterface(

  XExporter.class,

 
xMultiServiceFactory.createInstance("com.sun.star.drawing.GraphicExportFilte
r"));

  

PropertyValue[] exportProperties = new PropertyValue[2];

exportProperties[0] = new PropertyValue();

exportProperties[0].Name = "MediaType";

exportProperties[0].Value = "image/jpeg";

   

exportProperties[1] = new PropertyValue();

exportProperties[1].Name = "URL";

exportProperties[1].Value = "file:///E:/Temp/Chart_OO.jpeg
 ";



exporter.setSourceDocument(xDrawPageComp);

XFilter drawFilter = (XFilter)
UnoRuntime.queryInterface(XFilter.class, exporter);

drawFilter.filter(exportProperties);

 

 

Best regards,

Doan Nguyen Van

 



Re: Fwd: FW: Re: [graphics-dev] save chart image to file

2010-05-26 Thread Ingrid Halama

Hi,

In case the draw page from spreadsheet is used it is ok to export only the first shape from that page (as this first 
shape is the chart as it seems in this scenario). But different if you use the draw page of the chart. In that case it 
is wrong to only export the first shape. Try to use the draw page itself for export instead.


Hope that helps,
Ingrid

Am 26.05.10 11:00, Oleg Mikheev schrieb:

Hi!

Just checking if the mail list works or not.
The forwarded message was sent out one day ago - still
hasn't appeared on the list.
If you see this message we would be grateful if you could
(try to) answer the question.

Thanks!

 Original Message 
Subject:FW: Re: [graphics-dev] save chart image to file
Date:   Tue, 25 May 2010 13:51:11 +0400
From:   Doan Nguyen Van 
To: 'Oleg Mikheev' 





*From:* Doan Nguyen Van [mailto:ngvdoa...@yahoo.co.uk]
*Sent:* Tuesday, May 25, 2010 13:46
*To:* 'dev@graphics.openoffice.org'
*Cc:* 'ingrid.hal...@sun.com'
*Subject:* Re: [graphics-dev] save chart image to file



On 02/24/10 10:10, Ingrid Halama wrote:


Hi,





What is the problem? In case you want to access the generated shapes

within the chart: The chart document supports interface
::com::sun::star::srawing::XDrawPageSupplier. The given draw page
contains generated draw shapes as well as persistent ones.





Hi Ingrid,



I’ve been able to get interface XDrawPage from a XChartDocument. But
when I export the shapes in the draw page, the exported image is empty.
May be it’s a bug of OpenOffice.org? My code for exporting is:



XDrawPageSupplier drawPageSupplier =

  UnoRuntime./queryInterface/(XDrawPageSupplier.*class*,
aChartDoc);

XDrawPage drawPage = drawPageSupplier.getDrawPage();



Object shapeAsObject = drawPage.getByIndex(0);

XShape chartShape = (XShape)
UnoRuntime./queryInterface/(XShape.*class*, shapeAsObject);

XComponent pageToExport = (XComponent)
UnoRuntime./queryInterface/(XComponent.*class*,

  chartShape);



//Create an exporter

XExporter exporter = (XExporter)UnoRuntime./queryInterface/(

  XExporter.*class*,


xMultiServiceFactory.createInstance("com.sun.star.drawing.GraphicExportFilter"));



PropertyValue[] exportProperties = *new* PropertyValue[2];

exportProperties[0] = *new* PropertyValue();

exportProperties[0].Name = "MediaType";

exportProperties[0].Value = "image/jpeg";



exportProperties[1] = *new* PropertyValue();

exportProperties[1].Name = "URL";

exportProperties[1].Value = "file:///E:/Temp/Chart_OO.jpeg";



exporter.setSourceDocument(pageToExport);

XFilter drawFilter = (XFilter)
UnoRuntime./queryInterface/(XFilter.*class*, exporter);

drawFilter.filter(exportProperties);



aChartDoc is a XChartDocument. With XDrawPage received from
XSpreadsheet, the above code perfectly works.



Thanks and best regards,

Doan Nguyen Van


-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org





-
To unsubscribe, e-mail: dev-unsubscr...@graphics.openoffice.org
For additional commands, e-mail: dev-h...@graphics.openoffice.org