objServiceManager, objDesktop, objDocument sont des objets Automation dynamique
objServiceManager = allouer un objet Automation "com.sun.star.ServiceManager"
objDesktop = objServiceManager>>createInstance("com.sun.star.frame.Desktop")
args est un tableau de 0 entiers
//ouverture de excel
objDocument = objDesktop>>loadComponentFromURL("private:factory/scalc","_blank", 0, args)
//ouverture d'un document existant
objDocument = objDesktop>>loadComponentFromURL("file:///c|/test.doc","_blank", 0, args)
libérer objDocument
libérer objDesktop
libérer objServiceManager
//--------------------------------------------------------------------------------------
//Exemple de declaration dans delphi :
var Struct: variant;
begin
Struct := StarOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
Struct.Name := PropName;
Struct.Value := PropValue;
end;
//--------------------------------------------------------------------------------------
//Exemple de declaration dans VB :
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).name = "Hidden"
args(0).value = true
//Autre exemple pour acceder a cette structure en VB
//------------------------------------------------------------------------
Function setOOoProp(cName, uValue) As Object //fonction tampon pour la structure
Dim oPropertyValue As Object
Dim oSM As Object
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oPropertyValue = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oPropertyValue.Name = cName
oPropertyValue.Value = uValue
Set setOOoProp = oPropertyValue
End Function
Dim OpenPar(2) As Object
Set OpenPar(0) = setOOoProp("ReadOnly", True)
Set OpenPar(1) = setOOoProp("Password", "secret")
Set OpenPar(2) = setOOoProp("Hidden", False)
//--------------------------------------------------------------------------------------
//Exemple de tentatives infructueuse en windev (Erreur de CODE):
fileprop est un Variant
fileprop=objServiceManager>>Bridge_GetStruct("com.sun.star.beans.PropertyValue")
args est un tableau de 1 fileprop
//------------------------------------------
args est un tableau de 1 objServiceManager>>Bridge_GetStruct("com.sun.star.beans.PropertyValue")
//------------------------------------------
//D'apres l'exemple avec la fonction tampon :
PROCEDURE SProp(cName, uValue)
oPropertyValue est un objet Automation dynamique
oSM est un objet Automation dynamique
oSM = allouer un objet Automation "com.sun.star.ServiceManager"
oPropertyValue = oSM>>Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oPropertyValue>>Name = cName
oPropertyValue>>Value = uValue
RENVOYER oPropertyValue
args est un tableau de 1 objets Automation dynamique
args[1]=SProp("ReadOnly",True)
objDocument = objDesktop>>loadComponentFromURL(Url,"_blank", 0, args)
Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=12&topic_id=1773&post_id=7397