Issue 99524 - Using java api to insertString into mergeField in header throws RuntimeException
Summary: Using java api to insertString into mergeField in header throws RuntimeException
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: Unknown All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL: http://www.oooforum.org/forum/viewtop...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-23 11:35 UTC by andrejk
Modified: 2013-02-24 21:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description andrejk 2009-02-23 11:35:33 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.
Comment 1 jsc 2009-02-24 12:21:30 UTC
jsc -> tl: potential writer api issue
Comment 2 thomas.lange 2009-02-24 12:27:16 UTC
.
Comment 3 thomas.lange 2009-03-16 15:30:20 UTC
tl->andrejk : please attach the mentioned "letter1.ott" or some similar document
to reprocude the issue.
Comment 4 thomas.lange 2009-10-12 13:15:31 UTC
No response from submitter. Setting target to OOo 3.x for now.