summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-09-01 09:46:07 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-09-01 14:48:49 -0400
commit0ee265e82ea64839e559fcded4d268de721f4202 (patch)
tree1f3872f631d52f13ee21402075a52402fe4e7f36
parent0a57be8c6e397ed8e27611edaaf8bbf2677611de (diff)
Handle enabling / disabling of auto spell check.
Change-Id: I8f3fe06a41b825f233f4116ae8ba3b30cb4f1adc
-rw-r--r--sc/inc/spellcheckcontext.hxx3
-rw-r--r--sc/source/ui/app/scmod.cxx3
-rw-r--r--sc/source/ui/inc/gridwin.hxx1
-rw-r--r--sc/source/ui/inc/tabview.hxx1
-rw-r--r--sc/source/ui/view/gridwin.cxx12
-rw-r--r--sc/source/ui/view/gridwin2.cxx12
-rw-r--r--sc/source/ui/view/spellcheckcontext.cxx12
-rw-r--r--sc/source/ui/view/tabview.cxx11
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx4
9 files changed, 55 insertions, 4 deletions
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
index c92cee4965e6..5d81ad5b4601 100644
--- a/sc/inc/spellcheckcontext.hxx
+++ b/sc/inc/spellcheckcontext.hxx
@@ -34,6 +34,7 @@ struct SpellCheckContext
void setInvalid();
bool isValid() const;
+ void reset();
bool operator< (const CellPos& r) const;
bool operator== (const CellPos& r) const;
@@ -48,6 +49,8 @@ struct SpellCheckContext
bool isMisspelled( SCCOL nCol, SCROW nRow ) const;
const std::vector<editeng::MisspellRanges>* getMisspellRanges( SCCOL nCol, SCROW nRow ) const;
+
+ void reset();
};
}
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 37dee2fd5df1..a643736084a4 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1226,6 +1226,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
pDoc->RemoveAutoSpellObj(); // Edit-Text-Objekte wieder zurueckwandeln
}
+ if (pViewSh)
+ pViewSh->EnableAutoSpell(bDoAutoSpell);
+
//#92038#; don't set document modified, because this flag is no longer saved
// pDocSh->SetDocumentModified();
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index ba55617a4981..91a3774c5811 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -392,6 +392,7 @@ public:
void CursorChanged();
void DrawLayerCreated();
bool ContinueOnlineSpelling();
+ void EnableAutoSpell( bool bEnable );
void DeleteCopySourceOverlay();
void UpdateCopySourceOverlay();
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 69d9c54f159d..75215e878eca 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -522,6 +522,7 @@ public:
void SetInRefMode( bool bRefMode );
bool ContinueOnlineSpelling();
+ void EnableAutoSpell( bool bEnable );
};
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 7fc7050b6e6e..03dc2aa101ef 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -445,7 +445,6 @@ ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhic
mpOOHeader( NULL ),
mpOOShrink( NULL ),
mpAutoFillRect(static_cast<Rectangle*>(NULL)),
- mpSpellCheckCxt(new sc::SpellCheckContext),
pViewData( pData ),
eWhich( eWhichPos ),
pNoteMarker( NULL ),
@@ -5386,6 +5385,9 @@ IMPL_LINK(SpellCheckStatus, EventHdl, EditStatus*, pStatus)
bool ScGridWindow::ContinueOnlineSpelling()
{
+ if (!mpSpellCheckCxt)
+ return false;
+
if (!mpSpellCheckCxt->maPos.isValid())
return false;
@@ -5513,6 +5515,14 @@ bool ScGridWindow::ContinueOnlineSpelling()
return bChanged;
}
+void ScGridWindow::EnableAutoSpell( bool bEnable )
+{
+ if (bEnable)
+ mpSpellCheckCxt.reset(new sc::SpellCheckContext);
+ else
+ mpSpellCheckCxt.reset();
+}
+
// #114409#
void ScGridWindow::CursorChanged()
{
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index c104b463561b..c945165cc411 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -40,9 +40,10 @@
#include "checklistmenu.hrc"
#include "strload.hxx"
#include "userlist.hxx"
+#include "scabstdlg.hxx"
+#include "spellcheckcontext.hxx"
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
-#include "scabstdlg.hxx"
#include <vector>
#include <boost/unordered_map.hpp>
@@ -604,7 +605,14 @@ bool ScGridWindow::UpdateVisibleRange()
if (nYBottom > MAXROW) nYBottom = MAXROW;
// Store the current visible range.
- return maVisibleRange.set(nPosX, nPosY, nXRight, nYBottom);
+ bool bChanged = maVisibleRange.set(nPosX, nPosY, nXRight, nYBottom);
+ if (bChanged)
+ {
+ if (mpSpellCheckCxt)
+ mpSpellCheckCxt->reset();
+ }
+
+ return bChanged;
}
void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt )
diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx
index c064d2b69b45..d6cec232e889 100644
--- a/sc/source/ui/view/spellcheckcontext.cxx
+++ b/sc/source/ui/view/spellcheckcontext.cxx
@@ -33,6 +33,12 @@ bool SpellCheckContext::CellPos::isValid() const
return mnCol >= 0 && mnRow >= 0;
}
+void SpellCheckContext::CellPos::reset()
+{
+ mnCol = 0;
+ mnRow = 0;
+}
+
bool SpellCheckContext::CellPos::operator< (const CellPos& r) const
{
if (mnCol != r.mnCol)
@@ -65,6 +71,12 @@ const std::vector<editeng::MisspellRanges>* SpellCheckContext::getMisspellRanges
return &it->second;
}
+void SpellCheckContext::reset()
+{
+ maPos.reset();
+ maMisspellCells.clear();
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 3be9f36b908a..599b5a6e7560 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2347,4 +2347,15 @@ bool ScTabView::ContinueOnlineSpelling()
return bChanged;
}
+void ScTabView::EnableAutoSpell( bool bEnable )
+{
+ for (int i = 0; i < 4; ++i)
+ {
+ if (!pGridWin[i])
+ continue;
+
+ pGridWin[i]->EnableAutoSpell(bEnable);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 33478ae25b60..3be788daa896 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -82,6 +82,7 @@
#include "defaultsoptions.hxx"
#include "markdata.hxx"
#include "preview.hxx"
+#include "docoptio.hxx"
#include <com/sun/star/document/XDocumentProperties.hpp>
@@ -1475,9 +1476,10 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
SfxApplication* pSfxApp = SFX_APP();
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
-
bReadOnly = pDocSh->IsReadOnly();
+ EnableAutoSpell(pDoc->GetDocOptions().IsAutoSpell());
+
SetName(OUString("View")); // fuer SBX
Color aColBlack( COL_BLACK );
SetPool( &SC_MOD()->GetPool() );