How to create an object of type ::com::sun::star::chart2::data::XLabeledDataSequence ?

Michael Stahl mstahl at redhat.com
Wed May 20 04:58:13 PDT 2015


On 15.05.2015 22:03, Jan Rheinländer wrote:
> Hi,
> 
> I'm trying to insert an XYDiagram into a Writer (!) document by code.
> But I can't figure out how to get any data into it. All the examples on
> the web are always for Calc, never for Writer. The code I have got is below.

>   // Create two new sequences based on the two first default sequences,
> setting the roles correctly for an XYDiagram
>   Reference < ::com::sun::star::chart2::XChartDocument >
> chart(xEOS->getEmbeddedObject(), UNO_QUERY_THROW);
>   chart->createInternalDataProvider(true);
>   Reference< XDataProvider > dataProvider = chart->getDataProvider();

> ===>
> ===> Here the problems start: This gives an "unsatisified query" error
> ===>
>   // Create two sequences
>   Sequence< Reference< XLabeledDataSequence > > sequences(2);
>   sequences[0] = Reference <
> ::com::sun::star::chart2::data::XLabeledDataSequence >
> (cDocMSF->createInstance(OU("com.sun.star.chart2.data.LabeledDataSequence")),
> UNO_QUERY_THROW);

there is a service SwChartLabeledDataSequence but apparently it's not
possible to create it from the writer document factory.

it is created from SwChartDataProvider::createDataSource(), which takes
parameters like "DataRowSource", "FirstCellAsLabel",
"CellRangeRepresentation", "SequenceMapping", "ChartOleObjectName".

perhaps the "dataProvider" variable above would work?

i don't really know how any of this chart stuff works but here's the source:

http://opengrok.libreoffice.org/xref/core/sw/source/core/unocore/unochart.cxx



More information about the LibreOffice mailing list