[api-dev] how to dispatch ".uno:ClosePreview" from java ?

2006-08-06 Thread Oliver Brinzing
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

at the moment I am trying to convert some of my basic macros into a java 
component :-)
but get stuck with the following problem:

dispatching ".uno:ClosePreview" from java seems not to work in all cases,
if I open a message box directly after the "xDispatch.executeDispatch" the 
message
box will be displayed in the preview mode ... after closing the message box, we 
are
still in the preview mode  ... the dispatch got lost ???

I think this i caused due to the async behaviour of the dispatching framwork ...

I also tried xNotifyingDispatcher.dispatchWithNotification() without success 
... :-(

In Basic I used the following:

Function ClosePreview()

Dim oView as Object
Dim oDispatcher as Object
Dim mNoArgs()
Dim i as Integer

oView = ThisComponent.getCurrentController()

If Not hasUnoInterfaces(oView, "com.sun.star.sheet.XSpreadsheetView") 
Then
oDispatcher = 
createUnoService("com.sun.star.frame.DispatchHelper")

oDispatcher.executeDispatch(ThisComponent.getCurrentController().Frame, 
".uno:ClosePreview", "",
0, mNoArgs())
While Not hasUnoInterfaces(oView, 
"com.sun.star.sheet.XSpreadsheetView") and i < 10
Wait(0)
oView = ThisComponent.getCurrentController()
i = i + 1
Wend
EndIf

MsgBox "Hello World..." & CStr(i)
End Function

Any hints ?

Oliver
- --

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE1haCTiyrQM/QSkURArqIAJ9jFRKTyvkmU/u0/oeqGcu481KXvgCff5CJ
L3IkL+IJav7TP1H5UhXoi/0=
=hPV6
-END PGP SIGNATURE-

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



[api-dev] LoadComponentFromURL using an XInputStream in Basic

2006-08-06 Thread Andrew Douglas Pitonyak

I am using OOo 2.0.3 on Linux FC4.

I store a binary file into a database - Base document if it matters. 
First I tried to use a stream:


oStatement.setBinaryStream(2, oStream, oStream.getLength())

The error message said that there was an error from the ODBC driver 
stating that the stream was NULL. I found that the following works:


lLen = oStream.getLength()
ReDim oData(0 To lLen-1)
oStream.readBytes(oData(), lLen)
oStatement.setBytes(2, oData(), lLen)

I can extract the data from my database to a file.

oSimpleFileAccess.writeFile(sURL, oStream)

Rather than writing the file to disk, I would prefer to load the file 
directly.


Dim oProp(0) As New com.sun.star.beans.PropertyValue
oProp(0).Name  = "InputStream" : oProp(0).Value = oStream
REM oProp(1).Name  = "ReadOnly": oProp(1).Value = True
REM oProp(2).Name  = "FilterName"  : oProp(2).Value = "writer8"
StarDesktop.LoadComponentFromUrl("private:stream", "_blank", 0, oProp())

When I try this, however, soffice locks up and I have to manually kill 
soffice.


The closest that I could find to a solution is in Java, but it uses a 
com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter

The speculation is that the XInputStream does not support XSeekable.
http://joott.cvs.sourceforge.net/joott/jooconverter2/src/net/sf/jooreports/openoffice/converter/OpenOfficeDocumentConverter.java?view=markup

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

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



Re: [api-dev] LoadComponentFromURL using an XInputStream in Basic

2006-08-06 Thread Andreas Schlüns

Andrew Douglas Pitonyak wrote:

I am using OOo 2.0.3 on Linux FC4.

I store a binary file into a database - Base document if it matters. 
First I tried to use a stream:


oStatement.setBinaryStream(2, oStream, oStream.getLength())

The error message said that there was an error from the ODBC driver 
stating that the stream was NULL. I found that the following works:


lLen = oStream.getLength()
ReDim oData(0 To lLen-1)
oStream.readBytes(oData(), lLen)
oStatement.setBytes(2, oData(), lLen)

I can extract the data from my database to a file.

oSimpleFileAccess.writeFile(sURL, oStream)

Rather than writing the file to disk, I would prefer to load the file 
directly.


Dim oProp(0) As New com.sun.star.beans.PropertyValue
oProp(0).Name  = "InputStream" : oProp(0).Value = oStream
REM oProp(1).Name  = "ReadOnly": oProp(1).Value = True
REM oProp(2).Name  = "FilterName"  : oProp(2).Value = "writer8"
StarDesktop.LoadComponentFromUrl("private:stream", "_blank", 0, oProp())

When I try this, however, soffice locks up and I have to manually kill 
soffice.


The closest that I could find to a solution is in Java, but it uses a 
com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter

The speculation is that the XInputStream does not support XSeekable.
http://joott.cvs.sourceforge.net/joott/jooconverter2/src/net/sf/jooreports/openoffice/converter/OpenOfficeDocumentConverter.java?view=markup 



 An "InputStream" property of the MediaDescriptor has to support 
XSeekable also. Otherwhise OOo cant deal with it.

But normaly that shouldn't produce a "locked" office instance.
The load request should fail.

But a locked office can be produced by the content you try to load.
Might be the used filter does not match to the type of content you wish 
to load. You said that you tried to load a Base document ... but you use 
a writer filter ("writer8"). That can produce trouble.


Solutions:

a) Let your stream provide the interface XSeekable.
b) Use another filter or dont specify any filter so 
loadComponentFromURL() can search for it's own one.
c) Try to load several other contents, to make sure that your problem is 
not related to these.


Regards
Andreas

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



Re: [api-dev] how to dispatch ".uno:ClosePreview" from java ?

2006-08-06 Thread Andreas Schlüns

Oliver Brinzing wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

at the moment I am trying to convert some of my basic macros into a java 
component :-)
but get stuck with the following problem:

dispatching ".uno:ClosePreview" from java seems not to work in all cases,
if I open a message box directly after the "xDispatch.executeDispatch" the 
message
box will be displayed in the preview mode ... after closing the message box, we 
are
still in the preview mode  ... the dispatch got lost ???

I think this i caused due to the async behaviour of the dispatching framwork ...

I also tried xNotifyingDispatcher.dispatchWithNotification() without success 
... :-(

In Basic I used the following:

Function ClosePreview()

Dim oView as Object
Dim oDispatcher as Object
Dim mNoArgs()
Dim i as Integer

oView = ThisComponent.getCurrentController()

If Not hasUnoInterfaces(oView, "com.sun.star.sheet.XSpreadsheetView") 
Then
oDispatcher = 
createUnoService("com.sun.star.frame.DispatchHelper")
oDispatcher.executeDispatch(ThisComponent.getCurrentController().Frame, 
".uno:ClosePreview", "",
0, mNoArgs())
While Not hasUnoInterfaces(oView, 
"com.sun.star.sheet.XSpreadsheetView") and i < 10
Wait(0)
oView = ThisComponent.getCurrentController()
i = i + 1
Wend
EndIf

MsgBox "Hello World..." & CStr(i)
End Function

Any hints ?




Using of the interface XNotifyingDispatch does not make the dispatch 
itself synchron ... it guarantees only, that the given listener will be 
called. Becausde normal XStatusListener used for a XDispatch call are 
not guaranteed to be used !


If you wish to force a synchronous execution of your dispatch you should 
try the argument "Asynchron" as [bool] with a valud "false".
But note: Forcing the synchron mode for an asnychronous operation can 
make trouble. E.g. closing of such preview will destroy resources, which 
are used by your own java code. In such case Disposed- or 
RuntimeExcception can occure, which of course must be handled by your 
code. You have to make sure that all references to these preview was 
released by yourself


/Hint: GarbageCollector .-)


Oliver
- --



Regards
Andreas

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