diff options
author | Deena Francis <deena.francis@gmail.com> | 2015-03-15 02:34:55 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-05-05 21:30:09 +0000 |
commit | 5c793b582e5afda68bb6acf7aa22f70c48f59b12 (patch) | |
tree | 08a87befa9a5828278d22ef2ae5427cdf2ec4a84 | |
parent | 22da3ae40027ff2d31f89cf92f0d4ad7217aed1e (diff) |
Resolves tdf#84240 : Red squiggly underline does not appear instantly
Change-Id: I62d1b381ba8373cfa637f5838d5ef31691f4c260
Reviewed-on: https://gerrit.libreoffice.org/14872
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/viewfunc.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 142 |
4 files changed, 162 insertions, 0 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 07bb2270efab..aa683cb0a42f 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -414,6 +414,8 @@ public: void EnableAutoSpell( bool bEnable ); void ResetAutoSpell(); void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges ); + const std::vector<editeng::MisspellRanges>* GetAutoSpellData( SCCOL nPosX, SCROW nPosY ); + bool InsideVisibleRange( SCCOL nPosX, SCROW nPosY ); void DeleteCopySourceOverlay(); void UpdateCopySourceOverlay(); diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index 2e696f189014..6f3cabd13640 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -368,6 +368,8 @@ private: bool bAttrChanged, bool bAddUndo ); void MarkAndJumpToRanges(const ScRangeList& rRanges); + void CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount ); }; #endif diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 8cf05b2cdab5..6f0544a10baf 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5764,6 +5764,22 @@ void ScGridWindow::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector mpSpellCheckCxt->setMisspellRanges(nPosX, nPosY, pRanges); } +const std::vector<editeng::MisspellRanges>* ScGridWindow::GetAutoSpellData( SCCOL nPosX, SCROW nPosY ) +{ + if (!mpSpellCheckCxt) + return NULL; + + if (!maVisibleRange.isInside(nPosX, nPosY)) + return NULL; + + return mpSpellCheckCxt->getMisspellRanges(nPosX, nPosY); +} + +bool ScGridWindow::InsideVisibleRange( SCCOL nPosX, SCROW nPosY ) +{ + return maVisibleRange.isInside(nPosX, nPosY); +} + // #114409# void ScGridWindow::CursorChanged() { diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index db445ce55c91..070b109ac2ce 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -56,6 +56,7 @@ #include "docfunc.hxx" #include "docpool.hxx" #include "docsh.hxx" +#include "docoptio.hxx" #include "global.hxx" #include "patattr.hxx" #include "printfun.hxx" @@ -1204,6 +1205,10 @@ void ScViewFunc::FillSimple( FillDir eDir, bool bRecord ) { pDocSh->UpdateOle(&GetViewData()); UpdateScrollBars(); + bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); + if ( bDoAutoSpell ) + CopyAutoSpellData(eDir, aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), + ::std::numeric_limits<sal_uLong>::max()); } } else @@ -1249,6 +1254,10 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, pDocSh->UpdateOle(&GetViewData()); UpdateScrollBars(); + bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); + if ( bDoAutoSpell ) + CopyAutoSpellData(eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount); + if (ScModelObj* pModelObj = HelperNotifyChanges::getMustPropagateChangesModel(*pDocSh)) { ScRangeList aChangeRanges; @@ -1276,6 +1285,139 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, } } +void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount ) +{ + ScGridWindow* pWin = this->GetActiveWin(); + if ( pWin->InsideVisibleRange(nStartCol, nStartRow) && pWin->InsideVisibleRange(nEndCol, nEndRow) ) + { + if ( nCount == ::std::numeric_limits<sal_uLong>::max() ) + { + switch( eDir ) + { + case FILL_TO_BOTTOM: + for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr ) + { + const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nStartRow); + if ( !pRanges ) + continue; + for ( SCROW nRowItr = nStartRow + 1; nRowItr <= nEndRow; ++nRowItr ) + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + break; + case FILL_TO_TOP: + for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr ) + { + const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nEndRow); + if ( !pRanges ) + continue; + for ( SCROW nRowItr = nEndRow - 1; nRowItr >= nStartRow; --nRowItr ) + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + break; + case FILL_TO_RIGHT: + for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr ) + { + const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nStartCol, nRowItr); + if ( !pRanges ) + continue; + for ( SCCOL nColItr = nStartCol + 1; nColItr <= nEndCol; ++nColItr ) + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + break; + case FILL_TO_LEFT: + for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr ) + { + const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nEndCol, nRowItr); + if ( !pRanges ) + continue; + for ( SCCOL nColItr = nEndCol - 1; nColItr >= nStartCol; --nColItr ) + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + break; + } + return; + } + + typedef const std::vector<editeng::MisspellRanges>* MisspellRangesType; + SCROW nRowRepeatSize = (nEndRow - nStartRow + 1); + SCCOL nColRepeatSize = (nEndCol - nStartCol + 1); + SCROW nTillRow = 0; + SCCOL nTillCol = 0; + std::vector<std::vector<MisspellRangesType>> aSourceSpellRanges(nRowRepeatSize, std::vector<MisspellRangesType>(nColRepeatSize)); + + for ( SCROW nRowIdx = 0; nRowIdx < nRowRepeatSize; ++nRowIdx ) + for ( SCROW nColIdx = 0; nColIdx < nColRepeatSize; ++nColIdx ) + aSourceSpellRanges[nRowIdx][nColIdx] = pWin->GetAutoSpellData( nStartCol + nColIdx, nStartRow + nRowIdx ); + + switch( eDir ) + { + case FILL_TO_BOTTOM: + nTillRow = nEndRow + nCount; + for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr ) + { + for ( SCROW nRowItr = nEndRow + 1; nRowItr <= nTillRow; ++nRowItr ) + { + size_t nSourceRowIdx = ( ( nRowItr - nEndRow - 1 ) % nRowRepeatSize ); + MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol]; + if ( !pRanges ) + continue; + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + } + break; + + case FILL_TO_TOP: + nTillRow = nStartRow - nCount; + for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr ) + { + for ( SCROW nRowItr = nStartRow - 1; nRowItr >= nTillRow; --nRowItr ) + { + size_t nSourceRowIdx = nRowRepeatSize - 1 - ( ( nStartRow - 1 - nRowItr ) % nRowRepeatSize ); + MisspellRangesType pRanges = aSourceSpellRanges[nSourceRowIdx][nColItr - nStartCol]; + if ( !pRanges ) + continue; + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + } + break; + + case FILL_TO_RIGHT: + nTillCol = nEndCol + nCount; + for ( SCCOL nColItr = nEndCol + 1; nColItr <= nTillCol; ++nColItr ) + { + size_t nSourceColIdx = ( ( nColItr - nEndCol - 1 ) % nColRepeatSize ); + for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr ) + { + MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx]; + if ( !pRanges ) + continue; + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + } + break; + + case FILL_TO_LEFT: + nTillCol = nStartCol - nCount; + for ( SCCOL nColItr = nStartCol - 1; nColItr >= nTillCol; --nColItr ) + { + size_t nSourceColIdx = nColRepeatSize - 1 - ( ( nStartCol - 1 - nColItr ) % nColRepeatSize ); + for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr ) + { + MisspellRangesType pRanges = aSourceSpellRanges[nRowItr - nStartRow][nSourceColIdx]; + if ( !pRanges ) + continue; + pWin->SetAutoSpellData(nColItr, nRowItr, pRanges); + } + } + break; + } + } + else + pWin->ResetAutoSpell(); + +} + void ScViewFunc::FillTab( InsertDeleteFlags nFlags, sal_uInt16 nFunction, bool bSkipEmpty, bool bAsLink ) { //! allow source sheet to be protected |