Description: Calling getByName() on the bitmap table and expecting that the result can be set as a value for the GraphicURL property was no more possible in 6.1.1.2 release. This ability has been restored in 6.1.2.1 release: https://gerrit.libreoffice.org/#/c/59850/2 but it seems that it is only fixed in LO Writer. It would be great if this would be also available in other LO components like Draw and Impress. Steps to Reproduce: http://document-foundation-mail-archive.969070.n3.nabble.com/API-CHANGE-dropping-string-properties-which-use-vnd-sun-star-GraphicObject-URL-tp4235349p4247610.html Actual Results: Calling getByName() on the bitmap table causes an "Incorrect property value" error in LO Draw and Impress Expected Results: restored compatibility for other components as it is already available for Writer Reproducible: Always User Profile Reset: No Additional Info:
Could you please paste reproducer code for Impress? As far as I see the code from the link is for Writer. Thanks!
Up to the line that causes the error, the code is exactly the same as for Writer. Here it is: Function ImportBitmapIntoDraw(sURL As String, Optional oGraphicShape) As Object ' Imports a bitmap into Draw or Impress Dim oBitmaps As Object Dim sNewUrl Dim oDoc As Object oDoc = ThisComponent oBitmaps = oDoc.createInstance("com.sun.star.drawing.BitmapTable") If oBitmaps.hasByName( "OOoLilyPond" ) Then oBitmaps.removeByName( "OOoLilyPond" ) End If oBitmaps.insertByName( "OOoLilyPond", ConvertToURL(sURL) ) ' sURL contains a valid path to a SVG graphic file ' Here the "incorrect property value" error will occur: sNewURL = oBitmaps.getByName( "OOoLilyPond" ) ' do some more stuff... End Function
Could you please double-check this is indeed happening? My understand is that the problem happens when the URL would be used as a value for some Impress bitmap shape property. If you declare sNewUrl without a type, then it would be really surprising if you could not get your named bitmap from the bitmap table. What is unclear to me (but you probably know it) is the Impress equivalent of > oTextGraphic = oDoc.createInstance("com.sun.star.text.GraphicObject") > oTextGraphic.GraphicURL = sNewURL
Created attachment 145661 [details] Screenshot of LO Basic debugger
Yes, I can confirm this behaviour in the 6.1.2.1 release. In both functions (Writer and Draw/Impress), I've set a breakpoint on the line sNewURL = oBitmaps.getByName( "OOoLilyPond" ) and observed the bitmap table (see attached). It looks exactly the same in Writer, Draw and Impress. It contains one element called "OOoLilyPond". That looks correct so far. Executing the next step (i.e. the line containing getByName) causes the "incorrect property value" error. I'm not sure what you are referring to with "Impress equivalent". If you are talking about oDrawPage=oDocCtrl.getCurrentPage() later in the non-shortened ImportBitmapIntoDraw function: I have no clue. ;-) That code wasn't written by me, I just took over the project when the original developer retired. But apparently it has worked so far.
The problem with Draw and Impress persists in the 6.1.3.2 (x64) Release. Are there any further informations I could provide to help?
Yes; the question from comment 3 is still unanswered. :-) If you could please provide a simple macro which does the followings: - create an Impress bitmap shape - load an image into the bitmap table - get the bitmap from the bitmap table and set it on the bitmap shape and which works on 6.0.x, that would be great -- it would allow us to fix 6.1 and master relatively easily. I assume that your lilypond macro/extension does it already in some form. Thanks!
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
Created attachment 146621 [details] LilyPond-generated SVG file for testing
...just to be on the safe side: Is this test macro what you need? If anything is still missing, please let me know.
Right, confirmed the bug now.
I'll take care of this.
Miklos Vajna committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/+/e30f3e76a9350e2b027d99bba5a46aa0a0ff8256%5E%21 tdf#120527 svx GraphicObjectShape: handle XBitmap for GraphicURL It will be available in 6.3.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
It works! :) Tested with libo-master64~2018-11-27_20.06.55_LibreOfficeDev_6.3.0.0.alpha0_Win_x64 I can confirm that the problem in Draw and Impress is fixed now. Thanks a lot!
Cherry-picked to 6-2 in https://gerrit.libreoffice.org/#/c/64427/ @Miklos, should it be cherry-picked to 6-1 and 6-1-4 as well ? Thanks for fixing this!
+1 :) That would be great!
Miklos Vajna committed a patch related to this issue. It has been pushed to "libreoffice-6-2": https://git.libreoffice.org/core/+/07b098c126cdd01a2ce4335aeb4e1dad134c7f32%5E%21 tdf#120527 svx GraphicObjectShape: handle XBitmap for GraphicURL It will be available in 6.2.0.1. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
(In reply to Xisco Faulí from comment #15) > @Miklos, should it be cherry-picked to 6-1 and 6-1-4 as well ? https://gerrit.libreoffice.org/64643 Feel free to cherry-pick it further to libreoffice-6-1-4.
Miklos Vajna committed a patch related to this issue. It has been pushed to "libreoffice-6-1": https://git.libreoffice.org/core/+/323d12f278d3b0a51c7c2b8d3a362a27a6a232d3%5E%21 tdf#120527 svx GraphicObjectShape: handle XBitmap for GraphicURL It will be available in 6.1.5. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.