documentation

This commit is contained in:
Michael Hönnig
2004-10-28 14:49:01 +00:00
parent c4d92b50a2
commit 28cfd1f82d
4 changed files with 394 additions and 272 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: LocalOfficeConnection.java,v $ * $RCSfile: LocalOfficeConnection.java,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: mi $ $Date: 2004-10-18 07:15:36 $ * last change: $Author: mi $ $Date: 2004-10-28 15:49:00 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -106,12 +106,13 @@ public class LocalOfficeConnection
public static final String OFFICE_LIB_NAME = "officebean"; public static final String OFFICE_LIB_NAME = "officebean";
public static final String OFFICE_ID_SUFFIX = "_Office"; public static final String OFFICE_ID_SUFFIX = "_Office";
private static String mProgramPath;
private Process mProcess; private Process mProcess;
private ContainerFactory mContainerFactory; private ContainerFactory mContainerFactory;
private XComponentContext mContext; private XComponentContext mContext;
private String mURL; private String mURL;
private String mProgramPath;
private String mConnType; private String mConnType;
private String mPipe; private String mPipe;
private String mPort; private String mPort;
@@ -120,6 +121,61 @@ public class LocalOfficeConnection
private List mComponents = new Vector(); private List mComponents = new Vector();
//-------------------------------------------------------------------------
static
{
// preload shared libraries whichs import lips are linked to officebean
if ( System.getProperty( "os.name" ).startsWith( "Windows" ) )
{
try
{
NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr70");
}
catch (Throwable e)
{
// loading twice would fail
System.err.println( "cannot find msvcr70" );
}
try
{
NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr71");
}
catch (Throwable e)
{
// loading twice would fail
System.err.println( "cannot find msvcr71" );
}
try
{
NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "uwinapi");
}
catch (Throwable e)
{
// loading twice would fail
System.err.println( "cannot find uwinapi" );
}
try
{
NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "jawt");
}
catch (Throwable e)
{
// loading twice would fail
System.err.println( "cannot find jawt" );
}
}
// load shared library for JNI code
// String aSharedLibName = getProgramPath() + java.io.File.separator +
// System.mapLibraryName(OFFICE_LIB_NAME);
// System.load( aSharedLibName );
NativeLibraryLoader.loadLibrary( LocalOfficeConnection.class.getClassLoader(), "officebean" );
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// debugging method // debugging method
private void dbgPrint( String aMessage ) private void dbgPrint( String aMessage )
@@ -144,11 +200,6 @@ public class LocalOfficeConnection
} }
catch ( java.net.MalformedURLException e ) catch ( java.net.MalformedURLException e )
{} {}
// load libofficebean.so/officebean.dll
String aSharedLibName = getProgramPath() + java.io.File.separator +
System.mapLibraryName(OFFICE_LIB_NAME);
System.load( aSharedLibName );
} }
/** /**
@@ -379,7 +430,7 @@ public class LocalOfficeConnection
* *
* @return The path to the office program folder. * @return The path to the office program folder.
*/ */
private String getProgramPath() static private String getProgramPath()
{ {
if (mProgramPath == null) if (mProgramPath == null)
{ {
@@ -396,7 +447,7 @@ public class LocalOfficeConnection
// find soffice executable relative to this class's class loader: // find soffice executable relative to this class's class loader:
File path = NativeLibraryLoader.getResource( File path = NativeLibraryLoader.getResource(
this.getClass().getClassLoader(), aExec); LocalOfficeConnection.class.getClassLoader(), aExec);
if (path != null) if (path != null)
mProgramPath = path.getParent(); mProgramPath = path.getParent();

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: OOoBean.java,v $ * $RCSfile: OOoBean.java,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: mi $ $Date: 2004-10-14 10:37:13 $ * last change: $Author: mi $ $Date: 2004-10-28 15:49:00 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -176,21 +176,30 @@ public class OOoBean
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/// Sets the timeout for methods which launch OOo in milli seconds. /** Sets the timeout for methods which launch OOo in milli seconds.
This method does not need a connection to an OOo instance.
*/
public void setOOoStartTimeOut( int nMilliSecs ) public void setOOoStartTimeOut( int nMilliSecs )
{ {
nOOoStartTimeOut = nMilliSecs; nOOoStartTimeOut = nMilliSecs;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/// Sets the timeout for normal OOO methods calls in milli seconds. /** Sets the timeout for normal OOO methods calls in milli seconds.
This method does not need a connection to an OOo instance.
*/
public void setOOoCallTimeOut( int nMilliSecs ) public void setOOoCallTimeOut( int nMilliSecs )
{ {
nOOoCallTimeOut = nMilliSecs; nOOoCallTimeOut = nMilliSecs;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/// Sets the period length in milli seconds to check the OOo connection. /** Sets the period length in milli seconds to check the OOo connection.
This method does not need a connection to an OOo instance.
*/
public void setOOoCheckCycle( int nMilliSecs ) public void setOOoCheckCycle( int nMilliSecs )
{ {
nOOoCheckCycle = nMilliSecs; nOOoCheckCycle = nMilliSecs;
@@ -228,6 +237,12 @@ public class OOoBean
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// @requirement FUNC.CON.STRT/0.4 // @requirement FUNC.CON.STRT/0.4
/** Starts a connection to an OOo instance which is lauched if not running. /** Starts a connection to an OOo instance which is lauched if not running.
@throws HasConnectionException
if a connection was already established.
@throws NoConnectionException
if the specified connection cannot be established
*/ */
public void startOOoConnection( String aConnectionURL ) public void startOOoConnection( String aConnectionURL )
throws java.net.MalformedURLException, throws java.net.MalformedURLException,
@@ -247,20 +262,20 @@ public class OOoBean
*/ */
public boolean isOOoConnected() public boolean isOOoConnected()
{ {
// TBD: could there be an existing, but dead connection?
return iConnection != null; return iConnection != null;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// @requirement FUNC.CON.STOP/0.4 // @requirement FUNC.CON.STOP/0.4
/** Disconnects from the connected OOo instance. /** Disconnects from the connected OOo instance.
If there was no connection yet or anymore, this method can be called
anyway.
*/ */
public synchronized void stopOOoConnection() public synchronized void stopOOoConnection()
{ {
// clear OOo document, frame etc. // clear OOo document, frame etc.
try { clear(); } clear();
catch ( java.lang.InterruptedException aExc )
{} // ignore exceptions from an old, dead connection
// cut the connection // cut the connection
OfficeConnection iExConnection = iConnection; OfficeConnection iExConnection = iConnection;
@@ -282,6 +297,9 @@ public class OOoBean
/** Returns the a connection to an OOo instance. /** Returns the a connection to an OOo instance.
If no connection exists, a default connection will be created. If no connection exists, a default connection will be created.
@throws NoConnectionException
if no connection can be established
*/ */
public synchronized OfficeConnection getOOoConnection() public synchronized OfficeConnection getOOoConnection()
throws NoConnectionException throws NoConnectionException
@@ -299,6 +317,11 @@ public class OOoBean
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** Returns the service factory used by this OOoBean instance.
@throws NoConnectionException
if no connection is established and no default connection can be established.
*/
public synchronized com.sun.star.lang.XMultiServiceFactory getMultiServiceFactory() public synchronized com.sun.star.lang.XMultiServiceFactory getMultiServiceFactory()
throws NoConnectionException throws NoConnectionException
{ {
@@ -329,7 +352,11 @@ public class OOoBean
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/// TBD /** Returns the XDesktop interface of the OOo instance used by this OOoBean.
@throws NoConnectionException
if no connection is established and no default connection can be established.
*/
public synchronized com.sun.star.frame.XDesktop getOOoDesktop() public synchronized com.sun.star.frame.XDesktop getOOoDesktop()
throws NoConnectionException throws NoConnectionException
{ {
@@ -356,14 +383,16 @@ public class OOoBean
If a document is loaded and the content modified, If a document is loaded and the content modified,
the changes are dismissed. Otherwise nothing happens. the changes are dismissed. Otherwise nothing happens.
This method works with and without a connection. This method only does only work on specific subclasses.
@param bClearStateToo @param bClearStateToo
Not only the document content but also the state of the bean, Not only the document content but also the state of the bean,
like visibility of child components is cleared. like visibility of child components is cleared.
*/ */
public synchronized void clearDocument( boolean bClearStateToo ) public synchronized void clearDocument( boolean bClearStateToo )
throws com.sun.star.util.CloseVetoException throws
com.sun.star.util.CloseVetoException,
NoConnectionException
{ {
// TBD // TBD
com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable) com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.XCloseable)
@@ -380,50 +409,56 @@ public class OOoBean
Any loaded document is unloaded, no matter whether it is modified or not. Any loaded document is unloaded, no matter whether it is modified or not.
After calling this method, the OOoBean has no office document and no frame After calling this method, the OOoBean has no office document and no frame
anymore. The connection will stay, though. anymore. The connection will stay, though.
This method works with or without an established connection.
*/ */
public synchronized void clear() public synchronized void clear()
throws java.lang.InterruptedException
{ {
dbgPrint( "clear()" ); dbgPrint( "clear()" );
CallWatchThread aCallWatchThread = try
new CallWatchThread( nOOoCallTimeOut, "clear" );
aDocument = null;
xDispatcher = null;
aFrame = null;
// clear xFrameWindow
if ( xFrameWindow != null )
{ {
try { releaseSystemWindow(); } CallWatchThread aCallWatchThread =
catch ( NoConnectionException aExc ) new CallWatchThread( nOOoCallTimeOut, "clear" );
{} // ignore aDocument = null;
catch ( SystemWindowException aExc ) xDispatcher = null;
{} // ignore aFrame = null;
remove( xFrameWindow.getAWTComponent() );
xFrameWindow = null;
}
// clear xURTTransformer // clear xFrameWindow
if ( xURLTransformer != null ) if ( xFrameWindow != null )
{
try
{ {
com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent) try { releaseSystemWindow(); }
UnoRuntime.queryInterface( catch ( NoConnectionException aExc )
com.sun.star.lang.XComponent.class, xURLTransformer ); {} // ignore
if ( xComp != null ) catch ( SystemWindowException aExc )
xComp.dispose(); {} // ignore
remove( xFrameWindow.getAWTComponent() );
xFrameWindow = null;
} }
catch ( java.lang.Throwable aExc )
{} // ignore // clear xURTTransformer
xURLTransformer = null; if ( xURLTransformer != null )
{
try
{
com.sun.star.lang.XComponent xComp = (com.sun.star.lang.XComponent)
UnoRuntime.queryInterface(
com.sun.star.lang.XComponent.class, xURLTransformer );
if ( xComp != null )
xComp.dispose();
}
catch ( java.lang.Throwable aExc )
{} // ignore
xURLTransformer = null;
}
xDesktop = null;
xServiceFactory = null;
aCallWatchThread.cancel();
} }
catch ( java.lang.InterruptedException aExc )
xDesktop = null; { /* can be ignored */ }
xServiceFactory = null;
aCallWatchThread.cancel();
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -502,168 +537,172 @@ public class OOoBean
If no connection exists, a default connection is established. If no connection exists, a default connection is established.
@throws java.io.IOException
if an IO error occurs reading the ressource specified by the URL.
@throws IllegalArgumentException @throws IllegalArgumentException
if either of the arguments is out of the specified range. if either of the arguments is out of the specified range.
@throws NoConnectionException @throws java.io.IOException
if an IO error occurs reading the ressource specified by the URL.
@throws com.sun.star.lang.NoConnectionException
if no connection can be established. if no connection can be established.
*/ */
public void loadFromURL( public void loadFromURL(
final String aURL, final String aURL,
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException
{ {
dbgPrint( "loadFromURL()" ); dbgPrint( "loadFromURL()" );
// try loading // try loading
boolean bLoaded = false; try
while ( !bLoaded )
{ {
// watch loading in a thread with a timeout (if OOo hangs) boolean bLoaded = false;
CallWatchThread aCallWatchThread = while ( !bLoaded )
new CallWatchThread( nOOoStartTimeOut, "loadFromURL" );
try
{ {
// get window from OOo on demand // watch loading in a thread with a timeout (if OOo hangs)
if ( xFrameWindow == null ) CallWatchThread aCallWatchThread =
new CallWatchThread( nOOoStartTimeOut, "loadFromURL" );
try
{ {
// Establish the connection by request of the ServiceFactory. // get window from OOo on demand
getMultiServiceFactory(); if ( xFrameWindow == null )
// remove existing child windows
removeAll();
// Create the OfficeWindow.
xFrameWindow = getOOoConnection().createOfficeWindow(OOoBean.this);
add( xFrameWindow.getAWTComponent() );
}
// create the document frame from UNO window.
if ( aFrame == null )
{
// create the frame
com.sun.star.awt.XWindow xWindow =
(com.sun.star.awt.XWindow) UnoRuntime.queryInterface(
com.sun.star.awt.XWindow.class, xFrameWindow.getUNOWindowPeer());
Object xFrame = xServiceFactory.createInstance( "com.sun.star.frame.Frame");
aFrame = new Frame( (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
com.sun.star.frame.XFrame.class, xFrame ) );
aFrame.initialize( xWindow );
aFrame.setName( aFrame.toString() );
// register the frame at the desktop
com.sun.star.frame.XFrames xFrames =
( (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface(
com.sun.star.frame.XFramesSupplier.class, getOOoDesktop() ) ).getFrames();
xFrames.append( aFrame );
}
// Initializes the slot command execution environment.
xURLTransformer = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
com.sun.star.util.XURLTransformer.class,
xServiceFactory.createInstance( "com.sun.star.util.URLTransformer") );
xDispatcher = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface(
com.sun.star.frame.XDispatchProvider.class, aFrame );
// get XComponentLoader from frame
com.sun.star.frame.XComponentLoader xLoader = (com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, aFrame );
if ( xLoader == null )
{
throw new java.lang.RuntimeException(
"com.sun.star.frame.Frame(" + aFrame +
") without com.sun.star.frame.XComponentLoader" );
}
// Avoid Dialog 'Document changed' while reloading
if ( aDocument != null )
{
com.sun.star.frame.XController xOldController = null;
if ( aFrame != null && aFrame.getController() != null )
xOldController = aFrame.getController();
try
{ {
if ( aFrame != null && xOldController != null ) // Establish the connection by request of the ServiceFactory.
xOldController.suspend(true); getMultiServiceFactory();
if ( aDocument != null )
try { // remove existing child windows
// can be disposed if user closed document via UI removeAll();
aDocument.setModified(false);
} // Create the OfficeWindow.
catch ( com.sun.star.lang.DisposedException aExc ) {} xFrameWindow = getOOoConnection().createOfficeWindow(OOoBean.this);
add( xFrameWindow.getAWTComponent() );
} }
catch (java.lang.IllegalStateException exp)
{} // create the document frame from UNO window.
if ( aFrame == null )
{
// create the frame
com.sun.star.awt.XWindow xWindow =
(com.sun.star.awt.XWindow) UnoRuntime.queryInterface(
com.sun.star.awt.XWindow.class, xFrameWindow.getUNOWindowPeer());
Object xFrame = xServiceFactory.createInstance( "com.sun.star.frame.Frame");
aFrame = new Frame( (com.sun.star.frame.XFrame)UnoRuntime.queryInterface(
com.sun.star.frame.XFrame.class, xFrame ) );
aFrame.initialize( xWindow );
aFrame.setName( aFrame.toString() );
// register the frame at the desktop
com.sun.star.frame.XFrames xFrames =
( (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface(
com.sun.star.frame.XFramesSupplier.class, getOOoDesktop() ) ).getFrames();
xFrames.append( aFrame );
}
// Initializes the slot command execution environment.
xURLTransformer = (com.sun.star.util.XURLTransformer) UnoRuntime.queryInterface(
com.sun.star.util.XURLTransformer.class,
xServiceFactory.createInstance( "com.sun.star.util.URLTransformer") );
xDispatcher = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface(
com.sun.star.frame.XDispatchProvider.class, aFrame );
// get XComponentLoader from frame
com.sun.star.frame.XComponentLoader xLoader = (com.sun.star.frame.XComponentLoader)
UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, aFrame );
if ( xLoader == null )
{
throw new java.lang.RuntimeException(
"com.sun.star.frame.Frame(" + aFrame +
") without com.sun.star.frame.XComponentLoader" );
}
// Avoid Dialog 'Document changed' while reloading
if ( aDocument != null )
{
com.sun.star.frame.XController xOldController = null;
if ( aFrame != null && aFrame.getController() != null )
xOldController = aFrame.getController();
try
{
if ( aFrame != null && xOldController != null )
xOldController.suspend(true);
if ( aDocument != null )
try {
// can be disposed if user closed document via UI
aDocument.setModified(false);
}
catch ( com.sun.star.lang.DisposedException aExc ) {}
}
catch (java.lang.IllegalStateException exp)
{}
}
// load the document.
com.sun.star.beans.PropertyValue aArgs[] =
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
"MacroExecutionMode", -1,
new Short( com.sun.star.document.MacroExecMode.USE_CONFIG ),
com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
//String fn = aFRame.getName();
com.sun.star.lang.XComponent xComponent = xLoader.loadComponentFromURL(
aURL, /*aFrame.getName()*/"_self", com.sun.star.frame.FrameSearchFlag.ALL, aArgs );
// nothing loaded?
if ( xComponent == null && aDocument != null )
{
// reactivate old document
if ( aFrame != null && aFrame.getController() != null )
aFrame.getController().suspend(false);
aDocument.setModified(true);
// throw exception
throw new java.io.IOException(
"Can not load a document: \"" + aURL + "\"");
}
// mDocumentURL = aURL; TBD: still needed?
// Get document's XModifiable interface if any.
aDocument = new OfficeDocument(
(com.sun.star.frame.XModel) UnoRuntime.queryInterface(
com.sun.star.frame.XModel.class, xComponent ) );
bLoaded = true;
} }
catch ( NoConnectionException aExc )
// load the document.
com.sun.star.beans.PropertyValue aArgs[] =
addArgument( aArguments, new com.sun.star.beans.PropertyValue(
"MacroExecutionMode", -1,
new Short( com.sun.star.document.MacroExecMode.USE_CONFIG ),
com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
//String fn = aFRame.getName();
com.sun.star.lang.XComponent xComponent = xLoader.loadComponentFromURL(
aURL, /*aFrame.getName()*/"_self", com.sun.star.frame.FrameSearchFlag.ALL, aArgs );
// nothing loaded?
if ( xComponent == null && aDocument != null )
{ {
// reactivate old document // stop, clear and retry
if ( aFrame != null && aFrame.getController() != null ) stopOOoConnection();
aFrame.getController().suspend(false); }
aDocument.setModified(true); catch ( com.sun.star.lang.DisposedException aExc )
{
// throw exception // stop, clear and retry
throw new java.io.IOException( stopOOoConnection();
"Can not load a document: \"" + aURL + "\""); }
catch ( com.sun.star.uno.Exception aExc )
{
// TDB: handling failure in createInstance
aExc.printStackTrace();
throw new java.io.IOException();
} }
// mDocumentURL = aURL; TBD: still needed?
// Get document's XModifiable interface if any. aCallWatchThread.cancel();
aDocument = new OfficeDocument( if ( xServiceFactory == null )
(com.sun.star.frame.XModel) UnoRuntime.queryInterface( throw new NoConnectionException();
com.sun.star.frame.XModel.class, xComponent ) );
bLoaded = true;
} }
catch ( NoConnectionException aExc ) if ( iConnection == null )
{ {
// stop, clear and retry
stopOOoConnection();
}
catch ( com.sun.star.lang.DisposedException aExc )
{
// stop, clear and retry
stopOOoConnection();
}
catch ( com.sun.star.uno.Exception aExc )
{
// TDB: handling failure in createInstance
aExc.printStackTrace();
throw new java.io.IOException();
}
aCallWatchThread.cancel();
if ( xServiceFactory == null )
throw new NoConnectionException(); throw new NoConnectionException();
} }
if ( iConnection == null ) applyToolVisibilities();
}
catch ( java.lang.InterruptedException aExc )
{ {
throw new NoConnectionException(); throw new NoConnectionException();
} }
applyToolVisibilities();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -675,13 +714,10 @@ public class OOoBean
final java.io.InputStream iInStream, final java.io.InputStream iInStream,
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException
{ {
// wrap Java stream into UNO stream // wrap Java stream into UNO stream
/* /*
@@ -717,7 +753,7 @@ public class OOoBean
"InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) ); "InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
// call normal load method // call normal load method
loadFromURL( "private:stream/", aExtendedArguments ); loadFromURL( "private:stream", aExtendedArguments );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -729,13 +765,10 @@ public class OOoBean
final byte aInBuffer[], final byte aInBuffer[],
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException
{ {
// wrap byte arrray into UNO stream // wrap byte arrray into UNO stream
com.sun.star.io.XInputStream xStream = com.sun.star.io.XInputStream xStream =
@@ -748,36 +781,54 @@ public class OOoBean
"InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) ); "InputStream", -1, xStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
// call normal load method // call normal load method
loadFromURL( "private:stream/", aExtendedArguments ); loadFromURL( "private:stream", aExtendedArguments );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
/** Stores a document to a URL. /** Stores a document to the given URL.
*
* TBD @throws IllegalArgumentException
if either of the arguments is out of the specified range.
@throws java.io.IOException
if an IO error occurs reading the ressource specified by the URL.
@throws com.sun.star.lang.NoConnectionException
if no connection is established.
@throws NoDocumentException
if no document is loaded
*/ */
public void storeToURL( public void storeToURL(
final String aURL, final String aURL,
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException,
NoDocumentException
{ {
// start runtime timeout // no document available?
CallWatchThread aCallWatchThread = if ( aDocument == null )
new CallWatchThread( nOOoCallTimeOut, "storeToURL" ); throw new NoDocumentException();
// store the document try
try { aDocument.storeToURL( aURL, aArguments ); } {
catch ( com.sun.star.io.IOException aExc ) // start runtime timeout
{ throw new java.io.IOException(); } CallWatchThread aCallWatchThread =
new CallWatchThread( nOOoCallTimeOut, "storeToURL" );
// end runtime timeout // store the document
aCallWatchThread.cancel(); try { aDocument.storeToURL( aURL, aArguments ); }
catch ( com.sun.star.io.IOException aExc )
{ throw new java.io.IOException(); }
// end runtime timeout
aCallWatchThread.cancel();
}
catch ( java.lang.InterruptedException aExc )
{ throw new NoConnectionException(); }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -789,12 +840,11 @@ public class OOoBean
java.io.OutputStream aOutStream, java.io.OutputStream aOutStream,
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
NoDocumentException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException
{ {
// wrap Java stream into UNO stream // wrap Java stream into UNO stream
@@ -808,7 +858,7 @@ public class OOoBean
"OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) ); "OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
// call normal store method // call normal store method
storeToURL( "private:stream/", aExtendedArguments ); storeToURL( "private:stream", aExtendedArguments );
// get byte array from document stream // get byte array from document stream
try { aStream.closeOutput(); } try { aStream.closeOutput(); }
@@ -830,13 +880,11 @@ public class OOoBean
byte aOutBuffer[], byte aOutBuffer[],
final com.sun.star.beans.PropertyValue aArguments[] ) final com.sun.star.beans.PropertyValue aArguments[] )
throws throws
java.io.IOException,
java.lang.InterruptedException,
com.sun.star.lang.IllegalArgumentException,
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
NoConnectionException NoConnectionException,
NoDocumentException,
java.io.IOException,
com.sun.star.lang.IllegalArgumentException
{ {
// wrap byte arrray into UNO stream // wrap byte arrray into UNO stream
com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter aStream = com.sun.star.lib.uno.adapter.XOutputStreamToByteArrayAdapter aStream =
@@ -849,7 +897,7 @@ public class OOoBean
"OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) ); "OutputStream", -1, aStream, com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
// call normal store method // call normal store method
storeToURL( "private:stream/", aExtendedArguments ); storeToURL( "private:stream", aExtendedArguments );
// get byte array from document stream // get byte array from document stream
try { aStream.closeOutput(); } try { aStream.closeOutput(); }
@@ -877,11 +925,14 @@ public class OOoBean
@throws NoConnectionException @throws NoConnectionException
if the connection is not established. if the connection is not established.
@throws NotDocumentException
if no document is loaded an thus no frame is available.
*/ */
public Frame getFrame() public Frame getFrame()
// @requirement FUNC.CON.LOST/0.2 throws
throws NoConnectionException NoConnectionException // @requirement FUNC.CON.LOST/0.2
{ {
if ( iConnection == null ) if ( iConnection == null )
throw new NoConnectionException(); throw new NoConnectionException();
@@ -891,8 +942,8 @@ public class OOoBean
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// @requirement FUNC.BEAN.PROG/0.5 // @requirement FUNC.BEAN.PROG/0.5
// @requirement API.SIM.SEAP/0.2 // @requirement API.SIM.SEAP/0.2
// @estimation 1h // @estimation 1h
/** returns the <type scope="com::sun::star::frame::Controller"> of the bean. /** returns the <type scope="com::sun::star::frame::Controller"> of the bean.
@returns @returns
a Java class which implements all interfaces which the service a Java class which implements all interfaces which the service
@@ -902,17 +953,11 @@ public class OOoBean
@throws NoConnectionException @throws NoConnectionException
if the connection is not established. if the connection is not established.
@throws NotDocumentLoadedException
if no document is loaded an thus no controller is available.
*/ */
public Controller getController() public Controller getController()
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
throws NoConnectionException, throws NoConnectionException
// @requirement API.NODC
NoDocumentException
{ {
if ( iConnection == null ) if ( iConnection == null )
throw new NoConnectionException(); throw new NoConnectionException();
@@ -939,17 +984,11 @@ public class OOoBean
@throws NoConnectionException @throws NoConnectionException
if the connection is not established. if the connection is not established.
@throws NotDocumentLoadedException
if no document is loaded.
*/ */
public OfficeDocument getDocument() public OfficeDocument getDocument()
// @requirement FUNC.CON.LOST/0.2 // @requirement FUNC.CON.LOST/0.2
throws NoConnectionException, throws NoConnectionException
// @requirement API.NODC
NoDocumentException // TBD
{ {
if ( iConnection == null ) if ( iConnection == null )
throw new NoConnectionException(); throw new NoConnectionException();
@@ -966,10 +1005,12 @@ public class OOoBean
If an older OOoBean instance is used with a newer OOo instance, If an older OOoBean instance is used with a newer OOo instance,
some tool bars might not be affected by this method. some tool bars might not be affected by this method.
If no connection is established or no document is loaded,
the setting is memorized until a document is loaded. Same
is valid when the connection dies within this function call.
*/ */
public void setAllBarsVisible( boolean bVisible ) public void setAllBarsVisible( boolean bVisible )
throws
java.lang.InterruptedException
{ {
bIgnoreVisibility = true; bIgnoreVisibility = true;
setMenuBarVisible( bVisible ); setMenuBarVisible( bVisible );
@@ -1057,23 +1098,29 @@ public class OOoBean
If not connected or no document loaded, the value is stored If not connected or no document loaded, the value is stored
and automatically applied to the document after it is loaded. and automatically applied to the document after it is loaded.
Same is valid when the connection dies within this function call.
@param bVisible @param bVisible
If false, the menu bar is disabled, If false, the menu bar is disabled,
If true, the menu bar is visible. If true, the menu bar is visible.
*/ */
public void setMenuBarVisible(boolean bVisible) public void setMenuBarVisible(boolean bVisible)
throws
java.lang.InterruptedException
{ {
bMenuBarVisible = setToolVisible( "MenuBarVisible", "private:resource/menubar/menubar", try
SID_TOGGLEMENUBAR, "MenuBarVisible", bMenuBarVisible, bVisible ); {
bMenuBarVisible = setToolVisible( "MenuBarVisible", "private:resource/menubar/menubar",
SID_TOGGLEMENUBAR, "MenuBarVisible", bMenuBarVisible, bVisible );
}
catch ( java.lang.InterruptedException aExc )
{ bMenuBarVisible = bVisible; }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/* Returns the visibility of the menu bar. /* Returns the visibility of the menu bar.
This method works independently from a connetion or loaded document. This method works independently from a connetion or loaded document.
If no connection is established or no document is loaded,
this method just returns a memorized status.
@return @return
True if the menu bar is visible, True if the menu bar is visible,
@@ -1091,23 +1138,29 @@ public class OOoBean
If not connected or no document loaded, the value is stored If not connected or no document loaded, the value is stored
and automatically applied to the document after it is loaded. and automatically applied to the document after it is loaded.
Same is valid when the connection dies within this function call.
@param bVisible @param bVisible
If false, the main function bar is disabled, If false, the main function bar is disabled,
If true, the main function bar is visible. If true, the main function bar is visible.
*/ */
public void setStandardBarVisible(boolean bVisible) public void setStandardBarVisible(boolean bVisible)
throws
java.lang.InterruptedException
{ {
bStandardBarVisible = setToolVisible( "StandardBarVisible", "private:resource/toolbar/standardbar", try
SID_TOGGLEMAINBAR, "FunctionBarVisible", bStandardBarVisible, bVisible ); {
bStandardBarVisible = setToolVisible( "StandardBarVisible", "private:resource/toolbar/standardbar",
SID_TOGGLEMAINBAR, "FunctionBarVisible", bStandardBarVisible, bVisible );
}
catch ( java.lang.InterruptedException aExc )
{ bMenuBarVisible = bVisible; }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/* Returns the visibility of the main function bar. /* Returns the visibility of the main function bar.
This method works independently from a connetion or loaded document. This method works independently from a connetion or loaded document.
If no connection is established or no document is loaded,
this method just returns a memorized status.
@return @return
True if the main function bar is visible, True if the main function bar is visible,
@@ -1125,23 +1178,29 @@ public class OOoBean
If not connected or no document loaded, the value is stored If not connected or no document loaded, the value is stored
and automatically applied to the document after it is loaded. and automatically applied to the document after it is loaded.
Same is valid when the connection dies within this function call.
@param bVisible @param bVisible
If false, the tool function bar is disabled, If false, the tool function bar is disabled,
If true, the tool function bar is visible. If true, the tool function bar is visible.
*/ */
public void setToolBarVisible(boolean bVisible) public void setToolBarVisible(boolean bVisible)
throws
java.lang.InterruptedException
{ {
bToolBarVisible = setToolVisible( "ToolBarVisible", "private:resource/toolbar/toolbar", try
SID_TOGGLETOOLBAR, "ToolBarVisible", bToolBarVisible, bVisible ); {
bToolBarVisible = setToolVisible( "ToolBarVisible", "private:resource/toolbar/toolbar",
SID_TOGGLETOOLBAR, "ToolBarVisible", bToolBarVisible, bVisible );
}
catch ( java.lang.InterruptedException aExc )
{ bMenuBarVisible = bVisible; }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/* Returns the visibility of the tool function bar. /* Returns the visibility of the tool function bar.
This method works independently from a connetion or loaded document. This method works independently from a connetion or loaded document.
If no connection is established or no document is loaded,
this method just returns a memorized status.
@return @return
True if the tool function bar is visible, True if the tool function bar is visible,
@@ -1159,23 +1218,29 @@ public class OOoBean
If not connected or no document loaded, the value is stored If not connected or no document loaded, the value is stored
and automatically applied to the document after it is loaded. and automatically applied to the document after it is loaded.
Same is valid when the connection dies within this function call.
@param bVisible @param bVisible
If false, the status function bar is disabled, If false, the status function bar is disabled,
If true, the status function bar is visible. If true, the status function bar is visible.
*/ */
public void setStatusBarVisible(boolean bVisible) public void setStatusBarVisible(boolean bVisible)
throws
java.lang.InterruptedException
{ {
bStatusBarVisible = setToolVisible( "StatusBarVisible", "private:resource/statusbar/statusbar", try
SID_TOGGLESTATUSBAR, "StatusBarVisible", bStatusBarVisible, bVisible ); {
bStatusBarVisible = setToolVisible( "StatusBarVisible", "private:resource/statusbar/statusbar",
SID_TOGGLESTATUSBAR, "StatusBarVisible", bStatusBarVisible, bVisible );
}
catch ( java.lang.InterruptedException aExc )
{ bMenuBarVisible = bVisible; }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/* Returns the visibility of the status function bar. /* Returns the visibility of the status function bar.
This method works independently from a connetion or loaded document. This method works independently from a connetion or loaded document.
If no connection is established or no document is loaded,
this method just returns a memorized status.
@return @return
True if the status function bar is visible, True if the status function bar is visible,

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $ * $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: mi $ $Date: 2004-10-18 07:16:18 $ * last change: $Author: mi $ $Date: 2004-10-28 15:49:01 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -86,6 +86,9 @@
#define SYSTEM_MAC 5 #define SYSTEM_MAC 5
#define SYSTEM_XWINDOW 6 #define SYSTEM_XWINDOW 6
JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
(JNIEnv * env, jobject obj_this);
/*****************************************************************************/ /*****************************************************************************/
/* /*
* Class: com_sun_star_comp_beans_LocalOfficeWindow * Class: com_sun_star_comp_beans_LocalOfficeWindow

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $ * $RCSfile: com_sun_star_beans_LocalOfficeWindow.c,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: mi $ $Date: 2004-10-18 07:16:33 $ * last change: $Author: mi $ $Date: 2004-10-28 15:49:01 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -86,6 +86,9 @@
static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM ); static LRESULT APIENTRY OpenOfficeWndProc( HWND , UINT , WPARAM , LPARAM );
JNIEXPORT jlong JNICALL Java_com_sun_star_comp_beans_LocalOfficeWindow_getNativeWindow
(JNIEnv * env, jobject obj_this);
/*****************************************************************************/ /*****************************************************************************/
/* /*
* Class: com_sun_star_beans_LocalOfficeWindow * Class: com_sun_star_beans_LocalOfficeWindow