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

Joined: 06 Feb 2006 Posts: 12
|
Posted: Sun Feb 19, 2006 4:58 pm Post subject: background |
|
|
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 |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
|
| Back to top |
|
 |
anne General User

Joined: 06 Feb 2006 Posts: 12
|
Posted: Tue Feb 21, 2006 1:25 am Post subject: |
|
|
Thanks a lot for ur kindness to reply my problem.
Finally i got it work.
| 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 |
|
 |
|