summaryrefslogtreecommitdiff
path: root/starmath/source/edit.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'starmath/source/edit.cxx')
-rw-r--r--starmath/source/edit.cxx36
1 files changed, 10 insertions, 26 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index a60a7661f683..47ecd52d58ec 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -878,36 +878,20 @@ void SmEditWindow::SelPrevMark()
if (pEditEngine && pEditView)
{
ESelection eSelection = pEditView->GetSelection();
- sal_Int32 nPos = -1;
+ sal_Int32 nPara = eSelection.nStartPara;
sal_Int32 nMax = eSelection.nStartPos;
- OUString aText(pEditEngine->GetText(eSelection.nStartPara));
- OUString aMark("<?>");
- sal_Int32 nCounts = pEditEngine->GetParagraphCount();
-
- do
- {
- sal_Int32 nMarkIndex = aText.indexOf(aMark);
- while ((nMarkIndex < nMax) && (nMarkIndex != -1))
- {
- nPos = nMarkIndex;
- nMarkIndex = aText.indexOf(aMark, nMarkIndex + 1);
- }
-
- if (nPos == -1)
- {
- eSelection.nStartPara--;
- aText = pEditEngine->GetText(eSelection.nStartPara);
- nMax = aText.getLength();
- }
- }
- while ((eSelection.nStartPara < nCounts) &&
- (nPos == -1));
+ OUString aText(pEditEngine->GetText(nPara));
+ const OUString aMark("<?>");
+ sal_Int32 nPos;
- if (nPos != -1)
+ while ( (nPos = aText.lastIndexOf(aMark, nMax)) < 0 )
{
- pEditView->SetSelection(ESelection(
- eSelection.nStartPara, nPos, eSelection.nStartPara, nPos + 3));
+ if (--nPara < 0)
+ return;
+ aText = pEditEngine->GetText(nPara);
+ nMax = aText.getLength();
}
+ pEditView->SetSelection(ESelection(nPara, nPos, nPara, nPos + 3));
}
}