diff options
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 3 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 106 | ||||
-rw-r--r-- | basic/source/comp/dim.cxx | 5 |
3 files changed, 77 insertions, 37 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 68f16a12216e..78932cfe2e92 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -53,6 +53,7 @@ class SvxSearchItem; #include <vcl/textdata.hxx> #include <basic/codecompletecache.hxx> +#include "com/sun/star/reflection/XIdlClass.hpp" namespace com { namespace sun { namespace star { namespace beans { class XMultiPropertySet; @@ -119,6 +120,8 @@ private: CodeCompleteDataCache aCodeCompleteCache; boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number + std::vector< OUString > GetXIdlClassMethods( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const; + std::vector< OUString > GetXIdlClassFields( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const; protected: virtual void Paint( const Rectangle& ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index fd69045302f0..adcfd0be8d26 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -510,10 +510,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) if( pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn() ) { - std::cerr << "EditorWindow::KeyInput" << std::endl; + //std::cerr << "EditorWindow::KeyInput" << std::endl; pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt); if( rKEvt.GetKeyCode().GetCode() == KEY_UP - || rKEvt.GetKeyCode().GetCode() == KEY_DOWN ) + || rKEvt.GetKeyCode().GetCode() == KEY_DOWN + || rKEvt.GetKeyCode().GetCode() == KEY_TAB ) return; } @@ -672,7 +673,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) } } - if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() ) + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && + (CodeCompleteOptions::IsCodeCompleteOn() || CodeCompleteOptions::IsExtendedTypeDeclaration()) ) { rModulWindow.UpdateModule(); rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache); @@ -688,7 +690,10 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) for ( size_t i = 0; i < aPortions.size(); i++ ) { HighlightPortion& r = aPortions[i]; - if( r.tokenType == 1 ) // extract the identifers(methods, base variable) + if( r.tokenType == 1 || r.tokenType == 9) // extract the identifers(methods, base variable) + /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue + * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!) + * */ aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) ); } @@ -716,39 +721,51 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) while( j != aVect.size() ) { sMethName = aVect[j]; - Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName ); - if( xMethod != NULL ) //method OK + Reference< reflection::XIdlField> xField = xClass->getField( sMethName ); + if( xField != NULL ) { - xClass = xMethod->getReturnType(); + xClass = xField->getType(); if( xClass == NULL ) + { break; + } } else { - bReflect = false; - break; + if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) + { + Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName ); + if( xMethod != NULL ) //method OK + { + xClass = xMethod->getReturnType(); + if( xClass == NULL ) + { + break; + } + } + else + {//nothing to reflect + bReflect = false; + break; + } + } + else + {// no extended types allowed + bReflect = false; + break; + } } j++; } if( bReflect ) { - Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); - Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields(); - std::vector< OUString > aEntryVect; - - if( aMethods.getLength() != 0 ) - { - for(sal_Int32 l = 0; l < aMethods.getLength(); ++l) - { - aEntryVect.push_back(OUString(aMethods[l]->getName())); - } - } - if( aFields.getLength() != 0 ) - { - for(sal_Int32 l = 0; l < aFields.getLength(); ++l) - { - aEntryVect.push_back(OUString(aFields[l]->getName())); - } + std::vector< OUString > aEntryVect;//entries to be inserted into the list + std::vector< OUString > aMethVect = GetXIdlClassMethods(xClass);//methods + std::vector< OUString > aFieldVect = GetXIdlClassFields(xClass);//fields + aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() ); + if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) + {// if extended types on, reflect classes, else just the structs (XIdlClass without methods) + aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() ); } if( aEntryVect.size() > 0 ) { @@ -772,7 +789,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) pCodeCompleteWnd->ResizeListBox(); pCodeCompleteWnd->SelectFirstEntry(); pEditView->GetWindow()->GrabFocus(); - //pEditView->EnableCursor( true ); } } } @@ -822,6 +838,34 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) } } +std::vector< OUString > EditorWindow::GetXIdlClassMethods( Reference< reflection::XIdlClass > xClass ) const +{ + Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); + std::vector< OUString > aRetVect; + if( aMethods.getLength() != 0 ) + { + for(sal_Int32 l = 0; l < aMethods.getLength(); ++l) + { + aRetVect.push_back(OUString(aMethods[l]->getName())); + } + } + return aRetVect; +} + +std::vector< OUString > EditorWindow::GetXIdlClassFields( Reference< reflection::XIdlClass > xClass ) const +{ + Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields(); + std::vector< OUString > aRetVect; + if( aFields.getLength() != 0 ) + { + for(sal_Int32 l = 0; l < aFields.getLength(); ++l) + { + aRetVect.push_back(OUString(aFields[l]->getName())); + } + } + return aRetVect; +} + void EditorWindow::Paint( const Rectangle& rRect ) { if ( !pEditEngine ) // We need it now at latest @@ -2620,7 +2664,7 @@ void CodeCompleteListBox::SetVisibleEntries() void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) { - std::cerr << "CodeCompleteListBox::KeyInput" << std::endl; + //std::cerr << "CodeCompleteListBox::KeyInput" << std::endl; sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode(); if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) ) { @@ -2654,13 +2698,9 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) InsertSelectedEntry(); break; case KEY_UP: case KEY_DOWN: - std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl; - //GrabFocus(); + //std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl; NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt ); PreNotify(nEvt); - //pCodeCompleteWindow->pParent->GrabFocus(); - //SetVisibleEntries(); - //pCodeCompleteWindow->pParent->GrabFocus(); break; } } diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 9a030ccff85a..2b94c397ef52 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -405,12 +405,9 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic ) if( !bCompatible && !pDef->IsNew() ) { OUString aTypeName( aGblStrings.Find( pDef->GetTypeId() ) ); - /*std::cerr <<"CodeCompleteOptions::IsExtendedTypeDeclaration():" << CodeCompleteOptions::IsExtendedTypeDeclaration() << std::endl; - std::cerr << "IsUnoInterface("<<aTypeName<<"):"<< IsUnoInterface(aTypeName) << std::endl; - std::cerr << "finally: " << (CodeCompleteOptions::IsExtendedTypeDeclaration() && !IsUnoInterface(aTypeName)) << std::endl;*/ if( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) == NULL ) { - if(!CodeCompleteOptions::IsExtendedTypeDeclaration()) + if(!CodeCompleteOptions::IsCodeCompleteOn()) Error( SbERR_UNDEF_TYPE, aTypeName ); else { |