当前位置: 首页>>代码示例>>Python>>正文


Python unohelper.systemPathToFileUrl函数代码示例

本文整理汇总了Python中unohelper.systemPathToFileUrl函数的典型用法代码示例。如果您正苦于以下问题:Python systemPathToFileUrl函数的具体用法?Python systemPathToFileUrl怎么用?Python systemPathToFileUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了systemPathToFileUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

        def __init__(self, filename):
            """Create a reader"""
            local = uno.getComponentContext()
            resolver = local.ServiceManager.createInstanceWithContext(
                                "com.sun.star.bridge.UnoUrlResolver", local)

            try:
                context = resolver.resolve(
                    "uno:socket,host=localhost,port=2002;"
                    "urp;StarOffice.ComponentContext")
            except NoConnectException:
                raise Exception(CONNECT_MSG)

            desktop = context.ServiceManager.createInstanceWithContext(
                                        "com.sun.star.frame.Desktop", context)

            cwd = systemPathToFileUrl(os.getcwd())
            file_url = absolutize(cwd, systemPathToFileUrl(
                    os.path.join(os.getcwd(), filename)))
            in_props = PropertyValue("Hidden", 0, True, 0),
            document = desktop.loadComponentFromURL(
                file_url, "_blank", 0, in_props)
            self.rules = document.Sheets.getByName(u'rules')
            try:
                self.invalid = document.Sheets.getByName(u'invalid')
            except NoSuchElementException:
                self.invalid = None
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:27,代码来源:fsm_parser.py

示例2: exportDocUno

 def exportDocUno(self, filepath, pdfname, pdfproperties):
     debug("Export to pdf")
     #calculate the url
     self._cwd = systemPathToFileUrl(dirname(filepath))
     fileUrl = systemPathToFileUrl(filepath)
     inProps = PropertyValue("Hidden" , 0 , True, 0),
     
     #load the document
     debug("load")
     self._doc = self._desktop.loadComponentFromURL(fileUrl, '_blank', 0, inProps)
     self._doc.reformat()
     #try:
     #    self._exportToPDF('/tmp/nocreate')
     #except:
     #    pass
     f = self._doc.CurrentController.Frame
     debug("repaginate")
     self.dispatcher.executeDispatch(f, ".uno:Repaginate", "", 0, ())
     debug("update index")
     self._updateIndex()
     debug("read properties")
     self._readProperties(pdfproperties)
     debug("export")
     self._exportToPDF(pdfname)
     debug("dispose")
     self._doc.dispose()
     debug("end pdf generation")
开发者ID:amake,项目名称:kolekti,代码行数:27,代码来源:odtpdf.py

示例3: convert

    def convert(self):
        """Convert the document"""

        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)

        # load the document
        url = unohelper.systemPathToFileUrl(self.fullname)
        doc = desktop.loadComponentFromURL(url, "_blank", 0, ())

        filterName = "swriter: HTML (StarWriter)"
        storeProps = (PropertyValue("FilterName", 0, filterName, 0),)

        # pre-create a empty file for security reason
        url = unohelper.systemPathToFileUrl(self.outputfile)
        doc.storeToURL(url, storeProps)

        try:
            doc.close(True)
        except CloseVetoException:
            pass

        # maigic to release some resource
        ctx.ServiceManager
开发者ID:pigaov10,项目名称:plone4.3,代码行数:29,代码来源:office_uno.py

示例4: load_file

def load_file(desktop, path):
  cwd = systemPathToFileUrl(getcwd())
  file_url = absolutize(cwd, systemPathToFileUrl(path))
  sys.stderr.write(file_url + "\n")

  in_props = (
    #   PropertyValue("Hidden", 0 , True, 0),
    )
  return desktop.loadComponentFromURL(file_url, "_blank", 0, in_props)
开发者ID:bluevisiontec,项目名称:kivitendo-erp,代码行数:9,代码来源:oo-uno-convert-pdf.py

示例5: testUrlHelper

    def testUrlHelper(self):
        systemPath = os.getcwd()
        if systemPath.startswith("/"):
            self.failUnless("/tmp" == unohelper.fileUrlToSystemPath("file:///tmp"))
            self.failUnless("file:///tmp" == unohelper.systemPathToFileUrl("/tmp"))
        else:
            self.failUnless("c:\\temp" == unohelper.fileUrlToSystemPath("file:///c:/temp"))
            self.failUnless("file:///c:/temp" == unohelper.systemPathToFileUrl("c:\\temp"))

        systemPath = unohelper.systemPathToFileUrl(systemPath)
        self.failUnless(systemPath + "/a" == unohelper.absolutize(systemPath, "a"))
开发者ID:personal-wu,项目名称:core,代码行数:11,代码来源:impl.py

示例6: write_pdf

def write_pdf(doc, path):
  out_props = (
    PropertyValue("FilterName", 0, "writer_pdf_Export", 0),
    PropertyValue("Overwrite", 0, True, 0),
    )

  (dest, ext) = splitext(path)
  dest = dest + ".pdf"
  dest_url = absolutize(systemPathToFileUrl(getcwd()), systemPathToFileUrl(dest))
  sys.stderr.write(dest_url + "\n")
  doc.storeToURL(dest_url, out_props)
  doc.dispose()
开发者ID:bluevisiontec,项目名称:kivitendo-erp,代码行数:12,代码来源:oo-uno-convert-pdf.py

示例7: main

def main():
    retVal = 0
    doc = None

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hc:",["help", "connection-string=" , "html"])
        format = None
        url = "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
        filterName = "Text (Encoded)"
        for o, a in opts:
            if o in ("-h", "--help"):
                usage()
                sys.exit()
            if o in ("-c", "--connection-string" ):
                url = "uno:" + a + ";urp;StarOffice.ComponentContext"
            if o == "--html":
                filterName = "HTML (StarWriter)"
            
        print filterName
        if not len( args ):
              usage()
              sys.exit()
              
        ctxLocal = uno.getComponentContext()
        smgrLocal = ctxLocal.ServiceManager

        resolver = smgrLocal.createInstanceWithContext(
                 "com.sun.star.bridge.UnoUrlResolver", ctxLocal )
        ctx = resolver.resolve( url )
        smgr = ctx.ServiceManager

        desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx )

        cwd = systemPathToFileUrl( getcwd() )
        outProps = (
            PropertyValue( "FilterName" , 0, filterName , 0 ),
            PropertyValue( "OutputStream",0, OutputStream(),0))
        inProps = PropertyValue( "Hidden" , 0 , True, 0 ),
        for path in args:
            try:
                fileUrl = uno.absolutize( cwd, systemPathToFileUrl(path) )
                doc = desktop.loadComponentFromURL( fileUrl , "_blank", 0,inProps)

                if not doc:
                    raise UnoException( "Couldn't open stream for unknown reason", None )

                doc.storeToURL("private:stream",outProps)
            except IOException, e:
                sys.stderr.write( "Error during conversion: " + e.Message + "\n" )
                retVal = 1
            except UnoException, e:
                sys.stderr.write( "Error ("+repr(e.__class__)+") during conversion:" + e.Message + "\n" )
                retVal = 1
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:53,代码来源:ooextract.py

示例8: OdtConverter

def OdtConverter(conf,inputs,outputs):
	# get the uno component context from the PyUNO runtime  
	localContext = uno.getComponentContext()

	# create the UnoUrlResolver 
	# on a single line
	resolver = 	localContext.ServiceManager.createInstanceWithContext	("com.sun.star.bridge.UnoUrlResolver", localContext )

	# connect to the running office                                 
	ctx = resolver.resolve( conf["oo"]["server"].replace("::","=")+";urp;StarOffice.ComponentContext" )
	smgr = ctx.ServiceManager

	# get the central desktop object
	desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)

	# get the file name
	adressDoc=systemPathToFileUrl(conf["main"]["dataPath"]+"/"+inputs["InputDoc"]["value"])

	propFich=PropertyValue("Hidden", 0, True, 0),

	myDocument=0
	try:
	    myDocument = desktop.loadComponentFromURL(adressDoc,"_blank",0,propFich)
	except CannotConvertException, e:
	    print >> sys.stderr,  'Impossible de convertir le fichier pour les raisons suivantes : \n'
	    print >> sys.stderr,  e
	    sys.exit(0)
开发者ID:OSGeo,项目名称:zoo-project,代码行数:27,代码来源:Exporter.py

示例9: cmd_save_to

def cmd_save_to(ooo_info,args):
    """
    #<toutpt> seems storeAsURL doesn t work with the filter writer_pdf_Export
    #<toutpt> on 2.0.4
    #<toutpt> working with storeToURL
    #<lgodard> toutpt : yes
    #<lgodard> toutpt: it is a feature - StoreASUrl is for filter that OOo can render
    writer_pdf_Export
    """
    dest_file = args.split(',')[0]
    format = args.split(',')[1]
    doc = ooo_info['doc']
    dest_url = systemPathToFileUrl(dest_file)
    logger.info( "save to %s from %s"%(format,dest_file))
    pp_filter = PropertyValue()
    pp_url = PropertyValue()
    pp_overwrite = PropertyValue()
    pp_filter.Name = "FilterName"
    pp_filter.Value = format
    pp_url.Name = "URL"
    pp_url.Value = dest_url
    pp_overwrite.Name = "Overwrite"
    pp_overwrite.Value = True
    outprop = (pp_filter, pp_url, pp_overwrite)
    doc.storeToURL(dest_url, outprop)
开发者ID:toutpt,项目名称:ooo2tools.core,代码行数:25,代码来源:standard.py

示例10: cmd_save_as

def cmd_save_as(ooo_info,args):
    """
    The main diff is save as render the result
    save current document.
    TEXT
    HTML (StarWriter)
    MS Word 97
    """
    dest_file = args.split(',')[0]
    format = args.split(',')[1]
    doc = ooo_info['doc']
    dest_url = systemPathToFileUrl(dest_file)
    logger.info("save as %s from %s"%(format,dest_file))
    pp_filter = PropertyValue()
    pp_url = PropertyValue()
    pp_overwrite = PropertyValue()
    pp_selection = PropertyValue()
    pp_filter.Name = "FilterName"
    pp_filter.Value = format
    pp_url.Name = "URL"
    pp_url.Value = dest_url
    #pp_overwrite.Name = "Overwrite"
    #pp_overwrite.Value = True
    pp_selection.Name = "SelectionOnly"
    pp_selection.Value = True
    #outprop = (pp_filter, pp_url, pp_overwrite)
    outprop = (pp_filter, pp_url, pp_selection)
    doc.storeAsURL(dest_url, outprop)
    return ooo_info
开发者ID:toutpt,项目名称:ooo2tools.core,代码行数:29,代码来源:standard.py

示例11: create

 def create(self, data, filename, unlock):
     res = self.get_data("api/create/", data)
     if not filename:
         return False, "Bad file name"
     if res["result"] != "ok":
         return False, res["error"]
     else:
         doc = res["object"]
         # create a new doc
         rep = os.path.join(self.PLUGIN_DIR, doc["type"], doc["reference"],
                            doc["revision"])
         try:
             os.makedirs(rep, 0700)
         except os.error:
             # directory already exists, just ignores the exception
             pass
         gdoc = self.desktop.getCurrentComponent()
         path = os.path.join(rep, filename)
         gdoc.storeAsURL(unohelper.systemPathToFileUrl(path), ())
         doc_file = self.upload_file(doc, path)
         self.add_managed_file(doc, doc_file, path)
         self.load_file(doc, doc_file["id"], path)
         if not unlock:
             self.get_data("api/object/%s/lock/%s/" % (doc["id"], doc_file["id"]))
         else:
             self.send_thumbnail(gdoc)
             self.forget(gdoc, False)
         return True, ""
开发者ID:amarh,项目名称:openPLM,代码行数:28,代码来源:openplm.py

示例12: AddDataBase

    def AddDataBase(self, name):
        guard = OpenRTM_aist.ScopedLock(self._mutex)
        try:

            names = self.m_comp.base._context.getElementNames()
            for i in names:
                if name == str(i):
                    return False

            dbURL = self.m_comp.filepath[0] + "\\" + name + ".odb"
            if os.name == "posix":
                dbURL = self.m_comp.filepath[0] + "/" + name + ".odb"
            ofile = os.path.abspath(dbURL)

            oDB = self.m_comp.base._context.createInstance()
            oDB.URL = "sdbc:embedded:hsqldb"

            p = PropertyValue()
            properties = (p,)

            oDB.DatabaseDocument.storeAsURL(ofile, properties)

            oDS = XSCRIPTCONTEXT.getDesktop().loadComponentFromURL(
                unohelper.systemPathToFileUrl(ofile), "_blank", 0, ()
            )
            self.m_comp.base._context.registerObject(name, oDS.DataSource)
            oDS.close(True)
            del guard
            return True
        except:
            if guard:
                del guard
            return False

        raise CORBA.NO_IMPLEMENT(0, CORBA.COMPLETED_NO)
开发者ID:Nobu19800,项目名称:OOoBaseRTC,代码行数:35,代码来源:OOoBaseRTC.py

示例13: loadImage

 def loadImage(self,image_name,image_file):
     oBitmaps=self.doc.createInstance("com.sun.star.drawing.BitmapTable")
     try:
         oBitmaps.insertByName(image_name,systemPathToFileUrl(image_file))
     except Exception as e:
         print(": > "+e.Message,file=sys.stderr)
     return oBitmaps.getByName(image_name)
开发者ID:aristide,项目名称:mapmint,代码行数:7,代码来源:PaperMint.py

示例14: LoadPresentation

    def LoadPresentation(self, file):
        """
        This method opens a file and starts the viewing of it.
        """
        print "LoadPresentation:", file

        # Close existing presentation
        if self.doc:
            if not hasattr(self.doc, "close") :
                self.doc.dispose()
            else:
                self.doc.close(1)

        if not file:
            print "Blank presentation"
            self.doc = self.desktop.loadComponentFromURL("private:factory/simpress","_blank", 0, ()  )
        else:
            if str.startswith(file, "http"):
                print "loading from http"
                self.doc = self.desktop.loadComponentFromURL(file,"_blank", 0, ()  )
            else: 
                self.doc = self.desktop.loadComponentFromURL(unohelper.systemPathToFileUrl(file),"_blank", 0, ()  )

        if not self.doc:
            self.doc = self.desktop.loadComponentFromURL("private:factory/simpress","_blank", 0, ()  )

        self.numPages = self.doc.getDrawPages().getCount()
        self.openFile = file

        # Start viewing the slides in a window
        #self.presentation.SlideShowSettings.ShowType = win32com.client.constants.ppShowTypeWindow
        #self.win = self.presentation.SlideShowSettings.Run()
        self.win = 1
开发者ID:aabhasgarg,项目名称:accessgrid,代码行数:33,代码来源:ImpressViewer.py

示例15: insertImage

 def insertImage(self, imagelocation, border=0, width=0, height=0):
     """
     Insert an image object into the document
     
     @param imagelocation: path to image on filesystem
     @type imagelocation: string
     """
     if not os.path.exists(imagelocation):
         raise RuntimeError('Image with location %s does not exist on filesystem' % imagelocation)
     image = Image.open(imagelocation)
     origWidth = image.size[0]
     origHeight = image.size[1]
     if width and not height:
         height = float(origHeight*width)/origWidth
     elif height and not width:
         width = float(height*origWidth)/origHeight
     graph = self.document.createInstance('com.sun.star.text.GraphicObject')
     if border:
         bordersize = int(border) * 26.45833
         graph.LeftBorderDistance = bordersize
         graph.RightBorderDistance = bordersize
         graph.BottomBorderDistance = bordersize
         graph.TopBorderDistance = bordersize
         graph.BorderDistance = bordersize
     if width and height:
         graph.Width = int(width) * 26.45833
         graph.Height = int(height) * 26.45833
     graph.GraphicURL = unohelper.systemPathToFileUrl(imagelocation)
     graph.AnchorType = AS_CHARACTER
     self.document.Text.insertTextContent(self.cursor, graph, False)
开发者ID:racktivity,项目名称:ext-pylabs-core,代码行数:30,代码来源:PyUnoWrapper.py


注:本文中的unohelper.systemPathToFileUrl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。