forked from LibreOffice/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INTEGRATION: CWS opofxmlstorage (1.1.2); FILE ADDED
2006/09/15 11:11:33 mav 1.1.2.2: #i69455# add Graphic property 2006/05/19 11:43:33 mav 1.1.2.1: #i65548# test embedding API
- Loading branch information
Oliver Bolte
committed
Oct 13, 2006
1 parent
97d9381
commit c85f138
Showing
1 changed file
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package complex.embedding; | ||
|
||
import com.sun.star.uno.XInterface; | ||
import com.sun.star.lang.XMultiServiceFactory; | ||
import com.sun.star.lang.XSingleServiceFactory; | ||
|
||
import com.sun.star.bridge.XUnoUrlResolver; | ||
import com.sun.star.uno.UnoRuntime; | ||
import com.sun.star.uno.XInterface; | ||
import com.sun.star.beans.XPropertySet; | ||
import com.sun.star.frame.XLoadable; | ||
import com.sun.star.drawing.XDrawPagesSupplier; | ||
import com.sun.star.drawing.XDrawPages; | ||
import com.sun.star.drawing.XDrawPage; | ||
import com.sun.star.drawing.XShape; | ||
import com.sun.star.graphic.XGraphic; | ||
|
||
import com.sun.star.embed.*; | ||
|
||
import share.LogWriter; | ||
import complex.embedding.TestHelper; | ||
import complex.embedding.EmbeddingTest; | ||
|
||
public class Test01 implements EmbeddingTest { | ||
|
||
XMultiServiceFactory m_xMSF; | ||
TestHelper m_aTestHelper; | ||
|
||
public Test01( XMultiServiceFactory xMSF, LogWriter aLogWriter ) | ||
{ | ||
m_xMSF = xMSF; | ||
m_aTestHelper = new TestHelper( aLogWriter, "Test01: " ); | ||
} | ||
|
||
public boolean test() | ||
{ | ||
try | ||
{ | ||
Object oDoc = m_xMSF.createInstance( "com.sun.star.comp.Draw.DrawingDocument" ); | ||
XLoadable xLoad = (XLoadable) UnoRuntime.queryInterface( XLoadable.class, oDoc ); | ||
if ( xLoad == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get XLoadable!" ); | ||
return false; | ||
} | ||
|
||
xLoad.initNew(); | ||
|
||
XDrawPagesSupplier xDPSupply = (XDrawPagesSupplier) UnoRuntime.queryInterface( XDrawPagesSupplier.class, oDoc ); | ||
if ( xDPSupply == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get XDrawPagesSupplier!" ); | ||
return false; | ||
} | ||
|
||
XDrawPages xDrawPages = xDPSupply.getDrawPages(); | ||
if ( xDrawPages == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get XDrawPages object!" ); | ||
return false; | ||
} | ||
|
||
if ( xDrawPages.getCount() == 0 ) | ||
{ | ||
m_aTestHelper.Error( "There must be at least one page in the document!" ); | ||
return false; | ||
} | ||
|
||
Object oPage = xDrawPages.getByIndex( 0 ); | ||
XDrawPage xPage = (XDrawPage) UnoRuntime.queryInterface( XDrawPage.class, oPage ); | ||
if ( xPage == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get access to drawing page!" ); | ||
return false; | ||
} | ||
|
||
XMultiServiceFactory xDrFactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class, | ||
oDoc ); | ||
if ( xDrFactory == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get drawing factory!" ); | ||
return false; | ||
} | ||
|
||
Object oShape = xDrFactory.createInstance( "com.sun.star.drawing.OLE2Shape" ); | ||
XShape xShape = ( XShape ) UnoRuntime.queryInterface( XShape.class, oShape ); | ||
if ( xShape == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not create new shape!" ); | ||
return false; | ||
} | ||
|
||
XPropertySet xShapeProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, oShape ); | ||
if ( xShapeProps == null ) | ||
{ | ||
m_aTestHelper.Error( "Can not get access to shapes properties!" ); | ||
return false; | ||
} | ||
|
||
xPage.add( xShape ); | ||
xShapeProps.setPropertyValue( "CLSID", "078B7ABA-54FC-457F-8551-6147e776a997" ); | ||
|
||
Object oEmbObj = xShapeProps.getPropertyValue( "EmbeddedObject" ); | ||
XEmbeddedObject xEmbObj = ( XEmbeddedObject ) UnoRuntime.queryInterface( XEmbeddedObject.class, oEmbObj ); | ||
if ( xEmbObj == null ) | ||
{ | ||
m_aTestHelper.Error( "Embedded object can not be accessed!" ); | ||
return false; | ||
} | ||
|
||
XEmbeddedClient xClient = xEmbObj.getClientSite(); | ||
if ( xClient == null ) | ||
{ | ||
m_aTestHelper.Error( "The client for the object must be set!" ); | ||
return false; | ||
} | ||
|
||
Object oReplacement = xShapeProps.getPropertyValue( "Graphic" ); | ||
XGraphic xReplGraph = ( XGraphic ) UnoRuntime.queryInterface( XGraphic.class, oReplacement ); | ||
if ( xReplGraph == null ) | ||
{ | ||
m_aTestHelper.Error( "The replacement graphic should be available!" ); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
catch( Exception e ) | ||
{ | ||
m_aTestHelper.Error( "Exception: " + e ); | ||
return false; | ||
} | ||
} | ||
} | ||
|