• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python uno.systemPathToFileUrl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convert

    def convert(self, inputFile, outputFile):
        """
        Convert the input file (a spreadsheet) to a CSV file.
        """

        # Start openoffice if needed.
        if not self.desktop:
            if not self.oorunner:
                self.oorunner = ooutils.OORunner()

            self.desktop = self.oorunner.connect()

        inputUrl  = uno.systemPathToFileUrl(os.path.abspath(inputFile))
        outputUrl = uno.systemPathToFileUrl(os.path.abspath(outputFile))
        document  = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, ooutils.oo_properties(Hidden=True))

        try:
            # Additional property option:
            #   FilterOptions="59,34,0,1"
            #     59 - Field separator (semicolon), this is the ascii value.
            #     34 - Text delimiter (double quote), this is the ascii value.
            #      0 - Character set (system).
            #      1 - First line number to export.
            #
            # For more information see:
            #   http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options
            #
            document.storeToURL(outputUrl, ooutils.oo_properties(FilterName="Text - txt - csv (StarCalc)"))
        finally:
            document.close(True)
开发者ID:irrelevation,项目名称:sheet2table,代码行数:30,代码来源:ssconverter.py


示例2: __call__

    def __call__(self, xsl_path, inp_path, out_path):
        import uno
        import unohelper
        import os.path
        from hwp5.plat._uno import ucb
        from hwp5.plat._uno.adapters import OutputStreamToFileLike
        xsl_path = os.path.abspath(xsl_path)
        xsl_url = uno.systemPathToFileUrl(xsl_path)

        inp_path = os.path.abspath(inp_path)
        inp_url = uno.systemPathToFileUrl(inp_path)
        inp_stream = ucb.open_url(self.context, inp_url)

        out_path = os.path.abspath(out_path)
        with file(out_path, 'w') as out_file:
            out_stream = OutputStreamToFileLike(out_file, dontclose=True)

            from com.sun.star.io import XStreamListener

            class XSLTListener(unohelper.Base, XStreamListener):
                def __init__(self):
                    self.event = OneshotEvent()

                def started(self):
                    logger.info('XSLT started')

                def closed(self):
                    logger.info('XSLT closed')
                    self.event.signal()

                def terminated(self):
                    logger.info('XSLT terminated')
                    self.event.signal()

                def error(self, exception):
                    logger.error('XSLT error: %s', exception)
                    self.event.signal()

                def disposing(self, source):
                    logger.info('XSLT disposing: %s', source)
                    self.event.signal()

            listener = XSLTListener()
            transformer = XSLTTransformer(self.context, xsl_url, '', '')
            transformer.InputStream = inp_stream
            transformer.OutputStream = out_stream
            transformer.addListener(listener)

            transformer.start()
            import os.path
            xsl_name = os.path.basename(xsl_path)
            logger.info('xslt.soffice(%s) start', xsl_name)
            try:
                listener.event.wait()
            finally:
                logger.info('xslt.soffice(%s) end', xsl_name)

            transformer.removeListener(listener)
            return dict()
开发者ID:hongry18,项目名称:pyhwp,代码行数:59,代码来源:__init__.py


示例3: load_presentation

 def load_presentation(self):
     """
     Called when a presentation is added to the SlideController. It builds the environment, starts communcations with
     the background OpenOffice task started earlier. If OpenOffice is not present is is started. Once the environment
     is available the presentation is loaded and started.
     """
     log.debug('Load Presentation OpenOffice')
     if is_win():
         desktop = self.controller.get_com_desktop()
         if desktop is None:
             self.controller.start_process()
             desktop = self.controller.get_com_desktop()
         url = 'file:///' + self.file_path.replace('\\', '/').replace(':', '|').replace(' ', '%20')
     else:
         desktop = self.controller.get_uno_desktop()
         url = uno.systemPathToFileUrl(self.file_path)
     if desktop is None:
         return False
     self.desktop = desktop
     properties = []
     properties.append(self.create_property('Hidden', True))
     properties = tuple(properties)
     try:
         self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
     except:
         log.warning('Failed to load presentation %s' % url)
         return False
     self.presentation = self.document.getPresentation()
     self.presentation.Display = ScreenList().current['number'] + 1
     self.control = None
     self.create_thumbnails()
     self.create_titles_and_notes()
     return True
开发者ID:crossroadchurch,项目名称:paul,代码行数:33,代码来源:impresscontroller.py


示例4: getResultUrl

    def getResultUrl(self):
        '''Returns the path of the result file in the format needed by OO. If
           the result type and the input type are the same (ie the user wants to
           refresh indexes or some other action and not perform a real
           conversion), the result file is named
                           <inputFileName>.res.<resultType>.

           Else, the result file is named like the input file but with a
           different extension:
                           <inputFileName>.<resultType>
        '''
        import uno
        baseName = os.path.splitext(self.docPath)[0]
        if self.resultType != self.inputType:
            res = '%s.%s' % (baseName, self.resultType)
        else:
            res = '%s.res.%s' % (baseName, self.resultType)
        try:
            f = open(res, 'w')
            f.write('Hello')
            f.close()
            os.remove(res)
            return uno.systemPathToFileUrl(res)
        except (OSError, IOError), ioe:
            raise ConverterError(CANNOT_WRITE_RESULT % (res, ioe))
开发者ID:vampolo,项目名称:cacerp,代码行数:25,代码来源:converter.py


示例5: create_thumbnails

 def create_thumbnails(self):
     """
     Create thumbnail images for presentation.
     """
     log.debug('create thumbnails OpenOffice')
     if self.check_thumbnails():
         return
     if os.name == 'nt':
         thumb_dir_url = 'file:///' + self.get_temp_folder().replace('\\', '/') \
             .replace(':', '|').replace(' ', '%20')
     else:
         thumb_dir_url = uno.systemPathToFileUrl(self.get_temp_folder())
     properties = []
     properties.append(self.create_property('FilterName', 'impress_png_Export'))
     properties = tuple(properties)
     doc = self.document
     pages = doc.getDrawPages()
     if not pages:
         return
     if not os.path.isdir(self.get_temp_folder()):
         os.makedirs(self.get_temp_folder())
     for index in range(pages.getCount()):
         page = pages.getByIndex(index)
         doc.getCurrentController().setCurrentPage(page)
         url_path = '%s/%s.png' % (thumb_dir_url, str(index + 1))
         path = os.path.join(self.get_temp_folder(), str(index + 1) + '.png')
         try:
             doc.storeToURL(url_path, properties)
             self.convert_thumbnail(path, index + 1)
             delete_file(path)
         except ErrorCodeIOException as exception:
             log.exception('ERROR! ErrorCodeIOException %d' % exception.ErrCode)
         except:
             log.exception('%s - Unable to store openoffice preview' % path)
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:34,代码来源:impresscontroller.py


示例6: xslt_with_libreoffice

def xslt_with_libreoffice(xsl_path, inp_path, out_path):
    import os.path
    xsl_path = os.path.abspath(xsl_path)
    xsl_name = os.path.basename(xsl_path)
    xsl_url = uno.systemPathToFileUrl(xsl_path)

    inp_path = os.path.abspath(inp_path)
    inp_file = file(inp_path)
    inp_strm = InputStreamFromFileLike(inp_file, dontclose=True)

    out_path = os.path.abspath(out_path)
    out_file = file(out_path, 'w')
    out_strm = OutputStreamToFileLike(out_file, dontclose=True)

    transformer = XSLTTransformer(xsl_url, '', '')
    transformer.InputStream = inp_strm
    transformer.OutputStream = out_strm

    listener = XSLTListener()
    transformer.addListener(listener)

    transformer.start()
    logger.info('xslt.soffice(%s) start', xsl_name)
    try:
        listener.event.wait()
    finally:
        logger.info('xslt.soffice(%s) end', xsl_name)

    transformer.removeListener(listener)
    return dict()
开发者ID:hanul93,项目名称:pyhwp,代码行数:30,代码来源:__init__.py


示例7: create_thumbnails

 def create_thumbnails(self):
     """
     Create thumbnail images for presentation
     """
     log.debug(u'create thumbnails OpenOffice')
     if self.check_thumbnails():
         return
     if os.name == u'nt':
         thumbdirurl = u'file:///' + self.get_temp_folder().replace(u'\\', u'/') \
             .replace(u':', u'|').replace(u' ', u'%20')
     else:
         thumbdirurl = uno.systemPathToFileUrl(self.get_temp_folder())
     props = []
     props.append(self.create_property(u'FilterName', u'impress_png_Export'))
     props = tuple(props)
     doc = self.document
     pages = doc.getDrawPages()
     if not pages:
         return
     if not os.path.isdir(self.get_temp_folder()):
         os.makedirs(self.get_temp_folder())
     for idx in range(pages.getCount()):
         page = pages.getByIndex(idx)
         doc.getCurrentController().setCurrentPage(page)
         urlpath = u'%s/%s.png' % (thumbdirurl, unicode(idx + 1))
         path = os.path.join(self.get_temp_folder(), unicode(idx + 1) + u'.png')
         try:
             doc.storeToURL(urlpath, props)
             self.convert_thumbnail(path, idx + 1)
             delete_file(path)
         except ErrorCodeIOException, exception:
             log.exception(u'ERROR! ErrorCodeIOException %d' % exception.ErrCode)
         except:
开发者ID:marmyshev,项目名称:transitions,代码行数:33,代码来源:impresscontroller.py


示例8: open

 def open( self, filename ):
     """Open an OpenOffice document"""
     #http://www.oooforum.org/forum/viewtopic.phtml?t=35344
     properties = []
     properties.append( OpenOfficeDocument._makeProperty( 'Hidden', True ) ) 
     properties = tuple( properties )
     self.oodocument = self.openoffice.loadComponentFromURL( uno.systemPathToFileUrl( os.path.abspath( filename ) ), "_blank", 0, properties )
开发者ID:tedkulp,项目名称:pyMailMergeService,代码行数:7,代码来源:OpenOfficeDocument.py


示例9: addDocumentToEnd

 def addDocumentToEnd( self, documentUrl, pageBreak=True ):
     cursor = self.oodocument.Text.createTextCursor()
     if cursor:
         cursor.gotoEnd( False )
         if pageBreak:
             cursor.BreakType = PAGE_AFTER
         cursor.insertDocumentFromURL( uno.systemPathToFileUrl( os.path.abspath( documentUrl ) ), () )
         return True
     return False
开发者ID:bkulyk,项目名称:pyMailMergeService,代码行数:9,代码来源:WriterDocument.py


示例10: saveAs

 def saveAs( self, filename ):
     """Save the open office document to a new file, and possibly filetype. 
     The type of document is parsed out of the file extension of the filename given."""
     filename = uno.systemPathToFileUrl( os.path.abspath( filename ) )
     #filterlist: http://wiki.services.openoffice.org/wiki/Framework/Article/Filter/FilterList_OOo_3_0
     exportFilter = self._getExportFilter( filename )
     props = exportFilter, 
     #storeToURL: #http://codesnippets.services.openoffice.org/Office/Office.ConvertDocuments.snip
     self.oodocument.storeToURL( filename, props )
开发者ID:tedkulp,项目名称:pyMailMergeService,代码行数:9,代码来源:OpenOfficeDocument.py


示例11: test_searchAndCursor

 def test_searchAndCursor(self):
     ood = WriterDocument()
     ood.open("%s/docs/find_replace.odt" % self.path)
     search = ood.oodocument.createSearchDescriptor()
     search.setSearchString("search")
     result = ood.oodocument.findFirst(search)
     path = uno.systemPathToFileUrl("%s/docs/insertme.html" % self.path)
     result.insertDocumentFromURL(path, tuple())
     ood.saveAs("%s/docs/docInTheMiddle.pdf" % self.path)
     ood.close()
开发者ID:bkulyk,项目名称:pyMailMergeService,代码行数:10,代码来源:testWriterDocument.py


示例12: getInputUrls

 def getInputUrls(self, docPath):
     '''Returns the absolute path of the input file. In fact, it returns a
        tuple with some URL version of the path for OO as the first element
        and the absolute path as the second element.''' 
     import uno
     if not os.path.exists(docPath) and not os.path.isfile(docPath):
         raise ConverterError(DOC_NOT_FOUND % docPath)
     docAbsPath = os.path.abspath(docPath)
     # Return one path for OO, one path for me.
     return uno.systemPathToFileUrl(docAbsPath), docAbsPath
开发者ID:vampolo,项目名称:cacerp,代码行数:10,代码来源:converter.py


示例13: compare

    def compare(self, path, original_path, save_path):
        if not os.path.exists(path):
            raise DocumentCompareException("%s does not exist" % (path,))

        url = uno.systemPathToFileUrl(path)
        if not os.path.exists(original_path):
            raise DocumentCompareException("%s does not exist" % (original_path,))

        url_original = uno.systemPathToFileUrl(original_path)
        url_save = uno.systemPathToFileUrl(save_path)

        ### Load document
        p = PropertyValue()
        p.Name = "Hidden"
        p.Value = True
        properties = (p,)

        doc = self.desktop.loadComponentFromURL(url, "_blank", 0, properties)

        ### Compare with original document
        properties = []
        p = PropertyValue()
        p.Name = "URL"
        p.Value = url_original
        properties.append(p)
        properties = tuple(properties)

        dispatch_helper = self.servicemanager.createInstanceWithContext(
                                            "com.sun.star.frame.DispatchHelper",
                                            self.context)
        dispatch_helper.executeDispatch(doc.getCurrentController().getFrame(),
                                        ".uno:CompareDocuments", "",
                                        0, properties)

        ### Save File
        p = PropertyValue()
        p.Name = "Overwrite"
        p.Value = True
        properties = (p,)

        doc.storeToURL(url_save, properties)
        doc.dispose()
开发者ID:DieKatze,项目名称:pyodcompare,代码行数:42,代码来源:__init__.py


示例14: save

    def save(self, path, file_format='MS Word 97'):
        properties = (
            PropertyValue("FilterName", 0, file_format, 0),
            PropertyValue("Overwrite", 0, True, 0))

        if self.document:
            try:
                self.document.storeToURL(uno.systemPathToFileUrl(path), properties)
            except ErrorCodeIOException:
                self.errors.append("Save file error (may be already open): %s" % path)
                raise ODTFileError
开发者ID:ClearMind,项目名称:doin,代码行数:11,代码来源:__init__.py


示例15: save

 def save(self, path):
     from tools import Tools
     if not hasattr(self.document, 'getArgs'):
         return False
     # import_extension = self.imp[self.filter]
     if len(self.properties) == 0:
         export_extension = Tools.get_extension(path)
         properties = self.export_options[export_extension]
         self.set_properties(properties)
     self.document.storeToURL(uno.systemPathToFileUrl(abspath(path)), tuple(self.properties))
     return True
开发者ID:pheelixx,项目名称:konvert,代码行数:11,代码来源:document.py


示例16: searchAndReplaceWithDocument

 def searchAndReplaceWithDocument( self, phrase, documentPath, regex=False ):
     #http://api.openoffice.org/docs/DevelopersGuide/Text/Text.xhtml#1_3_1_1_Editing_Text
     #cursor = self.oodocument.Text.createTextCursor()
     #http://api.openoffice.org/docs/DevelopersGuide/Text/Text.xhtml#1_3_3_3_Search_and_Replace
     search = self.oodocument.createSearchDescriptor()
     search.setSearchString( phrase )
     search.SearchRegularExpression = regex
     result = self.oodocument.findFirst( search )
     path = uno.systemPathToFileUrl( os.path.abspath( documentPath ) )
     #http://api.openoffice.org/docs/DevelopersGuide/Text/Text.xhtml#1_3_1_5_Inserting_Text_Files
     return result.insertDocumentFromURL( path, tuple() )
开发者ID:bkulyk,项目名称:pyMailMergeService,代码行数:11,代码来源:WriterDocument.py


示例17: convert

    def convert(self, inputFile, outputFile, SheetName = None, DelimiterInAscii = 9):
        """
        Convert the input file (a spreadsheet) to a CSV file.
        @param DelimiterInAscii: the delimiter. Default value \t (Ascii: 9) 
        """

        # Start openoffice if needed.
        if not self.desktop:
            if not self.oorunner:
                self.oorunner = ooutils.OORunner()

            self.desktop = self.oorunner.connect()

        inputUrl  = uno.systemPathToFileUrl(os.path.abspath(inputFile))
        outputUrl = uno.systemPathToFileUrl(os.path.abspath(outputFile))
        
        try:
            document  = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, ooutils.oo_properties(Hidden=False))
        except IllegalArgumentException, e:
            raise IOError( "Failed to open '%s': %s" % (inputFile, e.Message) )
开发者ID:flindt,项目名称:skemapack,代码行数:20,代码来源:ssconverter.py


示例18: oeffne_text

    def oeffne_text(self,pfad_translation):
        if self.mb.debug: log(inspect.stack)
         
        prop = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
        prop.Name = 'Hidden'
        prop.Value = True

        url = uno.systemPathToFileUrl(pfad_translation)       
        self.ooo = self.mb.doc.CurrentController.Frame.loadComponentFromURL(url,'_blank',0,(prop,)) 
        
        return self.ooo.Text
开发者ID:kublaj,项目名称:Organon,代码行数:11,代码来源:index.py


示例19: convertOffice

def convertOffice(inputFileUrl, outputFileUrl):
    nRes = ErrorTypes["NoError"]
    try:
        desktop = initOffice()
        alert("office desktop created")
        
        inputFileUrl = uno.systemPathToFileUrl(abspath(inputFileUrl))
        alert("from " + inputFileUrl)
        outputFileUrl = uno.systemPathToFileUrl(abspath(outputFileUrl))
        alert("to " + outputFileUrl)

        loadProperties = { "Hidden": True }
        inputExt = getFileExt(inputFileUrl)
        if importFilterMap.get(inputExt):
            loadProperties.update(importFilterMap[inputExt])

        alert("document loading")
        document = desktop.loadComponentFromURL(inputFileUrl, "_blank", 0, toProperties(loadProperties))
        alert("document loaded")

        try:
            document.refresh()
        except AttributeError:
            pass

        family = detectFamily(document)
        overridePageStyleProperties(document, family)

        outputExt = getFileExt(outputFileUrl)
        storeProperties = getStoreProperties(document, outputExt)

        alert("document storing")
        try:
            document.storeToURL(outputFileUrl, toProperties(storeProperties))
            alert("document stored")
        finally:
            document.close(True)        
    except:
        alert("Error convert", True)
        nRes = ErrorTypes["ConvertLibreOffice"]
    return nRes
开发者ID:BIGGANI,项目名称:DocumentServer,代码行数:41,代码来源:FileConverter.py


示例20: load_component

def load_component(component_path, component_name):
    import os
    import os.path
    import uno
    from unokit.services import css
    loader = css.loader.Python()
    if loader:
        component_path = os.path.abspath(component_path)
        component_url = uno.systemPathToFileUrl(component_path)

        return loader.activate(component_name, '',
                               component_url, None)
开发者ID:hanul93,项目名称:pyhwp,代码行数:12,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unohelper.systemPathToFileUrl函数代码示例发布时间:2022-05-27
下一篇:
Python uno.invoke函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap