[Libreoffice-commits] core.git: basctl/source basic/source filter/source include/basic scripting/source sfx2/source

Arnaud Versini arnaud.versini at gmail.com
Sun Jun 12 07:43:29 UTC 2016


 basctl/source/basicide/baside2b.cxx    |    3 +--
 basctl/source/basicide/basobj3.cxx     |    6 +++---
 basctl/source/basicide/macrodlg.cxx    |    4 ++--
 basic/source/classes/sbxmod.cxx        |    6 ++++++
 basic/source/comp/exprtree.cxx         |    3 +--
 filter/source/msfilter/msvbahelper.cxx |   10 ++--------
 include/basic/sbmod.hxx                |    1 +
 scripting/source/basprov/basprov.cxx   |   16 ++++++----------
 sfx2/source/view/viewfrm.cxx           |    2 +-
 9 files changed, 23 insertions(+), 28 deletions(-)

New commits:
commit c0d7dfa56c8a335bdea1be2ddce33a0f19b28bbd
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Apr 24 21:00:05 2016 +0200

    BASIC : Add SbModule::FindMethod
    
    Change-Id: I3418c4a3d24b3b6630d6c80a6c8aa9d4ffb7e73a
    Reviewed-on: https://gerrit.libreoffice.org/24346
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e9f9ace..7b31978 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -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;
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 3d3b9c4..5aee287 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -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 )
     {
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 2072c74..a8ad232 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -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;
     }
 
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 375678f..ef6a679 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -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 )
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index f39bb76..179aaf3 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -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;
         }
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index 49e6190..dc86a4e 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -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 ) ) )
diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx
index 23ef220..3727d1d 100644
--- a/include/basic/sbmod.hxx
+++ b/include/basic/sbmod.hxx
@@ -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 );
 };
 
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 49ba354..185c4f9 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -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 );
                         }
                     }
                 }
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index fc96248..28ea8f5 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -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();


More information about the Libreoffice-commits mailing list