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.cxx,v $ * $RCSfile: ActiveMSPList.cxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: npower $ $Date: 2003-09-04 07:23:28 $ * last change: $Author: npower $ $Date: 2003-09-10 08:08:13 $
* *
* 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
...@@ -68,9 +68,9 @@ ...@@ -68,9 +68,9 @@
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/util/XMacroExpander.hpp>
#include <drafts/com/sun/star/script/framework/provider/XScriptProviderAccess.hpp>
#include <drafts/com/sun/star/script/framework/browse/BrowseNodeTypes.hpp> #include <drafts/com/sun/star/script/framework/browse/BrowseNodeTypes.hpp>
#include "MasterScriptProvider.hxx"
#include "ActiveMSPList.hxx" #include "ActiveMSPList.hxx"
using namespace com::sun::star; using namespace com::sun::star;
...@@ -83,35 +83,23 @@ namespace func_provider ...@@ -83,35 +83,23 @@ namespace func_provider
class BrowseNodeImpl : public ::cppu::WeakImplHelper1< browse::XBrowseNode > class BrowseNodeImpl : public ::cppu::WeakImplHelper1< browse::XBrowseNode >
{ {
public: public:
BrowseNodeImpl( const Reference< provider::XScriptProvider >& msp, const ::rtl::OUString& location ): m_sNodeName( location ), m_xSP( msp ) BrowseNodeImpl( const Reference< provider::XScriptProvider >& msp, const ::rtl::OUString& location ): m_xSP( msp )
{ {
// strip out the last leaf of location name m_sNodeName = parseLocationName( location );
// e.g. file://dir1/dir2/Blah.sxw - > Blah.sxw
::rtl::OUString temp = location;
sal_Int32 lastSlashIndex = temp.lastIndexOf( ::rtl::OUString::createFromAscii( "/" ) );
if ( ( lastSlashIndex + 1 ) < temp.getLength() )
{
temp = temp.copy( lastSlashIndex + 1 );
}
// maybe we should throw here!!!
else
{
OSL_TRACE("Something wrong with name, perhaps we should throw an exception");
}
m_sNodeName = temp ;
} }
virtual ::rtl::OUString
virtual ::rtl::OUString
SAL_CALL getName() SAL_CALL getName()
throw ( RuntimeException ) throw ( RuntimeException )
{ {
return m_sNodeName; return m_sNodeName;
} }
virtual Sequence< Reference< browse::XBrowseNode > > SAL_CALL virtual Sequence< Reference< browse::XBrowseNode > > SAL_CALL
getChildNodes() getChildNodes()
throw ( RuntimeException ) throw ( RuntimeException )
{ {
Reference < provider::XScriptProviderAccess > providerGetter( m_xSP, UNO_QUERY ); MasterScriptProvider* providerGetter = static_cast< MasterScriptProvider* >( m_xSP.get() );
Sequence< Reference< provider::XScriptProvider > > providers = providerGetter->getAllProviders(); Sequence< Reference< provider::XScriptProvider > > providers = providerGetter->getAllProviders();
Sequence< Reference< browse::XBrowseNode > > children( providers.getLength() ); Sequence< Reference< browse::XBrowseNode > > children( providers.getLength() );
for ( sal_Int32 index = 0; index < providers.getLength(); index++ ) for ( sal_Int32 index = 0; index < providers.getLength(); index++ )
...@@ -133,10 +121,116 @@ virtual sal_Int16 SAL_CALL getType() ...@@ -133,10 +121,116 @@ virtual sal_Int16 SAL_CALL getType()
{ {
return browse::BrowseNodeTypes::CONTAINER; return browse::BrowseNodeTypes::CONTAINER;
} }
private: protected:
::rtl::OUString parseLocationName( const ::rtl::OUString& location )
{
// strip out the last leaf of location name
// e.g. file://dir1/dir2/Blah.sxw - > Blah.sxw
::rtl::OUString temp = location;
sal_Int32 lastSlashIndex = temp.lastIndexOf( ::rtl::OUString::createFromAscii( "/" ) );
if ( ( lastSlashIndex + 1 ) < temp.getLength() )
{
temp = temp.copy( lastSlashIndex + 1 );
}
// maybe we should throw here!!!
else
{
OSL_TRACE("Something wrong with name, perhaps we should throw an exception");
}
return temp;
}
BrowseNodeImpl(){}
::rtl::OUString m_sNodeName; ::rtl::OUString m_sNodeName;
Reference < provider::XScriptProvider > m_xSP; Reference < provider::XScriptProvider > m_xSP;
}; };
class DocBrowseNodeImpl : public BrowseNodeImpl
{
public:
DocBrowseNodeImpl( const Reference< provider::XScriptProvider >& msp,
const Reference< frame::XModel >& xModel ) : m_xModel( xModel )
{
OSL_TRACE("DocBrowseNodeImpl() ctor");
m_sNodeName = parseLocationName( getDocNameOrURLFromModel( m_xModel ) );
m_xSP = msp;
}
virtual ::rtl::OUString SAL_CALL
getName() throw ( RuntimeException )
{
OSL_TRACE("DocBrowseNodeImpl::getName() have to change name");
if ( m_xModel->getURL().getLength() > 0 )
{
::rtl::OUString docName = parseLocationName( m_xModel->getURL() );
if ( !m_sNodeName.equals( docName ) )
{
m_sNodeName = docName;
}
}
return m_sNodeName;
}
private:
Reference< frame::XModel > m_xModel;
::rtl::OUString
getDocNameOrURLFromModel( const Reference< frame::XModel >& xModel )
{
// Set a default name, this should never be seen.
::rtl::OUString docNameOrURL;
docNameOrURL = ::rtl::OUString::createFromAscii("Unknown");
if ( xModel.is() )
{
if ( xModel->getURL().getLength() != 0)
{
docNameOrURL = xModel->getURL();
OSL_TRACE("DocBrowseNodeImpl::getDocNameOrURLFromModel() url for document %s.",
::rtl::OUStringToOString( docNameOrURL,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
else
// Untitled document
{
::rtl::OUString tempName;
try
{
Reference< beans::XPropertySet > propSet( xModel->getCurrentController()->getFrame(), UNO_QUERY );
if ( propSet.is() )
{
if ( sal_True == ( propSet->getPropertyValue(::rtl::OUString::createFromAscii( "Title" ) ) >>= tempName ) )
{
// process "UntitledX - YYYYYYYY"
// to get UntitledX
sal_Int32 pos = 0;
docNameOrURL = tempName.getToken(0,' ',pos);
OSL_TRACE("DocBrowseNodeImpl::getDocNameOrURLFromModel() Title for document is %s.",
::rtl::OUStringToOString( docNameOrURL,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
}
else
{
OSL_TRACE("DocBrowseNodeImpl::getDocNameOrURLFromModel() doc model invalid" );
}
}
catch ( Exception& e )
{
OSL_TRACE("DocBrowseNodeImpl::getDocNameOrURLFromModel() exception thrown: ",
::rtl::OUStringToOString( e.Message,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
}
}
else
{
OSL_TRACE("DocBrowseNodeImpl::getDocNameOrURLFromModel() doc model is null" );
}
return docNameOrURL;
}
};
ActiveMSPList::ActiveMSPList( const Reference< XComponentContext > & xContext ) : m_xContext( xContext ) ActiveMSPList::ActiveMSPList( const Reference< XComponentContext > & xContext ) : m_xContext( xContext )
{ {
OSL_TRACE("ActiveMSPList::ActiveMSPList) - ctor"); OSL_TRACE("ActiveMSPList::ActiveMSPList) - ctor");
...@@ -168,45 +262,37 @@ void ...@@ -168,45 +262,37 @@ void
ActiveMSPList::addActiveMSP( const Reference< frame::XModel >& xModel, ActiveMSPList::addActiveMSP( const Reference< frame::XModel >& xModel,
const Reference< dcsssf::provider::XScriptProvider >& msp ) const Reference< dcsssf::provider::XScriptProvider >& msp )
{ {
// add self as listener for document dispose
// should probably throw from this method!!, reexamine
try
{
Reference< lang::XComponent > xComponent =
Reference< lang::XComponent >( xModel, UNO_QUERY_THROW );
validateXRef( xComponent, "ActiveMSPList::addActiveMSP: model not XComponent\n" );
xComponent->addEventListener( this );
} ::osl::MutexGuard guard( m_mutex );
catch ( RuntimeException& e ) Model_map::const_iterator itr = m_mModels.find( xModel );
{ if ( itr == m_mModels.end() )
OSL_TRACE("ActiveMSPList::addActiveMSP() failed to add self as listener: %s",
::rtl::OUStringToOString( e.Message,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
::rtl::OUString doc = getDocNameOrURLFromModel( xModel );
if ( doc.getLength() != 0 )
{ {
::osl::MutexGuard guard( m_mutex ); MspInst theMsp;
Model_map::const_iterator itr = m_mModels.find( xModel ); theMsp.provider = msp;
if ( itr != m_mModels.end() ) theMsp.node = new DocBrowseNodeImpl( msp, xModel );
m_mModels[ xModel ] = theMsp;
// add self as listener for document dispose
// should probably throw from this method!!, reexamine
try
{ {
OSL_TRACE("ActiveMSPList::addActiveMSP() have MSP for model already" ); Reference< lang::XComponent > xComponent =
Reference< lang::XComponent >( xModel, UNO_QUERY_THROW );
validateXRef( xComponent, "ActiveMSPList::addActiveMSP: model not XComponent\n" );
xComponent->addEventListener( this );
} }
else catch ( RuntimeException& e )
{ {
MspInst theMsp; OSL_TRACE("ActiveMSPList::addActiveMSP() failed to add self as listener: %s",
theMsp.docName = doc; ::rtl::OUStringToOString( e.Message,
theMsp.provider = msp; RTL_TEXTENCODING_ASCII_US ).pData->buffer );
m_mModels[ xModel ] = theMsp;
} }
} }
else else
{ {
OSL_TRACE("ActiveMSPList::addActiveMSP() couldn't get document name from model" ); OSL_TRACE("ActiveMSPList::addActiveMSP() model for document exists already in map" );
} }
} }
...@@ -254,63 +340,13 @@ throw ( ::com::sun::star::uno::RuntimeException ) ...@@ -254,63 +340,13 @@ throw ( ::com::sun::star::uno::RuntimeException )
} }
} }
::rtl::OUString
ActiveMSPList::getDocNameOrURLFromModel( const Reference< frame::XModel >& xModel )
{
::rtl::OUString docNameOrURL;
if ( xModel.is() )
{
if ( xModel->getURL().getLength() != 0)
{
docNameOrURL = xModel->getURL();
OSL_TRACE("ActiveMSPList::getDocNameOrURLFromModel() url for document %s.",
::rtl::OUStringToOString( docNameOrURL,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
else
// Untitled document
{
::rtl::OUString tempName;
try
{
Reference< beans::XPropertySet > propSet( xModel->getCurrentController()->getFrame(), UNO_QUERY );
if ( propSet.is() )
{
if ( sal_True == ( propSet->getPropertyValue(::rtl::OUString::createFromAscii( "Title" ) ) >>= tempName ) )
{
// process "UntitledX - YYYYYYYY"
// to get UntitledX
sal_Int32 pos = 0;
docNameOrURL = tempName.getToken(0,' ',pos);
OSL_TRACE("ActiveMSPList::getDocNameOrURLFromModel() Title for document is %s.",
::rtl::OUStringToOString( docNameOrURL,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
}
else
{
OSL_TRACE("ActiveMSPList::getDocNameOrURLFromModel() doc model invalid" );
}
}
catch ( Exception& e )
{
OSL_TRACE("ActiveMSPList::getDocNameOrURLFromModel() exception thrown: ",
::rtl::OUStringToOString( e.Message,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
}
}
}
else
{
OSL_TRACE("ActiveMSPList::getDocNameOrURLFromModel() doc model is null" );
}
return docNameOrURL;
}
ActiveMSPList& ActiveMSPList&
ActiveMSPList::instance( const Reference< XComponentContext > & xContext ) ActiveMSPList::instance( const Reference< XComponentContext > & xContext )
{ {
static ActiveMSPList* inst = 0; static ActiveMSPList* inst = 0;
// need to not only hold a static pointer to this object but also
// keep it aqcuired
static Reference< lang::XEventListener > holder; static Reference< lang::XEventListener > holder;
if ( !inst ) if ( !inst )
{ {
...@@ -346,12 +382,18 @@ ActiveMSPList::createNonDocMSPs() ...@@ -346,12 +382,18 @@ ActiveMSPList::createNonDocMSPs()
args[ 0 ] <<= userDirString; args[ 0 ] <<= userDirString;
Reference< provider::XScriptProvider > userMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); Reference< provider::XScriptProvider > userMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
// should check if provider reference is valid // should check if provider reference is valid
m_hMsps[ userDirString ] = userMsp; MspInst userInstance;
userInstance.node = new BrowseNodeImpl( userMsp, userDirString );
userInstance.provider = userMsp;
m_hMsps[ userDirString ] = userInstance;
args[ 0 ] <<= shareDirString; args[ 0 ] <<= shareDirString;
Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY ); Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
MspInst shareInstance;
shareInstance.node = new BrowseNodeImpl( shareMsp, shareDirString );
shareInstance.provider = shareMsp;
// should check if provider reference is valid // should check if provider reference is valid
m_hMsps[ shareDirString ] = shareMsp; m_hMsps[ shareDirString ] = shareInstance;
created = true; created = true;
} }
...@@ -382,10 +424,12 @@ ActiveMSPList::getChildNodes() ...@@ -382,10 +424,12 @@ ActiveMSPList::getChildNodes()
Msp_hash::iterator h_itEnd = m_hMsps.end(); Msp_hash::iterator h_itEnd = m_hMsps.end();
Sequence< Reference< browse::XBrowseNode > > children( numChildNodes ); Sequence< Reference< browse::XBrowseNode > > children( numChildNodes );
sal_Int32 count = 0; sal_Int32 count = 0;
for ( Msp_hash::iterator h_it = m_hMsps.begin(); h_it != h_itEnd; ++h_it ) for ( Msp_hash::iterator h_it = m_hMsps.begin(); h_it != h_itEnd; ++h_it )
{ {
OSL_TRACE("Adding application browsenode index [ %d ]", count ); OSL_TRACE("Adding application browsenode index [ %d ]", count );
children[ count++ ] = new BrowseNodeImpl( h_it->second, h_it->first ); children[ count++ ] = h_it->second.node;
} }
// get providers for active documents // get providers for active documents
...@@ -394,16 +438,7 @@ ActiveMSPList::getChildNodes() ...@@ -394,16 +438,7 @@ ActiveMSPList::getChildNodes()
for ( Model_map::iterator m_it = m_mModels.begin(); m_it != m_itEnd; ++m_it ) for ( Model_map::iterator m_it = m_mModels.begin(); m_it != m_itEnd; ++m_it )
{ {
OSL_TRACE("Adding document browsenode index [ %d ]", count ); OSL_TRACE("Adding document browsenode index [ %d ]", count );
::rtl::OUString docName = m_it->second.docName; children[ count++ ] = m_it->second.node;
if ( m_it->first->getURL().getLength() > 0 )
{
if ( ! m_it->second.docName.equals( m_it->first->getURL() ) )
{
OSL_TRACE("Need to change doc name" );
m_it->second.docName = m_it->first->getURL();
}
}
children[ count++ ] = new BrowseNodeImpl( m_it->second.provider, m_it->second.docName );
} }
return children; return children;
......
...@@ -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