1 package complex
.checkColor
;
3 import com
.sun
.star
.awt
.Rectangle
;
4 import com
.sun
.star
.awt
.Size
;
5 import com
.sun
.star
.awt
.WindowDescriptor
;
6 import com
.sun
.star
.awt
.XControlModel
;
7 import com
.sun
.star
.awt
.XToolkit
;
8 import com
.sun
.star
.awt
.XWindow
;
9 import com
.sun
.star
.awt
.XWindowPeer
;
10 import com
.sun
.star
.beans
.PropertyValue
;
11 import com
.sun
.star
.beans
.XPropertySet
;
12 import com
.sun
.star
.container
.XNameAccess
;
13 import com
.sun
.star
.container
.XNameContainer
;
14 import com
.sun
.star
.drawing
.XControlShape
;
15 import com
.sun
.star
.drawing
.XShape
;
16 import com
.sun
.star
.frame
.XComponentLoader
;
17 import com
.sun
.star
.frame
.XController
;
18 import com
.sun
.star
.lang
.XComponent
;
19 import com
.sun
.star
.lang
.XMultiServiceFactory
;
20 import com
.sun
.star
.style
.XStyleFamiliesSupplier
;
21 import com
.sun
.star
.text
.XTextDocument
;
22 import com
.sun
.star
.uno
.UnoRuntime
;
23 import com
.sun
.star
.uno
.XInterface
;
24 import com
.sun
.star
.view
.XControlAccess
;
25 import complexlib
.ComplexTestCase
;
26 import java
.io
.PrintWriter
;
27 import util
.FormTools
;
28 import util
.SOfficeFactory
;
29 import util
.WriterTools
;
32 * Created because of complaint on dev@openoffice.org: check the changing of
33 * BackColor and IsLandscape properties on the PageStyle service.
35 public class CheckChangeColor
extends ComplexTestCase
{
37 private XToolkit xToolkit
= null;
38 private XWindowPeer xWinPeer
= null;
41 * Get all test method names.
42 * @return The test methods.
44 public String
[] getTestMethodNames() {
45 return new String
[] {"checkChangeColor"};
50 * Check BackColor and IsLandscape properties, wait for an exception: test
51 * is ok if no exception happened.
53 public void checkChangeColor() {
55 XMultiServiceFactory m_xMSF_
= (XMultiServiceFactory
)param
.getMSF();
56 XComponentLoader aLoader
= (XComponentLoader
)UnoRuntime
.queryInterface(XComponentLoader
.class,m_xMSF_
.createInstance( "com.sun.star.frame.Desktop" ));
57 XComponent xDocument
= (XComponent
)UnoRuntime
.queryInterface(XComponent
.class, aLoader
.loadComponentFromURL( "private:factory/swriter", "_blank", 0, new PropertyValue
[ 0 ] ) );
58 // xDocument.addEventListener( this );
60 XTextDocument oDoc
= (XTextDocument
) UnoRuntime
.queryInterface(XTextDocument
.class, xDocument
);
61 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
) UnoRuntime
.queryInterface(XMultiServiceFactory
.class, oDoc
);
63 // XInterface xInterface = (XInterface) oDocMSF.createInstance( "com.sun.star.style.PageStyle" );
65 // create a supplier to get the Style family collection
66 XStyleFamiliesSupplier xSupplier
= ( XStyleFamiliesSupplier
) UnoRuntime
.queryInterface(XStyleFamiliesSupplier
.class, oDoc
);
68 // get the NameAccess interface from the Style family collection
69 XNameAccess xNameAccess
= xSupplier
.getStyleFamilies();
71 XNameContainer xPageStyleCollection
= (XNameContainer
) UnoRuntime
.queryInterface(XNameContainer
.class, xNameAccess
.getByName( "PageStyles" ));
73 // create a PropertySet to set the properties for the new Pagestyle
74 XPropertySet xPropertySet
= (XPropertySet
) UnoRuntime
.queryInterface(XPropertySet
.class, xPageStyleCollection
.getByName("Standard") );
76 log
.println("BackColor @ "+xPropertySet
.getPropertyValue("BackColor").toString());
77 log
.println("IsLandscape @ "+xPropertySet
.getPropertyValue("IsLandscape").toString());
78 log
.println("Size @ H:"+((Size
)xPropertySet
.getPropertyValue("Size")).Height
+" W:"+((Size
)xPropertySet
.getPropertyValue("Size")).Width
);
80 log
.println("Set Landscape");
81 xPropertySet
.setPropertyValue("IsLandscape",new Boolean(true) );
82 log
.println("Set BackColor");
83 xPropertySet
.setPropertyValue("BackColor",new Integer((int)255000000) );