[Libreoffice-bugs] [Bug 120527] sw TextGraphicObject: handle XBitmap for GraphicURL - make it available in Draw and Impress

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Nov 14 16:08:15 UTC 2018


https://bugs.documentfoundation.org/show_bug.cgi?id=120527

--- Comment #8 from Klaus Blum <benbignoise at gmx.de> ---
Okay, now I know what is still missing. 

Here is a function for Draw and Impress that hopefully does what you need. 
It contains a path to a SVG file that you'd have to adjust to work on your
machine. 
I'll attach a LilyPond-generated SVG file, but of course any graphics file
should work. 

The following code works fine in 6.0.7.3, 
but fails in 6.1.0.3, 6.1.1.2, 6.1.2.1 and 6.1.3.2:

---------------------------------------------------------

Sub SVG_Test
        Dim oDrawPage As Object
        Dim oBitmaps As Object
        Dim sNewUrl
        Dim oSize As Object
        Dim oShape As Object
        Dim oDoc As Object
        Dim oDocCtrl As Object
        Dim oCrop As new com.sun.star.text.GraphicCrop

        oDoc = ThisComponent
        oDocCtrl = oDoc.getCurrentController

        oBitmaps = oDoc.createInstance("com.sun.star.drawing.BitmapTable")
        If oBitmaps.hasByName( "OOoLilyPond" ) Then
                oBitmaps.removeByName( "OOoLilyPond" )
        End If
        oBitmaps.insertByName( "OOoLilyPond",
ConvertToURL("C:\Users\Admin\Desktop\Test.svg") )
        ' Replace this by a valid path to a graphics file on your machine
        sNewURL = oBitmaps.getByName( "OOoLilyPond" )

        'Insert the Bitmap
        oDrawPage=oDocCtrl.getCurrentPage()
        oGraphicShape =
oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
        oGraphicShape.graphicURL=sNewURL   ' This line causes the error.
        oDrawPage.add(oGraphicShape)

        'Set the correct Size
        oSize = createUnoStruct( "com.sun.star.awt.Size" )
        oSize.width =  oGraphicShape.Graphic.Size100thMM.Width
        oSize.height = oGraphicShape.Graphic.Size100thMM.Height

        ' remove the Bitmap from the table
        ' (otherwise the Bitmaps of deleted Objects will still be referenced
and saved)
        oBitmaps.removeByName( "OOoLilyPond" )

        ' refresh the view
        oDocCtrl.restoreViewData(oDocCtrl.getViewData)          

        oGraphicShape.setSize(oSize)                                           
        ' apply size as calculated above
        oGraphicShape.setPropertyValue ("GraphicCrop", oCrop)   ' overwrite old
Crop settings
End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20181114/fb347513/attachment-0001.html>


More information about the Libreoffice-bugs mailing list