1*cdf0e10cSrcweir package org.openoffice.examples.embedding; 2*cdf0e10cSrcweir 3*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 4*cdf0e10cSrcweir import com.sun.star.uno.XComponentContext; 5*cdf0e10cSrcweir import com.sun.star.lang.XMultiComponentFactory; 6*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 7*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 8*cdf0e10cSrcweir import com.sun.star.lib.uno.helper.WeakBase; 9*cdf0e10cSrcweir import com.sun.star.io.XStream; 10*cdf0e10cSrcweir import com.sun.star.io.XOutputStream; 11*cdf0e10cSrcweir import com.sun.star.io.XInputStream; 12*cdf0e10cSrcweir import com.sun.star.io.XTruncate; 13*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet; 14*cdf0e10cSrcweir import com.sun.star.lang.XComponent; 15*cdf0e10cSrcweir import com.sun.star.document.EventObject; 16*cdf0e10cSrcweir import com.sun.star.embed.VisualRepresentation; 17*cdf0e10cSrcweir import com.sun.star.container.XNameAccess; 18*cdf0e10cSrcweir 19*cdf0e10cSrcweir 20*cdf0e10cSrcweir import com.sun.star.embed.*; 21*cdf0e10cSrcweir 22*cdf0e10cSrcweir import java.util.Vector; 23*cdf0e10cSrcweir import java.awt.Dimension; 24*cdf0e10cSrcweir import java.lang.Integer; 25*cdf0e10cSrcweir import org.omg.CORBA.COMM_FAILURE; 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir import org.openoffice.examples.embedding.EditorFrame; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir public final class OwnEmbeddedObject extends WeakBase 30*cdf0e10cSrcweir implements com.sun.star.embed.XEmbedPersist, 31*cdf0e10cSrcweir com.sun.star.embed.XEmbeddedObject 32*cdf0e10cSrcweir { 33*cdf0e10cSrcweir protected final XComponentContext m_xContext; 34*cdf0e10cSrcweir protected final byte[] m_aClassID; 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir protected boolean m_bDisposed = false; 37*cdf0e10cSrcweir protected int m_nObjectState = -1; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir protected com.sun.star.embed.XStorage m_xParentStorage; 40*cdf0e10cSrcweir protected com.sun.star.embed.XStorage m_xOwnStorage; 41*cdf0e10cSrcweir protected String m_aEntryName; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir protected com.sun.star.embed.XStorage m_xNewParentStorage; 44*cdf0e10cSrcweir protected com.sun.star.embed.XStorage m_xNewOwnStorage; 45*cdf0e10cSrcweir protected String m_aNewEntryName; 46*cdf0e10cSrcweir protected boolean m_bWaitSaveCompleted = false; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir protected EditorFrame m_aEditorFrame; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir protected Vector m_aListeners; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir com.sun.star.embed.VerbDescriptor[] m_pOwnVerbs; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir com.sun.star.embed.XEmbeddedClient m_xClient; 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir Dimension m_aObjSize; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // ------------------------------------------------------------- 59*cdf0e10cSrcweir protected Vector GetListeners() 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir if ( m_aListeners == null ) 62*cdf0e10cSrcweir m_aListeners = new Vector<Object>( 10, 10 ); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir return m_aListeners; 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir // ------------------------------------------------------------- 68*cdf0e10cSrcweir protected Dimension UpdateSizeAndGetFromActive() 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.ACTIVE ) 71*cdf0e10cSrcweir m_aObjSize = m_aEditorFrame.getAppSize(); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir if ( m_aObjSize != null ) 74*cdf0e10cSrcweir return m_aObjSize; 75*cdf0e10cSrcweir else 76*cdf0e10cSrcweir return new Dimension(); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // ------------------------------------------------------------- 80*cdf0e10cSrcweir protected void SwitchOwnPersistence( XStorage xParentStorage, XStorage xOwnStorage, String aEntryName ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir if ( xOwnStorage != m_xOwnStorage ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir if ( m_xOwnStorage != null ) 85*cdf0e10cSrcweir m_xOwnStorage.dispose(); 86*cdf0e10cSrcweir m_xParentStorage = xParentStorage; 87*cdf0e10cSrcweir m_xOwnStorage = xOwnStorage; 88*cdf0e10cSrcweir m_aEntryName = aEntryName; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // ------------------------------------------------------------- 93*cdf0e10cSrcweir protected void SwitchOwnPersistence( XStorage xParentStorage, String aEntryName ) throws com.sun.star.io.IOException 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir if ( xParentStorage != m_xParentStorage || !aEntryName.equals( m_aEntryName ) ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir try 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir XStorage xOwnStorage = xParentStorage.openStorageElement( aEntryName, com.sun.star.embed.ElementModes.READWRITE ); 100*cdf0e10cSrcweir SwitchOwnPersistence( xParentStorage, xOwnStorage, aEntryName ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir catch( com.sun.star.uno.RuntimeException e ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir throw e; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir catch( com.sun.star.io.IOException e ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir throw e; 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir catch( com.sun.star.uno.Exception e ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir throw new com.sun.star.io.IOException( "Error while switching object storage!" ); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // ------------------------------------------------------------- 118*cdf0e10cSrcweir protected static void SaveDataToStorage( XStorage xStorage, String aString, Dimension aDimension ) throws com.sun.star.io.IOException 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir try 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir // save the text 123*cdf0e10cSrcweir XStream xStream = xStorage.openStreamElement( "content.txt", com.sun.star.embed.ElementModes.READWRITE ); 124*cdf0e10cSrcweir XComponent xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream ); 125*cdf0e10cSrcweir if ( xStreamComp == null ) 126*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir XOutputStream xOutStream = xStream.getOutputStream(); 129*cdf0e10cSrcweir XTruncate xTruncate = ( XTruncate ) UnoRuntime.queryInterface( XTruncate.class, xOutStream ); 130*cdf0e10cSrcweir if ( xTruncate == null ) 131*cdf0e10cSrcweir throw new com.sun.star.io.IOException(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir xTruncate.truncate(); 134*cdf0e10cSrcweir xOutStream.writeBytes( aString.getBytes() ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // save the size 137*cdf0e10cSrcweir xStream = xStorage.openStreamElement( "properties.txt", com.sun.star.embed.ElementModes.READWRITE ); 138*cdf0e10cSrcweir xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream ); 139*cdf0e10cSrcweir if ( xStreamComp == null ) 140*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir xOutStream = xStream.getOutputStream(); 143*cdf0e10cSrcweir xTruncate = ( XTruncate ) UnoRuntime.queryInterface( XTruncate.class, xOutStream ); 144*cdf0e10cSrcweir if ( xTruncate == null ) 145*cdf0e10cSrcweir throw new com.sun.star.io.IOException(); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir xTruncate.truncate(); 148*cdf0e10cSrcweir String aProps = Integer.toString( (int)aDimension.getWidth() ) + "|" + Integer.toString( (int)aDimension.getHeight() ); 149*cdf0e10cSrcweir xOutStream.writeBytes( aProps.getBytes() ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // set the media type 152*cdf0e10cSrcweir XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xStorage ); 153*cdf0e10cSrcweir if ( xPropSet == null ) 154*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 155*cdf0e10cSrcweir xPropSet.setPropertyValue( "MediaType", "application/x-openoffice-embedded-69474366-FD6F-4806-8374-8EDD1B6E771D" ); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir XTransactedObject xTransact = ( XTransactedObject ) UnoRuntime.queryInterface( XTransactedObject.class, xStorage ); 158*cdf0e10cSrcweir if ( xTransact != null ) 159*cdf0e10cSrcweir xTransact.commit(); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir xStreamComp.dispose(); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir catch( com.sun.star.uno.RuntimeException e ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir throw e; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir catch( com.sun.star.io.IOException e ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir throw e; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir catch( com.sun.star.uno.Exception e ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir throw new com.sun.star.io.IOException( "Error while switching object storage!" ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir // ------------------------------------------------------------- 178*cdf0e10cSrcweir protected void PostEvent( String aEvEntryName ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir if ( m_aListeners != null ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir com.sun.star.document.EventObject aEventObject = new com.sun.star.document.EventObject( this, aEvEntryName ); 183*cdf0e10cSrcweir for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir try 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir com.sun.star.document.XEventListener xListener = ( com.sun.star.document.XEventListener ) 188*cdf0e10cSrcweir UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir if ( xListener != null ) 191*cdf0e10cSrcweir xListener.notifyEvent( aEventObject ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir catch( java.lang.Exception e ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir m_aListeners.remove( nInd ); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir // ------------------------------------------------------------- 202*cdf0e10cSrcweir protected void StateChangeNotification( boolean bBeforeChange, int nOldState, int nNewState ) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir if ( m_aListeners != null ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir com.sun.star.lang.EventObject aEventObject = new com.sun.star.lang.EventObject( this ); 207*cdf0e10cSrcweir for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir try 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir com.sun.star.embed.XStateChangeListener xListener = ( com.sun.star.embed.XStateChangeListener ) 212*cdf0e10cSrcweir UnoRuntime.queryInterface( com.sun.star.embed.XStateChangeListener.class, m_aListeners.get( nInd ) ); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir if ( xListener != null ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir if ( bBeforeChange ) 217*cdf0e10cSrcweir xListener.changingState( aEventObject, nOldState, nNewState ); 218*cdf0e10cSrcweir else 219*cdf0e10cSrcweir xListener.stateChanged( aEventObject, nOldState, nNewState ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir catch( java.lang.Exception e ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir m_aListeners.remove( nInd ); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // ------------------------------------------------------------- 231*cdf0e10cSrcweir protected String ReadStringFromStream( XStorage xStorage, String aStreamName ) throws com.sun.star.io.IOException 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if ( xStorage == null ) 234*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir try 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir XStream xStream = xStorage.openStreamElement( aStreamName, com.sun.star.embed.ElementModes.READWRITE ); 239*cdf0e10cSrcweir XComponent xStreamComp = ( XComponent ) UnoRuntime.queryInterface( XComponent.class, xStream ); 240*cdf0e10cSrcweir if ( xStreamComp == null ) 241*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir XInputStream xInStream = xStream.getInputStream(); 244*cdf0e10cSrcweir byte[][] aData = new byte[1][]; 245*cdf0e10cSrcweir aData[0] = new byte[0]; 246*cdf0e10cSrcweir String aResult = new String(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir int nLen = 0; 249*cdf0e10cSrcweir do 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir nLen = xInStream.readBytes( aData, 10 ); 252*cdf0e10cSrcweir if ( aData.length == 0 || aData[0] == null ) 253*cdf0e10cSrcweir throw new com.sun.star.io.IOException(); 254*cdf0e10cSrcweir aResult += new String( aData[0] ); 255*cdf0e10cSrcweir } while( nLen > 0 ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir xStreamComp.dispose(); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir return aResult; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir catch( com.sun.star.uno.RuntimeException e ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir throw e; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir catch( com.sun.star.io.IOException e ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir throw e; 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir catch( com.sun.star.uno.Exception e ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir throw new com.sun.star.io.IOException( "Error while reading one of object streams!" ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir // ------------------------------------------------------------- 276*cdf0e10cSrcweir protected void ReadSizeFromOwnStorage() throws com.sun.star.io.IOException 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir String aSize = ReadStringFromStream( m_xOwnStorage, "properties.txt" ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir int nSeparator = aSize.indexOf( '|' ); 281*cdf0e10cSrcweir if ( nSeparator > 0 && nSeparator < aSize.length() - 1 ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir int nWidth = Integer.parseInt( aSize.substring( 0, nSeparator ) ); 284*cdf0e10cSrcweir int nHeight = Integer.parseInt( aSize.substring( nSeparator + 1, aSize.length() ) ); 285*cdf0e10cSrcweir m_aObjSize = new Dimension( nWidth, nHeight ); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir // ------------------------------------------------------------- 290*cdf0e10cSrcweir public OwnEmbeddedObject( XComponentContext context, byte[] aClassID ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir m_xContext = context; 293*cdf0e10cSrcweir m_aClassID = aClassID; 294*cdf0e10cSrcweir }; 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir // ------------------------------------------------------------- 297*cdf0e10cSrcweir public void CloseFrameRequest() 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir com.sun.star.embed.XEmbeddedClient xClient = m_xClient; 300*cdf0e10cSrcweir if ( xClient == null ) 301*cdf0e10cSrcweir return; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir UpdateSizeAndGetFromActive(); 304*cdf0e10cSrcweir StateChangeNotification( true, com.sun.star.embed.EmbedStates.ACTIVE, com.sun.star.embed.EmbedStates.RUNNING ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir try{ 307*cdf0e10cSrcweir xClient.visibilityChanged( false ); 308*cdf0e10cSrcweir } catch( com.sun.star.uno.Exception e ){} 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir try{ 311*cdf0e10cSrcweir xClient.saveObject(); 312*cdf0e10cSrcweir } catch( com.sun.star.uno.Exception e ){} 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING; 315*cdf0e10cSrcweir StateChangeNotification( false, com.sun.star.embed.EmbedStates.ACTIVE, m_nObjectState ); 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir PostEvent( "OnVisAreaChanged" ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir // com.sun.star.embed.XCommonEmbedPersist: 321*cdf0e10cSrcweir // ------------------------------------------------------------- 322*cdf0e10cSrcweir public void storeOwn() throws com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir if ( m_bDisposed ) 325*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir if ( m_nObjectState == -1 || m_bWaitSaveCompleted ) 328*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // nothing to do, if the object is in loaded state 331*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 332*cdf0e10cSrcweir return; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if ( m_xOwnStorage == null ) 335*cdf0e10cSrcweir throw new com.sun.star.io.IOException(); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir PostEvent( "OnSave" ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir if ( m_aEditorFrame == null ) 340*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir SaveDataToStorage( m_xOwnStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir PostEvent( "OnSaveDone" ); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir // ------------------------------------------------------------- 348*cdf0e10cSrcweir public boolean isReadonly() throws com.sun.star.embed.WrongStateException 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir return false; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir // ------------------------------------------------------------- 354*cdf0e10cSrcweir public void reload(com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir // not implemented currently 357*cdf0e10cSrcweir return; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // com.sun.star.embed.XEmbedPersist: 361*cdf0e10cSrcweir // ------------------------------------------------------------- 362*cdf0e10cSrcweir public void setPersistentEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, int nEntryConnectionMode, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir if ( m_bDisposed ) 365*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir if ( xStorage == null || aEntryName.length() == 0 ) 368*cdf0e10cSrcweir throw new com.sun.star.lang.IllegalArgumentException(); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir if ( ( m_nObjectState != -1 || nEntryConnectionMode == com.sun.star.embed.EntryInitModes.NO_INIT ) 371*cdf0e10cSrcweir && ( m_nObjectState == -1 || nEntryConnectionMode != com.sun.star.embed.EntryInitModes.NO_INIT ) ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir // if the object is not loaded 374*cdf0e10cSrcweir // it can not get persistant representation without initialization 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir // if the object is loaded 377*cdf0e10cSrcweir // it can switch persistant representation only without initialization 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir if ( m_bWaitSaveCompleted ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.NO_INIT ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir if ( m_xParentStorage == xStorage && m_aEntryName.equals( aEntryName ) ) 387*cdf0e10cSrcweir saveCompleted( false ); 388*cdf0e10cSrcweir else if ( m_xNewParentStorage == xStorage && m_aNewEntryName.equals( aEntryName ) ) 389*cdf0e10cSrcweir saveCompleted( true ); 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir else 394*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir return; 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir boolean bElExists = xStorage.hasByName( aEntryName ); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.DEFAULT_INIT ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir SwitchOwnPersistence( xStorage, aEntryName ); 404*cdf0e10cSrcweir if ( bElExists ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_xOwnStorage ); 407*cdf0e10cSrcweir if ( xPropSet == null ) 408*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir String aMediaType = AnyConverter.toString( xPropSet.getPropertyValue( "MediaType" ) ); 411*cdf0e10cSrcweir if ( !aMediaType.equals( "application/x-openoffice-embedded-69474366-FD6F-4806-8374-8EDD1B6E771D" ) ) 412*cdf0e10cSrcweir throw new com.sun.star.lang.IllegalArgumentException(); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.LOADED; 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir else 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir m_aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 ); 419*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING; 420*cdf0e10cSrcweir m_aObjSize = m_aEditorFrame.getAppSize(); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir else if ( nEntryConnectionMode == com.sun.star.embed.EntryInitModes.TRUNCATE_INIT ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir SwitchOwnPersistence( xStorage, aEntryName ); 426*cdf0e10cSrcweir m_aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 ); 427*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING; 428*cdf0e10cSrcweir m_aObjSize = m_aEditorFrame.getAppSize(); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir else 431*cdf0e10cSrcweir throw new com.sun.star.lang.IllegalArgumentException(); 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // ------------------------------------------------------------- 435*cdf0e10cSrcweir public void storeToEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir if ( m_bDisposed ) 438*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir if ( m_nObjectState == -1 || m_bWaitSaveCompleted ) 441*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir m_xParentStorage.copyElementTo( m_aEntryName, xStorage, aEntryName ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir else 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir com.sun.star.embed.XStorage xSubStorage = 450*cdf0e10cSrcweir xStorage.openStorageElement( aEntryName, 451*cdf0e10cSrcweir com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.TRUNCATE ); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir String aContents = m_aEditorFrame.getText(); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir SaveDataToStorage( xSubStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() ); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir // ------------------------------------------------------------- 460*cdf0e10cSrcweir public void storeAsEntry(com.sun.star.embed.XStorage xStorage, String aEntryName, com.sun.star.beans.PropertyValue[] aMediaArgs, com.sun.star.beans.PropertyValue[] aObjectArgs) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.io.IOException, com.sun.star.uno.Exception 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir if ( m_bDisposed ) 463*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir if ( m_nObjectState == -1 || m_bWaitSaveCompleted ) 466*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir com.sun.star.embed.XStorage xSubStorage = null; 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir xSubStorage = 473*cdf0e10cSrcweir xStorage.openStorageElement( aEntryName, 474*cdf0e10cSrcweir com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.NOCREATE ); 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir m_xOwnStorage.copyToStorage( xSubStorage ); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir else 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir xSubStorage = 481*cdf0e10cSrcweir xStorage.openStorageElement( aEntryName, 482*cdf0e10cSrcweir com.sun.star.embed.ElementModes.READWRITE | com.sun.star.embed.ElementModes.TRUNCATE ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir SaveDataToStorage( xSubStorage, m_aEditorFrame.getText(), UpdateSizeAndGetFromActive() ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir m_bWaitSaveCompleted = true; 488*cdf0e10cSrcweir m_xNewOwnStorage = xSubStorage; 489*cdf0e10cSrcweir m_xNewParentStorage = xStorage; 490*cdf0e10cSrcweir m_aNewEntryName = aEntryName; 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir // ------------------------------------------------------------- 495*cdf0e10cSrcweir public void saveCompleted(boolean bUseNew) throws com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir if ( m_bDisposed ) 498*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 501*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir // it is allowed to call saveCompleted( false ) for nonstored objects 504*cdf0e10cSrcweir if ( !m_bWaitSaveCompleted && !bUseNew ) 505*cdf0e10cSrcweir return; 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir if ( !m_bWaitSaveCompleted ) 508*cdf0e10cSrcweir throw new com.sun.star.io.IOException(); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if ( bUseNew ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir SwitchOwnPersistence( m_xNewParentStorage, m_xNewOwnStorage, m_aNewEntryName ); 513*cdf0e10cSrcweir PostEvent( "OnSaveAsDone" ); 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir else 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir try 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir m_xNewOwnStorage.dispose(); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir catch( com.sun.star.uno.RuntimeException e ) 522*cdf0e10cSrcweir {} 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir m_xNewOwnStorage = null; 526*cdf0e10cSrcweir m_xNewParentStorage = null; 527*cdf0e10cSrcweir m_aNewEntryName = null; 528*cdf0e10cSrcweir m_bWaitSaveCompleted = false; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // ------------------------------------------------------------- 532*cdf0e10cSrcweir public boolean hasEntry() throws com.sun.star.embed.WrongStateException 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir if ( m_bDisposed ) 535*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir if ( m_bWaitSaveCompleted ) 538*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir if ( m_xOwnStorage != null ) 541*cdf0e10cSrcweir return true; 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir return false; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir // ------------------------------------------------------------- 547*cdf0e10cSrcweir public String getEntryName() throws com.sun.star.embed.WrongStateException 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir if ( m_bDisposed ) 550*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if ( m_nObjectState == -1 || m_bWaitSaveCompleted ) 553*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir return m_aEntryName; 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir // com.sun.star.embed.XVisualObject: 559*cdf0e10cSrcweir // ------------------------------------------------------------- 560*cdf0e10cSrcweir public void setVisualAreaSize(long nAspect, com.sun.star.awt.Size aSize) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir if ( m_bDisposed ) 563*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 566*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON ) 569*cdf0e10cSrcweir // the ICON aspect should be handled by the container 570*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 573*cdf0e10cSrcweir changeState( com.sun.star.embed.EmbedStates.RUNNING ); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir if ( m_aEditorFrame == null ) 576*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir m_aObjSize.setSize( aSize.Width, aSize.Height ); 579*cdf0e10cSrcweir m_aEditorFrame.setAppSize( m_aObjSize ); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir // ------------------------------------------------------------- 583*cdf0e10cSrcweir public com.sun.star.awt.Size getVisualAreaSize(long nAspect) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir if ( m_bDisposed ) 586*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 589*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON ) 592*cdf0e10cSrcweir // the ICON aspect should be handled by the container 593*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 596*cdf0e10cSrcweir changeState( com.sun.star.embed.EmbedStates.RUNNING ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir UpdateSizeAndGetFromActive(); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir return new com.sun.star.awt.Size( (int)m_aObjSize.getWidth(), (int)m_aObjSize.getHeight() ); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // ------------------------------------------------------------- 604*cdf0e10cSrcweir public VisualRepresentation getPreferredVisualRepresentation(long nAspect) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir if ( m_bDisposed ) 607*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 610*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON ) 613*cdf0e10cSrcweir // the ICON aspect should be handled by the container 614*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir if ( m_nObjectState == com.sun.star.embed.EmbedStates.LOADED ) 617*cdf0e10cSrcweir changeState( com.sun.star.embed.EmbedStates.RUNNING ); 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir byte[] aData = m_aEditorFrame.getReplacementImage(); 620*cdf0e10cSrcweir VisualRepresentation aVisRep = new VisualRepresentation(); 621*cdf0e10cSrcweir aVisRep.Data = aData; 622*cdf0e10cSrcweir aVisRep.Flavor = new com.sun.star.datatransfer.DataFlavor( "image/png", "png", new com.sun.star.uno.Type( byte[].class ) ); 623*cdf0e10cSrcweir return aVisRep; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir // ------------------------------------------------------------- 627*cdf0e10cSrcweir public int getMapUnit(long nAspect) throws com.sun.star.uno.Exception 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir if ( m_bDisposed ) 630*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 633*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir if ( nAspect == com.sun.star.embed.Aspects.MSOLE_ICON ) 636*cdf0e10cSrcweir // the ICON aspect should be handled by the container 637*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir return com.sun.star.embed.EmbedMapUnits.PIXEL; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir // com.sun.star.embed.XClassifiedObject: 643*cdf0e10cSrcweir // ------------------------------------------------------------- 644*cdf0e10cSrcweir public byte[] getClassID() 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir if ( m_bDisposed ) 647*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir return m_aClassID; 650*cdf0e10cSrcweir } 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir // ------------------------------------------------------------- 653*cdf0e10cSrcweir public String getClassName() 654*cdf0e10cSrcweir { 655*cdf0e10cSrcweir if ( m_bDisposed ) 656*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir return new String(); 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir // ------------------------------------------------------------- 662*cdf0e10cSrcweir public void setClassInfo(byte[] aClassID, String sClassName) throws com.sun.star.lang.NoSupportException 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir throw new com.sun.star.lang.NoSupportException(); 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir // com.sun.star.embed.XComponentSupplier: 668*cdf0e10cSrcweir // ------------------------------------------------------------- 669*cdf0e10cSrcweir public com.sun.star.util.XCloseable getComponent() 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir if ( m_bDisposed ) 672*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir // allows no access to the component, this simple example just has no 675*cdf0e10cSrcweir return null; 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir // com.sun.star.embed.XStateChangeBroadcaster: 679*cdf0e10cSrcweir // ------------------------------------------------------------- 680*cdf0e10cSrcweir public void addStateChangeListener(com.sun.star.embed.XStateChangeListener xListener) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir if ( m_bDisposed ) 683*cdf0e10cSrcweir return; 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir GetListeners().add( xListener ); 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir // ------------------------------------------------------------- 689*cdf0e10cSrcweir public void removeStateChangeListener(com.sun.star.embed.XStateChangeListener xListener) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir if ( m_bDisposed ) 692*cdf0e10cSrcweir return; 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir if ( m_aListeners != null ) 695*cdf0e10cSrcweir m_aListeners.remove( xListener ); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir // com.sun.star.document.XEventBroadcaster: 699*cdf0e10cSrcweir // ------------------------------------------------------------- 700*cdf0e10cSrcweir public void addEventListener(com.sun.star.document.XEventListener xListener) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir if ( m_bDisposed ) 703*cdf0e10cSrcweir return; 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir GetListeners().add( xListener ); 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir // ------------------------------------------------------------- 709*cdf0e10cSrcweir public void removeEventListener(com.sun.star.document.XEventListener xListener) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir if ( m_bDisposed ) 712*cdf0e10cSrcweir return; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir if ( m_aListeners != null ) 715*cdf0e10cSrcweir m_aListeners.remove( xListener ); 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir // com.sun.star.util.XCloseBroadcaster: 719*cdf0e10cSrcweir // ------------------------------------------------------------- 720*cdf0e10cSrcweir public void addCloseListener(com.sun.star.util.XCloseListener xListener) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir if ( m_bDisposed ) 723*cdf0e10cSrcweir return; 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir GetListeners().add( xListener ); 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir // ------------------------------------------------------------- 729*cdf0e10cSrcweir public void removeCloseListener(com.sun.star.util.XCloseListener xListener) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir if ( m_bDisposed ) 732*cdf0e10cSrcweir return; 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir if ( m_aListeners != null ) 735*cdf0e10cSrcweir m_aListeners.remove( xListener ); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir // com.sun.star.util.XCloseable: 739*cdf0e10cSrcweir // ------------------------------------------------------------- 740*cdf0e10cSrcweir public void close(boolean bDeliverOwnership) throws com.sun.star.util.CloseVetoException 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir if ( m_bDisposed ) 743*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir com.sun.star.lang.EventObject aEventObject = new com.sun.star.lang.EventObject( this ); 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir if ( m_aListeners != null ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ ) 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir try 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir com.sun.star.util.XCloseListener xListener = ( com.sun.star.util.XCloseListener ) 754*cdf0e10cSrcweir UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) ); 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir if ( xListener != null ) 757*cdf0e10cSrcweir xListener.queryClosing( aEventObject, bDeliverOwnership ); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir catch( com.sun.star.util.CloseVetoException e ) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir throw e; 762*cdf0e10cSrcweir } 763*cdf0e10cSrcweir catch( java.lang.Exception e ) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir m_aListeners.remove( nInd ); 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir m_bDisposed = true; 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir for ( int nInd = 0; nInd < m_aListeners.size(); nInd++ ) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir try 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir com.sun.star.util.XCloseListener xListener = ( com.sun.star.util.XCloseListener ) 776*cdf0e10cSrcweir UnoRuntime.queryInterface( com.sun.star.document.XEventListener.class, m_aListeners.get( nInd ) ); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir if ( xListener != null ) 779*cdf0e10cSrcweir xListener.notifyClosing( aEventObject ); 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir catch( java.lang.Exception e ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir m_aListeners.remove( nInd ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir m_aListeners.clear(); 788*cdf0e10cSrcweir } 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir m_bDisposed = true; 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir if ( m_aEditorFrame != null ) 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir m_aEditorFrame.dispose(); 795*cdf0e10cSrcweir m_aEditorFrame = null; 796*cdf0e10cSrcweir } 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir if ( m_xOwnStorage != null ) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir try { 801*cdf0e10cSrcweir m_xOwnStorage.dispose(); 802*cdf0e10cSrcweir } catch( java.lang.Exception e ) {} 803*cdf0e10cSrcweir m_xOwnStorage = null; 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir // com.sun.star.embed.XEmbeddedObject: 808*cdf0e10cSrcweir // ------------------------------------------------------------- 809*cdf0e10cSrcweir public void changeState(int nNewState) throws com.sun.star.embed.UnreachableStateException, com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir if ( m_bDisposed ) 812*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 815*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir int nOldState = m_nObjectState; 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir if ( nOldState == nNewState ) 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir if ( nOldState == com.sun.star.embed.EmbedStates.ACTIVE ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir if ( m_aEditorFrame == null ) 824*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 825*cdf0e10cSrcweir m_aEditorFrame.toFront(); 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir return; 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir if ( nNewState != com.sun.star.embed.EmbedStates.LOADED 832*cdf0e10cSrcweir && nNewState != com.sun.star.embed.EmbedStates.RUNNING 833*cdf0e10cSrcweir && nNewState != com.sun.star.embed.EmbedStates.ACTIVE ) 834*cdf0e10cSrcweir throw new com.sun.star.embed.UnreachableStateException(); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir StateChangeNotification( true, nOldState, nNewState ); 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir try 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir if ( nOldState == com.sun.star.embed.EmbedStates.LOADED ) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir // switch to the RUNNING state first 843*cdf0e10cSrcweir String aText = ReadStringFromStream( m_xOwnStorage, "content.txt" ); 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir EditorFrame aEditorFrame = new EditorFrame( m_aEntryName, this, 5, 20 ); 846*cdf0e10cSrcweir aEditorFrame.setText( aText ); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir ReadSizeFromOwnStorage(); 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir m_aEditorFrame = aEditorFrame; 851*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.RUNNING; 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir if ( nNewState == com.sun.star.embed.EmbedStates.ACTIVE ) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir if ( m_xClient == null ) 856*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir m_aEditorFrame.show(); 859*cdf0e10cSrcweir m_aEditorFrame.toFront(); 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir if ( m_aObjSize != null ) 862*cdf0e10cSrcweir aEditorFrame.setAppSize( m_aObjSize ); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir m_xClient.visibilityChanged( true ); 865*cdf0e10cSrcweir m_nObjectState = com.sun.star.embed.EmbedStates.ACTIVE; 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir else if ( nOldState == com.sun.star.embed.EmbedStates.RUNNING ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir if ( nNewState == com.sun.star.embed.EmbedStates.LOADED ) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir EditorFrame aFrame = m_aEditorFrame; 873*cdf0e10cSrcweir m_aEditorFrame = null; 874*cdf0e10cSrcweir aFrame.dispose(); 875*cdf0e10cSrcweir m_nObjectState = nNewState; 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir else // nNewState == ACTIVE 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir if ( m_aEditorFrame == null ) 880*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir if ( m_xClient == null ) 883*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir m_aEditorFrame.show(); 886*cdf0e10cSrcweir m_aEditorFrame.toFront(); 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir if ( m_aObjSize != null ) 889*cdf0e10cSrcweir m_aEditorFrame.setAppSize( m_aObjSize ); 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir m_xClient.visibilityChanged( true ); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir m_nObjectState = nNewState; 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir else // nOldState == ACTIVE 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir UpdateSizeAndGetFromActive(); 899*cdf0e10cSrcweir if ( nNewState == com.sun.star.embed.EmbedStates.RUNNING ) 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir m_aEditorFrame.hide(); 902*cdf0e10cSrcweir m_nObjectState = nNewState; 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir else // nNewState == LOADED 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir EditorFrame aFrame = m_aEditorFrame; 907*cdf0e10cSrcweir m_aEditorFrame = null; 908*cdf0e10cSrcweir aFrame.dispose(); 909*cdf0e10cSrcweir m_nObjectState = nNewState; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir catch( com.sun.star.uno.Exception e ) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir if ( nOldState != m_nObjectState ) 916*cdf0e10cSrcweir StateChangeNotification( false, nOldState, m_nObjectState ); 917*cdf0e10cSrcweir throw e; 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir StateChangeNotification( true, nOldState, nNewState ); 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir // ------------------------------------------------------------- 924*cdf0e10cSrcweir public int[] getReachableStates() throws com.sun.star.embed.NeedsRunningStateException, com.sun.star.embed.WrongStateException 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir if ( m_bDisposed ) 927*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 930*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir int[] pStates = new int[3]; 933*cdf0e10cSrcweir pStates[0] = com.sun.star.embed.EmbedStates.LOADED; 934*cdf0e10cSrcweir pStates[1] = com.sun.star.embed.EmbedStates.RUNNING; 935*cdf0e10cSrcweir pStates[2] = com.sun.star.embed.EmbedStates.ACTIVE; 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir return pStates; 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir // ------------------------------------------------------------- 941*cdf0e10cSrcweir public int getCurrentState() throws com.sun.star.embed.WrongStateException 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir if ( m_bDisposed ) 944*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 947*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir return m_nObjectState; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir // ------------------------------------------------------------- 953*cdf0e10cSrcweir public void doVerb(int nVerbID) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.embed.WrongStateException, com.sun.star.embed.UnreachableStateException, com.sun.star.uno.Exception 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir if ( m_bDisposed ) 956*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 959*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir if ( nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_PRIMARY 962*cdf0e10cSrcweir || nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_SHOW 963*cdf0e10cSrcweir || nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_OPEN ) 964*cdf0e10cSrcweir changeState( com.sun.star.embed.EmbedStates.ACTIVE ); 965*cdf0e10cSrcweir else if ( nVerbID == com.sun.star.embed.EmbedVerbs.MS_OLEVERB_HIDE ) 966*cdf0e10cSrcweir changeState( com.sun.star.embed.EmbedStates.RUNNING ); 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir // ------------------------------------------------------------- 970*cdf0e10cSrcweir public com.sun.star.embed.VerbDescriptor[] getSupportedVerbs() throws com.sun.star.embed.NeedsRunningStateException, com.sun.star.embed.WrongStateException 971*cdf0e10cSrcweir { 972*cdf0e10cSrcweir if ( m_bDisposed ) 973*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 976*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir if ( m_pOwnVerbs == null ) 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir try 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir XMultiComponentFactory xFactory = m_xContext.getServiceManager(); 983*cdf0e10cSrcweir Object obj = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", m_xContext ); 984*cdf0e10cSrcweir XMultiServiceFactory xConfProvider = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, obj ); 985*cdf0e10cSrcweir if ( xConfProvider == null ) 986*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir Object[] aArgs = new Object[1]; 989*cdf0e10cSrcweir aArgs[0] = "/org.openoffice.Office.Embedding/Objects"; 990*cdf0e10cSrcweir Object oSettings = xConfProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aArgs ); 991*cdf0e10cSrcweir XNameAccess xObjConfNA = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oSettings ); 992*cdf0e10cSrcweir if ( xObjConfNA == null ) 993*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 994*cdf0e10cSrcweir 995*cdf0e10cSrcweir Object oEmbObj = xObjConfNA.getByName( "69474366-FD6F-4806-8374-8EDD1B6E771D" ); 996*cdf0e10cSrcweir XNameAccess xEmbObjNA = (XNameAccess) UnoRuntime.queryInterface( XNameAccess.class, oEmbObj ); 997*cdf0e10cSrcweir if ( xEmbObjNA == null ) 998*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir String[] pVerbShortcuts = (String[]) AnyConverter.toArray( xEmbObjNA.getByName( "ObjectVerbs" ) ); 1001*cdf0e10cSrcweir if ( pVerbShortcuts != null && pVerbShortcuts.length != 0 ) 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir com.sun.star.embed.VerbDescriptor[] pVerbs = new com.sun.star.embed.VerbDescriptor[pVerbShortcuts.length]; 1004*cdf0e10cSrcweir aArgs[0] = "/org.openoffice.Office.Embedding/Verbs"; 1005*cdf0e10cSrcweir Object oVerbs = xConfProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", aArgs ); 1006*cdf0e10cSrcweir XNameAccess xVerbsConfNA = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, oVerbs ); 1007*cdf0e10cSrcweir if ( xVerbsConfNA == null ) 1008*cdf0e10cSrcweir throw new com.sun.star.uno.RuntimeException(); 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir for ( int nInd = 0; nInd < pVerbShortcuts.length; nInd++ ) 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir try 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir XNameAccess xVerbNA = (XNameAccess) UnoRuntime.queryInterface( 1015*cdf0e10cSrcweir XNameAccess.class, 1016*cdf0e10cSrcweir xVerbsConfNA.getByName( pVerbShortcuts[nInd] ) ); 1017*cdf0e10cSrcweir if ( xVerbNA != null ) 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir com.sun.star.embed.VerbDescriptor aVerb = new com.sun.star.embed.VerbDescriptor(); 1020*cdf0e10cSrcweir aVerb.VerbID = AnyConverter.toInt( xVerbNA.getByName( "VerbID" ) ); 1021*cdf0e10cSrcweir aVerb.VerbName = AnyConverter.toString( xVerbNA.getByName( "VerbUIName" ) ); 1022*cdf0e10cSrcweir aVerb.VerbFlags = AnyConverter.toInt( xVerbNA.getByName( "VerbFlags" ) ); 1023*cdf0e10cSrcweir aVerb.VerbAttributes = AnyConverter.toInt( xVerbNA.getByName( "VerbAttributes" ) ); 1024*cdf0e10cSrcweir pVerbs[nInd] = aVerb; 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir catch( java.lang.Exception e ) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir if ( pVerbs[nInd] == null ) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir // let the error be visible 1034*cdf0e10cSrcweir pVerbs[nInd] = new com.sun.star.embed.VerbDescriptor(); 1035*cdf0e10cSrcweir pVerbs[nInd].VerbID = com.sun.star.embed.EmbedVerbs.MS_OLEVERB_PRIMARY; 1036*cdf0e10cSrcweir pVerbs[nInd].VerbName = "ERROR!"; 1037*cdf0e10cSrcweir pVerbs[nInd].VerbFlags = 0; 1038*cdf0e10cSrcweir pVerbs[nInd].VerbAttributes = com.sun.star.embed.VerbAttributes.MS_VERBATTR_ONCONTAINERMENU; 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir } 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir m_pOwnVerbs = pVerbs; 1043*cdf0e10cSrcweir } 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir catch( com.sun.star.uno.Exception e ) 1046*cdf0e10cSrcweir {} 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir if ( m_pOwnVerbs != null ) 1050*cdf0e10cSrcweir return m_pOwnVerbs; 1051*cdf0e10cSrcweir 1052*cdf0e10cSrcweir return new com.sun.star.embed.VerbDescriptor[0]; 1053*cdf0e10cSrcweir } 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir // ------------------------------------------------------------- 1056*cdf0e10cSrcweir public void setClientSite(com.sun.star.embed.XEmbeddedClient xClient) throws com.sun.star.embed.WrongStateException 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir if ( m_bDisposed ) 1059*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 1062*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 1063*cdf0e10cSrcweir 1064*cdf0e10cSrcweir m_xClient = xClient; 1065*cdf0e10cSrcweir } 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir // ------------------------------------------------------------- 1068*cdf0e10cSrcweir public com.sun.star.embed.XEmbeddedClient getClientSite() throws com.sun.star.embed.WrongStateException 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir if ( m_bDisposed ) 1071*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1072*cdf0e10cSrcweir 1073*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 1074*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir return m_xClient; 1077*cdf0e10cSrcweir } 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir // ------------------------------------------------------------- 1080*cdf0e10cSrcweir public void update() throws com.sun.star.embed.WrongStateException, com.sun.star.uno.Exception 1081*cdf0e10cSrcweir { 1082*cdf0e10cSrcweir if ( m_bDisposed ) 1083*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 1086*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 1087*cdf0e10cSrcweir 1088*cdf0e10cSrcweir // not implemented 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir // ------------------------------------------------------------- 1092*cdf0e10cSrcweir public void setUpdateMode(int nMode) throws com.sun.star.embed.WrongStateException 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir if ( m_bDisposed ) 1095*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 1098*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir // not implemented 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir 1103*cdf0e10cSrcweir // ------------------------------------------------------------- 1104*cdf0e10cSrcweir public long getStatus(long nAspect) throws com.sun.star.embed.WrongStateException 1105*cdf0e10cSrcweir { 1106*cdf0e10cSrcweir if ( m_bDisposed ) 1107*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir if ( m_nObjectState == -1 ) 1110*cdf0e10cSrcweir throw new com.sun.star.embed.WrongStateException(); 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir return 0; 1113*cdf0e10cSrcweir } 1114*cdf0e10cSrcweir 1115*cdf0e10cSrcweir // ------------------------------------------------------------- 1116*cdf0e10cSrcweir public void setContainerName(String sName) 1117*cdf0e10cSrcweir { 1118*cdf0e10cSrcweir if ( m_bDisposed ) 1119*cdf0e10cSrcweir throw new com.sun.star.lang.DisposedException(); 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir // not implemented 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir 1125