[Libreoffice-commits] core.git: 10 commits - editeng/source include/editeng sc/inc sc/Library_sc.mk sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Sun Sep 1 11:45:32 PDT 2013
editeng/source/editeng/editdoc.cxx | 19 ++
editeng/source/editeng/editdoc.hxx | 3
editeng/source/editeng/editeng.cxx | 15 +
editeng/source/editeng/edtspell.cxx | 10 +
editeng/source/editeng/edtspell.hxx | 3
editeng/source/editeng/impedit.hxx | 9
editeng/source/editeng/impedit4.cxx | 40 ++++
editeng/source/editeng/misspellrange.cxx | 3
include/editeng/editeng.hxx | 7
include/editeng/misspellrange.hxx | 10 +
sc/Library_sc.mk | 1
sc/inc/column.hxx | 2
sc/inc/dociter.hxx | 7
sc/inc/document.hxx | 11 -
sc/inc/spellcheckcontext.hxx | 61 ++++++
sc/inc/table.hxx | 2
sc/source/core/data/column2.cxx | 46 ----
sc/source/core/data/dociter.cxx | 11 -
sc/source/core/data/documen8.cxx | 287 -------------------------------
sc/source/core/data/table4.cxx | 6
sc/source/ui/app/inputhdl.cxx | 16 +
sc/source/ui/app/scmod.cxx | 49 +++--
sc/source/ui/app/uiitems.cxx | 47 +++--
sc/source/ui/docshell/docfunc.cxx | 1
sc/source/ui/inc/gridwin.hxx | 21 +-
sc/source/ui/inc/output.hxx | 13 +
sc/source/ui/inc/tabview.hxx | 9
sc/source/ui/inc/uiitems.hxx | 9
sc/source/ui/view/cellsh3.cxx | 5
sc/source/ui/view/gridwin.cxx | 189 ++++++++++++++++++++
sc/source/ui/view/gridwin2.cxx | 9
sc/source/ui/view/gridwin4.cxx | 1
sc/source/ui/view/output.cxx | 8
sc/source/ui/view/output2.cxx | 39 +++-
sc/source/ui/view/spellcheckcontext.cxx | 102 +++++++++++
sc/source/ui/view/tabview.cxx | 48 +++++
sc/source/ui/view/tabview4.cxx | 15 -
sc/source/ui/view/tabvwsh4.cxx | 4
sc/source/ui/view/viewfun3.cxx | 8
sc/source/ui/view/viewfunc.cxx | 4
40 files changed, 697 insertions(+), 453 deletions(-)
New commits:
commit 0044fc8a722f3e52c8053b10f5032171f82b508f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 14:31:36 2013 -0400
Reset auto spell data in the view shell instead of in the doc shell.
It makes more sense that way.
Change-Id: Ib2e2167228b1c2a2a19a750477652e18ae69d105
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index acbee87..15355ee 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2010,9 +2010,6 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
rDocShell.ErrorMessage(STR_INSERT_FULL); // Spalte/Zeile voll
}
- if (pViewSh)
- pViewSh->ResetAutoSpell();
-
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
@@ -2494,10 +2491,6 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
}
}
- ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
- if (pViewSh)
- pViewSh->ResetAutoSpell();
-
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index ec74970..aa4b9e9 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1268,11 +1268,9 @@ bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
true, false, bIncludeFiltered );
}
-
pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
nEndCol, nEndRow, nEndTab ); // content after the change
-
// ggf. Autofilter-Koepfe loeschen
if (bCutMode)
if (pDoc->RefreshAutoFilter( nClipStartX,nClipStartY, nClipStartX+nClipSizeX,
@@ -1355,6 +1353,7 @@ bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,
nPaint, nExtFlags);
// AdjustBlockHeight has already been called above
+ ResetAutoSpell();
aModificator.SetDocumentModified();
PostPasteFromClip(aUserRange, rMark);
@@ -1530,6 +1529,8 @@ bool ScViewFunc::PasteMultiRangesFromClip(
pUndoMgr->LeaveListAction();
}
+
+ ResetAutoSpell();
aModificator.SetDocumentModified();
PostPasteFromClip(aMarkedRange, aMark);
return true;
@@ -1686,6 +1687,8 @@ bool ScViewFunc::PasteFromClipToMultiRanges(
pUndoMgr->AddUndoAction(pUndo, false);
pUndoMgr->LeaveListAction();
}
+
+ ResetAutoSpell();
aModificator.SetDocumentModified();
PostPasteFromClip(aRanges, aMark);
@@ -1808,6 +1811,7 @@ sal_Bool ScViewFunc::MoveBlockTo( const ScRange& rSource, const ScAddress& rDest
pDocSh->UpdateOle(GetViewData());
SelectionChanged();
+ ResetAutoSpell();
}
return bSuccess;
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 2096db7..6e026fb 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1489,6 +1489,7 @@ sal_Bool ScViewFunc::InsertCells( InsCellCmd eCmd, sal_Bool bRecord, sal_Bool bP
{
pDocSh->UpdateOle(GetViewData());
CellContentChanged();
+ ResetAutoSpell();
// #i97876# Spreadsheet data changes are not notified
ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
@@ -1552,6 +1553,7 @@ void ScViewFunc::DeleteCells( DelCellCmd eCmd, sal_Bool bRecord )
pDocSh->UpdateOle(GetViewData());
CellContentChanged();
+ ResetAutoSpell();
// #i97876# Spreadsheet data changes are not notified
ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
@@ -1750,6 +1752,8 @@ void ScViewFunc::DeleteMulti( sal_Bool bRows, sal_Bool bRecord )
pDocSh->PostPaint( static_cast<SCCOL>(pRanges[0]),0,nTab,
MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_TOP );
}
+
+ ResetAutoSpell();
aModificator.SetDocumentModified();
CellContentChanged();
commit b796e268630dd02f35a312b84867f63b3fa8da2f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 14:06:07 2013 -0400
Fix a crash when inserting a multi-line content into cell.
Change-Id: Idf2b6ca6873860a9bb3d2dae646b0383435e58c9
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 3fefacb..d091980 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1732,6 +1732,12 @@ sal_Unicode ContentNode::GetChar(sal_uInt16 nPos) const
return maString.GetChar(nPos);
}
+void ContentNode::EnsureWrongList()
+{
+ if (!mpWrongList)
+ CreateWrongList();
+}
+
WrongList* ContentNode::GetWrongList()
{
return mpWrongList.get();
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index b2928a6..3a4a4a0 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -283,6 +283,7 @@ public:
void CreateDefFont();
+ void EnsureWrongList();
WrongList* GetWrongList();
const WrongList* GetWrongList() const;
void SetWrongList( WrongList* p );
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 72bfa89..1b094f3 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2285,6 +2285,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC
if ( pThisNodeOnly )
pNode = pThisNodeOnly;
+ pNode->EnsureWrongList();
if (!pNode->GetWrongList()->IsValid())
{
WrongList* pWrongList = pNode->GetWrongList();
commit 309c766d99cc7efc11fc439d119ba1944f2d710a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 13:57:52 2013 -0400
Separate misspelled ranges when entering a new cell value.
And store them at appropriate locations.
Change-Id: Iaf38c0cd01e9b3dc9dc98f7ccc1951d572a422e9
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 8cd17b7..3fefacb 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1893,6 +1893,14 @@ public:
}
};
+struct ClearSpellErrorsHandler : std::unary_function<ContentNode, void>
+{
+ void operator() (ContentNode& rNode)
+ {
+ rNode.DestroyWrongList();
+ }
+};
+
}
void EditDoc::ImplDestroyContents()
@@ -2215,6 +2223,11 @@ EditPaM EditDoc::Clear()
return aPaM;
}
+void EditDoc::ClearSpellErrors()
+{
+ std::for_each(maContents.begin(), maContents.end(), ClearSpellErrorsHandler());
+}
+
void EditDoc::SetModified( bool b )
{
bModified = b;
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 1a6d1d0..b2928a6 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -750,6 +750,8 @@ public:
EditDoc( SfxItemPool* pItemPool );
~EditDoc();
+ void ClearSpellErrors();
+
bool IsModified() const { return bModified; }
void SetModified( bool b );
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 4e34071..e3309d4 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2327,6 +2327,11 @@ EESpellState EditEngine::HasSpellErrors()
return pImpEditEngine->HasSpellErrors();
}
+void EditEngine::ClearSpellErrors()
+{
+ pImpEditEngine->ClearSpellErrors();
+}
+
void EditEngine::StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc)
{
DBG_CHKTHIS( EditEngine, 0 );
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index b62bc02..34075af 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -907,6 +907,7 @@ public:
void DoOnlineSpelling( ContentNode* pThisNodeOnly = 0, bool bSpellAtCursorPos = false, bool bInteruptable = true );
EESpellState Spell( EditView* pEditView, sal_Bool bMultipleDoc );
EESpellState HasSpellErrors();
+ void ClearSpellErrors();
EESpellState StartThesaurus( EditView* pEditView );
::com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XSpellAlternatives >
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 99a9101..72bfa89 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2484,6 +2484,11 @@ EESpellState ImpEditEngine::HasSpellErrors()
return EE_SPELL_ERRORFOUND;
}
+void ImpEditEngine::ClearSpellErrors()
+{
+ aEditDoc.ClearSpellErrors();
+}
+
EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView )
{
EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index 7545317..c7debc4 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -416,6 +416,7 @@ public:
// For fast Pre-Test without view:
EESpellState HasSpellErrors();
+ void ClearSpellErrors();
sal_Bool HasText( const SvxSearchItem& rSearchItem );
//initialize sentence spelling
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
index 5d81ad5..e3f3f74 100644
--- a/sc/inc/spellcheckcontext.hxx
+++ b/sc/inc/spellcheckcontext.hxx
@@ -49,6 +49,7 @@ struct 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 );
void reset();
};
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 42cbbb1..7454a74 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -38,6 +38,7 @@
#include <editeng/unolingu.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/justifyitem.hxx>
+#include "editeng/misspellrange.hxx"
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/dispatch.hxx>
@@ -2557,6 +2558,7 @@ void ScInputHandler::EnterHandler( sal_uInt8 nBlockMode )
}
}
+ std::vector<editeng::MisspellRanges> aMisspellRanges;
pEngine->CompleteOnlineSpelling();
bool bSpellErrors = !bFormulaMode && pEngine->HasOnlineSpellErrors();
if ( bSpellErrors )
@@ -2646,7 +2648,7 @@ void ScInputHandler::EnterHandler( sal_uInt8 nBlockMode )
bool bAttrib = false; // Formatierung vorhanden ?
// check if EditObject is needed
- if ( bSpellErrors || nParCnt > 1 )
+ if (nParCnt > 1)
bAttrib = true;
else
{
@@ -2683,15 +2685,15 @@ void ScInputHandler::EnterHandler( sal_uInt8 nBlockMode )
// (der Test vorher ist trotzdem noetig wegen Zell-Attributen)
}
+ if (bSpellErrors)
+ pEngine->GetAllMisspellRanges(aMisspellRanges);
+
if (bMatrix)
bAttrib = false;
if (bAttrib)
{
- sal_uLong nCtrl = pEngine->GetControlWord();
- sal_uLong nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0;
- if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig )
- pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig );
+ pEngine->ClearSpellErrors();
pObject = pEngine->CreateTextObject();
}
else if (bAutoComplete) // Gross-/Kleinschreibung anpassen
@@ -2797,6 +2799,10 @@ void ScInputHandler::EnterHandler( sal_uInt8 nBlockMode )
ScInputStatusItem aItem( FID_INPUTLINE_STATUS,
aCursorPos, aCursorPos, aCursorPos,
aString, pObject );
+
+ if (!aMisspellRanges.empty())
+ aItem.SetMisspellRanges(&aMisspellRanges);
+
const SfxPoolItem* aArgs[2];
aArgs[0] = &aItem;
aArgs[1] = NULL;
diff --git a/sc/source/ui/app/uiitems.cxx b/sc/source/ui/app/uiitems.cxx
index d26337d..ab83063 100644
--- a/sc/source/ui/app/uiitems.cxx
+++ b/sc/source/ui/app/uiitems.cxx
@@ -45,28 +45,27 @@ TYPEINIT1(ScIndexHint, SfxHint);
// ScInputStatusItem - Status-Update fuer Eingabezeile
// -----------------------------------------------------------------------
-ScInputStatusItem::ScInputStatusItem( sal_uInt16 nWhichP,
- const ScAddress& rCurPos,
- const ScAddress& rStartPos,
- const ScAddress& rEndPos,
- const OUString& rString,
- const EditTextObject* pData )
- : SfxPoolItem ( nWhichP ),
- aCursorPos ( rCurPos ),
- aStartPos ( rStartPos ),
- aEndPos ( rEndPos ),
- aString ( rString ),
- pEditData ( pData ? pData->Clone() : NULL )
+ScInputStatusItem::ScInputStatusItem(
+ sal_uInt16 nWhichP, const ScAddress& rCurPos, const ScAddress& rStartPos,
+ const ScAddress& rEndPos, const OUString& rString, const EditTextObject* pData ) :
+ SfxPoolItem ( nWhichP ),
+ aCursorPos ( rCurPos ),
+ aStartPos ( rStartPos ),
+ aEndPos ( rEndPos ),
+ aString ( rString ),
+ pEditData ( pData ? pData->Clone() : NULL ),
+ mpMisspellRanges(NULL)
{
}
-ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem )
- : SfxPoolItem ( rItem ),
- aCursorPos ( rItem.aCursorPos ),
- aStartPos ( rItem.aStartPos ),
- aEndPos ( rItem.aEndPos ),
- aString ( rItem.aString ),
- pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : NULL )
+ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ aCursorPos ( rItem.aCursorPos ),
+ aStartPos ( rItem.aStartPos ),
+ aEndPos ( rItem.aEndPos ),
+ aString ( rItem.aString ),
+ pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : NULL ),
+ mpMisspellRanges(rItem.mpMisspellRanges)
{
}
@@ -96,6 +95,16 @@ SfxPoolItem* ScInputStatusItem::Clone( SfxItemPool * ) const
return new ScInputStatusItem( *this );
}
+void ScInputStatusItem::SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges )
+{
+ mpMisspellRanges = pRanges;
+}
+
+const std::vector<editeng::MisspellRanges>* ScInputStatusItem::GetMisspellRanges() const
+{
+ return mpMisspellRanges;
+}
+
//
// ScPaintHint ist nach schints.cxx verschoben
//
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index cbb774b..4288342 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -394,6 +394,7 @@ public:
bool ContinueOnlineSpelling();
void EnableAutoSpell( bool bEnable );
void ResetAutoSpell();
+ void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
void DeleteCopySourceOverlay();
void UpdateCopySourceOverlay();
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index cb94eb8..4964e6d 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -30,6 +30,10 @@
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
+namespace editeng {
+ struct MisspellRanges;
+}
+
class ScEditEngineDefaulter;
class ScGridWindow;
class ScOutlineWindow;
@@ -524,6 +528,7 @@ public:
bool ContinueOnlineSpelling();
void EnableAutoSpell( bool bEnable );
void ResetAutoSpell();
+ void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
};
diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx
index d475289..a74a08d 100644
--- a/sc/source/ui/inc/uiitems.hxx
+++ b/sc/source/ui/inc/uiitems.hxx
@@ -27,8 +27,13 @@
#include "paramisc.hxx"
#include <svl/poolitem.hxx>
+#include <vector>
#include <boost/scoped_ptr.hpp>
+namespace editeng {
+ struct MisspellRanges;
+}
+
class ScEditEngineDefaulter;
class EditTextObject;
class ScViewData;
@@ -46,6 +51,7 @@ class ScInputStatusItem : public SfxPoolItem
ScAddress aEndPos;
OUString aString;
EditTextObject* pEditData;
+ const std::vector<editeng::MisspellRanges>* mpMisspellRanges;
public:
TYPEINFO();
@@ -77,6 +83,9 @@ public:
const OUString& GetString() const { return aString; }
const EditTextObject* GetEditData() const { return pEditData; }
+
+ void SetMisspellRanges( const std::vector<editeng::MisspellRanges>* pRanges );
+ const std::vector<editeng::MisspellRanges>* GetMisspellRanges() const;
};
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 5830838..aa1aeea 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -232,6 +232,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
ScAddress aCursorPos = pStatusItem->GetPos();
String aString = pStatusItem->GetString();
const EditTextObject* pData = pStatusItem->GetEditData();
+
if (pData)
{
if (nSlot == FID_INPUTLINE_BLOCK)
@@ -285,9 +286,11 @@ void ScCellShell::Execute( SfxRequest& rReq )
pTabViewShell->EnterMatrix( aString, pDoc->GetGrammar() );
rReq.Done();
}
-
}
+ pTabViewShell->SetAutoSpellData(
+ aCursorPos.Col(), aCursorPos.Row(), pStatusItem->GetMisspellRanges());
+
// no GrabFocus here, as otherwise on a Mac the tab jumps before the
// sideview, when the input was not finished
// (GrabFocus is called in KillEditView)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 6949b8f..692fcec 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5533,6 +5533,17 @@ void ScGridWindow::ResetAutoSpell()
}
}
+void ScGridWindow::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges )
+{
+ if (!mpSpellCheckCxt)
+ return;
+
+ if (!maVisibleRange.isInside(nPosX, nPosY))
+ return;
+
+ mpSpellCheckCxt->setMisspellRanges(nPosX, nPosY, pRanges);
+}
+
// #114409#
void ScGridWindow::CursorChanged()
{
diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx
index d6cec23..66c218e 100644
--- a/sc/source/ui/view/spellcheckcontext.cxx
+++ b/sc/source/ui/view/spellcheckcontext.cxx
@@ -71,6 +71,26 @@ const std::vector<editeng::MisspellRanges>* SpellCheckContext::getMisspellRanges
return &it->second;
}
+void SpellCheckContext::setMisspellRanges(
+ SCCOL nCol, SCROW nRow, const std::vector<editeng::MisspellRanges>* pRanges )
+{
+ CellPos aPos(nCol, nRow);
+ CellMapType::iterator it = maMisspellCells.find(aPos);
+
+ if (pRanges)
+ {
+ if (it == maMisspellCells.end())
+ maMisspellCells.insert(CellMapType::value_type(aPos, *pRanges));
+ else
+ it->second = *pRanges;
+ }
+ else
+ {
+ if (it != maMisspellCells.end())
+ maMisspellCells.erase(it);
+ }
+}
+
void SpellCheckContext::reset()
{
maPos.reset();
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 2e9e612..7feb1b7 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2369,4 +2369,15 @@ void ScTabView::ResetAutoSpell()
}
}
+void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges )
+{
+ for (int i = 0; i < 4; ++i)
+ {
+ if (!pGridWin[i])
+ continue;
+
+ pGridWin[i]->SetAutoSpellData(nPosX, nPosY, pRanges);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 16c8c46d85d7aafcb9159b12e2d44bc0bf322c69
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 11:39:57 2013 -0400
Reset autospell data when inserting/deleting cells.
Change-Id: I4ec48afe4a1aebe96dfb0fe5d507c786bdecae66
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d0b0e50..acbee87 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2010,6 +2010,9 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
rDocShell.ErrorMessage(STR_INSERT_FULL); // Spalte/Zeile voll
}
+ if (pViewSh)
+ pViewSh->ResetAutoSpell();
+
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
@@ -2490,6 +2493,11 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
rDocShell.PostPaint( nPaintStartCol, nPaintStartRow, *itr, nPaintEndCol, nPaintEndRow, *itr+nScenarioCount, PAINT_TOP );
}
}
+
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+ if (pViewSh)
+ pViewSh->ResetAutoSpell();
+
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 91a3774..cbb774b 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -393,6 +393,7 @@ public:
void DrawLayerCreated();
bool ContinueOnlineSpelling();
void EnableAutoSpell( bool bEnable );
+ void ResetAutoSpell();
void DeleteCopySourceOverlay();
void UpdateCopySourceOverlay();
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 75215e8..cb94eb8 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -523,6 +523,7 @@ public:
bool ContinueOnlineSpelling();
void EnableAutoSpell( bool bEnable );
+ void ResetAutoSpell();
};
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 03dc2aa..6949b8f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5523,6 +5523,16 @@ void ScGridWindow::EnableAutoSpell( bool bEnable )
mpSpellCheckCxt.reset();
}
+void ScGridWindow::ResetAutoSpell()
+{
+ if (mpSpellCheckCxt)
+ {
+ mpSpellCheckCxt->reset();
+ mpSpellCheckCxt->maPos.mnCol = maVisibleRange.mnCol1;
+ mpSpellCheckCxt->maPos.mnRow = maVisibleRange.mnRow1;
+ }
+}
+
// #114409#
void ScGridWindow::CursorChanged()
{
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 2a057b5..ba28604 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -607,10 +607,7 @@ bool ScGridWindow::UpdateVisibleRange()
// Store the current visible range.
bool bChanged = maVisibleRange.set(nPosX, nPosY, nXRight, nYBottom);
if (bChanged)
- {
- if (mpSpellCheckCxt)
- mpSpellCheckCxt->reset();
- }
+ ResetAutoSpell();
return bChanged;
}
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 599b5a6..2e9e612 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2358,4 +2358,15 @@ void ScTabView::EnableAutoSpell( bool bEnable )
}
}
+void ScTabView::ResetAutoSpell()
+{
+ for (int i = 0; i < 4; ++i)
+ {
+ if (!pGridWin[i])
+ continue;
+
+ pGridWin[i]->ResetAutoSpell();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a50fe4298d6761567230a1570a544398cca850c6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 10:56:29 2013 -0400
These pieces of code are no longer needed.
Change-Id: I93a4abc84856a43d9d3a27ebadf111e589c62604
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4322c24..7308d22 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -431,8 +431,6 @@ public:
bool TestTabRefAbs(SCTAB nTable) const;
bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const;
- void RemoveAutoSpellObj();
-
void StartListening( SvtListener& rLst, SCROW nRow );
void EndListening( SvtListener& rLst, SCROW nRow );
void StartListening( sc::StartListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 23e310d..8a57ef3 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -440,13 +440,6 @@ public:
/// Set a(nother) sheet and (re)init.
void SetTab( SCTAB nTab );
- /**
- * When modifying a cell while still in iteration, call this to re-fetch
- * the column iterators used internally because the old iterators have
- * been invalidated.
- */
- void RehashCol( SCCOL nCol );
-
private:
void Advance();
};
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e8aa17d..b91e8d3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -315,9 +315,6 @@ private:
ScRange aEmbedRange;
ScAddress aCurTextWidthCalcPos;
- ScAddress aOnlineSpellPos; // within whole document
- ScRange aVisSpellRange;
- ScAddress aVisSpellPos; // within aVisSpellRange (see nVisSpellState)
Timer aTrackTimer;
@@ -1658,9 +1655,6 @@ public:
bool IsDetectiveDirty() const { return bDetectiveDirty; }
void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; }
- void RemoveAutoSpellObj();
- void SetOnlineSpellPos( const ScAddress& rPos );
-
sal_uInt8 GetMacroCallMode() const { return nMacroCallMode; }
void SetMacroCallMode(sal_uInt8 nNew) { nMacroCallMode = nNew; }
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 99c506b..69d2520 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -308,8 +308,6 @@ public:
void SetPageSize( const Size& rSize );
void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
- void RemoveAutoSpellObj();
-
void LockTable();
void UnlockTable();
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 9edca5f..855be2e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1019,45 +1019,6 @@ public:
}
};
-class RemoveAutoSpellObjHandler : public StrEntries
-{
- ScDocument* mpDoc;
- boost::scoped_ptr<ScTabEditEngine> mpEngine;
-
-public:
- RemoveAutoSpellObjHandler(sc::CellStoreType& rCells, ScDocument* pDoc) : StrEntries(rCells), mpDoc(pDoc) {}
-
- void operator() (size_t nRow, EditTextObject*& pObj)
- {
- // no query on HasOnlineSpellErrors, this makes it also work after loading
-
- // For the test on hard formatting (ScEditAttrTester), are the defaults in the
- // EditEngine of no importance. When the tester would later recognise the same
- // attributes in default and hard formatting and has to remove them, the correct
- // defaults must be set in the EditEngine for each cell.
-
- // test for attributes
- if (!mpEngine)
- mpEngine.reset(new ScTabEditEngine(mpDoc));
-
- mpEngine->SetText(*pObj);
-
- ScEditAttrTester aTester(mpEngine.get());
- if (aTester.NeedsObject()) // only remove spelling errors
- {
- // Overwrite the existing object.
- delete pObj;
- pObj = mpEngine->CreateTextObject();
- }
- else
- {
- // Store the string replacement for later commits.
- OUString aText = ScEditUtil::GetSpaceDelimitedString(*mpEngine);
- maStrEntries.push_back(StrEntry(nRow, aText));
- }
- }
-};
-
class RemoveEditAttribsHandler : public StrEntries
{
ScDocument* mpDoc;
@@ -1138,13 +1099,6 @@ public:
}
-void ScColumn::RemoveAutoSpellObj()
-{
- RemoveAutoSpellObjHandler aFunc(maCells, pDocument);
- sc::ProcessEditText(maCells, aFunc);
- aFunc.commitStrings();
-}
-
void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow )
{
RemoveEditAttribsHandler aFunc(maCells, pDocument);
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index a31b7aa..f951ea3 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1724,17 +1724,6 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP )
Advance();
}
-void ScHorizontalCellIterator::RehashCol( SCCOL nCol )
-{
- if (nCol < nStartCol || nEndCol < nCol)
- return;
-
- ColParam& rParam = maColPositions[nCol-nStartCol];
- ScColumn& rCol = pDoc->maTabs[mnTab]->aCol[nCol];
- rParam.maPos = rCol.maCells.position(mnRow).first;
- rParam.maEnd = rCol.maCells.end();
-}
-
ScRefCellValue* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
{
if (!bMore)
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 67fb76a..db94928 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -721,44 +721,6 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers
return aScope.getNeedMore();
}
-//------------------------------------------------------------------------
-
-class ScSpellStatus
-{
-public:
- bool bModified;
-
- ScSpellStatus() : bModified(false) {};
-
- DECL_LINK (EventHdl, EditStatus*);
-};
-
-IMPL_LINK( ScSpellStatus, EventHdl, EditStatus *, pStatus )
-{
- sal_uLong nStatus = pStatus->GetStatusWord();
- if ( nStatus & EE_STAT_WRONGWORDCHANGED )
- bModified = true;
-
- return 0;
-}
-
-void ScDocument::SetOnlineSpellPos( const ScAddress& rPos )
-{
- aOnlineSpellPos = rPos;
-
- // skip visible area for aOnlineSpellPos
- if ( aVisSpellRange.In( aOnlineSpellPos ) )
- aOnlineSpellPos = aVisSpellRange.aEnd;
-}
-
-void ScDocument::RemoveAutoSpellObj()
-{
- // alle Spelling-Informationen entfernen
-
- for (SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++)
- maTabs[nTab]->RemoveAutoSpellObj();
-}
-
void ScDocument::RepaintRange( const ScRange& rRange )
{
if ( bIsVisible && pShell )
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 3797a90..339ae4a 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -2055,12 +2055,6 @@ bool ScTable::GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
return false;
}
-void ScTable::RemoveAutoSpellObj()
-{
- for (SCCOL i=0; i <= MAXCOL; i++)
- aCol[i].RemoveAutoSpellObj();
-}
-
bool ScTable::TestTabRefAbs(SCTAB nTable) const
{
for (SCCOL i=0; i <= MAXCOL; i++)
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 20c2168..2fe4540 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1218,14 +1218,6 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
aNewOpt.SetAutoSpell( bDoAutoSpell );
pDoc->SetDocOptions( aNewOpt );
- if (bDoAutoSpell)
- pDoc->SetOnlineSpellPos( ScAddress(0,0,0) ); // vorne anfangen
- else
- {
- WaitObject aWait( pDocSh->GetActiveDialogParent() );
- pDoc->RemoveAutoSpellObj(); // Edit-Text-Objekte wieder zurueckwandeln
- }
-
if (pViewSh)
pViewSh->EnableAutoSpell(bDoAutoSpell);
commit b54c1a53b4d400b1c2d282c186af1fa8f151894e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 10:39:13 2013 -0400
Repaint grid view when the visible area changes.
Change-Id: I2fe1e103b3d7c6a51a2f845e27fee0cfb6309847
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index a643736..20c2168 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1229,10 +1229,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
if (pViewSh)
pViewSh->EnableAutoSpell(bDoAutoSpell);
- //#92038#; don't set document modified, because this flag is no longer saved
-// pDocSh->SetDocumentModified();
-
- bRepaint = sal_True; // weil HideAutoSpell evtl. ungueltig
+ bRepaint = true; // weil HideAutoSpell evtl. ungueltig
//! alle Views painten ???
}
}
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index c945165..2a057b5 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -605,7 +605,7 @@ bool ScGridWindow::UpdateVisibleRange()
if (nYBottom > MAXROW) nYBottom = MAXROW;
// Store the current visible range.
- bool bChanged = maVisibleRange.set(nPosX, nPosY, nXRight, nYBottom);
+ bool bChanged = maVisibleRange.set(nPosX, nPosY, nXRight, nYBottom);
if (bChanged)
{
if (mpSpellCheckCxt)
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index a7c4fac..3aa9a47 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -428,7 +428,10 @@ void ScTabView::UpdateScrollBars()
if ( aViewData.IsActive() )
{
if (UpdateVisibleRange())
+ {
SC_MOD()->AnythingChanged(); // if visible area has changed
+ PaintGrid();
+ }
}
}
commit 0ee265e82ea64839e559fcded4d268de721f4202
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 09:46:07 2013 -0400
Handle enabling / disabling of auto spell check.
Change-Id: I8f3fe06a41b825f233f4116ae8ba3b30cb4f1adc
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
index c92cee4..5d81ad5 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 37dee2f..a643736 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 ba55617..91a3774 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 69d9c54..75215e8 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 7fc7050..03dc2aa 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 c104b46..c945165 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 c064d2b..d6cec23 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 3be9f36..599b5a6 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 33478ae..3be788d 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() );
commit 0a57be8c6e397ed8e27611edaaf8bbf2677611de
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sun Sep 1 09:09:00 2013 -0400
Be sure to skip pivot table ranges.
Change-Id: I3e57960374772756d31e392966bbf00c9fa5b6e0
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index e91d74f..7fc7050 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5390,12 +5390,20 @@ bool ScGridWindow::ContinueOnlineSpelling()
return false;
ScDocument* pDoc = pViewData->GetDocument();
+ ScDPCollection* pDPs = NULL;
+ if (pDoc->HasPivotTable())
+ pDPs = pDoc->GetDPCollection();
+
SCTAB nTab = pViewData->GetTabNo();
SpellCheckStatus aStatus;
ScHorizontalCellIterator aIter(
pDoc, nTab, maVisibleRange.mnCol1, mpSpellCheckCxt->maPos.mnRow, maVisibleRange.mnCol2, maVisibleRange.mnRow2);
+ ScRangeList aPivotRanges;
+ if (pDPs)
+ aPivotRanges = pDPs->GetAllTableRanges(nTab);
+
SCCOL nCol;
SCROW nRow;
ScRefCellValue* pCell = aIter.GetNext(nCol, nRow);
@@ -5416,6 +5424,16 @@ bool ScGridWindow::ContinueOnlineSpelling()
{
++nTotalCellCount;
+ if (aPivotRanges.In(ScAddress(nCol, nRow, nTab)))
+ {
+ // Don't spell check within pivot tables.
+ if (nTotalCellCount >= 255)
+ break;
+
+ pCell = aIter.GetNext(nCol, nRow);
+ continue;
+ }
+
CellType eType = pCell->meType;
if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT)
{
commit 5f62f8e19d07c795b98ca85350b00b5d1edef3e2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Sat Aug 31 22:35:27 2013 -0400
Auto spell-check is no longer done in ScDocument.
Change-Id: I7ecfd6160443299887e31d784322a00580aac067
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9c307f5..e8aa17d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1649,8 +1649,6 @@ public:
bool IdleCalcTextWidth();
bool IdleCheckLinks();
- bool ContinueOnlineSpelling(); // TRUE = found s.th.
-
void RepaintRange( const ScRange& rRange );
void RepaintRange( const ScRangeList& rRange );
@@ -1662,7 +1660,6 @@ public:
void RemoveAutoSpellObj();
void SetOnlineSpellPos( const ScAddress& rPos );
- SC_DLLPUBLIC bool SetVisibleSpellRange( const ScRange& rRange ); // true = changed
sal_uInt8 GetMacroCallMode() const { return nMacroCallMode; }
void SetMacroCallMode(sal_uInt8 nNew) { nMacroCallMode = nNew; }
@@ -1760,8 +1757,6 @@ private:
ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab,
SCCOLROW nEndCol, SCCOLROW* pTranslate,
ScProgress* pProgress, sal_uLong nProAdd );
- bool OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
- sal_uInt16 nMaxTest );
DECL_LINK(TrackTimeHdl, void *);
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 4dfd029..67fb76a 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -91,10 +91,6 @@
#include <memory>
#include <boost/scoped_ptr.hpp>
-// states for online spelling in the visible range (0 is set initially)
-#define VSPL_START 0
-#define VSPL_DONE 1
-
using namespace com::sun::star;
// STATIC DATA -----------------------------------------------------------
@@ -746,225 +742,6 @@ IMPL_LINK( ScSpellStatus, EventHdl, EditStatus *, pStatus )
return 0;
}
-// SPELL_MAXCELLS muss mindestens 256 sein, solange am Iterator keine
-// Start-Spalte gesetzt werden kann
-
-//! SPELL_MAXTEST fuer Timer und Idle unterschiedlich ???
-
-// SPELL_MAXTEST now divided between visible and rest of document
-
-#define SPELL_MAXTEST_VIS 1
-#define SPELL_MAXTEST_ALL 3
-#define SPELL_MAXCELLS 256
-
-bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpellPos,
- sal_uInt16 nMaxTest )
-{
- ScEditEngineDefaulter* pEngine = NULL; //! am Dokument speichern
- SfxItemSet* pDefaults = NULL;
- ScSpellStatus aStatus;
-
- sal_uInt16 nCellCount = 0; // Zellen insgesamt
- sal_uInt16 nTestCount = 0; // Aufrufe Spelling
- bool bChanged = false; // Aenderungen?
-
- SCCOL nCol = rSpellRange.aStart.Col(); // iterator always starts on the left edge
- SCROW nRow = rSpellPos.Row();
- SCTAB nTab = rSpellPos.Tab();
- if ( nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] ) // sheet deleted?
- {
- nTab = rSpellRange.aStart.Tab();
- nRow = rSpellRange.aStart.Row();
- if ( nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
- {
- // may happen for visible range
- return false;
- }
- }
-
- ScRangeList aPivotRanges;
- if (pDPCollection)
- aPivotRanges = pDPCollection->GetAllTableRanges(nTab);
-
- ScHorizontalCellIterator aIter( this, nTab,
- rSpellRange.aStart.Col(), nRow,
- rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
- ScRefCellValue* pCell = aIter.GetNext( nCol, nRow );
- // skip everything left of rSpellPos:
- while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
- pCell = aIter.GetNext( nCol, nRow );
-
- for (; pCell; pCell = aIter.GetNext(nCol, nRow))
- {
- if (!aPivotRanges.empty() && aPivotRanges.In(ScAddress(nCol, nRow, nTab)))
- // Don't spell check within pivot tables.
- continue;
-
- CellType eType = pCell->meType;
- if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
- {
- if (!pEngine)
- {
- // ScTabEditEngine is needed
- // because MapMode must be set for some old documents
- pEngine = new ScTabEditEngine( this );
- pEngine->SetControlWord( pEngine->GetControlWord() |
- ( EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS ) );
- pEngine->SetStatusEventHdl( LINK( &aStatus, ScSpellStatus, EventHdl ) );
- // Delimiters hier wie in inputhdl.cxx !!!
- pEngine->SetWordDelimiters(
- ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
- pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
-
- com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
-
- pEngine->SetSpeller( xXSpellChecker1 );
- }
-
- const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
- if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) )
- {
- ScPatternAttr* pPreviewPattern = new ScPatternAttr( *pPattern );
- pPreviewPattern->SetStyleSheet(pPreviewStyle);
- pPreviewPattern->FillEditItemSet( pDefaults );
- delete pPreviewPattern;
- }
- else
- {
- SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab );
- pPattern->FillEditItemSet( pDefaults, pFontSet );
- }
- pEngine->SetDefaults( pDefaults, false ); //! noetig ?
-
- sal_uInt16 nCellLang = ((const SvxLanguageItem&)
- pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
- if ( nCellLang == LANGUAGE_SYSTEM )
- nCellLang = Application::GetSettings().GetLanguageTag().getLanguageType(); // never use SYSTEM for spelling
- pEngine->SetDefaultLanguage( nCellLang );
-
- if ( eType == CELLTYPE_STRING )
- {
- pEngine->SetText(*pCell->mpString);
- }
- else if (pCell->mpEditText)
- pEngine->SetText(*pCell->mpEditText);
- else
- pEngine->SetText(EMPTY_OUSTRING);
-
- aStatus.bModified = false;
- pEngine->CompleteOnlineSpelling();
- if ( aStatus.bModified ) // Fehler dazu oder weggekommen?
- {
- bool bNeedEdit = true; // Test auf einfachen Text
- if ( !pEngine->HasOnlineSpellErrors() )
- {
- ScEditAttrTester aTester( pEngine );
- bNeedEdit = aTester.NeedsObject();
- }
-
- if ( bNeedEdit )
- {
- // The cell will take ownership of pNewData.
- SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
- aIter.RehashCol(nCol);
- }
- else
- {
- ScSetStringParam aParam;
- aParam.setTextInput();
- SetString(ScAddress(nCol,nRow,nTab), pEngine->GetText(), &aParam);
- aIter.RehashCol(nCol);
- }
-
- // Paint
- if (pShell)
- {
- // Seitenvorschau ist davon nicht betroffen
- // (sollte jedenfalls nicht)
- ScPaintHint aHint( ScRange( nCol, nRow, nTab ), PAINT_GRID );
- aHint.SetPrintFlag( false );
- pShell->Broadcast( aHint );
- }
-
- bChanged = true;
- }
-
- if ( ++nTestCount >= nMaxTest ) // checked enough text?
- break;
- }
-
- if ( ++nCellCount >= SPELL_MAXCELLS ) // seen enough cells?
- break;
- }
-
- if ( pCell )
- {
- ++nCol; // continue after last cell
- if ( nCol > rSpellRange.aEnd.Col() )
- {
- nCol = rSpellRange.aStart.Col();
- ++nRow;
- if ( nRow > rSpellRange.aEnd.Row() )
- pCell = NULL;
- }
- }
-
- if (!pCell) // end of range reached -> next sheet
- {
- ++nTab;
- if ( nTab > rSpellRange.aEnd.Tab() || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab] )
- nTab = rSpellRange.aStart.Tab();
- nCol = rSpellRange.aStart.Col();
- nRow = rSpellRange.aStart.Row();
-
- nVisSpellState = VSPL_DONE; //! only if this is for the visible range
- }
- rSpellPos.Set( nCol, nRow, nTab );
-
- delete pDefaults;
- delete pEngine; // bevor aStatus out of scope geht
-
- return bChanged;
-}
-
-
-bool ScDocument::ContinueOnlineSpelling()
-{
- if (!mbIdleEnabled || !pDocOptions->IsAutoSpell() || (pShell && pShell->IsReadOnly()))
- return false;
-
- // #i48433# set bInsertingFromOtherDoc flag so there are no broadcasts when PutCell is called
- // (same behavior as in RemoveAutoSpellObj: just transfer the broadcaster)
- bool bOldInserting = IsInsertingFromOtherDoc();
- SetInsertingFromOtherDoc( true );
-
- //! use one EditEngine for both calls
-
- // first check visible range
- bool bResult = OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_VIS );
-
- // during first pass through visible range, always continue
- if ( nVisSpellState == VSPL_START )
- bResult = true;
-
- if (bResult)
- {
- // if errors found, continue there
- OnlineSpellInRange( aVisSpellRange, aVisSpellPos, SPELL_MAXTEST_ALL );
- }
- else
- {
- // if nothing found there, continue with rest of document
- ScRange aTotalRange( 0,0,0, MAXCOL,MAXROW,MAXTAB );
- bResult = OnlineSpellInRange( aTotalRange, aOnlineSpellPos, SPELL_MAXTEST_ALL );
- }
-
- SetInsertingFromOtherDoc( bOldInserting );
-
- return bResult;
-}
-
-
void ScDocument::SetOnlineSpellPos( const ScAddress& rPos )
{
aOnlineSpellPos = rPos;
@@ -974,32 +751,6 @@ void ScDocument::SetOnlineSpellPos( const ScAddress& rPos )
aOnlineSpellPos = aVisSpellRange.aEnd;
}
-bool ScDocument::SetVisibleSpellRange( const ScRange& rNewRange )
-{
- bool bChange = ( aVisSpellRange != rNewRange );
- if (bChange)
- {
- // continue spelling through visible range when scrolling down
- bool bContDown = ( nVisSpellState == VSPL_START && rNewRange.In( aVisSpellPos ) &&
- rNewRange.aStart.Row() > aVisSpellRange.aStart.Row() &&
- rNewRange.aStart.Col() == aVisSpellRange.aStart.Col() &&
- rNewRange.aEnd.Col() == aVisSpellRange.aEnd.Col() );
-
- aVisSpellRange = rNewRange;
-
- if ( !bContDown )
- {
- aVisSpellPos = aVisSpellRange.aStart;
- nVisSpellState = VSPL_START;
- }
-
- // skip visible area for aOnlineSpellPos
- if ( aVisSpellRange.In( aOnlineSpellPos ) )
- aOnlineSpellPos = aVisSpellRange.aEnd;
- }
- return bChange;
-}
-
void ScDocument::RemoveAutoSpellObj()
{
// alle Spelling-Informationen entfernen
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 74bb24a..37dee2f 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1942,11 +1942,15 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
}
bool bMore = false;
+ bool bAutoSpell = false;
ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current());
if ( pDocSh )
{
ScDocument* pDoc = pDocSh->GetDocument();
+ bAutoSpell = pDoc->GetDocOptions().IsAutoSpell();
+ if (pDocSh->IsReadOnly())
+ bAutoSpell = false;
sal_Bool bLinks = pDoc->IdleCheckLinks();
sal_Bool bWidth = pDoc->IdleCalcTextWidth();
@@ -1959,14 +1963,17 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
lcl_CheckNeedsRepaint( pDocSh );
}
- ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
- if (pViewSh)
+ if (bAutoSpell)
{
- bool bSpell = pViewSh->ContinueOnlineSpelling();
- if (bSpell)
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (pViewSh)
{
- aSpellTimer.Start();
- bMore = true;
+ bool bSpell = pViewSh->ContinueOnlineSpelling();
+ if (bSpell)
+ {
+ aSpellTimer.Start();
+ bMore = true;
+ }
}
}
commit 547f4fec93a023ff244e3bf509baf4b8001effa0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Aug 30 23:40:52 2013 -0400
First step toward showing mis-spelled words without modifying cells.
There are still tons of problems to fix.
Change-Id: Icae6e3d2c9b8b2266724d8d068abbab8acae96da
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 95a7ac2..4e34071 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2284,6 +2284,16 @@ void EditEngine::SetHyphenator( Reference< XHyphenator > & xHyph )
pImpEditEngine->SetHyphenator( xHyph );
}
+void EditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const
+{
+ pImpEditEngine->GetAllMisspellRanges(rRanges);
+}
+
+void EditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges )
+{
+ pImpEditEngine->SetAllMisspellRanges(rRanges);
+}
+
void EditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
{
DBG_CHKTHIS( EditEngine, 0 );
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index 6d7bcd1..6c2fdf7 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -207,6 +207,16 @@ WrongList::WrongList(const WrongList& r) :
WrongList::~WrongList() {}
+const std::vector<editeng::MisspellRange>& WrongList::GetRanges() const
+{
+ return maRanges;
+}
+
+void WrongList::SetRanges( const std::vector<editeng::MisspellRange>& rRanges )
+{
+ maRanges = rRanges;
+}
+
bool WrongList::IsValid() const
{
return mnInvalidStart == Valid;
diff --git a/editeng/source/editeng/edtspell.hxx b/editeng/source/editeng/edtspell.hxx
index c79c2ac..8049b5f 100644
--- a/editeng/source/editeng/edtspell.hxx
+++ b/editeng/source/editeng/edtspell.hxx
@@ -86,6 +86,9 @@ public:
WrongList(const WrongList& r);
~WrongList();
+ const std::vector<editeng::MisspellRange>& GetRanges() const;
+ void SetRanges( const std::vector<editeng::MisspellRange>& rRanges );
+
bool IsValid() const;
void SetValid();
void SetInvalidRange( size_t nStart, size_t nEnd );
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index f15f01a..b62bc02 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -100,6 +100,10 @@ namespace svtools {
class ColorConfig;
}
+namespace editeng {
+ struct MisspellRanges;
+}
+
struct DragAndDropInfo
{
Rectangle aCurCursor;
@@ -886,6 +890,10 @@ public:
void SetHyphenator( ::com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XHyphenator > &xHyph )
{ xHyphenator = xHyph; }
+
+ void GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const;
+ void SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges );
+
SpellInfo* GetSpellInfo() const { return pSpellInfo; }
void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; }
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 734a83c..99a9101 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1391,6 +1391,40 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
return aSel;
}
+void ImpEditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const
+{
+ std::vector<editeng::MisspellRanges> aRanges;
+ const EditDoc& rDoc = GetEditDoc();
+ for (sal_Int32 i = 0, n = rDoc.Count(); i < n; ++i)
+ {
+ const ContentNode* pNode = rDoc.GetObject(i);
+ const WrongList* pWrongList = pNode->GetWrongList();
+ if (!pWrongList)
+ continue;
+
+ aRanges.push_back(editeng::MisspellRanges(i, pWrongList->GetRanges()));
+ }
+
+ aRanges.swap(rRanges);
+}
+
+void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges )
+{
+ EditDoc& rDoc = GetEditDoc();
+ std::vector<editeng::MisspellRanges>::const_iterator it = rRanges.begin(), itEnd = rRanges.end();
+ for (; it != itEnd; ++it)
+ {
+ const editeng::MisspellRanges& rParaRanges = *it;
+ ContentNode* pNode = rDoc.GetObject(rParaRanges.mnParagraph);
+ if (!pNode)
+ continue;
+
+ pNode->CreateWrongList();
+ WrongList* pWrongList = pNode->GetWrongList();
+ pWrongList->SetRanges(rParaRanges.maRanges);
+ }
+}
+
LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos ) const
{
short nScriptType = GetScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen
diff --git a/editeng/source/editeng/misspellrange.cxx b/editeng/source/editeng/misspellrange.cxx
index 0136705..980a559 100644
--- a/editeng/source/editeng/misspellrange.cxx
+++ b/editeng/source/editeng/misspellrange.cxx
@@ -14,6 +14,9 @@ namespace editeng {
MisspellRange::MisspellRange() : mnStart(0), mnEnd(0) {}
MisspellRange::MisspellRange(size_t nStart, size_t nEnd) : mnStart(nStart), mnEnd(nEnd) {}
+MisspellRanges::MisspellRanges(size_t nParagraph, const std::vector<MisspellRange>& rRanges) :
+ mnParagraph(nParagraph), maRanges(rRanges) {}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index 6fd91a4..7545317 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -55,6 +55,9 @@ typedef std::vector<SpellPortion> SpellPortions;
namespace svl { class IUndoManager; }
namespace basegfx { class B2DPolyPolygon; }
+namespace editeng {
+ struct MisspellRanges;
+}
class ImpEditEngine;
class EditView;
@@ -398,6 +401,9 @@ public:
void SetHyphenator( ::com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XHyphenator >& xHyph );
+ void GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const;
+ void SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges );
+
void SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars );
void SetDefaultLanguage( LanguageType eLang );
diff --git a/include/editeng/misspellrange.hxx b/include/editeng/misspellrange.hxx
index 103b58a..4b34e22 100644
--- a/include/editeng/misspellrange.hxx
+++ b/include/editeng/misspellrange.hxx
@@ -12,6 +12,8 @@
#include "editeng/editengdllapi.h"
+#include <vector>
+
namespace editeng {
struct EDITENG_DLLPUBLIC MisspellRange
@@ -23,6 +25,14 @@ struct EDITENG_DLLPUBLIC MisspellRange
MisspellRange(size_t nStart, size_t nEnd);
};
+struct EDITENG_DLLPUBLIC MisspellRanges
+{
+ size_t mnParagraph;
+ std::vector<MisspellRange> maRanges;
+
+ MisspellRanges(size_t nParagraph, const std::vector<MisspellRange>& rRanges);
+};
+
}
#endif
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 1ef9a82..3c06eaf 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -592,6 +592,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/view/selectionstate \
sc/source/ui/view/spelldialog \
sc/source/ui/view/spelleng \
+ sc/source/ui/view/spellcheckcontext \
sc/source/ui/view/tabcont \
sc/source/ui/view/tabsplit \
sc/source/ui/view/tabview \
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx
new file mode 100644
index 0000000..c92cee4
--- /dev/null
+++ b/sc/inc/spellcheckcontext.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_SPELLCHECKCONTEXT_HXX
+#define SC_SPELLCHECKCONTEXT_HXX
+
+#include "address.hxx"
+#include "editeng/misspellrange.hxx"
+
+#include <boost/unordered_map.hpp>
+
+namespace sc {
+
+struct SpellCheckContext
+{
+ 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;
+
+ bool operator< (const CellPos& r) const;
+ bool operator== (const CellPos& r) const;
+ };
+
+ typedef boost::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;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index cad7a5d..74bb24a 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1941,19 +1941,17 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
return 0;
}
- sal_Bool bMore = false;
- ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+ bool bMore = false;
+ ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current());
+
if ( pDocSh )
{
ScDocument* pDoc = pDocSh->GetDocument();
sal_Bool bLinks = pDoc->IdleCheckLinks();
sal_Bool bWidth = pDoc->IdleCalcTextWidth();
- sal_Bool bSpell = pDoc->ContinueOnlineSpelling();
- if ( bSpell )
- aSpellTimer.Start(); // da ist noch was
- bMore = bLinks || bWidth || bSpell; // ueberhaupt noch was?
+ bMore = bLinks || bWidth; // ueberhaupt noch was?
// While calculating a Basic formula, a paint event may have occurred,
// so check the bNeedsRepaint flags for this document's views
@@ -1961,6 +1959,17 @@ IMPL_LINK_NOARG(ScModule, IdleHandler)
lcl_CheckNeedsRepaint( pDocSh );
}
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (pViewSh)
+ {
+ bool bSpell = pViewSh->ContinueOnlineSpelling();
+ if (bSpell)
+ {
+ aSpellTimer.Start();
+ bMore = true;
+ }
+ }
+
sal_uLong nOldTime = aIdleTimer.GetTimeout();
sal_uLong nNewTime = nOldTime;
if ( bMore )
@@ -1996,11 +2005,10 @@ IMPL_LINK_NOARG(ScModule, SpellTimerHdl)
return 0; // dann spaeter wieder...
}
- ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
- if ( pDocSh )
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (pViewSh)
{
- ScDocument* pDoc = pDocSh->GetDocument();
- if ( pDoc->ContinueOnlineSpelling() )
+ if (pViewSh->ContinueOnlineSpelling())
aSpellTimer.Start();
}
return 0;
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 1befc35..ba55617 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -32,6 +32,16 @@
#include <vector>
#include <memory>
#include <boost/scoped_ptr.hpp>
+#include <boost/unordered_map.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
+
+namespace editeng {
+ struct MisspellRanges;
+}
+
+namespace sc {
+ struct SpellCheckContext;
+}
struct ScTableInfo;
class ScDPObject;
@@ -81,8 +91,6 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe
// ScFilterListBox is always used for selection list
friend class ScFilterListBox;
-private:
-
enum RfCorner
{
NONE,
@@ -121,9 +129,11 @@ private:
bool isInside(SCCOL nCol, SCROW nRow) const;
bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
};
+
VisibleRange maVisibleRange;
-private:
+ boost::scoped_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
+
ScViewData* pViewData;
ScSplitPos eWhich;
ScHSplitPos eHWhich;
@@ -169,7 +179,6 @@ private:
sal_uInt16 nCurrentPointer;
-
ScDDComboBoxButton aComboButton;
Point aCurMousePos;
@@ -382,6 +391,7 @@ public:
// #114409#
void CursorChanged();
void DrawLayerCreated();
+ bool ContinueOnlineSpelling();
void DeleteCopySourceOverlay();
void UpdateCopySourceOverlay();
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index 4565354..ec894bd 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -27,6 +27,14 @@
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+namespace sc {
+ struct SpellCheckContext;
+}
+
+namespace editeng {
+ struct MisspellRanges;
+}
+
class Rectangle;
class Font;
class OutputDevice;
@@ -40,8 +48,6 @@ class ScTabViewShell;
class ScPageBreakData;
class FmFormView;
class ScFieldEditEngine;
-
-// #i74769# SdrPaintWindow predefine
class SdrPaintWindow;
// ---------------------------------------------------------------------------
@@ -100,6 +106,7 @@ private:
const SfxItemSet* mpOldCondSet;
const SfxItemSet* mpOldPreviewFontSet;
const RowInfo* mpThisRowInfo;
+ const std::vector<editeng::MisspellRanges>* mpMisspellRanges;
explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
@@ -203,6 +210,7 @@ private:
// #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
SdrPaintWindow* mpTargetPaintWindow;
+ const sc::SpellCheckContext* mpSpellCheckCxt;
// private methods
@@ -260,6 +268,7 @@ public:
~ScOutputData();
+ void SetSpellCheckContext( const sc::SpellCheckContext* pCxt );
void SetContentDevice( OutputDevice* pContentDev );
void SetRefDevice( OutputDevice* pRDev ) { mpRefDevice = pFmtDevice = pRDev; }
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 92a42ae..69d9c54 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -520,6 +520,8 @@ public:
void ResetBrushDocument();
void SetInRefMode( bool bRefMode );
+
+ bool ContinueOnlineSpelling();
};
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d2fb9ac..e91d74f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -27,6 +27,9 @@
#include <editeng/editstat.hxx>
#include <editeng/flditem.hxx>
#include <editeng/justifyitem.hxx>
+#include "editeng/unolingu.hxx"
+#include "editeng/langitem.hxx"
+#include "editeng/misspellrange.hxx"
#include <svx/svdetc.hxx>
#include <editeng/editobj.hxx>
#include <sfx2/dispatch.hxx>
@@ -120,6 +123,9 @@
#include "checklistmenu.hrc"
#include "strload.hxx"
#include "externalrefmgr.hxx"
+#include "dociter.hxx"
+#include "hints.hxx"
+#include "spellcheckcontext.hxx"
#include <svx/sdrpagewindow.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
@@ -439,6 +445,7 @@ 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 ),
@@ -5355,6 +5362,139 @@ void ScGridWindow::DrawLayerCreated()
ImpCreateOverlayObjects();
}
+namespace {
+
+struct SpellCheckStatus
+{
+ bool mbModified;
+
+ SpellCheckStatus() : mbModified(false) {};
+
+ DECL_LINK (EventHdl, EditStatus*);
+};
+
+IMPL_LINK(SpellCheckStatus, EventHdl, EditStatus*, pStatus)
+{
+ sal_uLong nStatus = pStatus->GetStatusWord();
+ if (nStatus & EE_STAT_WRONGWORDCHANGED)
+ mbModified = true;
+
+ return 0;
+}
+
+}
+
+bool ScGridWindow::ContinueOnlineSpelling()
+{
+ if (!mpSpellCheckCxt->maPos.isValid())
+ return false;
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SpellCheckStatus aStatus;
+
+ ScHorizontalCellIterator aIter(
+ pDoc, nTab, maVisibleRange.mnCol1, mpSpellCheckCxt->maPos.mnRow, maVisibleRange.mnCol2, maVisibleRange.mnRow2);
+
+ SCCOL nCol;
+ SCROW nRow;
+ ScRefCellValue* pCell = aIter.GetNext(nCol, nRow);
+ while (pCell && nRow < mpSpellCheckCxt->maPos.mnRow)
+ pCell = aIter.GetNext(nCol, nRow);
+
+ while (pCell && nCol < mpSpellCheckCxt->maPos.mnCol)
+ pCell = aIter.GetNext(nCol, nRow);
+
+ boost::scoped_ptr<ScTabEditEngine> pEngine;
+
+ // Check only up to 256 cells at a time.
+ size_t nTotalCellCount = 0;
+ size_t nTextCellCount = 0;
+ bool bChanged = false;
+
+ while (pCell)
+ {
+ ++nTotalCellCount;
+
+ CellType eType = pCell->meType;
+ if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT)
+ {
+ ++nTextCellCount;
+
+ if (!pEngine)
+ {
+ // ScTabEditEngine is needed
+ // because MapMode must be set for some old documents
+ pEngine.reset(new ScTabEditEngine(pDoc));
+ pEngine->SetControlWord(
+ pEngine->GetControlWord() | (EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS));
+ pEngine->SetStatusEventHdl(LINK(&aStatus, SpellCheckStatus, EventHdl));
+ // Delimiters hier wie in inputhdl.cxx !!!
+ pEngine->SetWordDelimiters(
+ ScEditUtil::ModifyDelimiters(pEngine->GetWordDelimiters()));
+
+ uno::Reference<linguistic2::XSpellChecker1> xXSpellChecker1(LinguMgr::GetSpellChecker());
+ pEngine->SetSpeller(xXSpellChecker1);
+ }
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, nTab);
+ sal_uInt16 nCellLang =
+ static_cast<const SvxLanguageItem&>(pPattern->GetItem(ATTR_FONT_LANGUAGE)).GetValue();
+ if (nCellLang == LANGUAGE_SYSTEM)
+ nCellLang = Application::GetSettings().GetLanguageTag().getLanguageType(); // never use SYSTEM for spelling
+ pEngine->SetDefaultLanguage(nCellLang);
+
+ if (eType == CELLTYPE_STRING)
+ pEngine->SetText(*pCell->mpString);
+ else
+ pEngine->SetText(*pCell->mpEditText);
+
+ aStatus.mbModified = false;
+ pEngine->CompleteOnlineSpelling();
+ if (aStatus.mbModified)
+ {
+ std::vector<editeng::MisspellRanges> aRanges;
+ pEngine->GetAllMisspellRanges(aRanges);
+ if (!aRanges.empty())
+ {
+ sc::SpellCheckContext::CellPos aPos(nCol, nRow);
+ mpSpellCheckCxt->maMisspellCells.insert(
+ sc::SpellCheckContext::CellMapType::value_type(aPos, aRanges));
+ }
+
+ // Broadcast for re-paint.
+ ScPaintHint aHint(ScRange(nCol, nRow, nTab), PAINT_GRID);
+ aHint.SetPrintFlag(false);
+ pDoc->GetDocumentShell()->Broadcast(aHint);
+ bChanged = true;
+ }
+ }
+
+ if (nTotalCellCount >= 255 || nTextCellCount >= 1)
+ break;
+
+ pCell = aIter.GetNext(nCol, nRow);
+ }
+
+ if (pCell)
+ // Move to the next cell position for the next iteration.
+ pCell = aIter.GetNext(nCol, nRow);
+
+ if (pCell)
+ {
+ // This will become the first cell position for the next time.
+ mpSpellCheckCxt->maPos.mnCol = nCol;
+ mpSpellCheckCxt->maPos.mnRow = nRow;
+ }
+ else
+ {
+ // No more cells to spell check.
+ mpSpellCheckCxt->maPos.setInvalid();
+ }
+
+ return bChanged;
+}
+
// #114409#
void ScGridWindow::CursorChanged()
{
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 1d2f133..7213f6a 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -488,6 +488,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
&aZoomX, &aZoomY );
aOutputData.SetMirrorWidth( nMirrorWidth ); // needed for RTL
+ aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get());
std::auto_ptr< VirtualDevice > xFmtVirtDev;
sal_Bool bLogicText = bTextWysiwyg; // call DrawStrings in logic MapMode?
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 8f13897..1208699 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -207,7 +207,8 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
bSnapPixel( false ),
bAnyRotated( false ),
bAnyClipped( false ),
- mpTargetPaintWindow(0) // #i74769# use SdrPaintWindow direct
+ mpTargetPaintWindow(NULL), // #i74769# use SdrPaintWindow direct
+ mpSpellCheckCxt(NULL)
{
if (pZoomX)
aZoomX = *pZoomX;
@@ -246,6 +247,11 @@ ScOutputData::~ScOutputData()
delete pFormulaColor;
}
+void ScOutputData::SetSpellCheckContext( const sc::SpellCheckContext* pCxt )
+{
+ mpSpellCheckCxt = pCxt;
+}
+
void ScOutputData::SetContentDevice( OutputDevice* pContentDev )
{
// use pContentDev instead of pDev where used
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 77b700c..5e361c3 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -59,6 +59,7 @@
#include "docsh.hxx"
#include "markdata.hxx"
#include "stlsheet.hxx"
+#include "spellcheckcontext.hxx"
#include <com/sun/star/i18n/DirectionProperty.hpp>
#include <comphelper/string.hxx>
@@ -1443,23 +1444,23 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
nPosX -= pRowInfo[0].pCellInfo[nLoopStartX+1].nWidth * nLayoutSign;
for (SCCOL nX=nLoopStartX; nX<=nX2; nX++)
{
- sal_Bool bMergeEmpty = false;
+ bool bMergeEmpty = false;
CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
- sal_Bool bEmpty = nX < nX1 || pInfo->bEmptyCellText;
+ bool bEmpty = nX < nX1 || pInfo->bEmptyCellText;
SCCOL nCellX = nX; // position where the cell really starts
SCROW nCellY = nY;
- sal_Bool bDoCell = false;
- sal_Bool bNeedEdit = false;
+ bool bDoCell = false;
+ bool bNeedEdit = false;
//
// Part of a merged cell?
//
- sal_Bool bOverlapped = ( pInfo->bHOverlapped || pInfo->bVOverlapped );
+ bool bOverlapped = (pInfo->bHOverlapped || pInfo->bVOverlapped);
if ( bOverlapped )
{
- bEmpty = sal_True;
+ bEmpty = true;
SCCOL nOverX; // start of the merged cells
SCROW nOverY;
@@ -1471,7 +1472,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
bDoCell = sal_True;
}
else
- bMergeEmpty = sal_True;
+ bMergeEmpty = true;
}
//
@@ -1489,7 +1490,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
!mpDoc->HasAttrib( nTempX,nY,nTab, nX1,nY,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
{
nCellX = nTempX;
- bDoCell = sal_True;
+ bDoCell = true;
}
}
@@ -1519,7 +1520,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
//
if (!bEmpty)
- bDoCell = sal_True;
+ bDoCell = true;
//
// don't output the cell that's being edited
@@ -1553,6 +1554,14 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
else if (aCell.meType == CELLTYPE_EDIT)
bNeedEdit = true;
}
+
+ // Check if this cell is mis-spelled.
+ if (bDoCell && !bNeedEdit && aCell.meType == CELLTYPE_STRING)
+ {
+ if (mpSpellCheckCxt && mpSpellCheckCxt->isMisspelled(nCellX, nCellY))
+ bNeedEdit = true;
+ }
+
if (bDoCell && !bNeedEdit)
{
if ( nCellY == nY && nCellX >= nX1 && nCellX <= nX2 )
@@ -2257,7 +2266,8 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
mpOldPattern(NULL),
mpOldCondSet(NULL),
mpOldPreviewFontSet(NULL),
- mpThisRowInfo(NULL)
+ mpThisRowInfo(NULL),
+ mpMisspellRanges(NULL)
{}
bool ScOutputData::DrawEditParam::readCellContent(
@@ -2302,6 +2312,10 @@ bool ScOutputData::DrawEditParam::readCellContent(
if ( pColor && !bSyntaxMode && !( bUseStyleColor && bForceAutoColor ) )
lcl_SetEditColor( *mpEngine, *pColor );
}
+
+ if (mpMisspellRanges)
+ mpEngine->SetAllMisspellRanges(*mpMisspellRanges);
+
return true;
}
@@ -4576,7 +4590,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
}
else
{
- bDoCell = sal_True;
+ bDoCell = true;
}
if ( bDoCell && bEditMode && nCellX == nEditCol && nCellY == nEditRow )
@@ -4644,6 +4658,9 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
aParam.mpOldCondSet = pOldCondSet;
aParam.mpOldPreviewFontSet = pOldPreviewFontSet;
aParam.mpThisRowInfo = pThisRowInfo;
+ if (mpSpellCheckCxt)
+ aParam.mpMisspellRanges = mpSpellCheckCxt->getMisspellRanges(nCellX, nCellY);
+
if (aParam.meHorJust == SVX_HOR_JUSTIFY_REPEAT)
{
// ignore orientation/rotation if "repeat" is active
diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx
new file mode 100644
index 0000000..c064d2b
--- /dev/null
+++ b/sc/source/ui/view/spellcheckcontext.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "spellcheckcontext.hxx"
+
+namespace sc {
+
+size_t SpellCheckContext::CellPos::Hash::operator() (const CellPos& rPos) const
+{
+ size_t nVal = rPos.mnCol;
+ nVal = nVal << 4;
+ nVal += rPos.mnRow;
+ return nVal;
+}
+
+SpellCheckContext::CellPos::CellPos() : mnCol(0), mnRow(0) {}
+SpellCheckContext::CellPos::CellPos(SCCOL nCol, SCROW nRow) : mnCol(nCol), mnRow(nRow) {}
+
+void SpellCheckContext::CellPos::setInvalid()
+{
+ mnCol = -1;
+ mnRow = -1;
+}
+
+bool SpellCheckContext::CellPos::isValid() const
+{
+ return mnCol >= 0 && mnRow >= 0;
+}
+
+bool SpellCheckContext::CellPos::operator< (const CellPos& r) const
+{
+ if (mnCol != r.mnCol)
+ return mnCol < r.mnCol;
+
+ return mnRow < r.mnRow;
+}
+
+bool SpellCheckContext::CellPos::operator== (const CellPos& r) const
+{
+ return mnCol == r.mnCol && mnRow == r.mnRow;
+}
+
+SpellCheckContext::SpellCheckContext()
+{
+}
+
+bool SpellCheckContext::isMisspelled( SCCOL nCol, SCROW nRow ) const
+{
+ return maMisspellCells.count(CellPos(nCol, nRow)) > 0;
+}
+
+const std::vector<editeng::MisspellRanges>* SpellCheckContext::getMisspellRanges(
+ SCCOL nCol, SCROW nRow ) const
+{
+ CellMapType::const_iterator it = maMisspellCells.find(CellPos(nCol,nRow));
+ if (it == maMisspellCells.end())
+ return NULL;
+
+ return &it->second;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index a83fba2..3be9f36 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2332,4 +2332,19 @@ void ScTabView::SetInRefMode( bool bRefMode )
pGridWin[SC_SPLIT_TOPRIGHT]->SetInRefMode( bRefMode );
}
+bool ScTabView::ContinueOnlineSpelling()
+{
+ bool bChanged = false;
+ for (int i = 0; i < 4; ++i)
+ {
+ if (!pGridWin[i] || !pGridWin[i]->IsVisible())
+ continue;
+
+ if (pGridWin[i]->ContinueOnlineSpelling())
+ bChanged = true;
+ }
+
+ return bChanged;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 47fbc14..a7c4fac 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -429,18 +429,6 @@ void ScTabView::UpdateScrollBars()
{
if (UpdateVisibleRange())
SC_MOD()->AnythingChanged(); // if visible area has changed
-
- ScSplitPos eActive = aViewData.GetActivePart();
- ScHSplitPos eHWhich = WhichH( eActive );
- ScVSplitPos eVWhich = WhichV( eActive );
- SCCOL nPosX = aViewData.GetPosX(eHWhich);
- SCROW nPosY = aViewData.GetPosY(eVWhich);
- SCCOL nEndX = nPosX + ( ( eHWhich == SC_SPLIT_LEFT ) ? nVisXL : nVisXR );
- SCROW nEndY = nPosY + ( ( eVWhich == SC_SPLIT_TOP ) ? nVisYT : nVisYB );
- if ( nEndX > MAXCOL ) nEndX = MAXCOL;
- if ( nEndY > MAXROW ) nEndY = MAXROW;
- ScRange aVisible( nPosX, nPosY, nTab, nEndX, nEndY, nTab );
- pDoc->SetVisibleSpellRange(aVisible);
}
}
More information about the Libreoffice-commits
mailing list