Пример #1
0
def test_wpp():
    hr, rpc = createWppRpcInstance()
    app = RpcProxy(rpc.getWppApplication())

    preses = app.Presentations
    print(len(preses))

    preses.Add()
    print(len(preses))

    preses.Add()
    print(len(preses))

    for pres in preses:
        print(pres.Name)

    app.Quit()
Пример #2
0
def test():
    hr, rpc = rpcwppapi.createWppRpcInstance()
    check_call("rpcwppapi.createWppRpcInstance", hr, rpc)

    hr, app = rpc.getWppApplication()
    check_call("rpc.getWppApplication", hr, app)

    hr, pid = rpc.getProcessPid()
    check_call("rpc.getProcessPid", hr, pid)

    hr, preses = app.get_Presentations()
    check_call("app.get_Presentations", hr, preses)

    hr, pres = preses.Add(wppapi.msoTrue)
    check_call("preses.Add", hr, pres)

    hr, pres = app.get_ActivePresentation()
    check_call("app.get_ActivePresentation", hr, pres)

    hr, name = pres.get_FullName()
    check_call("pres.get_FullName", hr, name)

    props = pres.CustomDocumentProperties
    print("Doc Props:")
    for prop in RpcIter(props):
        print("\t %s: %s" % (prop.Name, prop.Value))

    a_date = datetime.date(2020, 7, 20)
    hr, prop = props.Add("_a_date", False, Value=a_date)
    assert (hr == common.S_OK and prop.Value.date() == a_date)

    a_datetime = datetime.datetime(2020, 7, 21, 14, 15, 30)
    hr, prop = props.Add("_a_datetime", False, Value=a_datetime)
    assert (hr == common.S_OK and prop.Value == a_datetime)

    props = pres.BuiltInDocumentProperties
    print("Builtin Props:")
    for prop in RpcIter(props):
        print("\t %s: %s" % (prop.Name, prop.Value))

    hr = pres.Close()
    check_call("pres.Close", hr)

    hr = app.Quit()
    check_call("ap.Quit", hr)
Пример #3
0
def test_rpcwppapi():
    try:
        from pywpsrpc.rpcwppapi import (createWppRpcInstance, wppapi)
    except ImportError:
        return

    hr, rpc = createWppRpcInstance()
    if FAILED(hr):
        print("createWppRpcInstance failed with hr: ", hr)
        sys.exit(-1)

    app = RpcProxy(rpc.getWppApplication())

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "PresentationSave", _onPresentationSave)
    print("registerEvent:", hex(hr & 0xFFFFFFFF))

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "PresentationClose", _onPresentationClose)

    print("registerEvent:", hex(hr & 0xFFFFFFFF))

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "AfterNewPresentation", _onAfterNewPresentation)

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "AfterPresentationOpen", _onAfterPresentationOpen)

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "NewPresentation", _onNewPresentation)

    appEx = app.ApplicationEx
    hr = rpc.registerEvent(appEx.rpc_object, wpsapiex.DIID_ApplicationEventsEx,
                           "DocumentAfterPrint", _onDocumentAfterPrint)

    pres = app.Presentations.Add(wppapi.msoTrue)
    pres.SaveAs("test.ppt")
    pres.Close()

    pres = app.Presentations.Open("test.ppt", wppapi.msoFalse, wppapi.msoFalse,
                                  wppapi.msoTrue)

    pres.PrintOut()

    app.Quit()
Пример #4
0
def test_rpcwppapi():
    try:
        from pywpsrpc.rpcwppapi import (createWppRpcInstance, wppapi)
    except ImportError:
        return

    hr, rpc = createWppRpcInstance()
    if FAILED(hr):
        print("createWppRpcInstance failed with hr: ", hr)
        sys.exit(-1)

    app = RpcProxy(rpc.getWppApplication())

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "PresentationSave", _onPresentationSave)
    print("registerEvent:", hex(hr & 0xFFFFFFFF))

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "PresentationClose", _onPresentationClose)

    print("registerEvent:", hex(hr & 0xFFFFFFFF))

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "AfterNewPresentation", _onAfterNewPresentation)

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "AfterPresentationOpen", _onAfterPresentationOpen)

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "NewPresentation", _onNewPresentation)

    def _onWindowActivate(doc, window):
        ss = {
            wppapi.ppWindowNormal: "ppWindowNormal",
            wppapi.ppWindowMinimized: "ppWindowMinimized",
            wppapi.ppWindowMaximized: "ppWindowMaximized"
        }
        print("_onWindowActivate:", window.Caption, ss[window.WindowState])

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "WindowActivate", _onWindowActivate)

    def _onWindowDeactivate(doc, window):
        print("_onWindowDeactivate:", window.Caption)

    hr = rpc.registerEvent(app.rpc_object, wppapi.IID_EApplication,
                           "WindowDeactivate", _onWindowDeactivate)

    appEx = app.ApplicationEx
    hr = rpc.registerEvent(appEx.rpc_object, wpsapiex.DIID_ApplicationEventsEx,
                           "DocumentAfterPrint", _onDocumentAfterPrint)

    pres = app.Presentations.Add(wppapi.msoTrue)
    pres.SaveAs("test.ppt")
    pres.Close()

    pres = app.Presentations.Open("test.ppt", wppapi.msoFalse, wppapi.msoFalse,
                                  wppapi.msoTrue)

    pres.PrintOut()

    app.Quit()