OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problem with loadCompomentFromURL in OpenOffice 3.x

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
_francois_
General User
General User


Joined: 24 Nov 2005
Posts: 35

PostPosted: Mon Mar 15, 2010 8:41 am    Post subject: Problem with loadCompomentFromURL in OpenOffice 3.x Reply with quote

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
Back to top
View user's profile Send private message
_francois_
General User
General User


Joined: 24 Nov 2005
Posts: 35

PostPosted: Tue Mar 16, 2010 6:24 am    Post subject: Reply with quote

I just though of the tests I was doing yesterday and today and it just stroke me...

The problem is not in the loadComponentFromURL it comes from the dispose()

When I call the dispose() method (no matter of which object) my OpenOffice just takes a trip to neverland...

It explains me why yesterday morning it occasionaly worked with my OO 3.x, I can now focus my research of why the dispose() calls are dodgy in OO 3.x when they worked fine with OO 2.4

still if anyone has an idea I'd be gratefull
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group