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

background

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


Joined: 06 Feb 2006
Posts: 12

PostPosted: Sun Feb 19, 2006 4:58 pm    Post subject: background Reply with quote

Dear all

i have a problem with adding a slide background filling bitmap. I have already post before that i can fill all slides with the same background
http://www.oooforum.org/forum/viewtopic.phtml?t=31797&highlight=background

but my aim is to change only one slide background. in api , i found
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/Background.html
so i try to write
Code:

com.sun.star.drawing.XShape xShape = null;
           com.sun.star.lang.XMultiServiceFactory xDocMSF =
              (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
                com.sun.star.lang.XMultiServiceFactory.class, xDrawDoc );
                try {
                        Object oInt = xDocMSF.createInstance("com.sun.star.drawing.background");
                         xShape = (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
                                         com.sun.star.drawing.XShape.class, oInt);       
                } catch ( Exception e ) {
                         System.err.println( "Couldn't create instance "+ e );
                         e.printStackTrace(System.err);
               }

but exception occur. i can't createInstance with com.sun.star.drawing.background.

Can anyone help and guide me how to use that background service.
Thanks a lot for u help. I have been stucked with this problem and not know how to slove. [/url]
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Mon Feb 20, 2006 9:49 am    Post subject: Reply with quote

Do you know how to use the BackGround thing?
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/FillProperties.html

You obviously need to set the fill style to bitmap.
http://api.openoffice.org/docs/common/ref/com/sun/star/drawing/FillStyle.html

Not certain how to set the bitmap itself... And it may need to be an internal bitmap that you require. Danny demonstrated once how to create an internal bitmap URL, i think that I have it in my free macro document.

You will probably need to set the Background property of the specific draw pages to then use the Background.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
anne
General User
General User


Joined: 06 Feb 2006
Posts: 12

PostPosted: Tue Feb 21, 2006 1:25 am    Post subject: Reply with quote

Thanks a lot for ur kindness to reply my problem.
Finally i got it work. Wink Laughing

Code:
 com.sun.star.uno.XInterface xInterface = (com.sun.star.uno.XInterface)
                xDocMSF.createInstance("com.sun.star.drawing.Background");
           
         XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xInterface );
 java.io.File sourceFile = new java.io.File("liquid-blue.jpg");
           StringBuffer sUrl = new StringBuffer("file:///");
      sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
          System.out.println(sUrl.toString());
          xPropSet.setPropertyValue("FillStyle",com.sun.star.drawing.FillStyle.BITMAP);
          xPropSet.setPropertyValue("FillBitmapURL", sUrl.toString());
XPropertySet xpageset = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xPage);
xpageset.setPropertyValue("Background",xInterface);


The last code line make me crazy , finally i dump out all the property and i find it.
Thanks God.
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