Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


On 13.04.2015 18:06, Michael Stahl wrote:
looks like a deadlock, quite easy to reproduce, hope Stephan has some
time to look at it:


i forgot to attach the self contained reproducer based on Piet's code,
it connects to pipe named "ms"



import uno
import unohelper

from com.sun.star.document import XDocumentEventListener
#import PYUNO.DemoBase as DemoBase 

listener = None
globalBroadcaster =  None

class MyEventListener(XDocumentEventListener, unohelper.Base):
    # XDocumentEventListener
    def documentEventOccured(self, event):
        globalBroadcaster.removeDocumentEventListener(self)
        print("Event name: {}".format(event.EventName))
        if event.EventName == "OnLoadFinished":
            doc = event.Source
            print("Document: Title: {} Location: {}".format(doc.Title, doc.Location))
            showportions(doc)
        globalBroadcaster.addDocumentEventListener(self)

    # parent-interface XDocumentEventListener
    def disposing(self, event):
        pass

def showportions(doc):
    if doc.supportsService("com.sun.star.text.TextDocument"):
        parenum = doc.Text.createEnumeration()
        while parenum.hasMoreElements():
            para = parenum.nextElement()
            print("get para: {}".format(para.String))

#and in main (after setting up the connection):
#
def foo(context):
    global globalBroadcaster
#    context = XSCRIPTCONTEXT.getComponentContext()
    globalBroadcaster = context.getValueByName(
        '/singletons/com.sun.star.frame.theGlobalEventBroadcaster')
    listener = MyEventListener()
    globalBroadcaster.addDocumentEventListener(listener)

xLocalContext = uno.getComponentContext()

xUnoResolver = xLocalContext.ServiceManager.createInstanceWithContext(
                "com.sun.star.bridge.UnoUrlResolver", xLocalContext)

context = xUnoResolver.resolve("uno:%s;urp;StarOffice.ComponentContext" % "pipe,name=ms")

foo(context)

import time
time.sleep(100000)

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.