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