summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-06-24 16:02:24 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-06-24 16:02:24 +0200
commit2274cfb182e1c254b1ecd07d93bad6b421734316 (patch)
treedb3f8f1eca9d5531a50d903e38b1c284aaed1602
parent035be6eb0de0b02796ee73940817278f5007e112 (diff)
GSOC work week 3, showing methods in a ListBox
This patch allows the Code Completition feature to list methods in a custom ListBox class called CodeCompleteListBox. So, when the user presses the dot("."), a ListBox appears, and listed the methods(not just prints on the terminal). The user can select one from them, and it is put in the source code (after the dot). Change-Id: Ie5165e7bdaae1d96bbf40a9b996ca8ebbdb40dea
-rw-r--r--basctl/source/basicide/baside2.hxx14
-rw-r--r--basctl/source/basicide/baside2b.cxx46
2 files changed, 54 insertions, 6 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index fb48ae3202d4..774995de29dc 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -41,6 +41,7 @@ class SvxSearchItem;
#include <vcl/split.hxx>
#include <svl/lstner.hxx>
#include <svtools/colorcfg.hxx>
+#include "vcl/lstbox.hxx"
#include <sfx2/progress.hxx>
#include <unotools/options.hxx>
@@ -57,6 +58,7 @@ namespace basctl
{
class ObjectCatalog;
+class CodeCompleteListBox;
DBG_NAMEEX( ModulWindow )
@@ -109,6 +111,7 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
GetComponentInterface(sal_Bool bCreate = true);
std::vector< CodeCompleteData > aCodeCompleteCache;
+ CodeCompleteListBox* aListBox;
protected:
virtual void Paint( const Rectangle& );
@@ -463,6 +466,17 @@ private:
} aSyntaxColors;
};
+class CodeCompleteListBox: public ListBox
+{
+private:
+ EditorWindow* pParent; // parent window
+ DECL_LINK(ImplSelectHdl, void*);
+
+public:
+ CodeCompleteListBox(EditorWindow* pPar);
+ virtual ~CodeCompleteListBox();
+};
+
} // namespace basctl
#endif // BASCTL_BASIDE2_HXX
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index afde04026ee0..5d9daf281846 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -250,6 +250,7 @@ EditorWindow::EditorWindow (Window* pParent, ModulWindow* pModulWindow) :
s[0] = OUString( "FontHeight" );
s[1] = OUString( "FontName" );
n->addPropertiesChangeListener(s, listener_.get());
+ aListBox = new CodeCompleteListBox(this);
}
@@ -271,6 +272,7 @@ EditorWindow::~EditorWindow()
EndListening( *pEditEngine );
pEditEngine->RemoveView(pEditView.get());
}
+ delete aListBox;
}
OUString EditorWindow::GetWordAtCursor()
@@ -507,13 +509,27 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
{
Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW );
Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW );
- Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[j].sVarType);
- if( !xRefl.is() )
- break;
- Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
- for(sal_Int32 i = 0; i < aMethods.getLength(); ++i)
+ if( xRefl.is() )
{
- SAL_WARN("method information",aMethods[i]->getName());
+ Reference< reflection::XIdlClass > xClass = xRefl->forName(aCodeCompleteCache[j].sVarType);
+ if( xClass != NULL )
+ {
+ Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
+ aListBox->Clear();
+ for(sal_Int32 i = 0; i < aMethods.getLength(); ++i)
+ {
+ aListBox->InsertEntry( OUString(aMethods[i]->getName()) );
+ SAL_WARN("method information", aMethods[i]->getName());
+ }
+ aListBox->EnableAutoSize(true);
+ aListBox->Show();
+ aListBox->GetFocus();
+ aListBox->ToggleDropDown();
+ }
+ else
+ {
+ SAL_WARN("Type does not exist", aCodeCompleteCache[j].sVarType);
+ }
}
break;
}
@@ -2285,6 +2301,24 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
setBasicWatchMode( false );
}
+CodeCompleteListBox::CodeCompleteListBox(EditorWindow* pPar)
+: ListBox(pPar, WB_DROPDOWN),
+pParent(pPar)
+{
+ SetSelectHdl( LINK(this, CodeCompleteListBox, ImplSelectHdl) );
+}
+
+CodeCompleteListBox::~CodeCompleteListBox()
+{
+}
+
+IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectHdl)
+{
+ TextSelection aSel = this->pParent->GetEditView()->GetSelection();
+ pParent->GetEditEngine()->ReplaceText(aSel, (OUString) GetEntry(GetSelectEntryPos()) );
+ Clear();
+ return 0;
+}
} // namespace basctl