Apache OpenOffice (AOO) Bugzilla – Issue 99524
Using java api to insertString into mergeField in header throws RuntimeException
Last modified: 2013-02-24 21:08:45 UTC
I'm trying to replace a mergeField in a writer document header using insertString. The code throws a RuntimeException. Here's some example code: #!/usr/bin/python import sys import uno from os import getcwd from unohelper import Base, systemPathToFileUrl, absolutize from com.sun.star.beans import PropertyValue, UnknownPropertyException from com.sun.star.uno import Exception as UnoException, RuntimeException localContext = uno.getComponentContext() resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext ) ctx = resolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ComponentContext" ) smgr = ctx.ServiceManager desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx ) inProps = PropertyValue( "Hidden" , 0 , True, 0 ), fileUrl = absolutize(systemPathToFileUrl( getcwd() ) ,"letter1.ott") doc = desktop.loadComponentFromURL( fileUrl , "_blank", 0, inProps ) fields = doc.getTextFields().createEnumeration() while fields.hasMoreElements(): field = fields.nextElement() fieldname = field.getPresentation(0) try: isDatabaseField = field.getPropertyValue("DataBaseFormat") except UnknownPropertyException : isDatabaseField = False if isDatabaseField: try: doc.Text.insertString(field.getAnchor(),"New value for " + fieldname,1) except RuntimeException, e: print "RuntimeException while to replacing field: " + e.Message Each time i try to replace a databasefield in the header (field created using a ooo calc spreadsheet), the program throws a runtimeexception. I've tried it using java and python, both have the same problem.
jsc -> tl: potential writer api issue
.
tl->andrejk : please attach the mentioned "letter1.ott" or some similar document to reprocude the issue.
No response from submitter. Setting target to OOo 3.x for now.