*Job [#sc2937da] org.openoffice.Office.Job にある構成で特定のイベント発生時に com.sun.star.task.XJob インターフェースの execute メソッドを呼び出させることができます。 以下のコードは最小構成のタスクです。OnNew イベント (ドキュメントが作成されたとき) に execute メソッドが実行されます。 詳細は以下参照。 -[[Developers Guide Jobs>http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Jobs/Jobs]] **構成 [#w8e28d94] #code(){{ <?xml version="1.0"?> <oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:install="http://openoffice.org/2004/installation" oor:name="Jobs" oor:package="org.openoffice.Office"> <node oor:name="Jobs"> <node oor:name="StartIA" oor:op="replace"> <prop oor:name="Service"> <value>mytools.basicide.IATest</value> </prop> </node> </node> <node oor:name="Events"> <node oor:name="OnNew" oor:op="fuse"> <node oor:name="JobList"> <node oor:name="StartIA" oor:op="replace"/> </node> </node> </node> </oor:component-data> }} **コンポーネント [#f49ae583] #code(python){{ #! # -*- coding: utf-8 -*- import unohelper # interfaces from com.sun.star.task import XJob from com.sun.star.lang import XServiceInfo ImplName = "mytools.basicide.IATest" ServiceNames = ("com.sun.star.task.Job",) class IATest(unohelper.Base, XJob, XServiceInfo): def __init__(self,ctx): self.ctx = ctx print("initialized") # XJob def execute(self, args): print("job executed.") # XServiceInfo def getImplementationName(self): return ImplName def supportsService(self, name): return name in ServiceNames def getSupportedServiceNames(self): return ServiceNames g_ImplementationHelper = unohelper.ImplementationHelper() g_ImplementationHelper.addImplementation( IATest, ImplName, ServiceNames) }} |