summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-10-04 12:47:46 +0530
committerMichael Meeks <michael.meeks@collabora.com>2020-10-23 02:01:43 +0200
commit5001ae871df204035cbea77d7a5bcd849e133a2b (patch)
treeabc524e5e0d740fee3c3ade189c300baf3977b31 /sc/inc
parentb6c60a98f4c0cb08107a221486fa52aef6ca4da7 (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/+/103941 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/inc/spellcheckcontext.hxx72
2 files changed, 38 insertions, 36 deletions
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index e214771bd2e4..868f3d77c73c 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -81,7 +81,6 @@ class SfxDialogController;
class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener
{
Timer m_aIdleTimer;
- Idle m_aSpellIdle;
std::unique_ptr<ScDragData> m_pDragData;
ScSelectionTransferObj* m_pSelTransfer;
ScMessagePool* m_pMessagePool;
@@ -131,7 +130,6 @@ public:
// moved by the application
DECL_LINK( IdleHandler, Timer*, void ); // Timer instead of idle
- DECL_LINK( SpellTimerHdl, Timer*, void );
DECL_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
void Execute( SfxRequest& rReq );
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
index 42ec80389af2..07cab368443b 100644
--- a/sc/inc/spellcheckcontext.hxx
+++ b/sc/inc/spellcheckcontext.hxx
@@ -10,50 +10,54 @@
#ifndef INCLUDED_SC_INC_SPELLCHECKCONTEXT_HXX
#define INCLUDED_SC_INC_SPELLCHECKCONTEXT_HXX
+#include <i18nlangtag/lang.h>
#include <editeng/misspellrange.hxx>
#include "types.hxx"
-#include <unordered_map>
+#include <memory>
#include <vector>
-namespace sc {
+class ScDocument;
+class ScTabEditEngine;
-struct SpellCheckContext
+namespace sc
{
- struct CellPos
- {
- struct Hash
- {
- size_t operator() (const CellPos& rPos) const;
- };
-
- SCCOL mnCol;
- SCROW mnRow;
-
- CellPos();
- CellPos(SCCOL nCol, SCROW nRow);
-
- void setInvalid();
- bool isValid() const;
- void reset();
-
- bool operator== (const CellPos& r) const;
- };
-
- typedef std::unordered_map<CellPos, std::vector<editeng::MisspellRanges>, CellPos::Hash> CellMapType;
-
- CellPos maPos;
- CellMapType maMisspellCells;
-
- SpellCheckContext();
-
- bool isMisspelled( SCCOL nCol, SCROW nRow ) const;
- const std::vector<editeng::MisspellRanges>* getMisspellRanges( SCCOL nCol, SCROW nRow ) const;
- void setMisspellRanges( SCCOL nCol, SCROW nRow, const std::vector<editeng::MisspellRanges>* pRanges );
+/**
+ * Class shared between grid windows to cache
+ * spelling results.
+ */
+class SpellCheckContext
+{
+ class SpellCheckCache;
+ struct SpellCheckStatus;
+ struct SpellCheckResult;
+
+ std::unique_ptr<SpellCheckCache> mpCache;
+ std::unique_ptr<SpellCheckResult> mpResult;
+ ScDocument* pDoc;
+ std::unique_ptr<ScTabEditEngine> mpEngine;
+ std::unique_ptr<SpellCheckStatus> mpStatus;
+ SCTAB mnTab;
+ LanguageType meLanguage;
+
+public:
+ SpellCheckContext(ScDocument* pDocument, SCTAB nTab);
+ ~SpellCheckContext();
+ void dispose();
+
+ bool isMisspelled(SCCOL nCol, SCROW nRow) const;
+ const std::vector<editeng::MisspellRanges>* getMisspellRanges(SCCOL nCol, SCROW nRow) const;
+ void setMisspellRanges(SCCOL nCol, SCROW nRow,
+ const std::vector<editeng::MisspellRanges>* pRanges);
void reset();
-};
+ void resetForContentChange();
+private:
+ void ensureResults(SCCOL nCol, SCROW nRow);
+ void resetCache(bool bContentChangeOnly = false);
+ void resetEngine();
+};
}
#endif