Date: prev next · Thread: first prev next last
2016 Archives by date, by thread · List index



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
oRenderer.setPropertyValue("Device", oChartDialog.Peer.createGraphics.Device)
     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.setSourceDocument(oSheet.DrawPage.getByIndex(0))
    xExporter.filter(aArgs()) 'export to the dialog

xExporter = createUnoService("com.sun.star.drawing.GraphicExportFilter")
    xExporter.SetSourceDocument(Drawpage)

   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

Fernand




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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.