Issue 52649 - Opening a form an a Base document closes when the macro finishes.
Summary: Opening a form an a Base document closes when the macro finishes.
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: marc.neumann
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-30 15:18 UTC by andrew
Modified: 2013-02-24 21:07 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 andrew 2005-07-30 15:18:29 UTC
I open a form contained in a Base document using:

oFormDocs.loadComponentFromURL()

The form opens, but closes when the macro completes. See the complete macro
below. If I create an external variable that holds a reference to the document
definition, however, then the form stays open.

I discussed this with Frank Schönheit on the dba development mailing list, and
he had two comments:

1. He agrees that I should not have to hold a reference to the form definition
so that the form stays open. (This is the bug reported for this issue).

2. It seems silly that I need to provide an active connection. This active
connections may become a resource leak because it is not closed (this is
speculative of course).


Dim oXXX

Sub OpenFormInDB()
  Dim s As String     'Temporary string variable.
  Dim oDBDoc          'The database document that contains the form.
  Dim oFormDef        'com.sun.star.sdb.DocumentDefinition of the form.
  Dim oFormDocs       'The form documents container.
  Dim oFormDoc        'The actual form document.
  Dim oIHandler       'Interaction handler.
  Dim oCon            'Database connection.
  Dim oParms(1) As New com.sun.star.beans.PropertyValue
  Dim oBaseContext    'Global database context service.
  Dim oDataBase       'Database obtained from the database context.
  Dim sFormName$
  Dim sURL$

  sFormName = "Inventory_Form1"
  sURL = "file:///andrew0/home/andy/My%20Documents/Stamps_2005_07_22.odb"

  oDBDoc = StarDesktop.loadComponentFromURL(sURL, "_blank", 0, Array())
  oFormDocs = oDBDoc.getFormDocuments()
  oFormDef = oDBDoc.getFormDocuments().getByName(sFormName)
  REM Uncomment this next line to hold the form open
  'oXXX = oFormDef

  REM The database context is required for the connection.
  oBaseContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
  oDataBase = oBaseContext.getByName(sUrl)
  oCon = oDataBase.getConnection("", "")
  oParms(0).Name  = "OpenMode"
  oParms(0).Value = "openDesign"
  oParms(1).Name  = "ActiveConnection"
  oParms(1).Value = oCon

  oFormDoc = oFormDocs.loadComponentFromURL(sFormName, "", 0, oParms())
End Sub
Comment 1 stephan.wunderlich 2005-08-01 08:37:03 UTC
sw->oj: your area methinks
Comment 2 Frank Schönheit 2005-08-19 10:57:31 UTC
I think this is a serious problem for scripting OpenOffice.org Base, so let's
see if we can get this for 2.0.1
fs->oj: please investigate the effort and risk for fixing this.
Comment 3 ocke.janssen 2005-08-19 11:09:56 UTC
After a short discussion this one is no 2.0.1 issue. That back to OOLater.
Comment 4 Frank Schönheit 2005-10-06 15:12:56 UTC
fixed in CWS dba201d (targeted for 2.0.1).

Now the macro is as simple as:

  oDBDoc = StarDesktop.loadComponentFromURL(<document_url>, _
    "_default", 0, Array())
  oFormDocs = oDBDoc.getFormDocuments()
  oFormDoc = oFormDocs.loadComponentFromURL(<form_name>, "", 0, _
    oParms())

No need to keep anything alive, no need to pass an active connection.


side note: For loadComponentFormURL it's recommended to use "_default" instead
of "_blank", since the former already cares for a document which is already
opened, whereas "_blank" always loads the document into a new frame (possibly
readonly)
Comment 5 Frank Schönheit 2005-10-12 08:46:48 UTC
fs-> msc: please verify in CWS dba201d

re-open issue and reassign to msc
Comment 6 Frank Schönheit 2005-10-12 08:46:59 UTC
reassign to msc
Comment 7 marc.neumann 2005-10-13 13:41:04 UTC
set to fixed
Comment 8 marc.neumann 2005-10-20 12:19:48 UTC
verified in cws dba201d
Comment 9 marc.neumann 2005-11-15 13:43:49 UTC
Hi,

this is fixed in the current master. The current master is available at
http://download.openoffice.org/680/index.html

I close this issue now.

Bye Marc