From 265025d520fc7558ff366d016a94557a2331de1c Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Wed, 22 Mar 2006 09:53:27 +0000 Subject: [PATCH] INTEGRATION: CWS pyunofixes2 (1.3.40); FILE MERGED 2006/01/07 21:36:36 jbu 1.3.40.2: RESYNC: (1.3-1.4); FILE MERGED 2006/01/07 20:13:41 jbu 1.3.40.1: #i57379# added pyuno current context support --- pyuno/source/module/unohelper.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pyuno/source/module/unohelper.py b/pyuno/source/module/unohelper.py index 5a31f2059131..94ece13bed92 100644 --- a/pyuno/source/module/unohelper.py +++ b/pyuno/source/module/unohelper.py @@ -4,9 +4,9 @@ # # $RCSfile: unohelper.py,v $ # -# $Revision: 1.4 $ +# $Revision: 1.5 $ # -# last change: $Author: rt $ $Date: 2005-09-08 16:54:48 $ +# last change: $Author: obo $ $Date: 2006-03-22 10:53:27 $ # # The Contents of this file are made available subject to # the terms of GNU Lesser General Public License Version 2.1. @@ -38,7 +38,7 @@ import os import sys from com.sun.star.lang import XTypeProvider, XSingleComponentFactory, XServiceInfo -from com.sun.star.uno import RuntimeException +from com.sun.star.uno import RuntimeException, XCurrentContext from com.sun.star.beans.MethodConcept import ALL as METHOD_CONCEPT_ALL from com.sun.star.beans.PropertyConcept import ALL as PROPERTY_CONCEPT_ALL @@ -259,7 +259,24 @@ class Base(XTypeProvider): return _unohelper_getHandle( self )[0] def getImplementationId(self): return _unohelper_getHandle( self )[1] - + +class CurrentContext(XCurrentContext, Base ): + """a current context implementation, which first does a lookup in the given + hashmap and if the key cannot be found, it delegates to the predecessor + if available + """ + def __init__( self, oldContext, hashMap ): + self.hashMap = hashMap + self.oldContext = oldContext + + def getValueByName( self, name ): + if name in self.hashMap: + return self.hashMap[name] + elif self.oldContext != None: + return self.oldContext.getValueByName( name ) + else: + return None + # ------------------------------------------------- # implementation details # -------------------------------------------------