Frank Schönheit - Sun Microsystems Germany wrote:
Frank, please find below the code with tha global solution,
we are using the beamer for selecting the images who must been
insterted, the beamer act also as a "form" who gives "less" problems
to retrieve the InputStream who now is coming from the memory
we start from a simple database with the image stored in in the second
columb (1) and is present in the Beamer
we can slect 1 or several lines in the beamer
' finds which rows in the DataSourceBrowser are selected by the user
Dim frame1 As Object, frame2 As Object
Dim oModel As Object, oRowset As Object
Dim oDocument As Object, oGrid As Object
Dim oDataSourceBrowser as Object
Dim oSelection as Variant, ii As Long
oDoc = thiscomponent
oDocument = thiscomponent
frame1 = oDocument.CurrentController.Frame
frame2 = frame1.findFrame("_beamer",4) ' get DataBrowser frame
if IsNull(frame2) then
MsgBox("Beamer not found !", 16)
Exit Sub
end if
oDataSourcebrowser = frame2.Controller
' the DataSourceBrowser object has several getModel methods
' choose getModel from interface com.sun.star.awt.XTabController
' to get the form used by DataSourceBrowser
oModel = oDataSourcebrowser.com_sun_star_awt_XTabController_getModel
' creating a "clone" of the form
oRowset = oModel.createResultSet
oGrid = oDataSourceBrowser.CurrentControl
oSelection = oGrid.Selection
if UBound(oSelection) >= 0 then ' we get a list of Bookmarks
For ii= 0 To UBound(oSelection) and bStop <> true
if oRowset.moveToBookmark(oSelection(ii)) then
' MsgBox( oRowset.Columns(0).String & " : " &
oRowset.Columns(4).String )
else
MsgBox("Bookmark not found : " & oSelection(ii), 16)
exit sub
end if
oStream = oRowset.Columns(1).getbinarystream(1)
REM Author: Stephan Wunderlich. Two lines added by ms777 and
completed by Fernand
Dim oShape
Dim oProvider 'GraphicProvider service.
oShape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
oGraphic = oDoc.createInstance("com.sun.star.text.GraphicObject")
oDoc.getDrawPage().add(oShape)
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim oProps(0) as new com.sun.star.beans.PropertyValue
oProps(0).Name = "InputStream"
oProps(0).Value = oStream
' oProps(0).Name = "URL"
' oProps(0).Value = sGraphicURL
oShape.Graphic = oProvider.queryGraphic(oProps())
oGraphic.GraphicUrl = oShape.GraphicUrl
' Insert at the current cursor location
oDOc.text.insertTextContent(oDoc.getCurrentController().getViewCursor(),
oGraphic, false)
' We no longer require the shape object.
oDoc.getDrawPage().remove(oShape)
Greetz
Fernand
Hi Fernand,
A related question:
Can you give me some hints to produce a minimal code (maybe no code at
all :-) )to put images out of a database into a writerdoc who is the
base document to run a mailmerge using the beamer(F4)
In general, the database column is able to provide its content as stream
(getBinaryStream, being an XInputStream). Of course you could write this
to a file (though I do not know the API for this). Whether it's possible
to directly put the binary content into a text doc - not sure, perhaps
the css.graphic API has something for it. I suggest asking this in
detail in [EMAIL PROTECTED]
If your main problem is how to get the column which supplies the binary
stream, then I might be able to help - if you tell me somewhat more
about your setup.
Ciao
Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]