Hi,
I found a solution for Writer, on version 3.1. Here it is, as a subroutine in OOoBasic:
Code: Select all
Sub embedImagesInWriter(doc as Object)
Dim allImages As Object, imageX As Object
Dim x As Long
allImages = doc.GraphicObjects
for x = 0 to allImages.Count -1
imageX = allImages.getByIndex(x)
if InStr(1, imageX.GraphicURL, "vnd.sun.star.GraphicObject:", 0) = 0 then
imageX.Graphic = getGraphicFromURL(imageX.GraphicURL)
end if
next
End Sub
' This code is provided by Ariel Constenla-Haile, see
' http://www.mail-archive.com/dev@api.openoffice.org/msg09255.html
Function getGraphicFromURL( sURL as String) as com.sun.star.graphic.XGraphic
On Error Resume Next
Dim oGraphicProvider as Object
oGraphicProvider = createUnoservice("com.sun.star.graphic.GraphicProvider")
Dim aMediaProperties(0) as New com.sun.star.beans.PropertyValue
aMediaProperties(0).Name = "URL"
aMediaProperties(0).Value = sURL
getGraphicFromURL = oGraphicProvider.queryGraphic(aMediaProperties)
End Function
It really embeds image files in the document (contrary to user interface
Edit > Links which converts jpg images to png, see
issue 15508).
I could not find the equivalent for Calc or Draw/Impress. The internal design seems different.
I have solved the remaining problem and created
extension Images Embedder. It adds a new item in menu Tools > Options to embed images in the current document. It works on Writer, Calc, Draw, Impress documents.
______
Bernard