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