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-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 ngvdoa...@yahoo.co.uk
To: 'Oleg Mikheev' omikh...@gmail.com





*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



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
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

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
 

 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 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 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.

 

There is no way to get position of a chart?

 

Thanks and best regards,

 

Doan Nguyen Van



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

2010-03-03 Thread Oleg Mikheev
  Unfortunately ChartDocument does not support XDrawPageSupplier,
  at least that's what UNO API document states:
  http://api.openoffice.org/docs/common/ref/com/sun/star/chart/ChartDocument.html
 
  Or did you mean some other ChartDocument?
 

 No, the documentation is incomplete there.

Thanks Ingrid,

I've been able to solve my task by doing
com.sun.star.chart.XChartDocument aChartDocument = UnoRuntime.queryInterface(
com.sun.star.chart.XChartDocument.class,
(UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class,
chart)).getEmbeddedObject());
XDrawPageSupplier drawPageSupplier =
UnoRuntime.queryInterface(XDrawPageSupplier.class, aChartDocument);

To make sure that this approach is not something 'non-official' and
will not break with the next release documentation should reflect it.
So I filed a bug: http://www.openoffice.org/issues/show_bug.cgi?id=109765

Thanks again,
Oleg


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

2010-03-01 Thread Ingrid Halama

On 02/27/10 21:22, Oleg Mikheev wrote:

Unfortunately it still doesn't do what I need. The only way I can use
GraphicExport is to get a list of shapes and checking their CLSIDs as
described on

http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Accessing_Existing_Chart_Documents

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. 



Ingrid,

My problem is that I can't access chart/draw from
TableChart or ChartDocument.

Unfortunately ChartDocument does not support XDrawPageSupplier,
at least that's what UNO API document states:
http://api.openoffice.org/docs/common/ref/com/sun/star/chart/ChartDocument.html

Or did you mean some other ChartDocument?



No, the documentation is incomplete here.

Kind regards,
Ingrid




XDrawPageSupplier usage page suggests that the ONLY class that
supports it is Spreadsheet service:
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/XDrawPageSupplier-xref.html

So, is there anything in UNO API that would let me
get the Shape/DrawPage (or anything else that can be exported
to a image file) for a TableChart or ChartDocument?

Thanks,
Oleg

-
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



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

2010-03-01 Thread Ingrid Halama

On 02/27/10 21:22, Oleg Mikheev wrote:

Unfortunately it still doesn't do what I need. The only way I can use
GraphicExport is to get a list of shapes and checking their CLSIDs as
described on

http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Accessing_Existing_Chart_Documents

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. 



Ingrid,

My problem is that I can't access chart/draw from
TableChart or ChartDocument.

Unfortunately ChartDocument does not support XDrawPageSupplier,
at least that's what UNO API document states:
http://api.openoffice.org/docs/common/ref/com/sun/star/chart/ChartDocument.html

Or did you mean some other ChartDocument?



No, the documentation is incomplete there.

Kind regards,
Ingrid




XDrawPageSupplier usage page suggests that the ONLY class that
supports it is Spreadsheet service:
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/XDrawPageSupplier-xref.html

So, is there anything in UNO API that would let me
get the Shape/DrawPage (or anything else that can be exported
to a image file) for a TableChart or ChartDocument?

Thanks,
Oleg

-
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



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

2010-02-28 Thread Oleg Mikheev
 Unfortunately it still doesn't do what I need. The only way I can use
 GraphicExport is to get a list of shapes and checking their CLSIDs as
 described on
 
 http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Accessing_Existing_Chart_Documents
 
 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. 


Ingrid,

My problem is that I can't access chart/draw from
TableChart or ChartDocument.

Unfortunately ChartDocument does not support XDrawPageSupplier,
at least that's what UNO API document states:
http://api.openoffice.org/docs/common/ref/com/sun/star/chart/ChartDocument.html

Or did you mean some other ChartDocument?

XDrawPageSupplier usage page suggests that the ONLY class that
supports it is Spreadsheet service:
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/XDrawPageSupplier-xref.html

So, is there anything in UNO API that would let me
get the Shape/DrawPage (or anything else that can be exported
to a image file) for a TableChart or ChartDocument?

Thanks,
Oleg

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



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

2010-02-24 Thread Ingrid Halama

On 02/24/10 10:10, Oleg Mikheev wrote:

A usage example for GraphicExportFilter is at
http://codesnippets.services.openoffice.org/Office/Office.GraphicExport.snip.
It also works in Calc.



Hi

Unfortunately it still doesn't do what I need. The only way I can use
GraphicExport is to get a list of shapes and checking their CLSIDs as
described on
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Charts/Accessing_Existing_Chart_Documents


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.


Kind regards,
Ingrid

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



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

2010-02-23 Thread Christian Lippka - Sun Microsystems Gmbh - Hamburg

Hi Oleg,

please find an updated example here

http://www.ooowiki.de/DiagrammExport

It exports chart shapes directly from the current calc document.

Regards,
Christian

Am 22.02.2010 21:41, schrieb Oleg Mikheev:

Dear Developers,

I need to save a Calc chart to external graphical image file.
9 years ago it was promised that a special component would be introduced
for that purpose:
http://graphics.openoffice.org/servlets/ReadMsg?list=devmsgNo=70

I couldn't find any trace of such a component in current OO, and
the only way I could save a chart to an image was applying a workaround
that involved copying chart to drawing.

This page
http://graphics.openoffice.org/chart/chart2codestructure.html
statest that
The View is the creator of the visual screen representation. The chart view
creates Shapes as offered by Draw and Impress ( see API com::sun::star::drawing
http://api.openoffice.org/source/browse/api/offapi/com/sun/star/drawing/?only_with_tag=MAINservice
'Shape'). There are some c++ exports from this library (see
chart2/source/inc/chartview) offered for use in the controller. These are
candidates for UNO interfaces in future.

My questions are:
1. What is a recommended way of exporting charts to images in OO 3.2?
2. Will the View component be able to export images, and if yes - when it
will be available in UNO?

Thanks!

   



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



[graphics-dev] save chart image to file

2010-02-22 Thread Oleg Mikheev
Dear Developers,

I need to save a Calc chart to external graphical image file.
9 years ago it was promised that a special component would be introduced
for that purpose:
http://graphics.openoffice.org/servlets/ReadMsg?list=devmsgNo=70

I couldn't find any trace of such a component in current OO, and
the only way I could save a chart to an image was applying a workaround
that involved copying chart to drawing.

This page
http://graphics.openoffice.org/chart/chart2codestructure.html
statest that
The View is the creator of the visual screen representation. The chart view
creates Shapes as offered by Draw and Impress ( see API com::sun::star::drawing
http://api.openoffice.org/source/browse/api/offapi/com/sun/star/drawing/?only_with_tag=MAINservice
'Shape'). There are some c++ exports from this library (see
chart2/source/inc/chartview) offered for use in the controller. These are
candidates for UNO interfaces in future.

My questions are:
1. What is a recommended way of exporting charts to images in OO 3.2?
2. Will the View component be able to export images, and if yes - when it
will be available in UNO?

Thanks!