#i22116# - Complete XPropertySet implementation
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# $RCSfile: build.xml,v $
|
||||
#
|
||||
# $Revision: 1.26 $
|
||||
# $Revision: 1.27 $
|
||||
#
|
||||
# last change: $Author: dfoster $ $Date: 2003-11-03 16:07:05 $
|
||||
# last change: $Author: dfoster $ $Date: 2003-11-04 17:45:27 $
|
||||
#
|
||||
# The Contents of this file are made available subject to the terms of
|
||||
# either of the following licenses
|
||||
@@ -259,5 +259,5 @@
|
||||
</target>
|
||||
|
||||
<!-- ========================= All In One Build ======================= -->
|
||||
<target name="all" depends="clean,netbeans.jar,jar"/>
|
||||
<target name="all" depends="clean,jar"/>
|
||||
</project>
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptContext.java,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: toconnor $ $Date: 2003-10-29 15:01:13 $
|
||||
* last change: $Author: dfoster $ $Date: 2003-11-04 17:45:27 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -73,6 +73,9 @@ import com.sun.star.lang.WrappedTargetException;
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.AnyConverter;
|
||||
import com.sun.star.beans.PropertyAttribute;
|
||||
import com.sun.star.lib.uno.helper.PropertySet;
|
||||
import com.sun.star.uno.Type;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -80,13 +83,14 @@ import drafts.com.sun.star.script.provider.XScriptContext;
|
||||
|
||||
import com.sun.star.script.framework.log.LogUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Class
|
||||
*
|
||||
* @author Noel Power
|
||||
* @created August 2, 2002
|
||||
*/
|
||||
public class ScriptContext implements XScriptContext, XPropertySet
|
||||
public class ScriptContext extends PropertySet implements XScriptContext
|
||||
{
|
||||
/**
|
||||
* Description of the Class
|
||||
@@ -98,33 +102,41 @@ public class ScriptContext implements XScriptContext, XPropertySet
|
||||
public final static String HM_DOC_REF = "DocumentReference";
|
||||
public final static String HM_DESKTOP = "Desktop";
|
||||
public final static String HM_COMPONENT_CONTEXT = "ComponentContext";
|
||||
private HashMap m_properties = new HashMap();
|
||||
|
||||
private final static String DOC_REF = "SCRIPTING_DOC_REF";
|
||||
private final static String DOC_STORAGE_ID = "SCRIPTING_DOC_STORAGE_ID";
|
||||
private final static String DOC_URI = "SCRIPTING_DOC_URI";
|
||||
|
||||
|
||||
public XModel m_xModel = null;
|
||||
public String m_sDocURI = null;
|
||||
public XDesktop m_xDeskTop = null;
|
||||
public Integer m_iStorageID = null;
|
||||
public XComponentContext m_xComponentContext = null;
|
||||
|
||||
public ScriptContext( XComponentContext xmComponentContext,
|
||||
XDesktop xDesktop, XPropertySet invocationCtxPropSet)
|
||||
{
|
||||
XModel xmDocRef = null;
|
||||
this.m_xDeskTop = xDesktop;
|
||||
this.m_xComponentContext = xmComponentContext;
|
||||
try
|
||||
{
|
||||
xmDocRef = ( XModel ) UnoRuntime.queryInterface(
|
||||
m_xModel = ( XModel ) UnoRuntime.queryInterface(
|
||||
XModel.class,
|
||||
invocationCtxPropSet.getPropertyValue( DOC_REF ) );
|
||||
int iDocStorageID =
|
||||
AnyConverter.toInt( invocationCtxPropSet.getPropertyValue(
|
||||
DOC_STORAGE_ID ) );
|
||||
String sDocUri = ( String )
|
||||
m_iStorageID = new Integer ( AnyConverter.toInt( invocationCtxPropSet.getPropertyValue(
|
||||
DOC_STORAGE_ID ) ) );
|
||||
m_sDocURI = ( String )
|
||||
invocationCtxPropSet.getPropertyValue( DOC_URI );
|
||||
|
||||
LogUtils.DEBUG( "DOC_REF query for URL = " + xmDocRef.getURL() );
|
||||
LogUtils.DEBUG( "DOC_STORAGE_ID = " + iDocStorageID );
|
||||
LogUtils.DEBUG( "DOC_URI query for URL = " + sDocUri );
|
||||
LogUtils.DEBUG( "DOC_REF query for URL = " + m_xModel.getURL() );
|
||||
LogUtils.DEBUG( "DOC_STORAGE_ID = " + m_iStorageID );
|
||||
LogUtils.DEBUG( "DOC_URI query for URL = " + m_sDocURI );
|
||||
|
||||
m_properties.put( DOC_STORAGE_ID, new Integer( iDocStorageID ) );
|
||||
m_properties.put( DOC_URI, sDocUri );
|
||||
registerProperty( DOC_STORAGE_ID, new Type(Integer.class),
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_iStorageID");
|
||||
registerProperty( DOC_URI, new Type(String.class),
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_sDocURI");
|
||||
}
|
||||
catch ( UnknownPropertyException upe )
|
||||
{
|
||||
@@ -138,9 +150,12 @@ public class ScriptContext implements XScriptContext, XPropertySet
|
||||
{
|
||||
iae.printStackTrace();
|
||||
}
|
||||
m_properties.put( HM_DOC_REF, xmDocRef );
|
||||
m_properties.put( HM_DESKTOP, xDesktop );
|
||||
m_properties.put( HM_COMPONENT_CONTEXT, xmComponentContext );
|
||||
registerProperty( HM_DOC_REF, new Type(XModel.class),
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xModel");
|
||||
registerProperty( HM_DESKTOP, new Type(XDesktop.class),
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xDeskTop");
|
||||
registerProperty( HM_COMPONENT_CONTEXT, new Type(XDesktop.class),
|
||||
(short)(PropertyAttribute.MAYBEVOID | PropertyAttribute.TRANSIENT), "m_xComponentContext");
|
||||
}
|
||||
|
||||
public static ScriptContext createContext(Object invocationCtx,
|
||||
@@ -177,7 +192,7 @@ public class ScriptContext implements XScriptContext, XPropertySet
|
||||
*/
|
||||
public XModel getDocument()
|
||||
{
|
||||
return ( XModel )m_properties.get( HM_DOC_REF );
|
||||
return m_xModel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +203,7 @@ public class ScriptContext implements XScriptContext, XPropertySet
|
||||
*/
|
||||
public XDesktop getDesktop()
|
||||
{
|
||||
return ( XDesktop )m_properties.get( HM_DESKTOP );
|
||||
return m_xDeskTop;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,132 +214,7 @@ public class ScriptContext implements XScriptContext, XPropertySet
|
||||
*/
|
||||
public XComponentContext getComponentContext()
|
||||
{
|
||||
return ( XComponentContext )m_properties.get( HM_COMPONENT_CONTEXT );
|
||||
}
|
||||
|
||||
|
||||
/** @returns
|
||||
the <type>XPropertySetInfo</type> interface, which
|
||||
describes all properties of the object which supplies this
|
||||
interface.
|
||||
|
||||
@returns
|
||||
<const>NULL</const> if the implementation cannot or will
|
||||
not provide information about the properties; otherwise the
|
||||
interface <type>XPropertySetInfo</type> is returned.
|
||||
*/
|
||||
public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/** sets the value of the property with the specified name.
|
||||
|
||||
<p>If it is a bound property the value will be changed before
|
||||
the change event is fired. If it is a constrained property
|
||||
a vetoable event is fired before the property value can be
|
||||
changed. </p>
|
||||
|
||||
@raises com::sun::star::beans::PropertyVetoException
|
||||
if the property is read-only or vetoable
|
||||
and one of the listeners throws this exception
|
||||
because of an unaccepted new value.
|
||||
*/
|
||||
public void setPropertyValue( String aPropertyName,
|
||||
java.lang.Object aValue )
|
||||
throws UnknownPropertyException, PropertyVetoException,
|
||||
com.sun.star.lang.IllegalArgumentException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
throw new PropertyVetoException("No changes to ScriptContext allowed");
|
||||
}
|
||||
|
||||
/** @returns
|
||||
the value of the property with the specified name.
|
||||
|
||||
@param PropertyName
|
||||
This parameter specifies the name of the property.
|
||||
|
||||
@throws UnknownPropertyException
|
||||
if the property does not exist.
|
||||
|
||||
@throws com::sun::star::lang::WrappedTargetException
|
||||
if the implementation has an internal reason for the exception.
|
||||
In this case the original exception is wrapped into that
|
||||
<type scope="com::sun::star::lang">WrappedTargetException</type>.
|
||||
*/
|
||||
public java.lang.Object getPropertyValue( String PropertyName )
|
||||
throws UnknownPropertyException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
if( !m_properties.containsKey( PropertyName ) )
|
||||
{
|
||||
throw new UnknownPropertyException( "No property called " + PropertyName + " in ScriptContext" );
|
||||
}
|
||||
return m_properties.get( PropertyName );
|
||||
}
|
||||
|
||||
/** adds an <type>XPropertyChangeListener</type> to the specified property.
|
||||
|
||||
<p>An empty name ("") registers the listener to all bound
|
||||
properties. If the property is not bound, the behavior is
|
||||
not specified. </p>
|
||||
|
||||
@see removePropertyChangeListener
|
||||
*/
|
||||
public void addPropertyChangeListener( String aPropertyName,
|
||||
XPropertyChangeListener xListener )
|
||||
throws UnknownPropertyException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
throw new RuntimeException("ScriptContext::addPropertyChangeListener not supported.");
|
||||
}
|
||||
|
||||
/** removes an <type>XPropertyChangeListener</type> from
|
||||
the listener list.
|
||||
|
||||
<p>It is a "noop" if the listener is not registered. </p>
|
||||
|
||||
@see addPropertyChangeListener
|
||||
*/
|
||||
public void removePropertyChangeListener( String aPropertyName,
|
||||
XPropertyChangeListener aListener )
|
||||
throws UnknownPropertyException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
throw new RuntimeException("ScriptContext::removePropertyChangeListener not supported.");
|
||||
}
|
||||
|
||||
/** adds an <type>XVetoableChangeListener</type> to the specified
|
||||
property with the name PropertyName.
|
||||
|
||||
<p>An empty name ("") registers the listener to all
|
||||
constrained properties. If the property is not constrained,
|
||||
the behavior is not specified. </p>
|
||||
|
||||
@see removeVetoableChangeListener
|
||||
*/
|
||||
public void addVetoableChangeListener( String PropertyName,
|
||||
XVetoableChangeListener aListener )
|
||||
throws UnknownPropertyException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
throw new RuntimeException("ScriptContext::addVetoableChangeListener not supported.");
|
||||
}
|
||||
|
||||
/** removes an <type>XVetoableChangeListener</type> from the
|
||||
listener list.
|
||||
|
||||
<p>It is a "noop" if the listener is not registered. </p>
|
||||
|
||||
@see addVetoableChangeListener
|
||||
*/
|
||||
public void removeVetoableChangeListener( String PropertyName,
|
||||
XVetoableChangeListener aListener )
|
||||
throws UnknownPropertyException,
|
||||
com.sun.star.lang.WrappedTargetException
|
||||
{
|
||||
throw new RuntimeException("ScriptContext::removeVetoableChangeListener not supported.");
|
||||
return m_xComponentContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user