I can't get any XDispatch in Python except for CloseWin and CloseDoc, so there is no way to addStatusListener to a frame.
Still not shure if I made some stupid mistake, so I provide
two similar demos in Basic and Python:
###################### Basic #####################################
sub test_FrameDispatch()
'calls: bas_PushArray
        srv = createUnoService("com.sun.star.util.URLTransformer")
        oFrame = StarDesktop.getCurrentFrame()
        aGroups() = oFrame.getSupportedCommandGroups()
        dim all()
        for i = 0 to uBound(aGroups())
                aInfos = oFrame.getConfigurableDispatchInformation(aGroups(i))
                for j = 0 to uBound(aInfos())
                        bas_PushArray all(), aInfos(j)
                next
        next
        iCount1 = uBound(all()) +1
        iCount2 = iCount1
        For i = 0 to uBound(all())
                url = createUnoStruct("com.sun.star.util.URL")
        url.Complete = all(i).Command
                if srv.parseStrict(url) then
                        oDispatch = oFrame.queryDispatch(url, "", 0)
                        if isNull(oDispatch) then
                                REM never printed:
                                print "No such dispatch: "& all(i).Command
                                iCount2 = iCount2 -1
            endif
                endif
        next
        Msgbox "Queried Dispatches: "& iCount2 &" / "& iCount1, 0, oFrame.Title
end sub
Sub bas_PushArray(xArray(),vNextElement)
Dim iUB%,iLB%
        iLB = lBound(xArray())
        iUB = uBound(xArray())
        If iLB > iUB then
                iUB = iLB
                redim xArray(iLB To iUB)
        else
                iUB = iUB +1
                redim preserve xArray(iLB To iUB)
        endif
        xArray(iUB) = vNextElement
End Sub
############### Quick translation to Python ##########################
import uno
gConnect = "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"

def getDesktop(ctx):
return ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",ctx)

def getCurrentFrame(ctx):
    return getDesktop(ctx).getCurrentFrame()

def createUnoService(ctx, service):
    return ctx.ServiceManager.createInstance(service)

def test_FrameDispatch(ctx):
    srv = createUnoService(ctx, "com.sun.star.util.URLTransformer")
    oFrame = getCurrentFrame(ctx)
    print "Frame.Title: "+ oFrame.Title
    aGroups = oFrame.getSupportedCommandGroups()
    all = []
    for i in aGroups:
        aInfos = oFrame.getConfigurableDispatchInformation(i)
        all.extend(aInfos)
    iCount1 = len(all)
    iCount2 = iCount1
    for i in all:
        url = uno.createUnoStruct("com.sun.star.util.URL")
        url.Complete = i.Command
        if srv.parseStrict(url):
            oDispatch = oFrame.queryDispatch(url, "", 0)
            if not oDispatch:
                iCount2 -= 1
            else:
                print i.Command, i.GroupId
    print "Queried Dispatches: "+ str(iCount2) +" / "+ str(iCount1)

if __name__ == "__main__":
    localContext = uno.getComponentContext()
    resolver = localContext.ServiceManager.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", localContext)
    ctx = resolver.resolve(gConnect)

    test_FrameDispatch(ctx)
################################################################

Basic reports 593 / 593 for a spreadsheet-frame, whereas Python reports:
Frame.Title: Untitled1 - OpenOffice.org Calc
.uno:CloseWin 2
.uno:CloseDoc 3
Queried Dispatches: 2 / 593

Same results with other kinds of frames.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to