1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_scripting.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx> 34*cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <util/scriptingconstants.hxx> 37*cdf0e10cSrcweir #include <util/util.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "ScriptingContext.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir using namespace com::sun::star; 42*cdf0e10cSrcweir using namespace com::sun::star::uno; 43*cdf0e10cSrcweir #define DOC_REF_PROPID 1 44*cdf0e10cSrcweir #define DOC_STORAGE_ID_PROPID 2 45*cdf0e10cSrcweir #define DOC_URI_PROPID 3 46*cdf0e10cSrcweir #define RESOLVED_STORAGE_ID_PROPID 4 47*cdf0e10cSrcweir #define SCRIPT_INFO_PROPID 5 48*cdf0e10cSrcweir #define SCRIPTINGCONTEXT_DEFAULT_ATTRIBS() beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::MAYBEVOID 49*cdf0e10cSrcweir namespace func_provider 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //************************************************************************* 53*cdf0e10cSrcweir // XScriptingContext implementation 54*cdf0e10cSrcweir // 55*cdf0e10cSrcweir //************************************************************************* 56*cdf0e10cSrcweir ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : //ScriptingContextImpl_BASE( GetMutex()), 57*cdf0e10cSrcweir OPropertyContainer( GetBroadcastHelper() ), 58*cdf0e10cSrcweir m_xContext( xContext, UNO_SET_THROW ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir OSL_TRACE( "< ScriptingContext ctor called >\n" ); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir Any nullAny; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir scripting_constants::ScriptingConstantsPool& scriptingConstantsPool = 65*cdf0e10cSrcweir scripting_constants::ScriptingConstantsPool::instance(); 66*cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_REF, DOC_REF_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(),::getCppuType( (const Reference< css::frame::XModel >* ) NULL ), NULL ) ; 67*cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_STORAGE_ID, DOC_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ) ; 68*cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.DOC_URI, DOC_URI_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const ::rtl::OUString* ) NULL ), NULL ) ; 69*cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.RESOLVED_STORAGE_ID, RESOLVED_STORAGE_ID_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ); 70*cdf0e10cSrcweir registerPropertyNoMember( scriptingConstantsPool.SCRIPT_INFO, SCRIPT_INFO_PROPID, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32* ) NULL ), NULL ); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir ScriptingContext::~ScriptingContext() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir OSL_TRACE( "< ScriptingContext dtor called >\n" ); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 78*cdf0e10cSrcweir // OPropertySetHelper 79*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& ScriptingContext::getInfoHelper( ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir return *getArrayHelper(); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 87*cdf0e10cSrcweir // OPropertyArrayUsageHelper 88*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ScriptingContext::createArrayHelper( ) const 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir Sequence< beans::Property > aProps; 93*cdf0e10cSrcweir describeProperties( aProps ); 94*cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper( aProps ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 97*cdf0e10cSrcweir // XPropertySet 98*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir Reference< beans::XPropertySetInfo > ScriptingContext::getPropertySetInfo( ) throw (RuntimeException) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 103*cdf0e10cSrcweir return xInfo; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir // -----------------------------------------------------------------------------// XTypeProvider 106*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 107*cdf0e10cSrcweir IMPLEMENT_GET_IMPLEMENTATION_ID( ScriptingContext ) 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir css::uno::Sequence< css::uno::Type > SAL_CALL ScriptingContext::getTypes( ) throw (css::uno::RuntimeException) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir return OPropertyContainer::getTypes(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } // namespace func_provider 114