diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-11-04 10:36:15 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-11-04 10:36:15 +0100 |
commit | 9d30af3dab07e35b3a02218a693ebd349803d495 (patch) | |
tree | 8ee3fc245ca2902e20ebc5911344c248967660c0 /scripting/source/storage/ScriptStorageManager.cxx | |
parent | af22075998a021d23ec1b266433f239d3200c35d (diff) |
undoapi: replace validateXRef with UNO_QUERY/SET_THROW resp. ENSURE_OR_THROW
Diffstat (limited to 'scripting/source/storage/ScriptStorageManager.cxx')
-rw-r--r-- | scripting/source/storage/ScriptStorageManager.cxx | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx index 77ca5a45dd15..424f2752bc47 100644 --- a/scripting/source/storage/ScriptStorageManager.cxx +++ b/scripting/source/storage/ScriptStorageManager.cxx @@ -45,6 +45,7 @@ #include "ScriptStorageManager.hxx" #include <util/util.hxx> #include <util/scriptingconstants.hxx> +#include <tools/diagnose_ex.h> using namespace ::rtl; using namespace ::com::sun::star; @@ -70,32 +71,19 @@ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceNam // ScriptStorageManager Constructor ScriptStorageManager::ScriptStorageManager( const Reference< XComponentContext > & xContext ) SAL_THROW ( ( RuntimeException ) ) - : m_xContext( xContext ), m_count( 0 ), m_securityMgr( xContext ) + : m_xContext( xContext, UNO_SET_THROW ), m_count( 0 ), m_securityMgr( xContext ) { OSL_TRACE( "< ScriptStorageManager ctor called >\n" ); //s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); - validateXRef( m_xContext, - "ScriptStorageManager::ScriptStorageManager : cannot get component context" ); - - m_xMgr = m_xContext->getServiceManager(); - validateXRef( m_xMgr, - "ScriptStorageManager::ScriptStorageManager : cannot get service manager" ); + m_xMgr.set( m_xContext->getServiceManager(), UNO_SET_THROW ); try { // obtain the macro expander singleton to use in determining the // location of the application script storage - Any aAny = m_xContext->getValueByName( OUString::createFromAscii( - "/singletons/com.sun.star.util.theMacroExpander" ) ); - Reference< util::XMacroExpander > xME; - if ( sal_False == ( aAny >>= xME ) ) - { - throw RuntimeException( - OUSTR( "ScriptStorageManager::ScriptStorageManager: can't get XMacroExpander" ), - Reference< XInterface >() ); - } - validateXRef( xME, "ScriptStorageManager constructor: can't get MacroExpander" ); + Reference< util::XMacroExpander > xME( m_xContext->getValueByName( OUString::createFromAscii( + "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY_THROW ); OUString base = OUString::createFromAscii( SAL_CONFIGFILE( "${$BRAND_BASE_DIR/program/bootstrap" ) ); @@ -126,12 +114,13 @@ SAL_THROW ( ( RuntimeException ) ) { try { - Reference< XInterface > xInterface = + Reference< ucb::XSimpleFileAccess > xSFA( m_xMgr->createInstanceWithContext( - OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext ); - validateXRef( xInterface, - "ScriptStorageManager constructor: can't get SimpleFileAccess XInterface" ); - Reference< ucb::XSimpleFileAccess > xSFA( xInterface, UNO_QUERY_THROW ); + OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), + m_xContext + ), + UNO_QUERY_THROW + ); setupAnyStorage( xSFA, xME->expandMacros( storageStr ), appStr ); } @@ -168,13 +157,14 @@ SAL_THROW ( ( RuntimeException ) ) ::rtl::OUStringToOString( storageStr, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - Reference< XInterface > xInterface = + Reference< XInterface > xInterface( m_xMgr->createInstanceWithArgumentsAndContext( - OUString::createFromAscii( - "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), - aArgs, m_xContext ); - - validateXRef( xInterface, "ScriptStorageManager:: setupAnyStorage: Can't create ScriptStorage for share" ); + OUString::createFromAscii( "drafts.com.sun.star.script.framework.storage.ScriptStorage" ), + aArgs, + m_xContext + ), + UNO_QUERY_THROW + ); // and place it in the hash_map. Increment the counter m_ScriptStorageMap[ m_count++ ] = xInterface; @@ -215,8 +205,7 @@ ScriptStorageManager::createScriptStorage( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorage\n" ); - validateXRef( xSFA, - "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); return setupAnyStorage( xSFA, ::rtl::OUString::createFromAscii( "" ), ::rtl::OUString::createFromAscii( "" ) ); @@ -229,7 +218,7 @@ ScriptStorageManager::createScriptStorageWithURI( throw ( RuntimeException ) { OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorageWithURI\n" ); - validateXRef( xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); + ENSURE_OR_THROW( xSFA.is(), "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" ); // related to issue 11866 // warning dialog gets launched when adding binding to script in doc @@ -313,7 +302,7 @@ throw( RuntimeException ) OUSTR( "ScriptStorageManager::getScriptStorage: invalid storage ID" ), Reference< XInterface >() ); } - validateXRef( itr->second, + ENSURE_OR_THROW( itr->second.is(), "ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash" ); return itr->second; } |