To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=99524
                 Issue #|99524
                 Summary|Using java api to insertString into mergeField in head
                        |er throws RuntimeException
               Component|api
                 Version|OOo 3.0
                Platform|Unknown
                     URL|http://www.oooforum.org/forum/viewtopic.phtml?t=80185&;
                        |start=0&postdays=0&postorder=asc&highlight=
              OS/Version|All
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|code
             Assigned to|jsc
             Reported by|andrejk





------- Additional comments from andr...@openoffice.org Mon Feb 23 11:35:33 
+0000 2009 -------
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.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@api.openoffice.org
For additional commands, e-mail: issues-h...@api.openoffice.org


---------------------------------------------------------------------
To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org
For additional commands, e-mail: allbugs-h...@openoffice.org

Reply via email to