Well  - in case anyone is taking the challenge:

And because I said

"Remember - opening a Writer file hidden does work." in the last email, Ill send this along.

Remember we want to open a form from a command line ( e.g. a shortcut or OS menu ) The Base window should not to be opened on the desktop and should be available to the user.
It must not require that quickstarter be running

Below is another look at the Basic module - with a few more procedures.

This time I have a registered datasource named "Current_timestamp"
It has two forms, "Switchboard" and "v1".
There is a basic procedure are in a library named "cmdLine"

Form "Switchboard" has two buttons
One with "When initiating" assigned to the procedure onClickOpenV1.
The other to onClickNewWriter

At first run it seems like this works - and in a way it does. This command line

c:\openoffice231\program\swriter -invisible "macro:///cmdLine.Module1.LoadDBForm( "Current_timestamp" ,"Switchboard" )"

Will indeed open the form on the desktop.
Clicking on the button will indeed open the form v1.

In fact it can do pretty much any thing, as long as it runs from macros out of this library.
We can even open Writer documents, Calc documents

However we have problems - major problems.

The first is how to shut down. If you try to use a menu File>Exit this happens

"Microsoft Visual C++ Runtime Library"
Runtime Error

Program "C:\....\soffice.bin"
R6025
- pure Virtual function call

Well, that is one of the problems..anyway

And if we close that new Writer file - crash - no error displayed.
On the other hand, if we open embedded database forms ( onClickOpenV1 ) then we can use the form and close it without a problem.

Finally - if we don't crash and end up just closing the Switchboard form - no error, however the Base file is stuck in memory and we can start no new OpenOffice.org documents until we kill the current soffice.bin process.

Kind of a rough definition to having said " if you open a writer hidden file it works"...isn't it.




REM --------------------------

global tmpDoc as variant

function OpenForm( formContainer as variant, _
                  oConnection as variant, _
                  sFormName as string, _
                  optional strMode as string) as variant

Dim aProp(1) As New com.sun.star.beans.PropertyValue
Dim openMode as string

if ismissing( strMode ) then
openMode = "open"
else
openMode = strMode
endif

aProp(0).Name = "ActiveConnection"
aProp(0).Value = oConnection
aProp(1).Name = "OpenMode"
aProp(1).Value = strMode

OpenForm = formContainer.loadComponentFromURL(sFormName,"_blank",0,aProp())

end function

Sub LoadDBForm( dbName as string, frmName as string )
dim cntxt as variant
dim DB as variant
dim conn as variant
dim frm as variant
dim InteractionHandler as variant
dim ln as integer
dim errMessage as string

Dim aProp(1) As New com.sun.star.beans.PropertyValue

on error goto LoadDBForm_Error

aProp(0).Name = "Hidden"
aProp(0).Value = true

tmpDoc = starDesktop.loadcomponentfromURL( "private:factory/swriter", "_blank", 
0, aProp() )

ln = 1
cntxt = CreateUnoService("com.sun.star.sdb.DatabaseContext")

DB = cntxt.getByname( trim(dbName) )
ln = 2
If Not DB.IsPasswordRequired Then
conn = DB.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
conn = DB.ConnectWithCompletion(InteractionHandler)
End If
aProp(0).Name = "ActiveConnection"
aProp(0).Value = conn
aProp(1).Name = "OpenMode"
aProp(1).Value = "open"

ln = 3
frm = 
DB.DatabaseDocument.FormDocuments.loadComponentFromURL(trim(frmName),"_blank",0,aProp())
exit sub
  LoadDBForm_Error:
errMessage = error(err) & chr(10)
select case ln
case 1 : errMessage = errMessage & "Could not load datasource: " & dbName
case 2 : errMessage = errMessage & "Invalid UserName or password for: " & dbName
case 3 : errMessage = errMessage & "Could not load form: " & frmName
end select
print errMessage

End Sub

sub onClickOpenV1( oEvent as variant )
dim ds
dim ctnr
dim conn

ds = OEvent.Source.Model.Parent
conn = ds.ActiveConnection
ctnr = conn.Parent.DatabaseDocument.FormDocuments
OpenForm( ctnr, conn, "v1")
end sub

sub onClickNewWriter( oEvent as object )

Dim aProp(1) As New com.sun.star.beans.PropertyValue

starDesktop.loadcomponentfromURL( "private:factory/swriter", "_blank", 0, 
aProp() )

end sub



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to