[ Avaa Bypassed ]




Upload:

Command:

www-data@3.18.103.55: ~ $
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

# prepare Python environment - Add the path of this class
from os import path
from sys import modules
from sys import path as syspath

# pyUNO program itself
import uno, unohelper

# UNO GUI toolkit
from com.sun.star.awt.WindowClass import TOP, SIMPLE
from com.sun.star.awt.PushButtonType import STANDARD as standard
from com.sun.star.awt.PushButtonType import OK as ok
from com.sun.star.awt.PushButtonType import CANCEL as cancel
from com.sun.star.awt.PushButtonType import HELP as help
from com.sun.star.awt.TextAlign import CENTER as center
from com.sun.star.awt.TextAlign import LEFT as left
from com.sun.star.awt.TextAlign import RIGHT as right

# used UNO listeners
from com.sun.star.awt import XActionListener

class MsgBox(unohelper.Base):
    """Inspect UNO object, link to sdk and recursive calls"""

    def __init__(self, aContext):
        """acontext : a Valid UNO context
        """

        self.VERSION = '0.1'
        self.ctx = aContext
        self.smgr = aContext.ServiceManager
        # UI Dialog object
        self.dialog=None
        # List of opened Listeners
        self.lst_listeners={}
        #UI parameters
        self.ButtonSize = 50
        self.boxSize = 200
        self.lineHeight = 10
        self.fromBroxSize = False
        self.numberOfLines = -1

        self.Buttons = []
        self.Response = ''

        return

    #####################################################
    #                 GUI definition                    #
    #####################################################
    def _createBox(self):
        """Create the Box"""

        # computes parameters of the message dialog
        if self.numberOfLines == -1:
            #calculate
            numberOfLines = len(self.message.split(chr(10)))
        else:
            numberOfLines = self.numberOfLines

        numberOfButtons = len(self.Buttons)
        self.ButtonSpace = self.ButtonSize/2
        if self.fromBroxSize:
            # button size is calculated from boxsize
            size = (2 * self.boxSize) / (3 * numberOfButtons + 1)
            self.ButtonSize = size
            self.ButtonSpace = self.ButtonSize/2
        else:
            # boxsize is calculated from buttonsize
            self.boxSize = numberOfButtons * (self.ButtonSize +
                                            self.ButtonSpace) + self.ButtonSpace

        # create the dialog model and set the properties
        dialog_model = self.smgr.createInstanceWithContext(
                                    'com.sun.star.awt.UnoControlDialogModel',
                                    self.ctx)
        dialog_model.PositionX = 50
        dialog_model.Step = 1
        dialog_model.TabIndex = 7
        dialog_model.Width = self.boxSize#numberOfButtons * (self.ButtonSize +
                             #               self.ButtonSpace) + 25
        dialog_model.Height = 10 + self.lineHeight * numberOfLines + 10 + 12  + 10
        dialog_model.PositionY = 63
        dialog_model.Sizeable = True
        dialog_model.Closeable = False

        dialog = self.smgr.createInstanceWithContext(
                'com.sun.star.awt.UnoControlDialog', self.ctx)

        # label Label0
        label = dialog_model.createInstance(
                'com.sun.star.awt.UnoControlFixedTextModel')
        label.PositionX =  10
        label.TabIndex = 9
        label.Width = dialog_model.Width - label.PositionX
        label.Height = self.lineHeight* numberOfLines
        label.PositionY = 10
        label.Align = left
        label.MultiLine = True
        label.Label = self.message
        dialog_model.insertByName('Label0', label)

        nb = 0
        for buttonName in self.Buttons:
            nb +=1
            button = dialog_model.createInstance(
                                    'com.sun.star.awt.UnoControlButtonModel')
            button.PositionX = nb * self.ButtonSpace + (nb-1)* self.ButtonSize
            button.TabIndex = 8
            button.Height = 12
            button.Width = self.ButtonSize
            button.PositionY = 10 + label.Height + 10
            button.PushButtonType = standard
            if nb == 1:
                button.DefaultButton = True
            else:
                button.DefaultButton = False
            button.Label = buttonName
            dialog_model.insertByName('Btn' + str(nb), button )

        if not dialog.getModel():
            dialog.setModel(dialog_model)

        # UNO toolkit definition
        toolkit = self.smgr.createInstanceWithContext('com.sun.star.awt.Toolkit', self.ctx)
        a_rect = uno.createUnoStruct( 'com.sun.star.awt.Rectangle' )
        a_rect.X = 50
        dialog.setTitle ( self.title )
        a_rect.Width = 270
        a_rect.Height = 261
        a_rect.Y = 63
        win_descriptor = uno.createUnoStruct('com.sun.star.awt.WindowDescriptor')
        win_descriptor.Type = TOP
        win_descriptor.ParentIndex = -1
        win_descriptor.Bounds = a_rect
        peer = toolkit.createWindow( win_descriptor )
        dialog.createPeer( toolkit, peer )

        return dialog

    def _addListeners(self):
        """Add listeners to dialog"""
        nb = 0
        for buttonName in self.Buttons:
            nb +=1
            a_control = self.dialog.getControl('Btn'+str(nb))
            the_listener = ButtonListener(self)
            a_control.addActionListener(the_listener)
            self.lst_listeners['Btn'+str(nb)] = the_listener
        return

    def _removeListeners(self):
        """ remove listeners on exiting"""
        nb = 0
        for buttonName in self.Buttons:
            nb +=1
            a_control = self.dialog.getControl('Btn'+str(nb))
            a_control.removeActionListener(self.lst_listeners['Btn'+str(nb)])
        return

    def show(self, message, decoration, title):
        self.message = message
        self.decoration = decoration
        self.title = title
        # Create GUI
        self.dialog = self._createBox()
        self._addListeners()
        #execute the dialog --> blocking call
        self.dialog.execute()
        #end --> release listeners and dispose dialog
        self._removeListeners()
        self.dialog.dispose()
        return self.Response

    def addButton(self, caption):
        self.Buttons.append(caption)
        return

    def renderFromBoxSize(self, size = 150):
        self.boxSize = size
        self.fromBroxSize = True
        return

    def renderFromButtonSize(self, size = 50):
        self.ButtonSize = size
        self.fromBroxSize = False
        return

class ButtonListener(unohelper.Base, XActionListener):
    """Stops the MessageBox, sets the button label as returned value"""
    def __init__(self, caller):
        self.caller = caller

    def disposing(self, eventObject):
        pass

    def actionPerformed(self, actionEvent):
        button = actionEvent.Source
        self.caller.Response = button.Model.Label
        self.caller.dialog.endExecute()
        return

### TEST
if __name__ == '__main__':
    # get the uno component context from the PyUNO runtime
    localContext = uno.getComponentContext()

    # create the UnoUrlResolver
    resolver = localContext.ServiceManager.createInstanceWithContext(
                    "com.sun.star.bridge.UnoUrlResolver", localContext )

    # connect to the running office
    # LibO has to be launched in listen mode as
    # ./soffice "--accept=socket,host=localhost,port=2002;urp;"
    ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
    myBox = MsgBox(ctx)
    myBox.addButton("Yes")
    myBox.addButton("No")
    myBox.addButton("May be")
    myBox.renderFromBoxSize(150)
    myBox.numberOflines = 2

    print(myBox.show("A very long message A very long message A very long message A very long message A very long message A very long message A very long message A very long message A very long message A very long message " + chr(10)+chr(10)+"Do you agree ?",0,"Dialog title"))

    myBox = MsgBox(ctx)
    myBox.addButton("oK")
    myBox.renderFromButtonSize()
    myBox.numberOflines = 2

    print(myBox.show("A small message",0,"Dialog title"))

# vim: set shiftwidth=4 softtabstop=4 expandtab:

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
classes Folder 0755
opencl Folder 0755
opengl Folder 0755
services Folder 0755
shell Folder 0755
types Folder 0755
wizards Folder 0755
JREProperties.class File 1.65 KB 0644
bootstraprc File 111 B 0644
flat_logo.svg File 67.33 KB 0644
fundamentalrc File 2.29 KB 0644
gdbtrace File 334 B 0644
intro-highres.png File 47.55 KB 0644
intro.png File 29.98 KB 0644
java-set-classpath File 1.98 KB 0755
javaldx File 18.24 KB 0755
javavendors.xml File 1.79 KB 0644
jvmfwk3rc File 247 B 0644
libOGLTranslo.so File 247.25 KB 0644
libPresentationMinimizerlo.so File 391.5 KB 0644
libPresenterScreenlo.so File 1.01 MB 0644
libacclo.so File 1.37 MB 0644
libaffine_uno_uno.so File 18.46 KB 0644
libanalysislo.so File 375.59 KB 0644
libanimcorelo.so File 146.88 KB 0644
libavmediagst.so File 87.84 KB 0644
libbasctllo.so File 1.66 MB 0644
libbasprovlo.so File 131.58 KB 0644
libbiblo.so File 521.05 KB 0644
libbinaryurplo.so File 171.55 KB 0644
libbootstraplo.so File 488.91 KB 0644
libcached1.so File 263.41 KB 0644
libcairocanvaslo.so File 689.75 KB 0644
libcanvasfactorylo.so File 62.83 KB 0644
libchartcontrollerlo.so File 2.76 MB 0644
libchartcorelo.so File 3.26 MB 0644
libclewlo.so File 26.2 KB 0644
libcmdmaillo.so File 67.02 KB 0644
libcollator_data.so File 1.31 MB 0644
libctllo.so File 223.06 KB 0644
libcuilo.so File 3.34 MB 0644
libdatelo.so File 83.41 KB 0644
libdbahsqllo.so File 159.1 KB 0644
libdbalo.so File 2.65 MB 0644
libdeploymentgui.so File 393.03 KB 0644
libdict_ja.so File 1.01 MB 0644
libdict_zh.so File 2.17 MB 0644
libdlgprovlo.so File 171.45 KB 0644
libembobj.so File 387.88 KB 0644
libemboleobj.so File 239.41 KB 0644
libemfiolo.so File 180.76 KB 0644
libevtattlo.so File 87.02 KB 0644
libexpwraplo.so File 204.11 KB 0644
libfilelo.so File 729.99 KB 0644
libflashlo.so File 208.53 KB 0644
libforlo.so File 303.16 KB 0644
libforuilo.so File 122.93 KB 0644
libfps_officelo.so File 469.17 KB 0644
libfrmlo.so File 2.98 MB 0644
libfwllo.so File 357.03 KB 0644
libfwmlo.so File 171.47 KB 0644
libgcc3_uno.so File 70.95 KB 0644
libgielo.so File 349.13 KB 0644
libgraphicfilterlo.so File 59.08 KB 0644
libguesslanglo.so File 46.88 KB 0644
libhwplo.so File 555.76 KB 0644
libhyphenlo.so File 79.45 KB 0644
libi18nlangtag.so File 135.01 KB 0644
libi18nsearchlo.so File 78.98 KB 0644
libicglo.so File 130.97 KB 0644
libindex_data.so File 530.42 KB 0644
libintrospectionlo.so File 179.33 KB 0644
libinvocadaptlo.so File 50.9 KB 0644
libinvocationlo.so File 114.89 KB 0644
libiolo.so File 280.91 KB 0644
libjava_uno.so File 123.03 KB 0644
libjavaloaderlo.so File 50.8 KB 0644
libjavavmlo.so File 143.52 KB 0644
libjpipe.so File 14.19 KB 0644
libjuh.so File 14.23 KB 0644
libjuhx.so File 62.84 KB 0644
libjvmaccesslo.so File 34.59 KB 0644
libjvmfwklo.so File 152.07 KB 0644
libldapbe2lo.so File 67.05 KB 0644
liblnthlo.so File 83.44 KB 0644
liblocaledata_en.so File 323.16 KB 0644
liblocaledata_es.so File 298.69 KB 0644
liblocaledata_euro.so File 2.31 MB 0644
liblocaledata_others.so File 3.37 MB 0644
liblog_uno_uno.so File 18.41 KB 0644
libloglo.so File 139.75 KB 0644
liblosessioninstalllo.so File 50.95 KB 0644
liblwpftlo.so File 1.06 MB 0644
libmergedlo.so File 62.99 MB 0644
libmigrationoo2lo.so File 67.13 KB 0644
libmigrationoo3lo.so File 63 KB 0644
libmorklo.so File 445.63 KB 0644
libmozbootstraplo.so File 51.02 KB 0644
libmsformslo.so File 520.92 KB 0644
libmswordlo.so File 2.27 MB 0644
libmtfrendererlo.so File 46.88 KB 0644
libnamingservicelo.so File 30.7 KB 0644
libnumbertextlo.so File 369.59 KB 0644
libodfflatxmllo.so File 42.78 KB 0644
liboffacclo.so File 50.98 KB 0644
liboglcanvaslo.so File 372.27 KB 0644
libooxlo.so File 4.7 MB 0644
libpasswordcontainerlo.so File 127.33 KB 0644
libpcrlo.so File 1.56 MB 0644
libpdffilterlo.so File 248.58 KB 0644
libpdfimportlo.so File 476.81 KB 0644
libpdfiumlo.so File 4.23 MB 0644
libpricinglo.so File 99.62 KB 0644
libprotocolhandlerlo.so File 59 KB 0644
libproxyfaclo.so File 34.86 KB 0644
libpythonloaderlo.so File 30.91 KB 0644
libpyuno.so File 264.02 KB 0644
libreflectionlo.so File 163.24 KB 0644
libreglo.so File 115.19 KB 0644
libsal_textenclo.so File 1.62 MB 0644
libscdlo.so File 38.92 KB 0644
libscfiltlo.so File 4.71 MB 0644
libsclo.so File 16.9 MB 0644
libscnlo.so File 140.02 KB 0644
libscriptframe.so File 215.67 KB 0644
libscuilo.so File 662.52 KB 0644
libsdbtlo.so File 115.28 KB 0644
libsddlo.so File 34.98 KB 0644
libsdfiltlo.so File 658.74 KB 0644
libsdlo.so File 7.53 MB 0644
libsduilo.so File 526.84 KB 0644
libsimplecanvaslo.so File 66.9 KB 0644
libslideshowlo.so File 1.81 MB 0644
libsmdlo.so File 34.86 KB 0644
libsmlo.so File 1.33 MB 0644
libsolverlo.so File 107.19 KB 0644
libspelllo.so File 75.42 KB 0644
libsrtrs1.so File 171.46 KB 0644
libstaroffice-0.0-lo.so.0 File 2.46 MB 0644
libstocserviceslo.so File 139.59 KB 0644
libstoragefdlo.so File 50.92 KB 0644
libstorelo.so File 114.7 KB 0644
libstringresourcelo.so File 179.34 KB 0644
libsvgfilterlo.so File 789.23 KB 0644
libsvgiolo.so File 364.2 KB 0644
libswdlo.so File 34.85 KB 0644
libswlo.so File 17.46 MB 0644
libswuilo.so File 2.18 MB 0644
libsysshlo.so File 38.84 KB 0644
libt602filterlo.so File 123.08 KB 0644
libtextconv_dict.so File 285.95 KB 0644
libtextconversiondlgslo.so File 83.02 KB 0644
libtextfdlo.so File 42.99 KB 0644
libucpchelp1.so File 412.28 KB 0644
libucpcmis1lo.so File 327.91 KB 0644
libucpdav1.so File 440.66 KB 0644
libucpextlo.so File 107.31 KB 0644
libucpftp1.so File 231.8 KB 0644
libucpgio1lo.so File 168.03 KB 0644
libucphier1.so File 259.64 KB 0644
libucpimagelo.so File 38.84 KB 0644
libucppkg1.so File 223.53 KB 0644
libucptdoc1lo.so File 328.29 KB 0644
libuno_cppu.so.3 File 227.18 KB 0644
libuno_cppuhelpergcc3.so.3 File 942.09 KB 0644
libuno_purpenvhelpergcc3.so.3 File 30.51 KB 0644
libuno_sal.so.3 File 360.88 KB 0644
libuno_salhelpergcc3.so.3 File 34.67 KB 0644
libunoidllo.so File 471.16 KB 0644
libunopkgapp.so File 123.42 KB 0644
libunordflo.so File 228.1 KB 0644
libunsafe_uno_uno.so File 14.34 KB 0644
libupdatefeedlo.so File 91.13 KB 0644
libuuresolverlo.so File 38.75 KB 0644
libvbaeventslo.so File 123.43 KB 0644
libvbahelperlo.so File 841.67 KB 0644
libvbaobjlo.so File 2.38 MB 0644
libvbaswobjlo.so File 1.9 MB 0644
libvclcanvaslo.so File 662 KB 0644
libvclplug_genlo.so File 619.84 KB 0644
libvclplug_gtk3lo.so File 2.11 MB 0644
libwpftcalclo.so File 95.5 KB 0644
libwpftdrawlo.so File 703.99 KB 0644
libwpftimpresslo.so File 79.25 KB 0644
libwpftwriterlo.so File 356.84 KB 0644
libwriterfilterlo.so File 2.48 MB 0644
libwriterlo.so File 200 KB 0644
libwriterperfectlo.so File 70.98 KB 0644
libxmlfalo.so File 62.98 KB 0644
libxmlfdlo.so File 42.88 KB 0644
libxmlreaderlo.so File 50.57 KB 0644
libxmlsecurity.so File 633.3 KB 0644
libxoflo.so File 337.75 KB 0644
libxsec_xmlsec.so File 326.02 KB 0644
libxsltdlglo.so File 239.77 KB 0644
libxsltfilterlo.so File 135.73 KB 0644
lounorc File 1.03 KB 0644
mailmerge.py File 17.65 KB 0644
msgbox.py File 8.34 KB 0644
officehelper.py File 3.21 KB 0644
oosplash File 42.23 KB 0755
opencltest File 14.23 KB 0755
pagein-calc File 24 B 0644
pagein-common File 256 B 0644
pagein-draw File 24 B 0644
pagein-impress File 24 B 0644
pagein-writer File 24 B 0644
pythonloader.py File 6.7 KB 0644
pythonloader.unorc File 181 B 0644
pyuno.so File 14.18 KB 0644
redirectrc File 50 B 0644
regmerge File 26.32 KB 0755
regview File 14.24 KB 0755
scalc File 63 B 0755
sdraw File 63 B 0755
senddoc File 13.84 KB 0755
services.rdb File 8.54 KB 0644
setuprc File 32 B 0644
simpress File 66 B 0755
smath File 63 B 0755
soffice File 6.58 KB 0755
soffice.bin File 14.15 KB 0755
sofficerc File 1.26 KB 0644
swriter File 65 B 0755
types.rdb File 56.1 KB 0644
uno File 1.48 KB 0755
uno.bin File 74.46 KB 0755
unoinfo File 1.36 KB 0755
unopkg File 3.12 KB 0755
unopkg.bin File 14.15 KB 0755
unorc File 239 B 0644
uri-encode File 14.15 KB 0755
versionrc File 1.01 KB 0644
xpdfimport File 54.35 KB 0755