Bug 117427 - Get and Set GraphicURL using te API no longer working
Summary: Get and Set GraphicURL using te API no longer working
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.1.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:6.1.0
Keywords:
Depends on:
Blocks: Regressions-imageHandling
  Show dependency treegraph
 
Reported: 2018-05-04 12:03 UTC by Fernand
Modified: 2022-03-01 09:27 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
doc with macro's inserting and changing images (86.56 KB, application/vnd.oasis.opendocument.text)
2018-05-04 12:03 UTC, Fernand
Details
New macro's using "LoadAsLink" (29.33 KB, application/vnd.oasis.opendocument.text)
2018-05-14 17:43 UTC, Fernand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fernand 2018-05-04 12:03:31 UTC
Created attachment 141890 [details]
doc with macro's inserting and changing images

Due to API-CHANGE - dropping vnd.sun.star.GraphicObject string properties there is lost a lot of critical functionalities.

- As we not can "get" the GraphicURL how can we find out the URL where a image is linked  to?
- How can we know when a image is "linked" or "embeded" ?
  we uses in the past:
if left(oCheckgraphic1.GraphicURL,27) <> "vnd.sun.star.GraphicObject:" then 

-  As we not can "set" the GraphicURL Inserting its no longer possible to insert a "linked" image or change a linked image.(find a use case in the attached document)
Comment 1 Commit Notification 2018-05-12 08:08:23 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8484e52675052848d2d3ffe07378ce2ad29fd288

tdf#117427 missing API for determining and loading linked graphic

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 2 Fernand 2018-05-12 13:20:09 UTC
Tomaz,
Thanks for this, i will test as soon your work is present in the current master.
Can you also make it possible to query (using the descriptor) for the "DPI" stored in the ImageHeader
Comment 3 Fernand 2018-05-14 17:43:33 UTC
Created attachment 142098 [details]
New macro's using "LoadAsLink"
Comment 4 Fernand 2018-05-14 17:48:55 UTC
Tomaz
i tested with the Windows master from 13/05/2018

"LoadAsLink" is not working properly

function getGraphFromUrlAsLink(sFileUrl as String ) as Object 
  oProvider = createUnoService("com.sun.star.graphic.GraphicProvider") 
  Dim oPropsIN(1)as new com.sun.star.beans.PropertyValue 
  oPropsIN(0).Name  = "URL" 
  oPropsIN(0).Value = converttoURL(sFileUrl)
  oPropsIN(1).Name  = "LoadAsLink" 
  oPropsIN(1).Value = TRUE
  getGraphFromUrlAsLink = oProvider.queryGraphic(oPropsIN()) 
 end function
"Linked" and "OriginURL" returns empty values

oProvider = createUnoService("com.sun.star.graphic.GraphicProvider") 
Dim oPropsDESC(0)as new com.sun.star.beans.PropertyValue
oPropsDESC(0).Name = "URL"
oPropsDESC(0).Value = converttoURL("http://pmg.pmgroup.be/enews/deroulard/exploit1.jpg")
odesc = oProvider.queryGraphicdescriptor(oPropsDESC())
'xray odesc >> results in
Linked                    boolean                             False  read-only 
'OriginURL                 string                                 ""  read-only 

please use the latest attached writer doc to check my macro's
Comment 5 Tomaz Vajngerl 2018-05-15 04:53:22 UTC
Isn't it because you called getgraphfromurl and not getgraphfromurlAsLink (line 39)?
Comment 6 Tomaz Vajngerl 2018-05-15 05:06:38 UTC
Actually, you don't need to do any queryGraphicDescriptor stuff (that is to get the meta-data of the graphic without loading). 

You just do:

ographic = getgraphfromurlaslink(converttoURL("http://pmg.pmgroup.be/enews/deroulard/exploit1.jpg") )  

ographic.OriginURL
ographic.Linked

That works fine for me..
Comment 7 Fernand 2018-05-15 08:06:31 UTC
Tomaz,
Sorry my stupid mistake a was misslead by the UI properties who not shows the OriginURL in the "LINKfield".
It works indeed BUT as i sayed the OriginURL is not visible as "LINK" in the image UI properties.
Maybe my line 130 is faulty and i need to replace the Graphic in a other way to make the OriginURL visible in the UI properties ?

oGraphic01.graphic = getgraphfromurlAsLink(converttoURL("http://pmg.pmgroup.be/enews/deroulard/exploit1.jpg") ) 

Do you mean that "queryGraphicDescriptor" is a waste off time and we must forget this quering without loading
BTW: this querying is no longer possible because there we need also a "URL" to do the query.

Grtz
Comment 8 Tomaz Vajngerl 2018-05-15 08:43:18 UTC
queryGraphicDescriptor is useful when you want to know some meta-data about the image without the need to load it (or it will load it anyway in some cases). Otherwise XGraphic already has the properties so you don't need to call queryGraphicDescriptor.

I'll try to see what the problem is with setting oGraphic01.graphic...
Comment 9 Fernand 2018-05-15 11:04:48 UTC
Tomaz,

Can you add a extra property to the Xgrafic: the original DPI meta information ?

We have first to check if there is Hmm-data (if the hmm is 0  the there is no DPI stored in the iamge) and then devide the the pixels by the Hmm*25,24 to optain the DPI stored in the meta information. 
Libreoffice uses this DPI meta information to define the size of a inserted image. 
A Tool (UI and API) to change this DPI in a individual Image File (stored in the documentà would also been super !
And a tool to make the DPI the same in all image would be more than super !

Grtz.
Comment 10 Commit Notification 2018-05-15 15:31:33 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3c6b0eb0f16e4cb6d427a160e8ff766209c49f99

tdf#117427 need to check originURL when ReRead is called

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Tomaz Vajngerl 2018-05-16 04:11:52 UTC
Well, this is way out of the scope of this bug.
Comment 12 Fernand 2018-05-16 07:11:13 UTC
thanks anyhow