chi non muore si rivede

Sono un po' arrugginito, si possono esportare le immagini da un foglio di calcolo rilevandone la posizione della cella a cui erano linkati?
Codice: Seleziona tutto
Sub ExportImages
sPath = "F:\Download\"
oSheet = ThisComponent.CurrentController.ActiveSheet
For i=0 To oSheet.DrawPage.getCount()-1
g = oSheet.Drawpage.getByIndex(i)
saveGraphic(g.Graphic,ConvertToURL(sPath & g.Name & ".jpg"))
Next
End Sub
Sub saveGraphic(in_obj, out_url)
Dim i(0) As New com.sun.star.beans.PropertyValue
Dim a(1) As New com.sun.star.beans.PropertyValue
Dim p As Object
Dim g As Object
p = createUnoService("com.sun.star.graphic.GraphicProvider")
a(0).Name = "MimeType"
a(0).Value = "image/jpeg"
a(1).Name = "URL"
a(1).Value = out_url
p.storeGraphic(in_obj,a)
End Sub
Codice: Seleziona tutto
doc = XSCRIPTCONTEXT.getDocument()
def get_images():
path = "/home/sergio/customer/Pictures/"
for s in range(0, doc.Sheets.getCount()-1):
sheet = doc.Sheets.getByIndex(s)
draw_page = sheet.getDrawPage()
for i in range(0, draw_page.getCount()-1):
file_path = ''
graphic = draw_page.getByIndex(i)
cell = sheet.getCellRangeByName(graphic.getAnchor().AbsoluteName)
mime_type = graphic.Graphic.MimeType
ext = 'png'
if mime_type == "image/jpeg":
ext = 'jpg'
if mime_type == "image/x-wmf":
ext = 'wmf'
file_path = path + \
graphic.GraphicURL[len(graphic.GraphicURL)-27:] + \
'.' + ext
cell.String = file_path
Codice: Seleziona tutto
Sub ExportImages
Dim s As new com.sun.star.awt.Size
Dim gp As new com.sun.star.awt.Point
dim acell as object
'Dim ap As new com.sun.star.awt.Point
'Dim p As new com.sun.star.awt.Point
sPath = "F:\Download\"
oSheet = ThisComponent.CurrentController.ActiveSheet
For i=0 To oSheet.DrawPage.getCount()-1
g = oSheet.Drawpage.getByIndex(i)
s = g.getSize()
gp = g.getPosition()
aCell = g.anchor
oConv = ThisComponent.createInstance("com.sun.star.table.CellAddressConversion")
oConv.Address = aCell.getCellAddress
adr = oConv.UserInterfaceRepresentation
saveGraphic(g.Graphic,ConvertToURL(sPath & g.Name & "-" & adr & ".jpg"))
Next
End Sub
Sub saveGraphic(in_obj, out_url)
Dim i(0) As New com.sun.star.beans.PropertyValue
Dim a(1) As New com.sun.star.beans.PropertyValue
Dim p As Object
Dim g As Object
p = createUnoService("com.sun.star.graphic.GraphicProvider")
a(0).Name = "MimeType"
a(0).Value = "image/jpeg"
a(1).Name = "URL"
a(1).Value = out_url
p.storeGraphic(in_obj,a)
End Sub
Codice: Seleziona tutto
Sub ExportImages
sPath = "/home/sergio/customer/Pictures/"
oDoc = ThisComponent
For s=0 To oDoc.Sheets.getCount()-1
oSheet = oDoc.Sheets.getByIndex(s)
For i=0 To oSheet.DrawPage.getCount()-1
oGraphic = oSheet.Drawpage.getByIndex(i)
oCell = oSheet.getCellRangeByName(oGraphic.getAnchor().AbsoluteName)
address = oCell.CellAddress
oRightCell = oSheet.getCellByPosition(address.Column +1, address.Row, s)
saveGraphic(oGraphic.Graphic, ConvertToURL(sPath & oRightCell.String & ".jpg"))
Next
Next
End Sub
Sub saveGraphic(in_obj, out_url)
Dim a(1) As New com.sun.star.beans.PropertyValue
Dim p As Object
p = createUnoService("com.sun.star.graphic.GraphicProvider")
a(0).Name = "MimeType"
a(0).Value = "image/jpeg"
a(1).Name = "URL"
a(1).Value = out_url
p.storeGraphic(in_obj,a)
End Sub