swriter drawing

SOS sos at pmg.be
Thu Jan 14 00:18:42 PST 2016

On 14/01/2016 3:00, meilin wrote:
> Hi!
> we can draw some shapes in writer doc such as rect, line, circle and 
> so on.
> now i want to know how to draw these shapes to a virtual device.
> i have already saw some code about drawing,but it's too hard for me to 
> understand.
> so i ask you for help, if you have some documents about drawing? 
> please send me,thank you!
Yes i  exports Charts to a Dialog and also to a PNG grachip file
is use basic code below
we need the "Drawpage" with the chart in it
a "url" to save the png file

sub exportChart(Drawpage as object, url as string )
     'prepare the renderer for the GraphicExportFilter
     oRenderer = createUnoService("com.sun.star.graphic.GraphicRendererVCL")
     Dim sRect as new com.sun.star.awt.Rectangle
      Wfactor = oChartDialog.size.width/oChartDialog.model.width
      Hfactor = oChartDialog.size.height/oChartDialog.model.height
     sRect.X = 0
     sRect.Y = 0
     sRect.Height =  180*Hfactor  'de hight is in charhe
     sRect.Width = 29*Wfactor

     oRenderer.setPropertyValue("DestinationRect", sRect)
     'the renderer shall paint to the dialog window
      Dim aArgs (1) as new com.sun.star.beans.PropertyValue
     aArgs(0).Name  = "GraphicRenderer"
     aArgs(0).Value = oRenderer
     xExporter = 
createUnoService("com.sun.star.drawing.GraphicExportFilter" )
     xExporter.filter(aArgs()) 'export to the dialog

     xExporter = 

    Dim aURL as new com.sun.star.util.URL
    aURL.complete = url
    aArgs(0).Name  = "MediaType"
    aArgs(0).Value = "image/png"
    aArgs(1).Name  = "URL"
    aArgs(1).Value = aURL

REM Grafiek Opslaan
    xExporter.filter(aArgs()) ' export to a png file
End Sub

Hope it helps


> another problem
> i want to draw some shapes in printpreview window, whether it's 
> reasonable?
> waiting for you help, thank you!
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20160114/b565a34d/attachment.html>

More information about the LibreOffice mailing list