_francois_ General User

Joined: 24 Nov 2005 Posts: 35
|
Posted: Mon Mar 15, 2010 8:41 am Post subject: Problem with loadCompomentFromURL in OpenOffice 3.x |
|
|
Hi
I wrote a few years back a Powerbuilder program using the OpenOffice API via OLE automation
The program works great with OpenOffice 2.x but throws an exception with OpenOffice 3.x (tested with OpenOffice 3.1 and 3.2 on Windows XP PRO)
I've got the following error
| Code: | | InterfaceOleWrapper_Impl::doInvoke : Unexpected exception |
Here is a bit of my code
| Code: |
oOle.ConnectToNewObject("com.sun.star.ServiceManager")
... snip ...
oProp[1] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[1].name = "DocumentURL"
oProp[1].value = "file:///" + f_strReplace('\','/',f_strReplace(':','|',doc_source))
oProp[2] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[2].name = "DataSourceName"
oProp[2].value = "publipostage"
oProp[3] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[3].name = "CommandType"
oProp[3].value = 0
oProp[4] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[4].name = "Command"
oProp[4].value = f_getFileName(doc_data)
oProp[5] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[5].name = "OutputType"
oProp[5].value = 2
oProp[6] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[6].name = "OutputURL"
oProp[6].value = "file:///" + f_strReplace('\','/',f_strreplace(':','|',f_lit_anges_ini("General","repertoire_travail")))
oProp[7] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[7].name = "FileNamePrefix"
oProp[7].value = f_strReplace('.','_',f_getFileName(doc_data))
oProp[8] = oOle.Bridge_GetStruct("com.sun.star.beans.NamedValue")
oProp[8].name = "SaveAsSingleFile"
oProp[8].value = true
try
oMailMerge.execute(oProp)
catch (OLERuntimeError lt_12)
messageBox('Erreur','oMailMerge.execute~n' + f_clipped(oMailMerge.is_description))
lb_err = true
end try
if lb_err then goto erreur
try
oMailMerge.dispose()
catch (OLERuntimeError lt_13)
messageBox('Erreur','oMailMerge.dispose~n' + f_clipped(oMailMerge.is_description))
lb_err = true
end try
destroy oMailMerge
if lb_err then goto erreur
try
oDatabaseContext.dispose()
catch (OLERuntimeError lt_14)
messageBox('Erreur','oDatabaseContext.dispose~n' + f_clipped(oDatabaseContext.is_description))
lb_err = true
end try
destroy oDatabaseContext
if lb_err then goto erreur
oDProp[1] = oOle.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oDProp[1].name = "Hidden"
oDProp[1].value = false
try
oTmpDesk = oOle.createInstance("com.sun.star.frame.Desktop")
// Overload of the oleobject type to catch the error message when an exception is thrown
oDesk = create n_ole
// Copy the oleobject object to an instance of its inherited class to acess the error message property
oDesk.setAutomationPointer(oTmpDesk)
catch (OLERuntimeError lt_15)
messageBox('Erreur','oOle.createInstance("com.sun.star.frame.Desktop")~n' + f_clipped(oOle.is_description))
lb_err = true
end try
if lb_err then goto erreur
// File generated by the mailmerge
ls_ficPub = string(oProp[6].value) + '/' + string(oProp[7].value) + '0' + '.odt'
try
oTmpDoc = oDesk.loadComponentFromURL(ls_ficPub,"_blank", 0,oDProp)
oDoc = create n_ole
oDoc.setAutomationPointer(oTmpDoc)
catch (OLERuntimeError lt_16)
messageBox('Erreur','oDesk.loadComponentFromURL~n' + oDesk.is_description)
lb_err = true
end try
if lb_err then goto erreur
... /snip ...
|
Basicaly I do a mailerge which generates me a ficba0.odt (it just works fine)
Once the mailmerge is done I try to open my ficba0.odt with a call to loadComponentFromURL
It works fine on OpenOffice 2.4 but not in OpenOffice 3.x
When I launch the loadComponentFromURL OpenOffice Writer opens and it says "opening document" but there I get the exception
Is it because the mailmerge hasn't released yet the file with the merged data ?
Is there a way to wait until I'm sure the file is available ?
Is there a way to force the release of the file ?
Also is there a way to know for sure the name of the file generated by the mailerge ?
I gave ficba as filePrefix and then I use ficba0.odt assuming there was no prior ficba0.odt (because if there was I'll have a ficba1.rtd which is the file I'd be intereested in)
thanks in advance
Regards,
François |
|