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:
parent
412e91d33d
commit
2a87d09bc8
@ -54,6 +54,7 @@
|
|||||||
#include <comphelper/configurationhelper.hxx>
|
#include <comphelper/configurationhelper.hxx>
|
||||||
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
|
#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp"
|
||||||
#include "com/sun/star/reflection/XIdlMethod.hpp"
|
#include "com/sun/star/reflection/XIdlMethod.hpp"
|
||||||
|
#include "com/sun/star/reflection/XIdlField.hpp"
|
||||||
|
|
||||||
namespace basctl
|
namespace basctl
|
||||||
{
|
{
|
||||||
@ -505,6 +506,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
// see if there is an accelerator to be processed first
|
// see if there is an accelerator to be processed first
|
||||||
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
||||||
|
|
||||||
|
|
||||||
if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
|
if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
|
||||||
{//autoclose double quotes
|
{//autoclose double quotes
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
@ -513,6 +515,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
|
|
||||||
HighlightPortions aPortions;
|
HighlightPortions aPortions;
|
||||||
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
||||||
|
if( aPortions.size() != 0 )
|
||||||
|
{
|
||||||
if( aLine.getLength() > 0 && aLine[aLine.getLength()-1] != '"' && (aPortions[aPortions.size()-1].tokenType != 4) )
|
if( aLine.getLength() > 0 && aLine[aLine.getLength()-1] != '"' && (aPortions[aPortions.size()-1].tokenType != 4) )
|
||||||
{
|
{
|
||||||
GetEditView()->InsertText(OUString("\""));
|
GetEditView()->InsertText(OUString("\""));
|
||||||
@ -521,6 +525,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
|
GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
|
if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
|
||||||
{//autoclose parenthesis
|
{//autoclose parenthesis
|
||||||
@ -571,12 +576,15 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
|
|
||||||
HighlightPortions aPortions;
|
HighlightPortions aPortions;
|
||||||
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
||||||
|
if( aPortions.size() != 0 )
|
||||||
|
{
|
||||||
for ( size_t i = 0; i < aPortions.size(); i++ )
|
for ( size_t i = 0; i < aPortions.size(); i++ )
|
||||||
{
|
{
|
||||||
HighlightPortion& r = aPortions[i];
|
HighlightPortion& r = aPortions[i];
|
||||||
if( r.tokenType == 1 ) // extract the identifers(methods, base variable)
|
if( r.tokenType == 1 ) // extract the identifers(methods, base variable)
|
||||||
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
|
aVect.push_back( aLine.copy(r.nBegin, r.nEnd - r.nBegin) );
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString sBaseName = aVect[0];//variable name
|
OUString sBaseName = aVect[0];//variable name
|
||||||
OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
|
OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
|
||||||
|
|
||||||
@ -607,19 +615,35 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
|
Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
|
||||||
|
Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
|
||||||
|
std::vector< OUString > aEntryVect;
|
||||||
|
|
||||||
if( aMethods.getLength() != 0 )
|
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 );
|
Rectangle aRect = ( (TextEngine*) GetEditEngine() )->PaMtoEditCursor( aSel.GetEnd() , false );
|
||||||
aSel.GetStart().GetIndex() += 1;
|
aSel.GetStart().GetIndex() += 1;
|
||||||
aSel.GetEnd().GetIndex() += 1;
|
aSel.GetEnd().GetIndex() += 1;
|
||||||
pCodeCompleteWnd->ClearListBox();
|
pCodeCompleteWnd->ClearListBox();
|
||||||
pCodeCompleteWnd->SetTextSelection(aSel);
|
pCodeCompleteWnd->SetTextSelection(aSel);
|
||||||
|
for(unsigned int l = 0; l < aEntryVect.size(); ++l)
|
||||||
pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() );
|
|
||||||
for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
|
|
||||||
{
|
{
|
||||||
pCodeCompleteWnd->InsertEntry( OUString(aMethods[l]->getName()) );
|
pCodeCompleteWnd->InsertEntry( aEntryVect[l] );
|
||||||
}
|
}
|
||||||
|
pCodeCompleteWnd->SetPosPixel( aRect.BottomRight() );
|
||||||
pCodeCompleteWnd->Show();
|
pCodeCompleteWnd->Show();
|
||||||
pCodeCompleteWnd->ResizeListBox();
|
pCodeCompleteWnd->ResizeListBox();
|
||||||
pCodeCompleteWnd->SelectFirstEntry();
|
pCodeCompleteWnd->SelectFirstEntry();
|
||||||
@ -627,6 +651,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
|
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
|
||||||
{
|
{
|
||||||
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
|
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user