1 package complex
.embedding
;
3 import com
.sun
.star
.uno
.XInterface
;
4 import com
.sun
.star
.lang
.XMultiServiceFactory
;
5 import com
.sun
.star
.lang
.XSingleServiceFactory
;
7 import com
.sun
.star
.bridge
.XUnoUrlResolver
;
8 import com
.sun
.star
.uno
.UnoRuntime
;
9 import com
.sun
.star
.uno
.XInterface
;
10 import com
.sun
.star
.beans
.XPropertySet
;
11 import com
.sun
.star
.frame
.XLoadable
;
12 import com
.sun
.star
.drawing
.XDrawPagesSupplier
;
13 import com
.sun
.star
.drawing
.XDrawPages
;
14 import com
.sun
.star
.drawing
.XDrawPage
;
15 import com
.sun
.star
.drawing
.XShape
;
16 import com
.sun
.star
.graphic
.XGraphic
;
18 import com
.sun
.star
.embed
.*;
20 import share
.LogWriter
;
21 import complex
.embedding
.TestHelper
;
22 import complex
.embedding
.EmbeddingTest
;
24 public class Test01
implements EmbeddingTest
{
26 XMultiServiceFactory m_xMSF
;
27 TestHelper m_aTestHelper
;
29 public Test01( XMultiServiceFactory xMSF
, LogWriter aLogWriter
)
32 m_aTestHelper
= new TestHelper( aLogWriter
, "Test01: " );
39 Object oDoc
= m_xMSF
.createInstance( "com.sun.star.comp.Draw.DrawingDocument" );
40 XLoadable xLoad
= (XLoadable
) UnoRuntime
.queryInterface( XLoadable
.class, oDoc
);
43 m_aTestHelper
.Error( "Can not get XLoadable!" );
49 XDrawPagesSupplier xDPSupply
= (XDrawPagesSupplier
) UnoRuntime
.queryInterface( XDrawPagesSupplier
.class, oDoc
);
50 if ( xDPSupply
== null )
52 m_aTestHelper
.Error( "Can not get XDrawPagesSupplier!" );
56 XDrawPages xDrawPages
= xDPSupply
.getDrawPages();
57 if ( xDrawPages
== null )
59 m_aTestHelper
.Error( "Can not get XDrawPages object!" );
63 if ( xDrawPages
.getCount() == 0 )
65 m_aTestHelper
.Error( "There must be at least one page in the document!" );
69 Object oPage
= xDrawPages
.getByIndex( 0 );
70 XDrawPage xPage
= (XDrawPage
) UnoRuntime
.queryInterface( XDrawPage
.class, oPage
);
73 m_aTestHelper
.Error( "Can not get access to drawing page!" );
77 XMultiServiceFactory xDrFactory
= ( XMultiServiceFactory
) UnoRuntime
.queryInterface( XMultiServiceFactory
.class,
79 if ( xDrFactory
== null )
81 m_aTestHelper
.Error( "Can not get drawing factory!" );
85 Object oShape
= xDrFactory
.createInstance( "com.sun.star.drawing.OLE2Shape" );
86 XShape xShape
= ( XShape
) UnoRuntime
.queryInterface( XShape
.class, oShape
);
89 m_aTestHelper
.Error( "Can not create new shape!" );
93 XPropertySet xShapeProps
= ( XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, oShape
);
94 if ( xShapeProps
== null )
96 m_aTestHelper
.Error( "Can not get access to shapes properties!" );
101 xShapeProps
.setPropertyValue( "CLSID", "078B7ABA-54FC-457F-8551-6147e776a997" );
103 Object oEmbObj
= xShapeProps
.getPropertyValue( "EmbeddedObject" );
104 XEmbeddedObject xEmbObj
= ( XEmbeddedObject
) UnoRuntime
.queryInterface( XEmbeddedObject
.class, oEmbObj
);
105 if ( xEmbObj
== null )
107 m_aTestHelper
.Error( "Embedded object can not be accessed!" );
111 XEmbeddedClient xClient
= xEmbObj
.getClientSite();
112 if ( xClient
== null )
114 m_aTestHelper
.Error( "The client for the object must be set!" );
118 Object oReplacement
= xShapeProps
.getPropertyValue( "Graphic" );
119 XGraphic xReplGraph
= ( XGraphic
) UnoRuntime
.queryInterface( XGraphic
.class, oReplacement
);
120 if ( xReplGraph
== null )
122 m_aTestHelper
.Error( "The replacement graphic should be available!" );
130 m_aTestHelper
.Error( "Exception: " + e
);