I have written a program in AutoHotkey That adds and places a Picture into Calc (Which works)
but, I experiencing a variety of restrictions, that I do not know how they are managed.
This is the code(below) in Autohotkey language (I have not translated the code back to Basic).
Feel free to answer with examples from Basic or other programming language.
Code: Select all
#Warn ; Enable warnings to assist with detecting common errors.
SetBatchLines -1
;#SingleInstance force
;#NoEnv
; ;Persistent
; Process Priority,, High
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Create a new Calc spreadsheet.
oSM := ComObjCreate("com.sun.star.ServiceManager")
; objCoreReflection := objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
oDesk := oSM.createInstance("com.sun.star.frame.Desktop") ; Create the Desktop
oArgs := ComObjArray(VT_VARIANT := 12, 3)
oArgs[0] := MakePropertyValue(oSM, "", "")
sURL := "private:factory/scalc"
oDoc := oDesk.loadComponentFromURL(sURL, "_blank", 0, oArgs)
; oSheet := oDoc.getSheets().getByIndex( 0 )
oSheet := oDoc.Sheets.getByIndex( 0 )
LogoName = LogoExpo.jpg
LogoPath = C:\Users\Personal\Documents\Expo\Logo\Logotyper 2012\Squid
Logo := LogoPath "\" LogoName
IfNotExist %Logo%
{ MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, Missing image .: %LogoName% `nPath .: %LogoPath% `n`nProgram is ended!
ExitApp
}
StringReplace ImageURL, Logo, \, `/, All
ImageURL := "file:///" ImageURL ; ImageURL := "C:/Users/Personal/Documents/Expo/Logo/Logotyper 2012/Squid/LogoExpo.jpg"
; MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, Logo .:`n%Logo% `n`npicURL .:`n%ImageURL%
oImage := oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape") ; oImagen_obj = ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")
oImage.GraphicURL := ImageURL
oSize := oImage.Size
oSize.Height := 5000
oSize.Width := 5000
oImage.Size := oSize
oPos := oImage.Position
oPos.X := 5000
oPos.Y := 5000
oImage.Position := oPos
oDP := oDoc.DrawPages.getByIndex(0)
oDP.add(oImage)
MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, Ready!, 2
ExitApp
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Function MakePropertyValue(cName, uValue)
; Version 2 juni 2016
MakePropertyValue(oSM, cName, uValue)
{ ; oSM := ComObjCreate("com.sun.star.ServiceManager")
oPropertyValue := oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oPropertyValue.Name := cName
oPropertyValue.Value := uValue
Return oPropertyValue
}
Is there any method, to cause the image to place it behind other objects (like text)?
2.
In the example above, you must give values of both height and width. (the images loses usually the aspect ratio )
Is there a way where only one dimensions on the image is specified, and the other is follow?
3.
Is there any way in which the image follows the cells instead of x / y coordinates as the above example?
4.
Suppose a simple product catalog will be built up in Calc. To each product must an image and a barcode automatically be linked.
How to solve this in the best way?
5.
Is it possible to fill the entire cell with only one image? (even with merged cells)
6.
How do you know that the image will be included in the document (Calc)?
7.
Where to find more examples and ideas around image handle, primarily in Calc?
//Jan