diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-07-20 13:03:42 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:46 +0200 |
commit | 6165d0b4846590d1d85d559636dd6587ea0dadd8 (patch) | |
tree | dedff6fd0d6387b4edd9a17653580a72a549e85c /basctl | |
parent | 6c1854f9f3f7308dce0e326aa063d929f8da5881 (diff) |
GSOC work, some code fixes
Fixed the link error: declared CodeCompleteDataCache as BASIC_DLLPUBLIC and it worked fine.
Fixed sergmentation fault error in CodeCompleteWindow.
The new cache implementation is fully functional.
CodeCompleteWindow is now being used as boost::scoped_ptr.
Change-Id: I76a0fc7407d589e7f94280fc4d50cea51b9639db
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 55 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 149 |
2 files changed, 76 insertions, 128 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 8f361bed7ead..eaf700bdb5b2 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -115,9 +115,7 @@ private: virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface(sal_Bool bCreate = true); - //std::vector< CodeCompleteData > aCodeCompleteCache; CodeCompleteDataCache aCodeCompleteCache; - //CodeCompleteWindow* pCodeCompleteWnd; boost::scoped_ptr< CodeCompleteWindow > pCodeCompleteWnd; OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number @@ -474,32 +472,6 @@ private: } aSyntaxColors; }; -class CodeCompleteWindow: public Window -{ -friend class CodeCompleteListBox; -private: - EditorWindow* pParent; // parent window - TextSelection aTextSelection; - CodeCompleteListBox* pListBox; - - void InitListBox(); // initialize the ListBox - -public: - CodeCompleteWindow( EditorWindow* pPar ); - virtual ~CodeCompleteWindow(); - - void InsertEntry( const OUString& aStr ); - void ClearListBox(); - void SetTextSelection( const TextSelection& aSel ); - const TextSelection& GetTextSelection() const; - void ResizeListBox(); - void SelectFirstEntry(); //selects first entry in ListBox - -/*protected: - //virtual void KeyInput( const KeyEvent& rKeyEvt ); - virtual void LoseFocus();*/ -}; - class CodeCompleteListBox: public ListBox { friend class CodeCompleteWindow; @@ -517,16 +489,35 @@ private: void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable public: - CodeCompleteListBox(CodeCompleteWindow* pPar); - virtual ~CodeCompleteListBox(); + CodeCompleteListBox( CodeCompleteWindow* pPar ); void InsertSelectedEntry(); //insert the selected entry DECL_LINK(ImplDoubleClickHdl, void*); virtual long PreNotify( NotifyEvent& rNEvt ); -/*protected: - virtual void LoseFocus();*/ +}; + +class CodeCompleteWindow: public Window +{ +friend class CodeCompleteListBox; +private: + EditorWindow* pParent; // parent window + TextSelection aTextSelection; + CodeCompleteListBox* pListBox; + + void InitListBox(); // initialize the ListBox + +public: + CodeCompleteWindow( EditorWindow* pPar ); + ~CodeCompleteWindow(){ delete pListBox; } + + void InsertEntry( const OUString& aStr ); + void ClearListBox(); + void SetTextSelection( const TextSelection& aSel ); + const TextSelection& GetTextSelection() const; + void ResizeListBox(); + void SelectFirstEntry(); //selects first entry in ListBox }; diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 513894baef55..d3006427939d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -518,65 +518,57 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) ); } OUString sBaseName = aVect[0];//variable name - OUString sVarType = aCodeCompleteCache.GetVariableType(sBaseName, sActSub); - - /*for( unsigned int i = 0; i < aCodeCompleteCache.size(); ++i) - {*/ - /*if( aCodeCompleteCache[i].sVarName.equalsIgnoreAsciiCase( sBaseName ) && - ( aCodeCompleteCache[i].sVarParent == sActSub || aCodeCompleteCache[i].IsGlobal() ) ) - {*/ - if( sVarType != aCodeCompleteCache.NOT_FOUND ) - { - Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); - Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); + OUString sVarType = aCodeCompleteCache.GetVariableType(sBaseName, aCodeCompleteCache.GLOB_KEY); + if( sVarType == aCodeCompleteCache.NOT_FOUND ) + sVarType = aCodeCompleteCache.GetVariableType(sBaseName, sActSub); + + Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); + Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); - if( xRefl.is() ) + if( xRefl.is() ) + { + Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection + if( xClass != NULL ) + { + unsigned int j = 1; + OUString sMethName; + while( j != aVect.size() ) { - Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection - if( xClass != NULL ) + sMethName = aVect[j]; + Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName ); + if( xMethod != NULL ) //method OK { - unsigned int j = 1; - OUString sMethName; - while( j != aVect.size() ) - { - sMethName = aVect[j]; - Reference< reflection::XIdlMethod> xMethod = xClass->getMethod( sMethName ); - if( xMethod != NULL ) //method OK - { - xClass = xMethod->getReturnType(); - if( xClass == NULL ) - break; - } - else - { - break; - } - j++; - } - Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); - if( aMethods.getLength() != 0 ) - { - Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false ); - aSel.GetStart().GetIndex() += 1; - aSel.GetEnd().GetIndex() += 1; - pCodeCompleteWnd->ClearListBox(); - pCodeCompleteWnd->SetTextSelection(aSel); - - pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() ); - for(sal_Int32 l = 0; l < aMethods.getLength(); ++l) - { - pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) ); - } - pCodeCompleteWnd->Show(); - pCodeCompleteWnd->ResizeListBox(); - pCodeCompleteWnd->SelectFirstEntry(); - } + xClass = xMethod->getReturnType(); + if( xClass == NULL ) + break; + } + else + { + break; + } + j++; + } + Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods(); + if( aMethods.getLength() != 0 ) + { + Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false ); + aSel.GetStart().GetIndex() += 1; + aSel.GetEnd().GetIndex() += 1; + pCodeCompleteWnd->ClearListBox(); + pCodeCompleteWnd->SetTextSelection(aSel); + + pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() ); + for(sal_Int32 l = 0; l < aMethods.getLength(); ++l) + { + pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) ); } + pCodeCompleteWnd->Show(); + pCodeCompleteWnd->ResizeListBox(); + pCodeCompleteWnd->SelectFirstEntry(); } } - /*break; - }*/ - //} + } + } if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) ) { @@ -843,6 +835,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED ) { ParagraphInsertedDeleted( rTextHint.GetValue(), false ); + rModulWindow.UpdateModule(); aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); } else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED ) @@ -859,6 +852,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } else if( rTextHint.GetId() == TEXT_HINT_MODIFIED ) { + rModulWindow.UpdateModule(); aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars()); } } @@ -878,6 +872,7 @@ OUString EditorWindow::GetActualSubName( sal_uLong nLine ) pMeth->GetLineRange(l1,l2); if( (l1 <= nLine+1) && (nLine+1 <= l2) ) { + //std::cerr << "sName: " << sName << std::endl; return sName; } } @@ -2362,16 +2357,11 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped ) CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar ) : ListBox(pPar, WB_SORT | WB_BORDER ), -pCodeCompleteWindow(pPar) +pCodeCompleteWindow( pPar ) { SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl)); } -CodeCompleteListBox::~CodeCompleteListBox() -{ - delete pCodeCompleteWindow; -} - IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) { InsertSelectedEntry(); @@ -2434,7 +2424,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) case KEY_ESCAPE: // hide, do nothing pCodeCompleteWindow->Hide(); pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); - pCodeCompleteWindow->pParent->GrabFocus(); + //pCodeCompleteWindow->pParent->GrabFocus(); return 0; case KEY_TAB: case KEY_SPACE: /* space, tab the user probably have typed in the whole @@ -2462,11 +2452,6 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt ) } } } - /*if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) - { - //MouseEvent rMEvt = *rNEvt.GetMouseEvent(); - std::cerr << "parent active: " << (pCodeCompleteWindow->pParent->IsActive() == sal_True) << std::endl; - }*/ return ListBox::PreNotify( rNEvt ); } @@ -2482,16 +2467,10 @@ void CodeCompleteListBox::SetVisibleEntries() } } -/*void CodeCompleteListBox::LoseFocus() -{ - std::cerr << "CodeCompleteListBox::LoseFocus" << std::endl; - Window::LoseFocus(); - //pCodeCompleteWindow->Hide(); -}*/ - CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar ) : Window( pPar ), -pParent(pPar) +pParent( pPar ), +pListBox( new CodeCompleteListBox(this) ) { SetSizePixel( Size(151,151) ); //default, later it changes InitListBox(); @@ -2499,15 +2478,9 @@ pParent(pPar) void CodeCompleteWindow::InitListBox() { - pListBox = new CodeCompleteListBox( this ); pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length pListBox->Show(); - //pListBox->GrabFocus(); -} - -CodeCompleteWindow::~CodeCompleteWindow() -{ - delete pListBox; + pListBox->GrabFocus(); } void CodeCompleteWindow::InsertEntry( const OUString& aStr ) @@ -2522,14 +2495,6 @@ void CodeCompleteWindow::ClearListBox() pListBox->aEntryVect.clear(); pListBox->aFuncBuffer.makeStringAndClear(); } -/* -void CodeCompleteWindow::KeyInput( const KeyEvent& rKeyEvt ) -{ - if( rKeyEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) - {// ESC key closes the window: does not modify anything - Hide(); - } -}*/ void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel ) { @@ -2563,7 +2528,6 @@ void CodeCompleteWindow::ResizeListBox() aSize.setHeight( aSize.getHeight() + 1 ); SetSizePixel( aSize ); } - //pListBox->GrabFocus(); } void CodeCompleteWindow::SelectFirstEntry() @@ -2572,15 +2536,8 @@ void CodeCompleteWindow::SelectFirstEntry() { pListBox->SelectEntryPos( 0 ); } - //pListBox->GrabFocus(); } -/*void CodeCompleteWindow::LoseFocus() -{ - std::cerr << "CodeCompleteWindow::LoseFocus" << std::endl; - Window::LoseFocus(); -}*/ - } // namespace basctl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |