1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/beans/PropertyAttribute.hpp>
21 #include <com/sun/star/frame/XModel.hpp>
23 #include <cppuhelper/implementationentry.hxx>
24 #include <cppuhelper/factory.hxx>
26 #include <util/scriptingconstants.hxx>
27 #include <util/util.hxx>
29 #include "ScriptingContext.hxx"
31 using namespace com::sun::star
;
32 using namespace com::sun::star::uno
;
33 #define DOC_REF_PROPID 1
34 #define DOC_STORAGE_ID_PROPID 2
35 #define DOC_URI_PROPID 3
36 #define RESOLVED_STORAGE_ID_PROPID 4
37 #define SCRIPT_INFO_PROPID 5
38 #define SCRIPTINGCONTEXT_DEFAULT_ATTRIBS() beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::MAYBEVOID
39 namespace func_provider
42 //*************************************************************************
43 // XScriptingContext implementation
45 //*************************************************************************
46 ScriptingContext::ScriptingContext( const Reference
< XComponentContext
> & xContext
) : //ScriptingContextImpl_BASE( GetMutex()),
47 OPropertyContainer( GetBroadcastHelper() ),
48 m_xContext( xContext
, UNO_SET_THROW
)
50 OSL_TRACE( "< ScriptingContext ctor called >" );
54 scripting_constants::ScriptingConstantsPool
& scriptingConstantsPool
=
55 scripting_constants::ScriptingConstantsPool::instance();
56 registerPropertyNoMember( scriptingConstantsPool
.DOC_REF
, DOC_REF_PROPID
, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(),::getCppuType( (const Reference
< css::frame::XModel
>* ) NULL
), NULL
) ;
57 registerPropertyNoMember( scriptingConstantsPool
.DOC_STORAGE_ID
, DOC_STORAGE_ID_PROPID
, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32
* ) NULL
), NULL
) ;
58 registerPropertyNoMember( scriptingConstantsPool
.DOC_URI
, DOC_URI_PROPID
, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const OUString
* ) NULL
), NULL
) ;
59 registerPropertyNoMember( scriptingConstantsPool
.RESOLVED_STORAGE_ID
, RESOLVED_STORAGE_ID_PROPID
, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32
* ) NULL
), NULL
);
60 registerPropertyNoMember( scriptingConstantsPool
.SCRIPT_INFO
, SCRIPT_INFO_PROPID
, SCRIPTINGCONTEXT_DEFAULT_ATTRIBS(), ::getCppuType( (const sal_Int32
* ) NULL
), NULL
);
63 ScriptingContext::~ScriptingContext()
65 OSL_TRACE( "< ScriptingContext dtor called >" );
67 // -----------------------------------------------------------------------------
69 // -----------------------------------------------------------------------------
71 ::cppu::IPropertyArrayHelper
& ScriptingContext::getInfoHelper( )
73 return *getArrayHelper();
76 // -----------------------------------------------------------------------------
77 // OPropertyArrayUsageHelper
78 // -----------------------------------------------------------------------------
80 ::cppu::IPropertyArrayHelper
* ScriptingContext::createArrayHelper( ) const
82 Sequence
< beans::Property
> aProps
;
83 describeProperties( aProps
);
84 return new ::cppu::OPropertyArrayHelper( aProps
);
86 // -----------------------------------------------------------------------------
88 // -----------------------------------------------------------------------------
90 Reference
< beans::XPropertySetInfo
> ScriptingContext::getPropertySetInfo( ) throw (RuntimeException
)
92 Reference
< beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
95 // -----------------------------------------------------------------------------// XTypeProvider
96 // -----------------------------------------------------------------------------
97 IMPLEMENT_GET_IMPLEMENTATION_ID( ScriptingContext
)
99 css::uno::Sequence
< css::uno::Type
> SAL_CALL
ScriptingContext::getTypes( ) throw (css::uno::RuntimeException
)
101 return OPropertyContainer::getTypes();
103 } // namespace func_provider
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */