LibreOffice Basic macro stops working after upgrade from LO 6.0 to LO 6.1

Hi,

I have a macro that loads a svg image file and inserts it into a Writer
document:

In earlier LO versions up to 6.0.6.2 this works without problems.
Now I have upgraded to 6.0.1.3 and the line
  
causes the following error:
  
OS is Windows 7 (64bit).
I have no idea what is happening here... can anybody help me?
Thanks for any hint.

Best wishes,
Klaus

Hi Klaus,

no macro could be seen here. Attachements aren't allowed.
You know there is a German mailinglist? (users@de.libreoffice.org)

Regards

Robert

Hi Robert,

thanks for your reply.
I have formatted all code snippets as "raw". In the preview, they were still
there, but here it seems that nabble has completely removed them. This time,
I'll work without formatting.

Okay, here is my question again:

I have a macro that loads a svg image file and inserts it into a Writer
document:

' --------------------------------------------------------
Function ImportBitmapIntoWriter(sFile As String) As Object

  Dim oBitmaps As Object
  Dim sNewUrl As String
  Dim oDoc As Object
  
  oDoc = ThisComponent
  
  oBitmaps = oDoc.createInstance("com.sun.star.drawing.BitmapTable")
  ' If there is an older entry with that name, remove it:
  If oBitmaps.hasByName( "OOoLilyPond" ) Then
    oBitmaps.removeByName( "OOoLilyPond" )
  End If
  
  ' Load the image into the internal bitmap table:
  oBitmaps.insertByName( "OOoLilyPond", ConvertToURL(sFile) ) ' Up to here,
everything works fine.
  sNewURL = oBitmaps.getByName( "OOoLilyPond" ) ' This line causes the
error.
  
  ' ... some more stuff...
End Function
' --------------------------------------------------------

In earlier LO versions up to 6.0.6.2 this works without problems.
Now I have upgraded to 6.0.1.3 and the line
  sNewURL = oBitmaps.getByName( "OOoLilyPond" )
causes the following error:
  "Incorrect property value."

I have no idea what is happening here... can anybody help me?
Thanks for any hint.

Best wishes,
Klaus

P.S.: It's about the "OOoLilyPond" extension:
https://extensions.libreoffice.org/extensions/ooolilypond
https://github.com/openlilylib/LO-ly

Hi Klaus,

  ' Load the image into the internal bitmap table:
  oBitmaps.insertByName( "OOoLilyPond", ConvertToURL(sFile) ) ' Up to here,
everything works fine.
  sNewURL = oBitmaps.getByName( "OOoLilyPond" ) ' This line causes the
error.

So the error is one row above. Have tried it with xray. There isn't any
element in the bitmap table, so you can't get the element.

Then I downloaded the API for LO 6.1 and looked for insertByName in
bitmap table - nothing changed here. But the release-notes for 6.1 about
image-handling could be an entry for looking for the buggy behavior:
https://wiki.documentfoundation.org/ReleaseNotes/6.1#Images_2

Put the part of the code in a writer-document and report this as a bug.
I could confirm the buggy behavior.

Regards

Robert

Hi Klaus,

have tried it a little bit more. URL was wrong the first time.
I get the object oBitmaps.getByName( "OOoLilyPond" )
... but you will create a string of this. This coudn't work. What do you
wan't to get from the object?

Regards

Robert

Hi Robert,

thanks a lot for your examinations.

Robert Großkopf wrote

... but you will create a string of this. This coudn't work. What do you
wan't to get from the object?

You are right, it's only the beginning of the function. I tried to strip it
down to a minimal example.
The string is used to assign the file URL to a GraphicObject which is
created afterwards:

    oTextGraphic = oDoc.createInstance("com.sun.star.text.GraphicObject")
    oTextGraphic.GraphicURL = sNewURL

The whole function can be found here (starting with line 235):
https://github.com/openlilylib/LO-ly/blob/master/extension/OOoLilyPond/Tools.xba

Up to LO 6.0 this worked fine.
In LO 6.1, I commented out the suspect lines step-by-step to find the one
causing the error.
(The thing is, I don't understand every step. The original developer of the
project has retired and I'm continuing his work...)

Cheers,
Klaus

Hi all,

I'm guessing that this is all down to the recent rework of the URL
resolver for graphics handling and management - seems like you either
need to adapt to the new way of doing things, or else, the recent
changes have introduced an unfortunate side-effect.

Alex

Look for a message with the following title on the dev mailing list :

API-CHANGE - dropping string properties which use
vnd.sun.star.GraphicObject URL

Alex

Hi Alex,

Alex Thurgood wrote

Look for a message with the following title on the dev mailing list :

API-CHANGE - dropping string properties which use
vnd.sun.star.GraphicObject URL

Thanks for your info. After lots of reading, now I know that I used a
deprecated way of loading image files into a document, and that I'll have to
replace that outdated code.
I learned that the use of GraphicURL has to be replaced by something called
XGraphic.
Now the big question is, where can I find a documentation of that?

Or is this something I should ask directly in that thread on the dev mailing
list?

Cheers,
Klaus

XGrphic information I've found in the SDK documentation at
<your LibreOffice Install

sdk/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1graphic_1_1XGraphic.html

Wanting use this also, later this week, for reading images into database
fields with a python script - so happened to look that up over the weekend.
Haven't tried using it yet though.