diff options
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 29 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 78 | ||||
-rw-r--r-- | basctl/source/basicide/basobj3.cxx | 2 |
4 files changed, 83 insertions, 28 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index c468932e9768..af77aec82b7e 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1118,6 +1118,35 @@ void ModulWindow::GetState( SfxItemSet &rSet ) } } break; + case SID_BASICIDE_STAT_TITLE: + { + // search for current procedure name (Sub or Function) + TextView* pView = GetEditView(); + if ( pView ) + { + + OUString sProcName; + bool bFound = false; + + TextSelection aSel = pView->GetSelection(); + long nLine = aSel.GetStart().GetPara(); + + for (long i = nLine; i >= 0 && !bFound; --i) + { + OUString aCurrLine = GetEditEngine()->GetText( i ); + OUString sProcType; + bFound = GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName); + } + + OUString aTitle = CreateQualifiedName(); + if (!sProcName.isEmpty()) + aTitle += "." + sProcName; + + SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle ); + rSet.Put( aTitleItem ); + } + } + break; case SID_ATTR_INSERT: { TextView* pView = GetEditView(); diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 1008643e7993..224782089129 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -156,6 +156,8 @@ public: bool CanModify() { return ImpCanModify(); } void UpdateSyntaxHighlighting (); + + bool GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName); }; diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 31721b1c540c..0aadfead07f9 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -428,6 +428,7 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt ) if (SfxBindings* pBindings = GetBindingsPtr()) { pBindings->Invalidate( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); } } } @@ -567,8 +568,12 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) if (SfxBindings* pBindings = GetBindingsPtr()) { pBindings->Invalidate( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) + { pBindings->Update( SID_BASICIDE_STAT_POS ); + pBindings->Update( SID_BASICIDE_STAT_TITLE ); + } if ( !bWasModified && pEditEngine->IsModified() ) { pBindings->Invalidate( SID_SAVEDOC ); @@ -729,42 +734,19 @@ void EditorWindow::HandleAutoCloseDoubleQuotes() void EditorWindow::HandleProcedureCompletion() { + TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); OUString aLine( pEditEngine->GetText( nLine ) ); - std::vector<HighlightPortion> aPortions; - aHighlighter.getHighlightPortions( aLine, aPortions ); - - if( aPortions.empty() ) - return; - + bool bFoundName = false; OUString sProcType; OUString sProcName; - bool bFoundType = false; - bool bFoundName = false; - - for (std::vector<HighlightPortion>::iterator i(aPortions.begin()); - i != aPortions.end(); ++i) - { - OUString sTokStr = aLine.copy(i->nBegin, i->nEnd - i->nBegin); - if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub") - || sTokStr.equalsIgnoreAsciiCase("function")) ) - { - sProcType = sTokStr; - bFoundType = true; - } - if( i->tokenType == 1 && bFoundType ) - { - sProcName = sTokStr; - bFoundName = true; - break; - } - } + bFoundName = GetProcedureName(aLine, sProcType, sProcName); - if( !bFoundType || !bFoundName ) - return;// no sub/function keyword or there is no identifier + if (!bFoundName) + return; OUString sText("\nEnd "); aSel = GetEditView()->GetSelection(); @@ -807,6 +789,43 @@ void EditorWindow::HandleProcedureCompletion() } } +bool EditorWindow::GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName) +{ + std::vector<HighlightPortion> aPortions; + aHighlighter.getHighlightPortions(rLine, aPortions); + + if( aPortions.empty() ) + return false; + + bool bFoundType = false; + bool bFoundName = false; + + for (std::vector<HighlightPortion>::iterator i(aPortions.begin()); + i != aPortions.end(); ++i) + { + OUString sTokStr = rLine.copy(i->nBegin, i->nEnd - i->nBegin); + + if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub") + || sTokStr.equalsIgnoreAsciiCase("function")) ) + { + rProcType = sTokStr; + bFoundType = true; + } + if( i->tokenType == 1 && bFoundType ) + { + rProcName = sTokStr; + bFoundName = true; + break; + } + } + + if( !bFoundType || !bFoundName ) + return false;// no sub/function keyword or there is no identifier + + return true; + +} + void EditorWindow::HandleCodeCompletion() { rModulWindow.UpdateModule(); @@ -1003,7 +1022,10 @@ void EditorWindow::CreateEditEngine() InitScrollBars(); if (SfxBindings* pBindings = GetBindingsPtr()) + { pBindings->Invalidate( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); + } DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" ); diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 141ddaeb22ce..60ada3d5af34 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -362,6 +362,8 @@ void InvalidateDebuggerSlots() pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); pBindings->Invalidate( SID_BASICIDE_STAT_POS ); pBindings->Update( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); + pBindings->Update( SID_BASICIDE_STAT_TITLE ); } } |