"Fossies" - the Fresh Open Source Software Archive

Member "libreoffice-6.3.2.2/dictionaries/ru_RU/pythonpath/lightproof_handler_ru_RU.py" (18 Sep 2019, 4007 Bytes) of package /linux/misc/libreoffice/src/libreoffice-dictionaries-6.3.2.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 import uno
    2 import unohelper
    3 import lightproof_opts_ru_RU
    4 from lightproof_impl_ru_RU import pkg
    5 
    6 from com.sun.star.lang import XServiceInfo
    7 from com.sun.star.awt import XContainerWindowEventHandler
    8 
    9 # options
   10 options = {}
   11 
   12 def load(context):
   13     try:
   14         l = LightproofOptionsEventHandler(context)
   15         for i in lightproof_opts_ru_RU.lopts:
   16             l.load(i)
   17     except:
   18         pass
   19 
   20 def get_option(page, option):
   21     try:
   22         return options[page + "," + option]
   23     except:
   24         try:
   25             return options[page[:2] + "," + option]
   26         except:
   27             return 0
   28 
   29 def set_option(page, option, value):
   30     options[page + "," + option] = int(value)
   31 
   32 class LightproofOptionsEventHandler( unohelper.Base, XServiceInfo, XContainerWindowEventHandler ):
   33     def __init__( self, ctx ):
   34         p = uno.createUnoStruct( "com.sun.star.beans.PropertyValue" )
   35         p.Name = "nodepath"
   36         p.Value = "/org.openoffice.Lightproof_%s/Leaves"%pkg
   37         self.xConfig = ctx.ServiceManager.createInstance( 'com.sun.star.configuration.ConfigurationProvider' )
   38         self.node = self.xConfig.createInstanceWithArguments( 'com.sun.star.configuration.ConfigurationUpdateAccess', (p, ) )
   39         self.service = "org.libreoffice.comp.pyuno.LightproofOptionsEventHandler." + pkg
   40         self.ImplementationName = self.service
   41         self.services = (self.service, )
   42 
   43     # XContainerWindowEventHandler
   44     def callHandlerMethod(self, aWindow, aEventObject, sMethod):
   45         if sMethod == "external_event":
   46             return self.handleExternalEvent(aWindow, aEventObject)
   47 
   48     def getSupportedMethodNames(self):
   49         return ("external_event", )
   50 
   51     def handleExternalEvent(self, aWindow, aEventObject):
   52         sMethod = aEventObject
   53         if sMethod == "ok":
   54             self.saveData(aWindow)
   55         elif sMethod == "back" or sMethod == "initialize":
   56             self.loadData(aWindow)
   57         return True
   58 
   59     def load(self, sWindowName):
   60         child = self.getChild(sWindowName)
   61         for i in lightproof_opts_ru_RU.lopts[sWindowName]:
   62             sValue = child.getPropertyValue(i)
   63             if sValue == '':
   64                 if i in lightproof_opts_ru_RU.lopts_default[sWindowName]:
   65                     sValue = 1
   66                 else:
   67                     sValue = 0
   68             set_option(sWindowName, i, sValue)
   69 
   70     def loadData(self, aWindow):
   71         sWindowName = self.getWindowName(aWindow)
   72         if (sWindowName == None):
   73             return
   74         child = self.getChild(sWindowName)
   75         for i in lightproof_opts_ru_RU.lopts[sWindowName]:
   76             sValue = child.getPropertyValue(i)
   77             if sValue == '':
   78                 if i in lightproof_opts_ru_RU.lopts_default[sWindowName]:
   79                     sValue = 1
   80                 else:
   81                     sValue = 0
   82             xControl = aWindow.getControl(i)
   83             xControl.State = sValue
   84             set_option(sWindowName, i, sValue)
   85 
   86     def saveData(self, aWindow):
   87         sWindowName = self.getWindowName(aWindow)
   88         if (sWindowName == None):
   89             return
   90         child = self.getChild(sWindowName)
   91         for i in lightproof_opts_ru_RU.lopts[sWindowName]:
   92             xControl = aWindow.getControl(i)
   93             sValue = xControl.State
   94             child.setPropertyValue(i, str(sValue))
   95             set_option(sWindowName, i, sValue)
   96         self.commitChanges()
   97 
   98     def getWindowName(self, aWindow):
   99         sName = aWindow.getModel().Name
  100         if sName in lightproof_opts_ru_RU.lopts:
  101             return sName
  102         return None
  103 
  104     # XServiceInfo method implementations
  105     def getImplementationName (self):
  106         return self.ImplementationName
  107 
  108     def supportsService(self, ServiceName):
  109         return (ServiceName in self.services)
  110 
  111     def getSupportedServiceNames (self):
  112         return self.services
  113 
  114     def getChild(self, name):
  115         return self.node.getByName(name)
  116 
  117     def commitChanges(self):
  118         self.node.commitChanges()
  119         return True