Code: Select all
<?php
//Invoke the OpenOffice.org service manager
$osm = new COM("com.sun.star.ServiceManager",null,CP_UTF8);
?>
Any method or property?
Code: Select all
<?php
//Invoke the OpenOffice.org service manager
$osm = new COM("com.sun.star.ServiceManager",null,CP_UTF8);
?>
Code: Select all
class Office:
'''Frequently used methods in office context'''
def __init__(self, ctx=uno.getComponentContext()):
self.ctx = ctx
self.smgr = self.ctx.ServiceManager
def createUnoService(self, service):
return self.smgr.createInstance(service)
def getDesktop(self):
return self.smgr.createInstanceWithContext("com.sun.star.frame.Desktop",self.ctx)
def getCurrentComponent(self):
return self.getDesktop().getCurrentComponent()
def getCurrentFrame(self):
return self.getDesktop().getCurrentFrame()
def getCurrentComponentWindow(self):
return self.getCurrentFrame().getComponentWindow()
def getCurrentContainerWindow(self):
return self.getCurrentFrame().getContainerWindow()
def getCurrentController(self):
return self.getCurrentFrame().getController()
def callXray(self, obj=None):
"""Macro to call Basic XRay by Bernard Marcelly from Python.
If no object is given, the current document's selection is used"""
sURL = "vnd.sun.star.script:XRayTool._Main.Xray?language=Basic&location=application"
if not obj:
obj = self.getCurrentController().getSelection()
oMSPF = self.createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
oMSP = oMSPF.createScriptProvider('')
oScript = oMSP.getScript(sURL)
oScript.invoke((obj,), (), ())
oMSPF = self.createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")
oMSP = oMSPF.createScriptProvider('')
oScript = oMSP.getScript(sURL)
x = oScript.invoke((thisComponent,), (), ())
def callMRI(self,obj=None):
'''Create an instance of MRI inspector and inspect the given object (default is selection)'''
if not obj:
obj = self.getCurrentController().getSelection()
mri = self.createUnoService("mytools.Mri")
mri.inspect(obj)
def getOOoSetupNode(self, sNodePath):
aConfigProvider = self.createUnoService("com.sun.star.configuration.ConfigurationProvider")
arg = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
arg.Name = "nodepath"
arg.Value = sNodePath
return aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", (arg,))
def getOOoSetupValue(self, sNodePath,sProperty):
oNode = self.getOOoSetupNode(sNodePath)
return oNode.getByName(sProperty)
def setOOoSetupValue(self, sNodePath, sProperty, sValue):
xconfig = self.createUnoService("com.sun.star.configuration.ConfigurationProvider")
arg = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
arg.Name = "nodepath"
arg.Value = sNodePath
try:
xAccess = xconfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",(arg,))
xAccess.setPropertyValue(sProperty, sValue)
xAccess.commitChanges()
except:
return False
else:
return True