#!/usr/bin/env python

FILE='file:///home/shpigor/Documents/test.doc'

import getopt, sys, os, glob, time

extrapaths = glob.glob('/usr/lib/openoffice.org/basis3.1/program/') + glob.glob('/usr/lib*/ooo*/program') + [ '/Applications/NeoOffice.app/Contents/program', ]
for path in extrapaths:
    try:
        sys.path.append(path)
        import uno, unohelper
        os.environ['PATH'] = '%s:' % path + os.environ['PATH']
        break
    except ImportError:
        sys.path.remove(path)
        continue
else:
    print >>sys.stderr, "unoconv: Cannot find the pyuno.so library in sys.path and known paths."
    print >>sys.stderr, "Please locate this library and send your feedback to <tools@lists.rpmforge.net>."
    sys.exit(1)

from com.sun.star.beans import PropertyValue

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)
inputprops = ( PropertyValue( "Hidden" , 0 , True, 0 ), )
doc = desktop.loadComponentFromURL( FILE , "_blank", 0, inputprops )
