GSOC work, code fixes
Small fix in the listbox size: I'm using GetOptimalSize to set the correct width. EditorWindow::KeyInput: autocomplete/codecomplete functions have been placed into separate functions. Function autoclose sub/functions: duplicate code removal. Change-Id: I44678753fc9737fd7a0913af3caa4f1f565aca28
This commit is contained in:
@@ -122,6 +122,11 @@ private:
|
|||||||
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
|
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
|
||||||
std::vector< OUString > GetXIdlClassMethods( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
std::vector< OUString > GetXIdlClassMethods( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
||||||
std::vector< OUString > GetXIdlClassFields( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
std::vector< OUString > GetXIdlClassFields( ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > xClass ) const;
|
||||||
|
void HandleAutoCorrect();
|
||||||
|
void HandleAutoCloseParen();
|
||||||
|
void HandleAutoCloseDoubleQuotes();
|
||||||
|
void HandleCodeCompletition();
|
||||||
|
void HandleProcedureCompletition();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Paint( const Rectangle& );
|
virtual void Paint( const Rectangle& );
|
||||||
|
@@ -521,6 +521,74 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE ||
|
if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE ||
|
||||||
rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
|
rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
|
||||||
rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
|
rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
|
||||||
|
{
|
||||||
|
HandleAutoCorrect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
|
||||||
|
{//autoclose double quotes
|
||||||
|
HandleAutoCloseDoubleQuotes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
|
||||||
|
{//autoclose parenthesis
|
||||||
|
HandleAutoCloseParen();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN && CodeCompleteOptions::IsProcedureAutoCompleteOn() )
|
||||||
|
{//autoclose implementation
|
||||||
|
HandleProcedureCompletition();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT &&
|
||||||
|
(CodeCompleteOptions::IsCodeCompleteOn() || CodeCompleteOptions::IsExtendedTypeDeclaration()) )
|
||||||
|
{
|
||||||
|
HandleCodeCompletition();
|
||||||
|
}
|
||||||
|
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
|
||||||
|
{
|
||||||
|
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
|
||||||
|
!rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() )
|
||||||
|
{
|
||||||
|
TextSelection aSel( pEditView->GetSelection() );
|
||||||
|
if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() )
|
||||||
|
{
|
||||||
|
bDelayHighlight = false;
|
||||||
|
if ( !rKEvt.GetKeyCode().IsShift() )
|
||||||
|
pEditView->IndentBlock();
|
||||||
|
else
|
||||||
|
pEditView->UnindentBlock();
|
||||||
|
bDelayHighlight = true;
|
||||||
|
bDone = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !bDone )
|
||||||
|
bDone = pEditView->KeyInput( rKEvt );
|
||||||
|
}
|
||||||
|
if ( !bDone )
|
||||||
|
{
|
||||||
|
Window::KeyInput( rKEvt );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SfxBindings* pBindings = GetBindingsPtr())
|
||||||
|
{
|
||||||
|
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
|
||||||
|
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
|
||||||
|
pBindings->Update( SID_BASICIDE_STAT_POS );
|
||||||
|
if ( !bWasModified && pEditEngine->IsModified() )
|
||||||
|
{
|
||||||
|
pBindings->Invalidate( SID_SAVEDOC );
|
||||||
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
||||||
|
pBindings->Invalidate( SID_UNDO );
|
||||||
|
}
|
||||||
|
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
|
||||||
|
pBindings->Invalidate( SID_ATTR_INSERT );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWindow::HandleAutoCorrect()
|
||||||
{
|
{
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
sal_uLong nLine = aSel.GetStart().GetPara();
|
sal_uLong nLine = aSel.GetStart().GetPara();
|
||||||
@@ -549,8 +617,23 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
|
void EditorWindow::HandleAutoCloseParen()
|
||||||
{//autoclose double quotes
|
{
|
||||||
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
|
sal_uLong nLine = aSel.GetStart().GetPara();
|
||||||
|
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
|
||||||
|
|
||||||
|
if( aLine.getLength() > 0 && aLine[aSel.GetEnd().GetIndex()-1] != '(' )
|
||||||
|
{
|
||||||
|
GetEditView()->InsertText(OUString(")"));
|
||||||
|
//leave the cursor on it's place: inside the parenthesis
|
||||||
|
TextPaM aEnd(nLine, aSel.GetEnd().GetIndex());
|
||||||
|
GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWindow::HandleAutoCloseDoubleQuotes()
|
||||||
|
{
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
sal_uLong nLine = aSel.GetStart().GetPara();
|
sal_uLong nLine = aSel.GetStart().GetPara();
|
||||||
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
|
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
|
||||||
@@ -569,23 +652,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
|
void EditorWindow::HandleProcedureCompletition()
|
||||||
{//autoclose parenthesis
|
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
|
||||||
sal_uLong nLine = aSel.GetStart().GetPara();
|
|
||||||
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
|
|
||||||
|
|
||||||
if( aLine.getLength() > 0 && aLine[aSel.GetEnd().GetIndex()-1] != '(' )
|
|
||||||
{
|
{
|
||||||
GetEditView()->InsertText(OUString(")"));
|
|
||||||
//leave the cursor on it's place: inside the parenthesis
|
|
||||||
TextPaM aEnd(nLine, aSel.GetEnd().GetIndex());
|
|
||||||
GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN && CodeCompleteOptions::IsProcedureAutoCompleteOn() )
|
|
||||||
{//autoclose implementation
|
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
sal_uLong nLine = aSel.GetStart().GetPara();
|
sal_uLong nLine = aSel.GetStart().GetPara();
|
||||||
OUString aLine( pEditEngine->GetText( nLine ) );
|
OUString aLine( pEditEngine->GetText( nLine ) );
|
||||||
@@ -618,13 +686,14 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
if( bFoundType && bFoundName )
|
if( bFoundType && bFoundName )
|
||||||
{// found, search for end
|
{// found, search for end
|
||||||
if( nLine+1 == pEditEngine->GetParagraphCount() )
|
|
||||||
{ //append to the end
|
|
||||||
OUString sText("\nEnd ");
|
OUString sText("\nEnd ");
|
||||||
if( sProcType.equalsIgnoreAsciiCase("function") )
|
if( sProcType.equalsIgnoreAsciiCase("function") )
|
||||||
sText += OUString( "Function\n" );
|
sText += OUString( "Function\n" );
|
||||||
if( sProcType.equalsIgnoreAsciiCase("sub") )
|
if( sProcType.equalsIgnoreAsciiCase("sub") )
|
||||||
sText += OUString( "Sub\n" );
|
sText += OUString( "Sub\n" );
|
||||||
|
|
||||||
|
if( nLine+1 == pEditEngine->GetParagraphCount() )
|
||||||
|
{ //append to the end
|
||||||
pEditView->InsertText( sText );
|
pEditView->InsertText( sText );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -643,21 +712,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
{
|
{
|
||||||
if( sStr1.equalsIgnoreAsciiCase("sub") )
|
if( sStr1.equalsIgnoreAsciiCase("sub") )
|
||||||
{
|
{
|
||||||
OUString sText("\nEnd ");
|
|
||||||
if( sProcType.equalsIgnoreAsciiCase("function") )
|
|
||||||
sText += OUString( "Function\n" );
|
|
||||||
if( sProcType.equalsIgnoreAsciiCase("sub") )
|
|
||||||
sText += OUString( "Sub\n" );
|
|
||||||
pEditView->InsertText( sText );
|
pEditView->InsertText( sText );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( sStr1.equalsIgnoreAsciiCase("function") )
|
if( sStr1.equalsIgnoreAsciiCase("function") )
|
||||||
{
|
{
|
||||||
OUString sText("\nEnd ");
|
|
||||||
if( sProcType.equalsIgnoreAsciiCase("function") )
|
|
||||||
sText += OUString( "Function\n" );
|
|
||||||
if( sProcType.equalsIgnoreAsciiCase("sub") )
|
|
||||||
sText += OUString( "Sub\n" );
|
|
||||||
pEditView->InsertText( sText );
|
pEditView->InsertText( sText );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -673,8 +732,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rKEvt.GetKeyCode().GetCode() == KEY_POINT &&
|
void EditorWindow::HandleCodeCompletition()
|
||||||
(CodeCompleteOptions::IsCodeCompleteOn() || CodeCompleteOptions::IsExtendedTypeDeclaration()) )
|
|
||||||
{
|
{
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
|
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
|
||||||
@@ -796,48 +854,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) )
|
|
||||||
{
|
|
||||||
if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() &&
|
|
||||||
!rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() )
|
|
||||||
{
|
|
||||||
TextSelection aSel( pEditView->GetSelection() );
|
|
||||||
if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() )
|
|
||||||
{
|
|
||||||
bDelayHighlight = false;
|
|
||||||
if ( !rKEvt.GetKeyCode().IsShift() )
|
|
||||||
pEditView->IndentBlock();
|
|
||||||
else
|
|
||||||
pEditView->UnindentBlock();
|
|
||||||
bDelayHighlight = true;
|
|
||||||
bDone = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !bDone )
|
|
||||||
bDone = pEditView->KeyInput( rKEvt );
|
|
||||||
}
|
|
||||||
if ( !bDone )
|
|
||||||
{
|
|
||||||
Window::KeyInput( rKEvt );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SfxBindings* pBindings = GetBindingsPtr())
|
|
||||||
{
|
|
||||||
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
|
|
||||||
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
|
|
||||||
pBindings->Update( SID_BASICIDE_STAT_POS );
|
|
||||||
if ( !bWasModified && pEditEngine->IsModified() )
|
|
||||||
{
|
|
||||||
pBindings->Invalidate( SID_SAVEDOC );
|
|
||||||
pBindings->Invalidate( SID_DOC_MODIFIED );
|
|
||||||
pBindings->Invalidate( SID_UNDO );
|
|
||||||
}
|
|
||||||
if ( rKEvt.GetKeyCode().GetCode() == KEY_INSERT )
|
|
||||||
pBindings->Invalidate( SID_ATTR_INSERT );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector< OUString > EditorWindow::GetXIdlClassMethods( Reference< reflection::XIdlClass > xClass ) const
|
std::vector< OUString > EditorWindow::GetXIdlClassMethods( Reference< reflection::XIdlClass > xClass ) const
|
||||||
{
|
{
|
||||||
@@ -2659,7 +2675,6 @@ void CodeCompleteListBox::SetVisibleEntries()
|
|||||||
|
|
||||||
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
||||||
{
|
{
|
||||||
//std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
|
|
||||||
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
||||||
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
||||||
{
|
{
|
||||||
@@ -2768,8 +2783,9 @@ void CodeCompleteWindow::ResizeListBox()
|
|||||||
const Font& aFont = pListBox->GetUnzoomedControlPointFont();
|
const Font& aFont = pListBox->GetUnzoomedControlPointFont();
|
||||||
|
|
||||||
Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() );
|
Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() );
|
||||||
Size aSize = pListBox->CalcSize( nColumns+1, nLines );
|
Size aSize = pListBox->GetOptimalSize();//this sets the correct width
|
||||||
aSize.setWidth(nWidth+5);
|
aSize.setHeight( pListBox->CalcSize( nColumns, nLines ).getHeight() );
|
||||||
|
|
||||||
Point aBottomPoint = aVisArea.BottomRight();
|
Point aBottomPoint = aVisArea.BottomRight();
|
||||||
Point aTopPoint = aVisArea.TopRight();
|
Point aTopPoint = aVisArea.TopRight();
|
||||||
long nYDiff = std::abs((aBottomPoint.Y() - aTopPoint.Y()) - GetPosPixel().Y());
|
long nYDiff = std::abs((aBottomPoint.Y() - aTopPoint.Y()) - GetPosPixel().Y());
|
||||||
|
Reference in New Issue
Block a user