GSOC work, extend reflection+crash fix

Fixed creash error on accessing elements of an empty vector.
Reflection is now extract fields also.

Change-Id: Ic41353cbe9fc404115eb0d2b2f9d5706fc044dab
This commit is contained in:
Gergo Mocsi 2013-07-26 17:28:54 +02:00
parent 412e91d33d
commit 2a87d09bc8

View File

@ -54,6 +54,7 @@
#include <comphelper/configurationhelper.hxx>
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
#include "com/sun/star/reflection/XIdlMethod.hpp"
#include "com/sun/star/reflection/XIdlField.hpp"
namespace basctl
{
@ -505,6 +506,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
// see if there is an accelerator to be processed first
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
{//autoclose double quotes
TextSelection aSel = GetEditView()->GetSelection();
@ -513,6 +515,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
HighlightPortions aPortions;
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
if( aPortions.size() != 0 )
{
if( aLine.getLength() > 0 && aLine[aLine.getLength()-1] != '"' && (aPortions[aPortions.size()-1].tokenType != 4) )
{
GetEditView()->InsertText(OUString("\""));
@ -521,6 +525,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
}
}
}
if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
{//autoclose parenthesis
@ -571,12 +576,15 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
HighlightPortions aPortions;
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
if( aPortions.size() != 0 )
{
for ( size_t i = 0; i < aPortions.size(); i++ )
{
HighlightPortion& r = aPortions[i];
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];//variable name
OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
@ -607,19 +615,35 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
j++;
}
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()));
}
}
if( aEntryVect.size() > 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)
for(unsigned int l = 0; l < aEntryVect.size(); ++l)
{
pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) );
pCodeCompleteWnd->InsertEntry( aEntryVect[l] );
}
pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() );
pCodeCompleteWnd->Show();
pCodeCompleteWnd->ResizeListBox();
pCodeCompleteWnd->SelectFirstEntry();
@ -627,6 +651,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
}
}
}
}
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
{
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&