1# 2# This file is part of the LibreOffice project. 3# 4# This Source Code Form is subject to the terms of the Mozilla Public 5# License, v. 2.0. If a copy of the MPL was not distributed with this 6# file, You can obtain one at http://mozilla.org/MPL/2.0/. 7# 8# This file incorporates work covered by the following license notice: 9# 10# Licensed to the Apache Software Foundation (ASF) under one or more 11# contributor license agreements. See the NOTICE file distributed 12# with this work for additional information regarding copyright 13# ownership. The ASF licenses this file to you under the Apache 14# License, Version 2.0 (the "License"); you may not use this file 15# except in compliance with the License. You may obtain a copy of 16# the License at http://www.apache.org/licenses/LICENSE-2.0 . 17# 18import unohelper 19import traceback 20 21from .LetterWizardDialogImpl import LetterWizardDialogImpl, Desktop 22 23from com.sun.star.lang import XServiceInfo 24from com.sun.star.task import XJobExecutor 25 26# pythonloader looks for a static g_ImplementationHelper variable 27g_ImplementationHelper = unohelper.ImplementationHelper() 28g_implName = "com.sun.star.wizards.letter.CallWizard" 29 30# implement a UNO component by deriving from the standard unohelper.Base class 31# and from the interface(s) you want to implement. 32class CallWizard(unohelper.Base, XJobExecutor, XServiceInfo): 33 def __init__(self, ctx): 34 # store the component context for later use 35 self.ctx = ctx 36 37 def trigger(self, args): 38 try: 39 lw = LetterWizardDialogImpl(self.ctx.ServiceManager) 40 lw.startWizard(self.ctx.ServiceManager) 41 except Exception as e: 42 print ("Wizard failure exception " + str(type(e)) + 43 " message " + str(e) + " args " + str(e.args) + 44 traceback.format_exc()) 45 46 @classmethod 47 def callRemote(self): 48 #Call the wizard remotely(see README) 49 try: 50 ConnectStr = \ 51 "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" 52 xLocMSF = Desktop.connect(ConnectStr) 53 lw = LetterWizardDialogImpl(xLocMSF) 54 lw.startWizard(xLocMSF) 55 except Exception as e: 56 print ("Wizard failure exception " + str(type(e)) + 57 " message " + str(e) + " args " + str(e.args) + 58 traceback.format_exc()) 59 60 def getImplementationName(self): 61 return g_implName 62 63 def supportsService(self, ServiceName): 64 return g_ImplementationHelper.supportsService(g_implName, ServiceName) 65 66 def getSupportedServiceNames(self): 67 return g_ImplementationHelper.getSupportedServiceNames(g_implName) 68 69g_ImplementationHelper.addImplementation( \ 70 CallWizard, # UNO object class 71 g_implName, # implementation name 72 ("com.sun.star.task.Job",),) # list of implemented services 73 # (the only service) 74 75# vim:set shiftwidth=4 softtabstop=4 expandtab: 76