def RemoteGetDoc():
    """
    Retrieve the document instance when accessing OOo 'out of process', using uno over a socket.
    """
    import uno
    localContext = uno.getComponentContext()
    resolver = localContext.ServiceManager.createInstanceWithContext(
                    "com.sun.star.bridge.UnoUrlResolver", localContext )
    ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
    doc = desktop.getCurrentComponent()
    return doc

    Retrieve the document instance when accessing OOo 'out of process', using uno over a socket.
    
recipes/Python/576796_PythSyntax_Highlighting_OpenOffice/recipe-576796.py