| View previous topic :: View next topic |
| Author |
Message |
ishanthilina General User

Joined: 17 Mar 2012 Posts: 46
|
Posted: Sun Jul 01, 2012 7:40 am Post subject: [Solved][python] loading an image to xGraphic |
|
|
Hi,
I have used the following method to load a graphic to xGraphic variable. But the method always returns None.
| Code: |
def __getGraphic(self, sImageUrl):
"""
Arguments:
- `sImageUrl`:String
"""
xGraphic=None
#create a GraphicProvider at the global service manager...
oGraphicProvider = self.xMultiComponentFactory.createInstanceWithContext(
"com.sun.star.graphic.GraphicProvider", self.m_xContext)
aPropertyValue=PropertyValue()
aPropertyValue.Name = "URL"
aPropertyValue.Value = sImageUrl
aPropertyValues=(aPropertyValue,)
xGraphic=oGraphicProvider.queryGraphic(aPropertyValues)
return xGraphic
|
The value of sImageUrl is set to /home/ishan/.libreoffice/3/user/uno_packages/cache/uno_packages/luikzuk9.tmp_/out.oxt/images/information.png. I verified that information.png exists in that directory.
Any idea..? 
Last edited by ishanthilina on Mon Jul 02, 2012 10:37 pm; edited 1 time in total |
|
| Back to top |
|
 |
ishanthilina General User

Joined: 17 Mar 2012 Posts: 46
|
Posted: Mon Jul 02, 2012 10:36 pm Post subject: |
|
|
I was able to solve the problem. It seems that giving the file system path does not work here.
I had to replace the path(which was /home/ishan/.libreoffice/3/user/uno_packages/cache/uno_packages/luikzuk9.tmp_/out.oxt/images/information.png ) with the following .
vnd.sun.star.extension://org.creativecommons.openoffice.CcOOoAddin/images/information.png
where org.creativecommons.openoffice.CcOOoAddin is the extension id.
Hope this helps someone . |
|
| Back to top |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Tue Jul 03, 2012 4:39 am Post subject: |
|
|
UNO related function uses UCB (Universal Content Broker) mechanism to load something from somewhere. This is work like Virtual File System.
UCB is based on URI specification, so all provider (provides contents for a URI bounds to specific protocol) must use it. Individual content provider is an UNO component that is pluggable and listed under org.openoffice.ucb.Configuration/ContentProviders configuration with their service name and processed protocol by each provider. |
|
| Back to top |
|
 |
|