OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Solved][python] loading an image to xGraphic

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
ishanthilina
General User
General User


Joined: 17 Mar 2012
Posts: 46

PostPosted: Sun Jul 01, 2012 7:40 am    Post subject: [Solved][python] loading an image to xGraphic Reply with quote

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..? Confused


Last edited by ishanthilina on Mon Jul 02, 2012 10:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
ishanthilina
General User
General User


Joined: 17 Mar 2012
Posts: 46

PostPosted: Mon Jul 02, 2012 10:36 pm    Post subject: Reply with quote

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 Smile.
Back to top
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Tue Jul 03, 2012 4:39 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group