If I understand correctly you want to embed a GraphicObjectShape, ie
first linking an image that is actually located somewhere and then
telling the office to embed it into the document structure absolutely
and permanently, so that the original image file does not be existent
anymore because it is fully incorporated into the document.

DannyB investigated on this and came up with something that did right
this, using the css::drawing::BitmapTable service. It is one of the
most useful SB code snippets I have seen so far, Danny Brewer is well
known for providing excellent and useful code examples to the OOo
community.

I extracted the code and did some changes here and there (I guess it
was only about the file url ;-) ), so you get this slightly modified
version pasted to here:

<code>
Sub EmbedAnImageCompletely
   oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter",
"_blank", 0, Array() )
   oDrawPage = oDoc.getDrawPage()
   
   cFile = "C:\hero-left.bmp"
   'cFile = "/home/danny/Desktop/microsoft cash cow.jpg"
   cUrl = ConvertToUrl( cFile )
   
   ' Convert the URL into an internal URL within the document.
   ' If you comment out this line, then the shape that is created from the url
   '  will refer to the external graphic, which must always be present.
   cUrl = LoadGraphicIntoDocument( oDoc, cUrl, "Cash Cow" )
   ' Now the URL points to a graphic *inside* of the document's Zip file,
   '  rather than an external url.
   
   ' Create a GraphicObjectShape.
   oShape = MakeGraphicObjectShape( oDoc, MakePoint( 1500, 3000 ),
MakeSize( 3000, 4000 ) )
   ' Add it to the drawing page.
   oDrawPage.add( oShape )
   ' Set its URL to a particular graphic.
   oShape.GraphicURL = cUrl
End Sub 



' Given a URL to an external graphic resource,
'  load that graphic permanently into this drawing document,
'  and return a new URL to the internal resource.
' The new URL can be used in place of the old URL.
Function LoadGraphicIntoDocument( oDoc As Object, cUrl As String,
cInternalName As String ) As String
   ' Get the BitmapTable from this drawing document.
   ' It is a service that maintains a list of bitmaps that are internal
   '  to the document.
   oBitmaps = oDoc.createInstance( "com.sun.star.drawing.BitmapTable" )
   
   ' Add an external graphic to the BitmapTable of this document.
   oBitmaps.insertByName( cInternalName, cUrl )
   
   ' Now ask for it back.
   ' What we get back is an different Url that points to a graphic
   '  which is inside this document, and remains with the document.
   cNewUrl = oBitmaps.getByName( cInternalName )
   
   LoadGraphicIntoDocument = cNewUrl
End Function 
</code>

The descriptions and the original code can be found on
http://www.oooforum.org/forum/viewtopic.phtml?t=14979 .

As you can see there is nothing about dispatches, everything are pure
API style calls ;).

Hope this helps somehow.

2005/8/3, MuiFull Tam <[EMAIL PROTECTED]>:
> Hi all,
> 
> I would like to insert embedded graphics into Writer. By using the API,
> I could successfully insert graphics which are linked to image files. I
> realize that there is a "Link" menu under the Edit menu which displays a
> dialog box and allow the removal of links. I suppose this option fits my
> need perfectly and I started finding ways to achieve what the Links
> dialog box does.
> 
> I tried record my actions as macro, the following code display the Edit
> Links dialog box. But I do not want to have user intervention during the
> link removal process, so I tried finding other ways...
> dispatcher.executeDispatch(document, ".uno:LinkDialog", "", 0, Array())
> 
> Then, I found the interface XLinkageSupport, which I thought it might be
> helpful as it offers the breakLink() method. However, I could not figure
> out what objects should be used for querying the XLinkageSupport
> interface. I have tried querying both the text document (XTextDocument)
> and the graphic (XTextContent) but both return null.
> 
> Is there any possibility to do what I am attempting to do? If
> XLinkageSupport does work for my need, could anyone please explain
> briefly how to use the XLinkageSupport interface?
> 
> Thanks for any help in advance!
> 
> Best Regards,
> MuiFull
> 
> PS. I browsed through the forum and knew that embedded graphics could be
> created through the use of dispatch interface, but this is not the best
> solution for my case. This is because I need to have an accurate
> positioning for graphics, and by using dispatch, I need to obtain
> references of the created graphics in further, and to do the positioning
> through normal API. Performance issue is then a big concern...
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Best Regards
Christian Junker

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to