Thomas Krumbein wrote:
Hey guys,
I tried to solve a very similar problem as discribed in a thread showing
in mid of march, title: ImageURL in a UnoControlImageControlModel
author: Fernand Vanrie <[EMAIL PROTECTED]>
Fernand wrote, he has a solution and it works fine, but unfortuantly I
cannot get it to work.
Short indroduction: I want to show in a dialog (ImageControl) embeded
graphic-objects (Bitmaps) of an word-document. The solution of Fernand was:
sub Render
oDialogControl = createUnoService( "com.sun.star.awt.UnoControlDialog" )
oRenderer = createUnoService("com.sun.star.graphic.GraphicRendererVCL")
Dim sRect as new com.sun.star.awt.Rectangle
sRect.X = 0
sRect.Y = 0
sRect.Width = 800
sRect.Height = 600
oRenderer.setPropertyValue("DestinationRect", sRect)
'the renderer shall paint to the dialog window
xray odialog
oDialogControl = Odialog
oRenderer.setPropertyValue("Device",
oDialogControl.Peer.createGraphics.Device)
here we needs a "imagecontrol in the dialog you can mae it "FOTO1"
then the code is like:
oFoto1 = oDialog.getControl("FOTO1")
sRect.X = 0
sRect.Y = 0
sRect.Width = lwidth 'defined by the pixels in oPreviewGraph
sRect.Height = lheight
oRenderer.Device = oFoto1.Peer.createGraphics.Device
oRenderer.DestinationRect = sRect
oRenderer.render(oPreviewGraph)
aArgs(0).Name = "GraphicRenderer"
aArgs(0).Value = oRenderer
xExporter = createUnoService( "com.sun.star.drawing.GraphicExportFilter" )
xray odocument.drawpage
xExporter.setSourceDocument( odocument.drawpage.getbyindex(5))
oPaintListener = CreateUnoListener("MyDialog_",
"com.sun.star.awt.XPaintListener")
oDialogControl.Peer.addPaintListener( oPaintListener )
odialog.execute
'oDoc.close(true)
end sub
sub MyDialog_windowPaint(oEvt)
if oEvt.count > 0 then exit sub
sRect.X = 0
sRect.Y = 0
sRect.Width = lwidth
sRect.Height = lheight
oRenderer.Device = oFoto1.Peer.createGraphics.Device
oRenderer.DestinationRect = sRect
oRenderer.render(oPreviewGraph)
end sub
sub MyDialog_disposing(oEvt As Object)
end sub
But I think, this is only a part of his code. I did not get it to work.
I know the original code out of the forum - but even this did not work.
As I understand - maybe Fernand can help? - the "xExporter" object is
not used here?
ist part of the peace of code i found on the forum, we do not need a
exporter here
What is "oPreviewGraph"? An Inputstream?
a imputstream :-)
a graficObject - and how did
you get it?
nono a just a "silly" name for the repepresenstation of the original
graphic staying on disk an contanning all the information we needs to
show this graphic in a dialog, pixels etc
code:
If InStr(1, sGraphicURL, "vnd.sun.star.GraphicObject:", 0) = 1 Then '
this is a embeded graphic
' get the picture name (comes without the extension)
sGraphicURL = Mid(sGraphicURL, 28, Len(sGraphicURL))
' so search all files in pictures folder for the current
picture ...
For j = 0 to oGraphics.getcount-1
If InStr(1, mFiles(j), sGraphicURL, 0) Then
' create new name with extension ...
sGraphicName = oGraphic.getName() & Mid(mFiles(j),
Len(sGraphicURL)+1, Len(mFiles(j))
oPreviewGraph =
getGraphFromStream(oPictures.getByName(mFiles(j)).getInputStream())
exit for
else
end if
next
' here we need a function:
function getGraphFromStream(oInputStream as Object) as Object
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim oPropsIN(0)as new com.sun.star.beans.PropertyValue
oPropsIN(0).Name = "InputStream"
oPropsIN(0).Value = oInputStream
getGraphFromStream = oProvider.queryGraphic(oPropsIN())
end function
I get an error at this point - and it stopps in a endless loop, only to
stop by killing the task - not really productiv for learning.
So, is it possible to get the whole code so that I can understand how
its work?
no problem but you also need the "dialog" itself so gives me your email
ans i send you the a working document where we crop images using a dialog
Or can someone else give me a shot help how to show embedded Graphics
easy in a dialogs-control?
My solution at the time is to export the graphic to an external file and
then use the URL proberty to import the graphic to the Control. It
works, but I think, there must be an easier way.
Many thanks for your help
best regards
Thomas
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]