summaryrefslogtreecommitdiff
path: root/scripting/source
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/source')
-rwxr-xr-xscripting/source/provider/ScriptingContext.cxx138
-rw-r--r--scripting/source/provider/ScriptingContext.hxx87
2 files changed, 74 insertions, 151 deletions
diff --git a/scripting/source/provider/ScriptingContext.cxx b/scripting/source/provider/ScriptingContext.cxx
index ea52bc049cd5..777dcff9242f 100755
--- a/scripting/source/provider/ScriptingContext.cxx
+++ b/scripting/source/provider/ScriptingContext.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptingContext.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dfoster $ $Date: 2002-10-23 14:13:25 $
+ * last change: $Author: dfoster $ $Date: 2003-11-04 17:45:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,6 +58,8 @@
*
*
************************************************************************/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/frame/XModel.hpp>
#include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/factory.hxx>
@@ -69,7 +71,12 @@
using namespace com::sun::star;
using namespace com::sun::star::uno;
-
+#define DOC_REF_PROPID 1
+#define DOC_STORAGE_ID_PROPID 2
+#define DOC_URI_PROPID 3
+#define RESOLVED_STORAGE_ID_PROPID 4
+#define SCRIPT_INFO_PROPID 5
+#define SCRIPTINGCONTEXT_DEFAULT_ATTRIBS() beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::MAYBEVOID
namespace func_provider
{
@@ -77,7 +84,8 @@ namespace func_provider
// XScriptingContext implementation
//
//*************************************************************************
-ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) :
+ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : //ScriptingContextImpl_BASE( GetMutex()),
+ OPropertyContainer( GetBroadcastHelper() ),
m_xContext( xContext )
{
OSL_TRACE( "< ScriptingContext ctor called >\n" );
@@ -85,121 +93,55 @@ ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xCont
validateXRef( m_xContext,
"ScriptingContext::ScriptingContext: No context available\n" );
- //Setup internal hash map
Any nullAny;
scripting_constants::ScriptingConstantsPool& scriptingConstantsPool =
scripting_constants::ScriptingConstantsPool::instance();
- m_propertyMap[ scriptingConstantsPool.DOC_REF ] = nullAny;
- m_propertyMap[ scriptingConstantsPool.DOC_STORAGE_ID ] = nullAny;
- m_propertyMap[ scriptingConstantsPool.DOC_URI ] = nullAny;
- m_propertyMap[ scriptingConstantsPool.RESOLVED_STORAGE_ID ] = nullAny;
- m_propertyMap[ scriptingConstantsPool.SCRIPT_INFO ] = nullAny;
+ registerPropertyNoMember( scriptingConstantsPool.DOC_REF, DOC_REF_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(),::getCppuType( (const Reference< css::frame::XModel >* ) NULL ), NULL ) ;
+ registerPropertyNoMember( scriptingConstantsPool.DOC_STORAGE_ID, DOC_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ) ;
+ registerPropertyNoMember( scriptingConstantsPool.DOC_URI, DOC_URI_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const ::rtl::OUString* ) NULL ), NULL ) ;
+ registerPropertyNoMember( scriptingConstantsPool.RESOLVED_STORAGE_ID, RESOLVED_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL );
+ registerPropertyNoMember( scriptingConstantsPool.SCRIPT_INFO, SCRIPT_INFO_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL );
}
-//*************************************************************************
-bool ScriptingContext::validateKey( const ::rtl::OUString& key )
-{
- ::osl::Guard< osl::Mutex > aGuard( m_mutex );
- return ( m_propertyMap.find( key ) != m_propertyMap.end() );
-}
-
-//*************************************************************************
ScriptingContext::~ScriptingContext()
{
OSL_TRACE( "< ScriptingContext dtor called >\n" );
}
+// -----------------------------------------------------------------------------
+// OPropertySetHelper
+// -----------------------------------------------------------------------------
-//*************************************************************************
-// XPropertySet implementation
-//*************************************************************************
-Reference< beans::XPropertySetInfo > SAL_CALL ScriptingContext::getPropertySetInfo( )
- throw ( RuntimeException )
+::cppu::IPropertyArrayHelper& ScriptingContext::getInfoHelper( )
{
- return Reference< beans::XPropertySetInfo > (); // Not supported
+ return *getArrayHelper();
}
-//*************************************************************************
-void SAL_CALL ScriptingContext::setPropertyValue( const ::rtl::OUString& aPropertyName,
- const Any& aValue )
- throw ( beans::UnknownPropertyException, beans::PropertyVetoException,
- lang::IllegalArgumentException, lang::WrappedTargetException,
- RuntimeException )
-{
- if ( !validateKey( aPropertyName ) )
- {
- throw RuntimeException(
- OUSTR( "ScriptingContext::setPropertyValue: invalid key" ),
- Reference< XInterface >() );
- }
- ::osl::Guard< osl::Mutex > aGuard( m_mutex );
- m_propertyMap[ aPropertyName ] = aValue;
-}
+// -----------------------------------------------------------------------------
+// OPropertyArrayUsageHelper
+// -----------------------------------------------------------------------------
-//*************************************************************************
-Any SAL_CALL ScriptingContext::getPropertyValue( const ::rtl::OUString& PropertyName )
- throw ( beans::UnknownPropertyException,
- lang::WrappedTargetException, RuntimeException )
+::cppu::IPropertyArrayHelper* ScriptingContext::createArrayHelper( ) const
{
- if ( !validateKey( PropertyName ) )
- {
- throw RuntimeException(
- OUSTR( "ScriptingContext::getPropertyValue: invalid key" ),
- Reference< XInterface >() );
- }
-
- ::osl::Guard< osl::Mutex > aGuard( m_mutex );
- Any returnValue = m_propertyMap[ PropertyName ];
-
- return returnValue;
-}
-
-//*************************************************************************
-void SAL_CALL ScriptingContext::addPropertyChangeListener(
- const ::rtl::OUString& aPropertyName,
- const Reference< beans::XPropertyChangeListener >& xListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- OUSTR( "ScriptingContext::addPropertyChangeListener: method not supported" ),
- Reference< XInterface >() );
-}
-
-//*************************************************************************
-void SAL_CALL ScriptingContext::removePropertyChangeListener(
- const ::rtl::OUString& aPropertyName,
- const Reference< beans::XPropertyChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- OUSTR( "ScriptingContext::removePropertyChangeListener: method not supported" ),
- Reference< XInterface >() );
+ Sequence< beans::Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
}
+// -----------------------------------------------------------------------------
+// XPropertySet
+// -----------------------------------------------------------------------------
-//*************************************************************************
-void SAL_CALL ScriptingContext::addVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const Reference< beans::XVetoableChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
+Reference< beans::XPropertySetInfo > ScriptingContext::getPropertySetInfo( ) throw (RuntimeException)
{
- throw RuntimeException(
- OUSTR( "ScriptingContext::addVetoableChangeListener: method not supported" ),
- Reference< XInterface >() );
+ Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
}
+// -----------------------------------------------------------------------------// XTypeProvider
+// -----------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( ScriptingContext )
-//*************************************************************************
-void SAL_CALL ScriptingContext::removeVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const Reference< beans::XVetoableChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
+css::uno::Sequence< css::uno::Type > SAL_CALL ScriptingContext::getTypes( ) throw (css::uno::RuntimeException)
{
- throw RuntimeException(
- OUSTR( "ScriptingContext::removeVetoableChangeListener: method not supported" ),
- Reference< XInterface >() );
+ return OPropertyContainer::getTypes();
}
-
} // namespace func_provider
diff --git a/scripting/source/provider/ScriptingContext.hxx b/scripting/source/provider/ScriptingContext.hxx
index 776d073ceb14..2ce1aeacc8e7 100644
--- a/scripting/source/provider/ScriptingContext.hxx
+++ b/scripting/source/provider/ScriptingContext.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptingContext.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: npower $ $Date: 2002-10-01 10:45:10 $
+ * last change: $Author: dfoster $ $Date: 2003-11-04 17:45:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,82 +62,63 @@
#ifndef _FRAMEWORK_SCRIPT_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
#define _FRAMEWORK_SCRIPT_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
-#include <hash_map>
#include <osl/mutex.hxx>
#include <rtl/ustring>
#include <cppuhelper/implbase1.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/proparrhlp.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/weak.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-
+#include <comphelper/broadcasthelper.hxx>
namespace func_provider
{
// for simplification
#define css ::com::sun::star
-#define dcsssf ::drafts::com::sun::star::script::framework
//Typedefs
//=============================================================================
-typedef ::std::hash_map < ::rtl::OUString, css::uno::Any, ::rtl::OUStringHash,
- ::std::equal_to< ::rtl::OUString > > ScriptingConext_hash;
-typedef ::std::vector< ::rtl::OUString > OUString_vec;
+//typedef ::cppu::WeakImplHelper1< css::beans::XPropertySet > ScriptingContextImpl_BASE;
-class ScriptingContext : public ::cppu::WeakImplHelper1< css::beans::XPropertySet >
+class ScriptingContext : public ::comphelper::OMutexAndBroadcastHelper, public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper< ScriptingContext >, public css::lang::XTypeProvider, public ::cppu::OWeakObject
{
public:
ScriptingContext( const css::uno::Reference< css::uno::XComponentContext > & xContext );
~ScriptingContext();
+ // XInterface
- // XPropertySet implementation
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo( )
- throw ( css::uno::RuntimeException );
- virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
- const css::uno::Any& aValue )
- throw ( css::beans::UnknownPropertyException,
- css::beans::PropertyVetoException,
- css::lang::IllegalArgumentException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
- virtual css::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
- throw ( css::beans::UnknownPropertyException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
- virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
- const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
- throw ( css::beans::UnknownPropertyException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
- virtual void SAL_CALL removePropertyChangeListener(
- const ::rtl::OUString& aPropertyName,
- const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
- throw ( css::beans::UnknownPropertyException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
- virtual void SAL_CALL addVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
- throw ( css::beans::UnknownPropertyException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
- virtual void SAL_CALL removeVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
- throw ( css::beans::UnknownPropertyException,
- css::lang::WrappedTargetException,
- css::uno::RuntimeException );
+ css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType )
+ throw( css::uno::RuntimeException )
+ {
+ css::uno::Any aRet( OPropertySetHelper::queryInterface( rType ) );
+ return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
+ }
+ void SAL_CALL acquire() throw() { ::cppu::OWeakObject::acquire(); }
+ void SAL_CALL release() throw() { ::cppu::OWeakObject::release(); }
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
+ throw ( css::uno::RuntimeException );
+ //XTypeProvider
+ DECLARE_XTYPEPROVIDER( )
+protected:
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper( );
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
private:
- // to obtain other services if needed
- ScriptingConext_hash m_propertyMap;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
- osl::Mutex m_mutex;
-
- // Private helper methods
- bool validateKey( const ::rtl::OUString& key );
};
} // func_provider