Kaydet (Commit) c0d7dfa5 authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Noel Grandin

BASIC : Add SbModule::FindMethod

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