diff options
author | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2011-02-07 13:06:08 +0100 |
commit | bebf85efd10e676c8a9409c6ebd98a6e767d16f0 (patch) | |
tree | ab9f9265bb021e5eb6fc357e79234bba20bc4b8f /basic/source | |
parent | e4ee5496696455f7ef6657c15696f36d3da78659 (diff) | |
parent | a1a2a5a68046e75aba3dfd6ba06083a314f12182 (diff) |
removetooltypes01: Rebase to DEV300m99
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/app/appedit.cxx | 4 | ||||
-rw-r--r-- | basic/source/basmgr/basmgr.cxx | 112 |
2 files changed, 114 insertions, 2 deletions
diff --git a/basic/source/app/appedit.cxx b/basic/source/app/appedit.cxx index e51fd41ea3af..9aa06ffad38e 100644 --- a/basic/source/app/appedit.cxx +++ b/basic/source/app/appedit.cxx @@ -201,8 +201,8 @@ long AppEdit::InitMenu( Menu* pMenu ) if( pDataEdit ) { - sal_uInt16 UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount(); - sal_uInt16 RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount(); + size_t UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount(); + size_t RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount(); pMenu->EnableItem( RID_EDITUNDO, UndoCount > 0 ); pMenu->EnableItem( RID_EDITREDO, RedoCount > 0 ); diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index d1f68fed511b..bb686c765f4c 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -42,6 +42,8 @@ #include <tools/diagnose_ex.h> #include <basic/sbmod.hxx> #include <basic/sbobjmod.hxx> +#include <unotools/intlwrapper.hxx> +#include <comphelper/processfactory.hxx> #include <basic/sbuno.hxx> #include <basic/basmgr.hxx> @@ -1868,6 +1870,116 @@ bool BasicManager::LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequen return false; } + +namespace +{ + SbMethod* lcl_queryMacro( BasicManager* i_manager, String const& i_fullyQualifiedName ) + { + sal_uInt16 nLast = 0; + String sMacro = i_fullyQualifiedName; + String sLibName = sMacro.GetToken( 0, '.', nLast ); + String sModule = sMacro.GetToken( 0, '.', nLast ); + sMacro.Erase( 0, nLast ); + + IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() ); + const CollatorWrapper* pCollator = aIntlWrapper.getCollator(); + sal_uInt16 nLibCount = i_manager->GetLibCount(); + for ( sal_uInt16 nLib = 0; nLib < nLibCount; ++nLib ) + { + if ( COMPARE_EQUAL == pCollator->compareString( i_manager->GetLibName( nLib ), sLibName ) ) + { + StarBASIC* pLib = i_manager->GetLib( nLib ); + if( !pLib ) + { + i_manager->LoadLib( nLib ); + pLib = i_manager->GetLib( nLib ); + } + + if( pLib ) + { + sal_uInt16 nModCount = pLib->GetModules()->Count(); + for( sal_uInt16 nMod = 0; nMod < nModCount; ++nMod ) + { + SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod ); + if ( pMod && COMPARE_EQUAL == pCollator->compareString( pMod->GetName(), sModule ) ) + { + SbMethod* pMethod = (SbMethod*)pMod->Find( sMacro, SbxCLASS_METHOD ); + if( pMethod ) + return pMethod; + } + } + } + } + } + return 0; + } +} + +bool BasicManager::HasMacro( String const& i_fullyQualifiedName ) const +{ + return ( NULL != lcl_queryMacro( const_cast< BasicManager* >( this ), i_fullyQualifiedName ) ); +} + +ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ) +{ + SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); + ErrCode nError = 0; + if ( pMethod ) + { + if ( i_arguments ) + pMethod->SetParameters( i_arguments ); + nError = pMethod->Call( i_retValue ); + } + else + nError = ERRCODE_BASIC_PROC_UNDEFINED; + return nError; +} + +ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ) +{ + SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); + if ( !pMethod ) + return ERRCODE_BASIC_PROC_UNDEFINED; + + // arguments must be quoted + String sQuotedArgs; + String sArgs( i_commaSeparatedArgs ); + if ( sArgs.Len()<2 || sArgs.GetBuffer()[1] == '\"') + // no args or already quoted args + sQuotedArgs = sArgs; + else + { + // quote parameters + sArgs.Erase( 0, 1 ); + sArgs.Erase( sArgs.Len()-1, 1 ); + + sQuotedArgs = '('; + + sal_uInt16 nCount = sArgs.GetTokenCount(','); + for ( sal_uInt16 n=0; n<nCount; ++n ) + { + sQuotedArgs += '\"'; + sQuotedArgs += sArgs.GetToken( n, ',' ); + sQuotedArgs += '\"'; + if ( n<nCount-1 ) + sQuotedArgs += ','; + } + + sQuotedArgs += ')'; + } + + // add quoted arguments and do the call + String sCall( '[' ); + sCall += pMethod->GetName(); + sCall += sQuotedArgs; + sCall += ']'; + + SbxVariable* pRet = pMethod->GetParent()->Execute( sCall ); + if ( pRet ) + *i_retValue = *pRet; + return SbxBase::GetError(); +} + //===================================================================== class ModuleInfo_Impl : public ModuleInfoHelper |