BASIC : Add SbModule::FindMethod
Change-Id: I3418c4a3d24b3b6630d6c80a6c8aa9d4ffb7e73a Reviewed-on: https://gerrit.libreoffice.org/24346 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
parent
2ed5fa14f0
commit
c0d7dfa56c
@ -1139,8 +1139,7 @@ OUString EditorWindow::GetActualSubName( sal_uLong nLine )
|
||||
SbxArrayRef pMethods = rModulWindow.GetSbModule()->GetMethods();
|
||||
for( sal_uInt16 i=0; i < pMethods->Count(); i++ )
|
||||
{
|
||||
SbxVariable* p = dynamic_cast<SbMethod*>( pMethods->Get( i ) );
|
||||
SbMethod* pMeth = dynamic_cast<SbMethod*>( p );
|
||||
SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( i ) );
|
||||
if( pMeth )
|
||||
{
|
||||
sal_uInt16 l1,l2;
|
||||
|
@ -58,7 +58,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
|
||||
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
|
||||
}
|
||||
|
||||
if ( pModule->GetMethods()->Find( rMacroName, SbxClassType::Method ) )
|
||||
if ( pModule->FindMethod( rMacroName, SbxClassType::Method ) )
|
||||
return nullptr;
|
||||
|
||||
OUString aMacroName( rMacroName );
|
||||
@ -75,7 +75,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
|
||||
aMacroName = "Macro";
|
||||
aMacroName += OUString::number( nMacro );
|
||||
// test whether existing...
|
||||
bValid = pModule->GetMethods()->Find( aMacroName, SbxClassType::Method ) == nullptr;
|
||||
bValid = pModule->FindMethod( aMacroName, SbxClassType::Method ) == nullptr;
|
||||
nMacro++;
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
|
||||
}
|
||||
}
|
||||
|
||||
SbMethod* pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Find( aMacroName, SbxClassType::Method ));
|
||||
SbMethod* pMethod = pModule->FindMethod( aMacroName, SbxClassType::Method );
|
||||
|
||||
if( pDispatcher )
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ SbMethod* MacroChooser::GetMacro()
|
||||
if ( pEntry )
|
||||
{
|
||||
OUString aMacroName( m_pMacroBox->GetEntryText( pEntry ) );
|
||||
pMethod = static_cast<SbMethod*>(pModule->GetMethods()->Find( aMacroName, SbxClassType::Method ));
|
||||
pMethod = pModule->FindMethod( aMacroName, SbxClassType::Method );
|
||||
}
|
||||
}
|
||||
return pMethod;
|
||||
@ -370,7 +370,7 @@ SbMethod* MacroChooser::CreateMacro()
|
||||
}
|
||||
|
||||
OUString aSubName = m_pMacroNameEdit->GetText();
|
||||
DBG_ASSERT( !pModule || !pModule->GetMethods()->Find( aSubName, SbxClassType::Method ), "Macro existiert schon!" );
|
||||
DBG_ASSERT( !pModule || !pModule->FindMethod( aSubName, SbxClassType::Method ), "Macro existiert schon!" );
|
||||
pMethod = pModule ? basctl::CreateMacro( pModule, aSubName ) : nullptr;
|
||||
}
|
||||
|
||||
|
@ -579,6 +579,12 @@ SbMethod* SbModule::GetMethod( const OUString& rName, SbxDataType t )
|
||||
return pMeth;
|
||||
}
|
||||
|
||||
SbMethod* SbModule::FindMethod( const OUString& rName, SbxClassType t )
|
||||
{
|
||||
return dynamic_cast<SbMethod*> (pMethods->Find( rName, t ));
|
||||
}
|
||||
|
||||
|
||||
// request/create property
|
||||
|
||||
SbProperty* SbModule::GetProperty( const OUString& rName, SbxDataType t )
|
||||
|
@ -269,8 +269,7 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
|
||||
|
||||
// #i109184: Check if symbol is or later will be defined inside module
|
||||
SbModule& rMod = pParser->aGen.GetModule();
|
||||
SbxArray* pModMethods = rMod.GetMethods();
|
||||
if( pModMethods->Find( aSym, SbxClassType::DontCare ) )
|
||||
if( rMod.FindMethod( aSym, SbxClassType::DontCare ) )
|
||||
{
|
||||
pDef = nullptr;
|
||||
}
|
||||
|
@ -202,15 +202,9 @@ bool hasMacro( SfxObjectShell* pShell, const OUString& sLibrary, OUString& sMod,
|
||||
if ( !sMod.isEmpty() ) // we wish to find the macro is a specific module
|
||||
{
|
||||
SbModule* pModule = pBasic->FindModule( sMod );
|
||||
if ( pModule )
|
||||
if ( pModule && pModule->FindMethod( sMacro, SbxClassType::Method ))
|
||||
{
|
||||
SbxArray* pMethods = pModule->GetMethods();
|
||||
if ( pMethods )
|
||||
{
|
||||
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( sMacro, SbxClassType::Method ) );
|
||||
if ( pMethod )
|
||||
bFound = true;
|
||||
}
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
else if( SbMethod* pMethod = dynamic_cast< SbMethod* >( pBasic->Find( sMacro, SbxClassType::Method ) ) )
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
bool createCOMWrapperForIface( css::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
|
||||
void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
|
||||
const SbxArrayRef& GetMethods() { return pMethods;}
|
||||
SbMethod* FindMethod( const OUString&, SbxClassType );
|
||||
static OUString GetKeywordCase( const OUString& sKeyword );
|
||||
};
|
||||
|
||||
|
@ -361,17 +361,13 @@ namespace basprov
|
||||
SbModule* pModule = pBasic->FindModule( aModule );
|
||||
if ( pModule )
|
||||
{
|
||||
SbxArray* pMethods = pModule->GetMethods();
|
||||
if ( pMethods )
|
||||
SbMethod* pMethod = pModule->FindMethod( aMethod, SbxClassType::Method );
|
||||
if ( pMethod && !pMethod->IsHidden() )
|
||||
{
|
||||
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( aMethod, SbxClassType::Method ) );
|
||||
if ( pMethod && !pMethod->IsHidden() )
|
||||
{
|
||||
if ( m_pDocBasicManager == pBasicMgr )
|
||||
xScript = new BasicScriptImpl( aDescription, pMethod, *m_pDocBasicManager, m_xInvocationContext );
|
||||
else
|
||||
xScript = new BasicScriptImpl( aDescription, pMethod );
|
||||
}
|
||||
if ( m_pDocBasicManager == pBasicMgr )
|
||||
xScript = new BasicScriptImpl( aDescription, pMethod, *m_pDocBasicManager, m_xInvocationContext );
|
||||
else
|
||||
xScript = new BasicScriptImpl( aDescription, pMethod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2550,7 +2550,7 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
|
||||
if ( pBasic )
|
||||
{
|
||||
SbModule* pModule = pBasic->FindModule( aModuleName );
|
||||
SbMethod* pMethod = pModule ? static_cast<SbMethod*>(pModule->GetMethods()->Find(aMacroName, SbxClassType::Method)) : nullptr;
|
||||
SbMethod* pMethod = pModule ? pModule->FindMethod(aMacroName, SbxClassType::Method) : nullptr;
|
||||
if (pMethod)
|
||||
{
|
||||
aOUSource = pModule->GetSource32();
|
||||
|
Loading…
x
Reference in New Issue
Block a user