本文整理汇总了Python中unohelper.systemPathToFileUrl函数的典型用法代码示例。如果您正苦于以下问题:Python systemPathToFileUrl函数的具体用法?Python systemPathToFileUrl怎么用?Python systemPathToFileUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了systemPathToFileUrl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: loadDoc
def loadDoc(self,name):
""" Load a document
@param name Document filename
"""
# get the file name of the document
if list(self.docList.keys()).count(name)>0:
self.doc=self.docList[name][0]
self.format=self.docList[name][1]
else:
addressDoc=systemPathToFileUrl(name)
if self.filterOptions is not None:
tmp=name.split('/')
tmp=tmp[len(tmp)-1].split('.')
print(tmp,file=sys.stderr)
propFich=(
PropertyValue("Hidden", 0, True, 0),
PropertyValue("FilterName", 0, self.outputFormat["ODS"][tmp[len(tmp)-1].lower()][1], 0),
PropertyValue("FilterOptions", 0, self.filterOptions, 0),
)
else:
propFich=PropertyValue("Hidden", 0, True, 0),
doc=0
try:
self.doc=self.desktop.loadComponentFromURL(addressDoc,"_blank",0,propFich)
#print(self.doc,file=sys.stderr)
tmp=name.split('/')
self.format=tmp[len(tmp)-1].split('.')[1].upper()
self.docList[name]=[self.doc,self.format,addressDoc]
except Exception as e:
print('Unable to open the file for the following reasons:\n'+str(e),file=sys.stderr)
return None
开发者ID:aristide,项目名称:mapmint,代码行数:31,代码来源:PaperMint.py
示例17: 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 unohelper
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 unohelper.systemPathToFileUrl(res)
except (OSError, IOError), ioe:
raise ConverterError(CANNOT_WRITE_RESULT % (res, ioe))
开发者ID:a-iv,项目名称:appy,代码行数:25,代码来源:converter.py
示例18: createAddress
def createAddress(self, id):
# get the central desktop object
desktop = self.smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",self.ctx)
path = os.environ['CUON_OO_DOC']
inProps = PropertyValue( "Hidden" , 0 , True, 0 ),
fileUrl = uno.absolutize('test.sxc' , systemPathToFileUrl(path) )
model = desktop.loadComponentFromURL( fileUrl , "_blank", 0, inProps)
# access the current writer document
#model = desktop.getCurrentComponent()
# access the document's text property
text = model.Text
# create a cursor
cursor = text.createTextCursor()
liAddress = self.unpickleObject(id)
for i in range(0,len(liAddress)):
# insert the text into the document
text.insertString( cursor, `liAddress[i]`, 0 )
# Do a nasty thing before exiting the python process. In case the
# last call is a oneway call (e.g. see idl-spec of insertString),
# it must be forced out of the remote-bridge caches before python
# exits the process. Otherwise, the oneway call may or may not reach
# the target object.
# I do this here by calling a cheap synchronous call (getPropertyValue).
self.ctx.ServiceManager
开发者ID:CuonDeveloper,项目名称:cuon,代码行数:31,代码来源:letter.py
示例19: DumpNamedSheet
def DumpNamedSheet(XmlFileName, CsvFileName, SheetName, Separator):
model, desktop = LaunchCalcWithFile(XmlFileName)
sheet = model.Sheets.getByName(SheetName)
# Now save it in CSV format.
filename = CsvFileName
os.path.expanduser(filename)
filename = os.path.abspath(filename)
out_props = (
PropertyValue("FilterName", 0, "Text - txt - csv (StarCalc)", 0),
PropertyValue("Overwrite", 0, True, 0),
PropertyValue("Separator", 0, Separator, 0),
)
csv_url = unohelper.systemPathToFileUrl(filename)
model.storeToURL( csv_url, out_props)
time.sleep(1)
model.dispose()
ShutdownCalc( desktop )
pass
开发者ID:flindt,项目名称:skemapack,代码行数:27,代码来源:DumpCsvFromXml.py
示例20: save
def save(self, fileUrl):
if not self.doc:
raise "Failed to save cause there is no document"
if fileUrl.startswith("file://"):
fileUrl = fileUrl[7:]
if not fileUrl:
raise "Failed to save cause invalid file \"%s\" defined." % fileUrl
try:
import unohelper
outUrl = unohelper.systemPathToFileUrl(fileUrl)
outProps = []
fileExt = os.path.splitext(fileUrl)[1].lower()
if fileExt == '.txt' or fileExt == '.text':
outProps.append( UnoPropertyValue('FilterName', 0, 'Text (encoded)', 0) )
elif fileExt == '.htm' or fileExt == '.html':
outProps.append( UnoPropertyValue('FilterName', 0, 'HTML (StarWriter)', 0) )
elif fileExt == '.pdf':
outProps.append( UnoPropertyValue('FilterName', 0, 'writer_pdf_Export', 0) )
#else: opendocument...
print "Save to: %s" % outUrl
self.doc.storeToURL(outUrl, tuple(outProps))
except:
traceback.print_exc()
开发者ID:KDE,项目名称:calligra,代码行数:26,代码来源:oouno.py
注:本文中的unohelper.systemPathToFileUrl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论