Interesting question....
When you insert your image into the document, it then has an internal
URL. The question is.... how to remove the image from the GUI and leave
it in the file.
On 08/05/2013 12:21 PM, K.Misha wrote:
>
>
> From: K.Misha [mailto:misha@4k.com.ua]
> Sent: Monday, August 05, 2013 7:21 PM
> To: 'ooapi@openoffice.com'
> Subject: insert image into calc document
>
>
>
> Hello!
>
>
>
> I have a problem with inserting image into calc document!
>
> I'm doing it this way:
>
>
>
> void insertImage( imgPosition iPos, imgSize iSize, char * imgUrl )
>
> {
>
> Reference< com::sun::star::drawing::XDrawPagesSupplier >
> xDrawPagesSupplier(xCalcComponent, UNO_QUERY);
>
> Reference< XDrawPages > xDrawPages(
> xDrawPagesSupplier->getDrawPages(), UNO_QUERY );
>
> Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex(irSheet),
> UNO_QUERY );
>
> Reference< XShapes > xShapes(xDrawPage, UNO_QUERY);
>
>
>
> com::sun::star::awt::Point imgPoint;
>
> com::sun::star::awt::Size imgSize;
>
>
>
> imgSize.Height = iSize.h;
>
> imgSize.Width = iSize.w;
>
> imgPoint.X = iPos.x;
>
> imgPoint.Y = iPos.y;
>
> ////////the size in 100/th mm
>
>
>
> Reference<XSpreadsheetDocument> xSheetDocument
> (xCalcComponent,UNO_QUERY);
>
> Reference< XModel > aDrawDoc (xSheetDocument, UNO_QUERY);
>
> Reference<XMultiServiceFactory> aFact(aDrawDoc,UNO_QUERY);
>
> Reference< XShape > xShape(
> aFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.Graphi
> cObjectShape")), UNO_QUERY);
>
> //Reference< XShape > xShape( xShapes->getByIndex(0), UNO_QUERY);
>
>
>
> Reference<XPropertySet> rColProps(xShape, UNO_QUERY);
>
>
>
> char * img = imgUrl;//"file:///D:/getImage3.jpeg";
>
> int nLenOfWideCharStr
> =MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,img,-1,NULL,0);
>
> wchar_t *cImg = (PWSTR)HeapAlloc(GetProcessHeap(), 0,
> nLenOfWideCharStr * sizeof(WCHAR));
>
>
> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,img,-1,cImg,nLenOfWideCharStr);
>
>
>
> OUString sstring = cImg;
>
>
>
>
> rColProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL
> ")), makeAny(sstring));
>
>
> //rColProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Name")),
> makeAny(sstring));
>
>
>
> xShape->setPosition(imgPoint);
>
> xShape->setSize(imgSize);
>
> xDrawPage->add(xShape);
>
> }
>
>
>
> //////////////////////////////////////
>
> But every time when i open this calc document, image must be in this path -
> imgUrl. How can i insert image into file body of calc document?
>
>
>
> Thanks!
>
>
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org
|