1*2c696243SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2c696243SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2c696243SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2c696243SAndrew Rist * distributed with this work for additional information 6*2c696243SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2c696243SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2c696243SAndrew Rist * "License"); you may not use this file except in compliance 9*2c696243SAndrew Rist * with the License. You may obtain a copy of the License at 10*2c696243SAndrew Rist * 11*2c696243SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2c696243SAndrew Rist * 13*2c696243SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2c696243SAndrew Rist * software distributed under the License is distributed on an 15*2c696243SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2c696243SAndrew Rist * KIND, either express or implied. See the License for the 17*2c696243SAndrew Rist * specific language governing permissions and limitations 18*2c696243SAndrew Rist * under the License. 19*2c696243SAndrew Rist * 20*2c696243SAndrew Rist *************************************************************/ 21*2c696243SAndrew Rist 22*2c696243SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_scripting.hxx" 26cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 27cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx> 30cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <util/scriptingconstants.hxx> 33cdf0e10cSrcweir #include <util/util.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "ScriptingContext.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir using namespace com::sun::star; 38cdf0e10cSrcweir using namespace com::sun::star::uno; 39cdf0e10cSrcweir #define DOC_REF_PROPID 1 40cdf0e10cSrcweir #define DOC_STORAGE_ID_PROPID 2 41cdf0e10cSrcweir #define DOC_URI_PROPID 3 42cdf0e10cSrcweir #define RESOLVED_STORAGE_ID_PROPID 4 43cdf0e10cSrcweir #define SCRIPT_INFO_PROPID 5 44cdf0e10cSrcweir #define SCRIPTINGCONTEXT_DEFAULT_ATTRIBS() beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::MAYBEVOID 45cdf0e10cSrcweir namespace func_provider 46cdf0e10cSrcweir { 47cdf0e10cSrcweir 48cdf0e10cSrcweir //************************************************************************* 49cdf0e10cSrcweir // XScriptingContext implementation 50cdf0e10cSrcweir // 51cdf0e10cSrcweir //************************************************************************* 52cdf0e10cSrcweir ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : //ScriptingContextImpl_BASE( GetMutex()), 53cdf0e10cSrcweir OPropertyContainer( GetBroadcastHelper() ), 54cdf0e10cSrcweir m_xContext( xContext, UNO_SET_THROW ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir OSL_TRACE( "< ScriptingContext ctor called >\n" ); 57cdf0e10cSrcweir 58cdf0e10cSrcweir Any nullAny; 59cdf0e10cSrcweir 60cdf0e10cSrcweir scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 61cdf0e10cSrcweir scripting_constants::ScriptingConstantsPool::instance(); 62cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_REF, DOC_REF_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(),::getCppuType( (const Reference< css::frame::XModel >* ) NULL ), NULL ) ; 63cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_STORAGE_ID, DOC_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ) ; 64cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_URI, DOC_URI_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const ::rtl::OUString* ) NULL ), NULL ) ; 65cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.RESOLVED_STORAGE_ID, RESOLVED_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ); 66cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.SCRIPT_INFO, SCRIPT_INFO_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir ScriptingContext::~ScriptingContext() 70cdf0e10cSrcweir { 71cdf0e10cSrcweir OSL_TRACE( "< ScriptingContext dtor called >\n" ); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir // ----------------------------------------------------------------------------- 74cdf0e10cSrcweir // OPropertySetHelper 75cdf0e10cSrcweir // ----------------------------------------------------------------------------- 76cdf0e10cSrcweir 77cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& ScriptingContext::getInfoHelper( ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir return *getArrayHelper(); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir // ----------------------------------------------------------------------------- 83cdf0e10cSrcweir // OPropertyArrayUsageHelper 84cdf0e10cSrcweir // ----------------------------------------------------------------------------- 85cdf0e10cSrcweir 86cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ScriptingContext::createArrayHelper( ) const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir Sequence< beans::Property > aProps; 89cdf0e10cSrcweir describeProperties( aProps ); 90cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper( aProps ); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir // ----------------------------------------------------------------------------- 93cdf0e10cSrcweir // XPropertySet 94cdf0e10cSrcweir // ----------------------------------------------------------------------------- 95cdf0e10cSrcweir 96cdf0e10cSrcweir Reference< beans::XPropertySetInfo > ScriptingContext::getPropertySetInfo( ) throw (RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 99cdf0e10cSrcweir return xInfo; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir // -----------------------------------------------------------------------------// XTypeProvider 102cdf0e10cSrcweir // ----------------------------------------------------------------------------- 103cdf0e10cSrcweir IMPLEMENT_GET_IMPLEMENTATION_ID( ScriptingContext ) 104cdf0e10cSrcweir 105cdf0e10cSrcweir css::uno::Sequence< css::uno::Type > SAL_CALL ScriptingContext::getTypes( ) throw (css::uno::RuntimeException) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir return OPropertyContainer::getTypes(); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } // namespace func_provider 110