summaryrefslogtreecommitdiff
path: root/basctl/source
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-19 22:00:29 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-19 22:00:29 +0200
commit1ca65c728b36daa93eba550d22bd2b6959d9d454 (patch)
tree1cbc4028c22b239f3d9abf8108f035bf35dbe07e /basctl/source
parent002622077bedfc5e1ec4f65bbb57806221d407ff (diff)
GSOC work, code fixes + cache implementation
WARNING: cache implementation gives a link error to it's methods. Created the cache called CodeCompleteDataCache in file include/basic/codecompletecache.hxx This class should replace the std::vector< CodeCompleteData > int file baside2b.cxx When issuing command "make basic", it compiles fine, but, when "make basctl", it gives a link error (ld returned status 1) to CodeCompleteDataCache's methods. Change-Id: If78c6533b7fb5653cc459d22b80c98d097b886eb
Diffstat (limited to 'basctl/source')
-rw-r--r--basctl/source/basicide/baside2.hxx16
-rw-r--r--basctl/source/basicide/baside2b.cxx107
2 files changed, 84 insertions, 39 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8bb34cf6f5ed..8f361bed7ead 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -52,6 +52,7 @@ class SvxSearchItem;
#include <boost/scoped_ptr.hpp>
#include <vcl/textdata.hxx>
+#include <basic/codecompletecache.hxx>
namespace com { namespace sun { namespace star { namespace beans {
class XMultiPropertySet;
@@ -114,8 +115,10 @@ private:
virtual
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(sal_Bool bCreate = true);
- std::vector< CodeCompleteData > aCodeCompleteCache;
- CodeCompleteWindow* pCodeCompleteWnd;
+ //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
protected:
@@ -492,8 +495,9 @@ public:
void ResizeListBox();
void SelectFirstEntry(); //selects first entry in ListBox
-protected:
- virtual void KeyInput( const KeyEvent& rKeyEvt );
+/*protected:
+ //virtual void KeyInput( const KeyEvent& rKeyEvt );
+ virtual void LoseFocus();*/
};
class CodeCompleteListBox: public ListBox
@@ -520,6 +524,10 @@ public:
DECL_LINK(ImplDoubleClickHdl, void*);
virtual long PreNotify( NotifyEvent& rNEvt );
+
+/*protected:
+ virtual void LoseFocus();*/
+
};
} // namespace basctl
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 3c8fbbe523bc..6c099c865d71 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -232,7 +232,8 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) :
nCurTextWidth(0),
bHighlightning(false),
bDoSyntaxHighlight(true),
- bDelayHighlight(true)
+ bDelayHighlight(true),
+ pCodeCompleteWnd(new CodeCompleteWindow(this))
{
SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor()));
SetPointer( Pointer( POINTER_TEXT ) );
@@ -250,9 +251,6 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) :
s[0] = OUString( "FontHeight" );
s[1] = OUString( "FontName" );
n->addPropertiesChangeListener(s, listener_.get());
- //aListBox = new CodeCompleteListBox(this);
- //pCodeCopleteWnd = new CodeCompleteWindow(this);
- pCodeCompleteWnd = new CodeCompleteWindow( this );
}
@@ -274,8 +272,6 @@ EditorWindow::~EditorWindow()
EndListening( *pEditEngine );
pEditEngine->RemoveView(pEditView.get());
}
-
- delete pCodeCompleteWnd;
}
OUString EditorWindow::GetWordAtCursor()
@@ -504,7 +500,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
TextSelection aSel = GetEditView()->GetSelection();
sal_uLong nLine = aSel.GetStart().GetPara();
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
- OUString aStr = aLine.copy( std::max(aLine.lastIndexOf(" "), aLine.lastIndexOf("\t"))+1 ); // variable name
OUString sActSub = GetActualSubName( nLine );
std::vector< OUString > aVect;
@@ -516,18 +511,22 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
if( r.tokenType == 1 ) // extract the identifers(methods, base variable)
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
}
- OUString sBaseName = aVect[0];
- for( unsigned int i = 0; i < aCodeCompleteCache.size(); ++i)
- {
- if( aCodeCompleteCache[i].sVarName.equalsIgnoreAsciiCase( sBaseName ) &&
+ 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 );
if( xRefl.is() )
{
- Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[i].sVarType);//get the base class for reflection
+ Reference< reflection::XIdlClass > xClass = xRefl->forName(sVarType);//get the base class for reflection
if( xClass != NULL )
{
unsigned int j = 1;
@@ -552,8 +551,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
if( aMethods.getLength() != 0 )
{
Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false );
- //GetEditView()->EnableCursor( false );
-
aSel.GetStart().GetIndex() += 1;
aSel.GetEnd().GetIndex() += 1;
pCodeCompleteWnd->ClearListBox();
@@ -564,15 +561,16 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
{
pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) );
}
- pCodeCompleteWnd->ResizeListBox();
pCodeCompleteWnd->Show();
+ pCodeCompleteWnd->ResizeListBox();
pCodeCompleteWnd->SelectFirstEntry();
}
}
}
- break;
}
- }
+ /*break;
+ }*/
+ //}
}
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
{
@@ -834,12 +832,12 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
ParagraphInsertedDeleted( rTextHint.GetValue(), true );
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
rModulWindow.UpdateModule();
- aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse();
+ aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
}
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
{
ParagraphInsertedDeleted( rTextHint.GetValue(), false );
- aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse();
+ aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
}
else if( rTextHint.GetId() == TEXT_HINT_PARACONTENTCHANGED )
{
@@ -855,7 +853,7 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
else if( rTextHint.GetId() == TEXT_HINT_MODIFIED )
{
- aCodeCompleteCache = rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse();
+ aCodeCompleteCache.SetVars(rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse().GetVars());
}
}
}
@@ -878,7 +876,7 @@ OUString EditorWindow::GetActualSubName( sal_uLong nLine )
}
}
}
- return OUString("");
+ return aCodeCompleteCache.GLOB_KEY;
}
void EditorWindow::SetScrollBarRanges()
@@ -2357,7 +2355,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar )
-: ListBox(pPar, WB_SORT | WB_BORDER),
+: ListBox(pPar, WB_SORT | WB_BORDER ),
pCodeCompleteWindow(pPar)
{
SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
@@ -2376,7 +2374,7 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
void CodeCompleteListBox::InsertSelectedEntry()
{
- if( GetEntry( GetSelectEntryPos() ) != OUString("") )
+ if( aFuncBuffer.toString() != OUString("") )
{
// if the user typed in something: remove, and insert
TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength());
@@ -2384,16 +2382,35 @@ void CodeCompleteListBox::InsertSelectedEntry()
pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
- pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
- pCodeCompleteWindow->Hide();
- pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- pCodeCompleteWindow->pParent->GrabFocus();
+ if( GetEntry( GetSelectEntryPos() ) != OUString("") )
+ {//if the user selected something
+ pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
+ pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+ pCodeCompleteWindow->pParent->GrabFocus();
+ }
+ else
+ {
+ pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+ pCodeCompleteWindow->pParent->GrabFocus();
+ }
+ }
+ else
+ {
+ if( GetEntry( GetSelectEntryPos() ) != OUString("") )
+ {//if the user selected something
+ pCodeCompleteWindow->pParent->GetEditView()->InsertText( (OUString) GetEntry(GetSelectEntryPos()), sal_True );
+ pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+ pCodeCompleteWindow->pParent->GrabFocus();
+ }
}
}
long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
{
- if( ( rNEvt.GetType() == EVENT_KEYINPUT ) )
+ if( rNEvt.GetType() == EVENT_KEYINPUT )
{
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode();
@@ -2439,6 +2456,11 @@ 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 );
}
@@ -2454,12 +2476,19 @@ void CodeCompleteListBox::SetVisibleEntries()
}
}
+/*void CodeCompleteListBox::LoseFocus()
+{
+ std::cerr << "CodeCompleteListBox::LoseFocus" << std::endl;
+ Window::LoseFocus();
+ //pCodeCompleteWindow->Hide();
+}*/
+
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
-: Window( pPar, WB_BORDER ),
+: Window( pPar ),
pParent(pPar)
{
+ SetSizePixel( Size(151,151) ); //default, later it changes
InitListBox();
- SetSizePixel( Size(150,150) ); //default, later it changes
}
void CodeCompleteWindow::InitListBox()
@@ -2467,7 +2496,7 @@ void CodeCompleteWindow::InitListBox()
pListBox = new CodeCompleteListBox( this );
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
pListBox->Show();
- pListBox->GrabFocus();
+ //pListBox->GrabFocus();
}
CodeCompleteWindow::~CodeCompleteWindow()
@@ -2487,15 +2516,14 @@ 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
- //pParent->GetEditView()->EnableCursor( true );
Hide();
}
-}
+}*/
void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel )
{
@@ -2525,8 +2553,11 @@ void CodeCompleteWindow::ResizeListBox()
aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(),pListBox->GetEntryCount()).getWidth() );
pListBox->SetSizePixel( aSize );
+ aSize.setWidth( aSize.getWidth() + 1 );
+ aSize.setHeight( aSize.getHeight() + 1 );
SetSizePixel( aSize );
}
+ //pListBox->GrabFocus();
}
void CodeCompleteWindow::SelectFirstEntry()
@@ -2534,10 +2565,16 @@ void CodeCompleteWindow::SelectFirstEntry()
if( pListBox->GetEntryCount() > 0 )
{
pListBox->SelectEntryPos( 0 );
- pListBox->GrabFocus();
}
+ //pListBox->GrabFocus();
}
+/*void CodeCompleteWindow::LoseFocus()
+{
+ std::cerr << "CodeCompleteWindow::LoseFocus" << std::endl;
+ Window::LoseFocus();
+}*/
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */