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