Kaydet (Commit) 4fe2c8f9 authored tarafından Noel Power's avatar Noel Power

#i12906#

Updates from code inspection
üst de11ba9e
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: ActiveMSPList.hxx,v $ * $RCSfile: ActiveMSPList.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: npower $ $Date: 2003-09-04 07:23:12 $ * last change: $Author: npower $ $Date: 2003-09-10 08:08:14 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -87,19 +87,21 @@ namespace func_provider ...@@ -87,19 +87,21 @@ namespace func_provider
//Typedefs //Typedefs
//============================================================================= //=============================================================================
typedef ::std::hash_map< ::rtl::OUString,
css::uno::Reference< dcsssf::provider::XScriptProvider >,
::rtl::OUStringHash,
::std::equal_to< ::rtl::OUString > > Msp_hash;
struct MspInst struct MspInst
{ {
css::uno::Reference< dcsssf::provider::XScriptProvider > provider; css::uno::Reference< dcsssf::provider::XScriptProvider > provider;
::rtl::OUString docName; css::uno::Reference< dcsssf::browse::XBrowseNode > node;
}; };
typedef ::std::map < css::uno::Reference< css::frame::XModel >, typedef ::std::map < css::uno::Reference< css::frame::XModel >,
MspInst > Model_map; MspInst > Model_map;
typedef ::std::hash_map< ::rtl::OUString,
MspInst,
::rtl::OUStringHash,
::std::equal_to< ::rtl::OUString > > Msp_hash;
class ActiveMSPList : public ::cppu::WeakImplHelper2< css::lang::XEventListener , dcsssf::browse::XBrowseNode > class ActiveMSPList : public ::cppu::WeakImplHelper2< css::lang::XEventListener , dcsssf::browse::XBrowseNode >
{ {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: MasterScriptProvider.cxx,v $ * $RCSfile: MasterScriptProvider.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: npower $ $Date: 2003-09-04 07:24:47 $ * last change: $Author: npower $ $Date: 2003-09-10 08:08:14 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -98,7 +98,7 @@ Sequence< ::rtl::OUString > s_serviceNames = Sequence < ...@@ -98,7 +98,7 @@ Sequence< ::rtl::OUString > s_serviceNames = Sequence <
// //
//************************************************************************* //*************************************************************************
MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > & xContext ) throw ( RuntimeException ): MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > & xContext ) throw ( RuntimeException ):
m_xContext( xContext ), m_bInitialised( false ), m_bIsValid( false ), m_xContext( xContext ), m_bIsValid( false ), m_bInitialised( false ),
m_pPCache( 0 ) m_pPCache( 0 )
{ {
OSL_TRACE( "< MasterScriptProvider ctor called >\n" ); OSL_TRACE( "< MasterScriptProvider ctor called >\n" );
...@@ -135,7 +135,13 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > ...@@ -135,7 +135,13 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext >
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() ); throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
} }
//Sequence< ::rtl::OUString >& providers = getProviderNames(); // Set up contextless cache
// if initialise method is called a new ProviderCache will be
// created with the appropriate context supplied as an argument
Sequence< Any > invokeArgs(1);
invokeArgs[ 0 ] <<= m_XScriptingContext;
m_pPCache = new ProviderCache( m_xContext, invokeArgs );
m_bIsValid = true; m_bIsValid = true;
} }
...@@ -165,6 +171,7 @@ throw ( Exception, RuntimeException ) ...@@ -165,6 +171,7 @@ throw ( Exception, RuntimeException )
m_bIsValid = false; m_bIsValid = false;
// related to issue 11866 // related to issue 11866
// warning dialog gets launched when adding binding to script in doc // warning dialog gets launched when adding binding to script in doc
// workaround issue: no functionProvider created on doc open // workaround issue: no functionProvider created on doc open
...@@ -339,12 +346,15 @@ throw ( Exception, RuntimeException ) ...@@ -339,12 +346,15 @@ throw ( Exception, RuntimeException )
//invokeArgs[ 0 ] <<= m_XScriptingContext; //invokeArgs[ 0 ] <<= m_XScriptingContext;
invokeArgs = Sequence< Any >( 0 ); // no arguments invokeArgs = Sequence< Any >( 0 ); // no arguments
} }
// should be initialised from ctor ( in case createInstance called
// should be zero, if not initialised, put assert here // instead of createInsanceWithArgs.... )
if ( m_pPCache == 0 ) if ( m_pPCache != 0 )
{ {
m_pPCache = new ProviderCache( m_xContext, invokeArgs ); OSL_TRACE("** MSP init, creating provider cache");
delete m_pPCache;
} }
m_pPCache = new ProviderCache( m_xContext, invokeArgs );
if ( m_xModel.is() ) if ( m_xModel.is() )
{ {
// This MSP created from a document, add to ActiveMSPList // This MSP created from a document, add to ActiveMSPList
...@@ -496,46 +506,6 @@ MasterScriptProvider::getLanguageFromURI( const ::rtl::OUString& scriptURI ) ...@@ -496,46 +506,6 @@ MasterScriptProvider::getLanguageFromURI( const ::rtl::OUString& scriptURI )
//************************************************************************* //*************************************************************************
Reference< provider::XScriptProvider >
MasterScriptProvider::getScriptProvider(
const ::rtl::OUString& language,
const Sequence< Any >& aArgs ) throw ( RuntimeException )
{
Reference< provider::XScriptProvider > xScriptProvider;
try
{
// need to attempt to get the runtime service (not singleton) for the lang
::rtl::OUStringBuffer buf( 80 );
buf.appendAscii( "drafts.com.sun.star.script.framework.provider.ScriptProviderFor");
buf.append( language );
::rtl::OUString serviceName = buf.makeStringAndClear();
OSL_TRACE( "Service name is %s",
::rtl::OUStringToOString( serviceName,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
Reference< XInterface > xInterface =
m_xMgr->createInstanceWithArgumentsAndContext(
serviceName, aArgs, m_xContext );
// need to get the XScriptProvider interface from the service
validateXRef( xInterface,
"MasterScriptProvider::getScriptProvider: cannot get appropriate language ScriptProvider Service");
xScriptProvider = Reference< provider::XScriptProvider > ( xInterface,
UNO_QUERY_THROW );
validateXRef( xScriptProvider,
"Service doesn't support XScriptProvider interface" );
}
catch ( RuntimeException & e )
{
::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScriptProvider: can't get ScriptProvider for " );
temp.concat( language );
temp.concat( OUSTR( " :" ) );
throw RuntimeException( temp.concat( e.Message ),
Reference< XInterface >() );
}
return xScriptProvider;
}
::rtl::OUString SAL_CALL ::rtl::OUString SAL_CALL
MasterScriptProvider::getName() MasterScriptProvider::getName()
throw ( css::uno::RuntimeException ) throw ( css::uno::RuntimeException )
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: MasterScriptProvider.hxx,v $ * $RCSfile: MasterScriptProvider.hxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: npower $ $Date: 2003-09-04 07:24:47 $ * last change: $Author: npower $ $Date: 2003-09-10 08:08:14 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,13 +63,12 @@ ...@@ -63,13 +63,12 @@
#define _FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_ #define _FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_
#include <rtl/ustring> #include <rtl/ustring>
#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase4.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <drafts/com/sun/star/script/framework/provider/XScriptProvider.hpp> #include <drafts/com/sun/star/script/framework/provider/XScriptProvider.hpp>
#include <drafts/com/sun/star/script/framework/provider/XScriptProviderAccess.hpp>
#include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp> #include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp> #include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
#include <drafts/com/sun/star/script/framework/browse/XBrowseNode.hpp> #include <drafts/com/sun/star/script/framework/browse/XBrowseNode.hpp>
...@@ -83,9 +82,9 @@ namespace func_provider ...@@ -83,9 +82,9 @@ namespace func_provider
#define dcsssf ::drafts::com::sun::star::script::framework #define dcsssf ::drafts::com::sun::star::script::framework
class MasterScriptProvider : class MasterScriptProvider :
public ::cppu::WeakImplHelper5 < dcsssf::provider::XScriptProvider, public ::cppu::WeakImplHelper4 < dcsssf::provider::XScriptProvider,
dcsssf::browse::XBrowseNode, dcsssf::provider::XScriptProviderAccess, dcsssf::browse::XBrowseNode, css::lang::XServiceInfo,
css::lang::XServiceInfo, css::lang::XInitialization > css::lang::XInitialization >
{ {
public: public:
MasterScriptProvider( MasterScriptProvider(
...@@ -107,9 +106,7 @@ public: ...@@ -107,9 +106,7 @@ public:
virtual sal_Int16 SAL_CALL getType() virtual sal_Int16 SAL_CALL getType()
throw ( css::uno::RuntimeException ); throw ( css::uno::RuntimeException );
// XBrowseNode implementation
virtual css::uno::Sequence< css::uno::Reference< dcsssf::provider::XScriptProvider > > SAL_CALL
getAllProviders() throw ( css::uno::RuntimeException );
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw( css::uno::RuntimeException ); throw( css::uno::RuntimeException );
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
...@@ -128,22 +125,34 @@ public: ...@@ -128,22 +125,34 @@ public:
*/ */
virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any > & args ) virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any > & args )
throw ( css::uno::Exception, css::uno::RuntimeException); throw ( css::uno::Exception, css::uno::RuntimeException);
// Public method to return all Language Providers in this MasterScriptProviders
// context.
css::uno::Sequence< css::uno::Reference< dcsssf::provider::XScriptProvider > > SAL_CALL
getAllProviders() throw ( css::uno::RuntimeException );
private: private:
void addStorageAsListener() throw( css::uno::RuntimeException ); void addStorageAsListener() throw( css::uno::RuntimeException );
bool isValid(); bool isValid();
const css::uno::Sequence< ::rtl::OUString >& getProviderNames(); const css::uno::Sequence< ::rtl::OUString >& getProviderNames();
::rtl::OUString getLanguageFromURI(const ::rtl::OUString& scriptURI ); ::rtl::OUString getLanguageFromURI(const ::rtl::OUString& scriptURI );
css::uno::Reference< dcsssf::provider::XScriptProvider >
getScriptProvider( const ::rtl::OUString& language,
const css::uno::Sequence< css::uno::Any >& args )
throw ( css::uno::RuntimeException );
/* to obtain other services if needed */ /* to obtain other services if needed */
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr; css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
css::uno::Reference< css::frame::XModel > m_xModel; css::uno::Reference< css::frame::XModel > m_xModel;
css::uno::Reference < dcsssf::storage::XScriptStorageManager > m_xScriptStorageMgr; css::uno::Reference < dcsssf::storage::XScriptStorageManager > m_xScriptStorageMgr;
bool m_bInitialised;
// This component supports XInitialization, it can be created
// using createInstanceXXX() or createInstanceWithArgumentsXXX using
// the service Mangager.
// Need to detect proper initialisation and validity
// for the object, so m_bIsValid indicates that the object is valid is set in ctor
// in case of createInstanceWithArgumentsXXX() called m_bIsValid is set to reset
// and then set to true when initialisation is complete
bool m_bIsValid; bool m_bIsValid;
// m_bInitialised ensure initialisation only takes place once.
bool m_bInitialised;
css::uno::Reference< css::beans::XPropertySet > m_XScriptingContext; css::uno::Reference< css::beans::XPropertySet > m_XScriptingContext;
ProviderCache* m_pPCache; ProviderCache* m_pPCache;
osl::Mutex m_mutex; osl::Mutex m_mutex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment