From 9d0f86326cbf6b986176c5b5fe7660fa510c8d70 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 15 Aug 2015 15:03:35 +0200 Subject: Rework loops so to have exit condition on correct unsigned value Change-Id: I91e647d6b1aebe8342f95c88fc81bd2c5a43ce71 --- basctl/source/basicide/baside2.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'basctl') diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index ee451cf59d8c..339f2d65733a 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -1113,19 +1113,18 @@ void ModulWindow::GetState( SfxItemSet &rSet ) 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) + sal_uInt32 i = aSel.GetStart().GetPara(); + do { OUString aCurrLine = GetEditEngine()->GetText( i ); OUString sProcType; - bFound = GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName); - } + if (GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName)) + break; + } while (i--); OUString aTitle = CreateQualifiedName(); if (!sProcName.isEmpty()) -- cgit