summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/viewfun2.cxx
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-10-04 12:47:46 +0530
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-10-28 08:39:25 +0100
commitbdd149b1ff3d43b94cadc0d43365100c287c7639 (patch)
treea23299569c37922d7f531076d750e517ff01bb3a /sc/source/ui/view/viewfun2.cxx
parent2beecc277959051026d7d1303e3c3ad7922c326c (diff)
Improve spell checking performance and impl. in several ways:
* do synchronous spell checking, avoiding an idle handler * avoid continuous invalidations caused per-cell by spell-checking * cache spell-checking information for a given SharedString to avoid repeated checking of frequently recurring strings. Change-Id: Ie251f263a8932465297dd8bd66dfc4aa10984947 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104705 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/view/viewfun2.cxx')
-rw-r--r--sc/source/ui/view/viewfun2.cxx32
1 files changed, 30 insertions, 2 deletions
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 572b62cf4036..9bad80bb01d0 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1477,6 +1477,10 @@ 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 )
{
+ const ScDocument* pDoc = &GetViewData().GetDocument();
+ SCTAB nTab = GetViewData().GetTabNo();
+ CellType eCellType;
+
ScGridWindow* pWin = GetActiveWin();
if ( pWin->InsideVisibleRange(nStartCol, nStartRow) && pWin->InsideVisibleRange(nEndCol, nEndRow) )
{
@@ -1487,6 +1491,10 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
case FILL_TO_BOTTOM:
for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
{
+ pDoc->GetCellType(nColItr, nStartRow, nTab, eCellType); // We need this optimization only for EditTextObject source cells
+ if (eCellType != CELLTYPE_EDIT)
+ continue;
+
const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nStartRow);
if ( !pRanges )
continue;
@@ -1497,6 +1505,10 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
case FILL_TO_TOP:
for ( SCCOL nColItr = nStartCol; nColItr <= nEndCol; ++nColItr )
{
+ pDoc->GetCellType(nColItr, nEndRow, nTab, eCellType); // We need this optimization only for EditTextObject source cells
+ if (eCellType != CELLTYPE_EDIT)
+ continue;
+
const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nColItr, nEndRow);
if ( !pRanges )
continue;
@@ -1507,6 +1519,10 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
case FILL_TO_RIGHT:
for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
{
+ pDoc->GetCellType(nStartCol, nRowItr, nTab, eCellType); // We need this optimization only for EditTextObject source cells
+ if (eCellType != CELLTYPE_EDIT)
+ continue;
+
const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nStartCol, nRowItr);
if ( !pRanges )
continue;
@@ -1517,6 +1533,10 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
case FILL_TO_LEFT:
for ( SCROW nRowItr = nStartRow; nRowItr <= nEndRow; ++nRowItr )
{
+ pDoc->GetCellType(nEndCol, nRowItr, nTab, eCellType); // We need this optimization only for EditTextObject source cells
+ if (eCellType != CELLTYPE_EDIT)
+ continue;
+
const std::vector<editeng::MisspellRanges>* pRanges = pWin->GetAutoSpellData(nEndCol, nRowItr);
if ( !pRanges )
continue;
@@ -1533,11 +1553,19 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
SCCOL nColRepeatSize = nEndCol - nStartCol + 1;
SCROW nTillRow = 0;
SCCOL nTillCol = 0;
- std::vector<std::vector<MisspellRangesType>> aSourceSpellRanges(nRowRepeatSize, std::vector<MisspellRangesType>(nColRepeatSize));
+ std::vector<std::vector<MisspellRangesType>> aSourceSpellRanges(nRowRepeatSize, std::vector<MisspellRangesType>(nColRepeatSize, nullptr));
for ( SCROW nRowIdx = 0; nRowIdx < nRowRepeatSize; ++nRowIdx )
+ {
for ( SCCOL nColIdx = 0; nColIdx < nColRepeatSize; ++nColIdx )
+ {
+ pDoc->GetCellType(nStartCol + nColIdx, nStartRow + nRowIdx, nTab, eCellType); // We need this optimization only for EditTextObject source cells
+ if (eCellType != CELLTYPE_EDIT)
+ continue;
+
aSourceSpellRanges[nRowIdx][nColIdx] = pWin->GetAutoSpellData( nStartCol + nColIdx, nStartRow + nRowIdx );
+ }
+ }
switch( eDir )
{
@@ -1603,7 +1631,7 @@ void ScViewFunc::CopyAutoSpellData( FillDir eDir, SCCOL nStartCol, SCROW nStartR
}
}
else
- pWin->ResetAutoSpell();
+ pWin->ResetAutoSpellForContentChange();
}