Organize methods that update invalidated ranges for online spell checker.

Change-Id: Iaf9295e33e4771f39a085f6ee3cb88ebbf662ff0
This commit is contained in:
Kohei Yoshida 2013-08-27 13:01:40 -04:00
parent 2a58a45b82
commit a4772f2ba4
6 changed files with 22 additions and 19 deletions

View File

@ -1132,8 +1132,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
if (xSavDic.is())
xSavDic->store();
aPaM.GetNode()->GetWrongList()->GetInvalidStart() = 0;
aPaM.GetNode()->GetWrongList()->GetInvalidEnd() = aPaM.GetNode()->Len();
aPaM.GetNode()->GetWrongList()->ResetInvalidRange(0, aPaM.GetNode()->Len());
PIMPEE->StartOnlineSpellTimer();
if ( pCallBack )

View File

@ -218,12 +218,19 @@ void WrongList::SetValid()
nInvalidEnd = 0;
}
void WrongList::MarkInvalid( sal_uInt16 nS, sal_uInt16 nE )
void WrongList::SetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd )
{
if ( (nInvalidStart == Valid) || ( nInvalidStart > nS ) )
nInvalidStart = nS;
if ( nInvalidEnd < nE )
nInvalidEnd = nE;
if (nInvalidStart == Valid || nStart < nInvalidStart)
nInvalidStart = nStart;
if (nInvalidEnd < nEnd)
nInvalidEnd = nEnd;
}
void WrongList::ResetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd )
{
nInvalidStart = nStart;
nInvalidEnd = nEnd;
}
void WrongList::TextInserted( sal_uInt16 nPos, sal_uInt16 nLength, bool bPosIsSep )
@ -471,7 +478,7 @@ void WrongList::InsertWrong( sal_uInt16 nStart, sal_uInt16 nEnd )
void WrongList::MarkWrongsInvalid()
{
if (!maRanges.empty())
MarkInvalid(maRanges.front().nStart, maRanges.back().nEnd );
SetInvalidRange(maRanges.front().nStart, maRanges.back().nEnd);
}
WrongList* WrongList::Clone() const

View File

@ -93,13 +93,11 @@ public:
bool IsValid() const;
void SetValid();
void MarkInvalid( sal_uInt16 nS, sal_uInt16 nE );
void SetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd );
void ResetInvalidRange( sal_uInt16 nStart, sal_uInt16 nEnd );
sal_uInt16 GetInvalidStart() const { return nInvalidStart; }
sal_uInt16& GetInvalidStart() { return nInvalidStart; }
sal_uInt16 GetInvalidEnd() const { return nInvalidEnd; }
sal_uInt16& GetInvalidEnd() { return nInvalidEnd; }
void TextInserted( sal_uInt16 nPos, sal_uInt16 nLength, bool bPosIsSep );
void TextDeleted( sal_uInt16 nPos, sal_uInt16 nLength );

View File

@ -2230,7 +2230,7 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR
xub_StrLen nEnd = pLeft->Len();
xub_StrLen nInv = nEnd ? nEnd-1 : nEnd;
pLeft->GetWrongList()->ClearWrongs( nInv, 0xFFFF, pLeft ); // Possibly remove one
pLeft->GetWrongList()->MarkInvalid( nInv, nEnd+1 );
pLeft->GetWrongList()->SetInvalidRange(nInv, nEnd+1);
// Take over misspelled words
WrongList* pRWrongs = pRight->GetWrongList();
for (WrongList::iterator i = pRWrongs->begin(); i < pRWrongs->end(); ++i)
@ -2833,11 +2833,11 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib
}
sal_uInt16 nInv = nEnd ? nEnd-1 : nEnd;
if ( nEnd )
pLWrongs->MarkInvalid( nInv, nEnd );
pLWrongs->SetInvalidRange(nInv, nEnd);
else
pLWrongs->SetValid();
pRWrongs->SetValid(); // otherwise 0 - 0xFFFF
pRWrongs->MarkInvalid( 0, 1 ); // Only test the first word
pRWrongs->SetInvalidRange(0, 1); // Only test the first word
}
ParaPortion* pPortion = FindParaPortion( rPaM.GetNode() );

View File

@ -2311,9 +2311,8 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, sal_Bool bSpel
if ( bCursorPos )
{
// Then continue to mark as invalid ...
pWrongList->GetInvalidStart() = nWStart;
pWrongList->GetInvalidEnd() = nWEnd;
bRestartTimer = sal_True;
pWrongList->ResetInvalidRange(nWStart, nWEnd);
bRestartTimer = true;
}
else
{

View File

@ -581,7 +581,7 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_
{
pPortion->MarkSelectionInvalid( nStartPos, nEndPos-nStartPos );
if ( bCheckLanguage )
pNode->GetWrongList()->MarkInvalid( nStartPos, nEndPos );
pNode->GetWrongList()->SetInvalidRange(nStartPos, nEndPos);
}
}
}