openoffice-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "K.Misha" <mi...@4k.com.ua>
Subject RE: insert image into calc document
Date Tue, 06 Aug 2013 18:03:47 GMT
Sorry, but i don't know english very well and i can't express my opinion in
an affordable manner.<неиI want to leave image in file body of calc
document. Code that i wrote here only leaves a link to image like
'D:\image.jpeg'.<неиBut i want to insert image how it insert OpenOffice.org.
<неи<неиCan you help me in this
question?<неи<неиThanks.<неи<неи-----Original Message-----<неиFrom:
Andrew
Douglas Pitonyak [mailto:andrew@pitonyak.org] <неиSent: Tuesday, August 06,
2013 6:58 PM<неиTo: api@openoffice.apache.org<неиSubject: Re: insert image
into calc document<неи<неи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<неи<неи


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Mime
View raw message