insert image into calc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

insert image into calc

k.misha
Hello!

I have this code:

Reference< com::sun::star::drawing::XDrawPagesSupplier >
xDrawPagesSupplier(xCalcComponent, UNO_QUERY);

Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(),
UNO_QUERY );

Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex(0), UNO_QUERY );

Reference< XShapes > xShapes(xDrawPage, UNO_QUERY);

 

com::sun::star::awt::Point imgPoint;

com::sun::star::awt::Size imgSize;

 

imgSize.Height = 5000;

imgSize.Width = 25000;

imgPoint.X = 6500;

imgPoint.Y = 8100;

 

Reference<XSpreadsheetDocument> xSheetDocument (xCalcComponent,UNO_QUERY);

Reference< XModel > aDrawDoc (xSheetDocument, UNO_QUERY);

Reference<XChartDocument> aChartDoc;

Reference<XMultiServiceFactory> aFact(aDrawDoc,UNO_QUERY);

Reference< XShape > xShape(
aFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.OLE2Sh
ape")), UNO_QUERY);

 

xShape->setPosition(imgPoint);

xShape->setSize(imgSize);

xDrawPage->add(xShape);

 

This code inserts empty ole object into calc document with my imgSize and
imgPoint.

But how can I set the image for this ole object?

Something like this:

xShape->SetUrl("C:\\1.png") or xShape->SetImage("C:\\1.png").

 

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: insert image into calc

Regina Henschel
Hi,

k.misha schrieb:

> Hello!
>
> I have this code:
>
> Reference< com::sun::star::drawing::XDrawPagesSupplier >
> xDrawPagesSupplier(xCalcComponent, UNO_QUERY);
>
> Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(),
> UNO_QUERY );
>
> Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex(0), UNO_QUERY );
>
> Reference< XShapes > xShapes(xDrawPage, UNO_QUERY);
>
>
>
> com::sun::star::awt::Point imgPoint;
>
> com::sun::star::awt::Size imgSize;
>
>
>
> imgSize.Height = 5000;
>
> imgSize.Width = 25000;
>
> imgPoint.X = 6500;
>
> imgPoint.Y = 8100;
>
>
>
> Reference<XSpreadsheetDocument> xSheetDocument (xCalcComponent,UNO_QUERY);
>
> Reference< XModel > aDrawDoc (xSheetDocument, UNO_QUERY);
>
> Reference<XChartDocument> aChartDoc;
>
> Reference<XMultiServiceFactory> aFact(aDrawDoc,UNO_QUERY);
>
> Reference< XShape > xShape(
> aFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.OLE2Sh
> ape")), UNO_QUERY);
>
>
>
> xShape->setPosition(imgPoint);
>
> xShape->setSize(imgSize);
>
> xDrawPage->add(xShape);
>
>
>
> This code inserts empty ole object into calc document with my imgSize and
> imgPoint.

As far as I see, it inserts only a shape. You have to set the property
CLSID to create the chart document itself. For a chart it is
CLSID="12DCAE26-281F-416F-a234-c3086127382e"

>
> But how can I set the image for this ole object?

You have to set the chart type and fill the data table or the reference
to the data range of the spreadsheet. That should be in Model.

>
> Something like this:
>
> xShape->SetUrl("C:\\1.png") or xShape->SetImage("C:\\1.png").

I think, the picture should be generated automatically, but I'm not sure
whether a kind of update/refresh is necessary.

Kind regards
Regina

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: insert image into calc

k.misha
<неи<неи-----Original Message-----<неиFrom: Regina Henschel [mailto:[hidden email]] <неиSent: Friday, May 10, 2013 7:15 PM<неиTo: [hidden email]<неиSubject: Re: insert image into calc<неи<неиHi,<неи<неиk.misha schrieb:<неи> Hello!<неи><неи> I have this code:<неи><неи> Reference< com::sun::star::drawing::XDrawPagesSupplier ><неи> xDrawPagesSupplier(xCalcComponent, UNO_QUERY);<неи><неи> Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(),<неи> UNO_QUERY );<неи><неи> Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex(0), UNO_QUERY );<неи><неи> Reference< XShapes > xShapes(xDrawPage, UNO_QUERY);<неи><неи><неи><неи> com::sun::star::awt::Point imgPoint;<неи><неи> com::sun::star::awt::Size imgSize;<неи><неи><неи><неи> imgSize.Height = 5000;<неи><неи> imgSize.Width = 25000;<неи><неи> imgPoint.X = 6500;<неи><неи> imgPoint.Y = 8100;<неи><неи><неи><неи> Reference<XSpreadsheetDocument> xSheetDocument (xCalcComponent,UNO_QUERY);<неи><неи> Reference< XModel > aDrawDoc (xSheetDocument, UNO_QUERY);<неи><неи> Reference<XChartDocument> aChartDoc;<неи><неи> Reference<XMultiServiceFactory> aFact(aDrawDoc,UNO_QUERY);<неи><неи> Reference< XShape > xShape(<неи> aFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.OLE2Sh<неи> ape")), UNO_QUERY);<неи><неи><неи><неи> xShape->setPosition(imgPoint);<неи><неи> xShape->setSize(imgSize);<неи><неи> xDrawPage->add(xShape);<неи><неи><неи><неи> This code inserts empty ole object into calc document with my imgSize and<неи> imgPoint.<неи<неиAs far as I see, it inserts only a shape. You have to set the property <неиCLSID to create the chart document itself. For a chart it is <неиCLSID="12DCAE26-281F-416F-a234-c3086127382e"<неи<неи><неи> But how can I set the image for this ole object?<неи<неиYou have to set the chart type and fill the data table or the reference <неиto the data range of the spreadsheet. That should be in Model.<неи<неи><неи> Something like this:<неи><неи> xShape->SetUrl("C:\\1.png") or xShape->SetImage("C:\\1.png").<неи<неиI think, the picture should be generated automatically, but I'm not sure <неиwhether a kind of update/refresh is necessary.<неи<неиKind regards<неиRegina<неи<неи<неи<неи---------------------------------------------------------------------<неиTo unsubscribe, e-mail: [hidden email]<неиFor additional commands, e-mail: api-help@ope<неи<неи<неиRegina, I have understood how to do it.<неиIn documentation of service with wich I initialize XShape are some properties. <неиUsing XPropertySet and setPropertyValue I set option for XShape like UrlPath.<неиAfter this in empty image object appears real image path of wich I set.<неиIf you need this code, tell me please.<неи<неиRegards.<неи

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]