merge the formfield patch from ooo-build
[ooovba.git] / scripting / source / provider / MasterScriptProvider.hxx
blobd8d39a6421bd1be92e9c403e983e4f2f4d56f572
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: MasterScriptProvider.hxx,v $
10 * $Revision: 1.15 $
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 #ifndef _FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_
32 #define _FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_
34 #include <rtl/ustring.hxx>
36 #include <cppuhelper/implbase5.hxx>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/uno/RuntimeException.hpp>
40 #include <com/sun/star/container/XNameContainer.hpp>
41 #include <com/sun/star/document/XScriptInvocationContext.hpp>
43 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <com/sun/star/script/provider/XScriptProvider.hpp>
46 #include <com/sun/star/script/browse/XBrowseNode.hpp>
48 #include "ProviderCache.hxx"
50 namespace func_provider
52 // for simplification
53 #define css ::com::sun::star
55 typedef ::cppu::WeakImplHelper5<
56 css::script::provider::XScriptProvider,
57 css::script::browse::XBrowseNode, css::lang::XServiceInfo,
58 css::lang::XInitialization,
59 css::container::XNameContainer > t_helper;
61 class MasterScriptProvider :
62 public t_helper
64 public:
65 MasterScriptProvider(
66 const css::uno::Reference< css::uno::XComponentContext >
67 & xContext ) throw( css::uno::RuntimeException );
68 ~MasterScriptProvider();
70 // XServiceInfo implementation
71 virtual ::rtl::OUString SAL_CALL getImplementationName( )
72 throw( css::uno::RuntimeException );
74 // XBrowseNode implementation
75 virtual ::rtl::OUString SAL_CALL getName()
76 throw ( css::uno::RuntimeException );
77 virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes()
78 throw ( css::uno::RuntimeException );
79 virtual sal_Bool SAL_CALL hasChildNodes()
80 throw ( css::uno::RuntimeException );
81 virtual sal_Int16 SAL_CALL getType()
82 throw ( css::uno::RuntimeException );
83 // XNameContainer
84 virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const css::uno::Any& aElement ) throw ( css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, css::uno::RuntimeException);
85 virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
87 // XNameReplace
88 virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const css::uno::Any& aElement ) throw ( css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
89 // XNameAccess
90 virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
91 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw ( css::uno::RuntimeException);
92 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
94 // XElementAccess
95 virtual css::uno::Type SAL_CALL getElementType( ) throw ( css::uno::RuntimeException);
96 virtual sal_Bool SAL_CALL hasElements( ) throw ( css::uno::RuntimeException);
97 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
98 throw( css::uno::RuntimeException );
99 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
100 throw( css::uno::RuntimeException );
102 // XScriptProvider implementation
103 virtual css::uno::Reference < css::script::provider::XScript > SAL_CALL
104 getScript( const ::rtl::OUString& scriptURI )
105 throw( css::script::provider::ScriptFrameworkErrorException,
106 css::uno::RuntimeException );
109 * XInitialise implementation
111 * @param args expected to contain a single ::rtl::OUString
112 * containing the URI
114 virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any > & args )
115 throw ( css::uno::Exception, css::uno::RuntimeException);
117 // Public method to return all Language Providers in this MasterScriptProviders
118 // context.
119 css::uno::Sequence< css::uno::Reference< css::script::provider::XScriptProvider > > SAL_CALL
120 getAllProviders() throw ( css::uno::RuntimeException );
122 bool isPkgProvider() { return m_bIsPkgMSP; }
123 css::uno::Reference< css::script::provider::XScriptProvider > getPkgProvider() { return m_xMSPPkg; }
124 // returns context string for this provider, eg
125 ::rtl::OUString getContextString() { return m_sCtxString; }
127 private:
128 ::rtl::OUString parseLocationName( const ::rtl::OUString& location );
129 void createPkgProvider();
130 bool isValid();
131 ::rtl::OUString getURLForModel();
132 const css::uno::Sequence< ::rtl::OUString >& getProviderNames();
134 ProviderCache* providerCache();
135 /* to obtain other services if needed */
136 css::uno::Reference< css::uno::XComponentContext > m_xContext;
137 css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
138 css::uno::Reference< css::frame::XModel > m_xModel;
139 css::uno::Reference< css::document::XScriptInvocationContext > m_xInvocationContext;
140 css::uno::Sequence< css::uno::Any > m_sAargs;
141 ::rtl::OUString m_sNodeName;
143 // This component supports XInitialization, it can be created
144 // using createInstanceXXX() or createInstanceWithArgumentsXXX using
145 // the service Mangager.
146 // Need to detect proper initialisation and validity
147 // for the object, so m_bIsValid indicates that the object is valid is set in ctor
148 // in case of createInstanceWithArgumentsXXX() called m_bIsValid is set to reset
149 // and then set to true when initialisation is complete
150 bool m_bIsValid;
151 // m_bInitialised ensure initialisation only takes place once.
152 bool m_bInitialised;
153 bool m_bIsPkgMSP;
154 css::uno::Reference< css::script::provider::XScriptProvider > m_xMSPPkg;
155 ProviderCache* m_pPCache;
156 osl::Mutex m_mutex;
157 ::rtl::OUString m_sCtxString;
159 } // namespace func_provider
160 #endif //_FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_