diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-09-01 13:57:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-09-01 14:48:50 -0400 |
commit | 309c766d99cc7efc11fc439d119ba1944f2d710a (patch) | |
tree | 38b0df248625639f1ef5afc3b5fb1dced8525da6 /sc | |
parent | 16c8c46d85d7aafcb9159b12e2d44bc0bf322c69 (diff) |
Separate misspelled ranges when entering a new cell value.
And store them at appropriate locations.
Change-Id: Iaf38c0cd01e9b3dc9dc98f7ccc1951d572a422e9
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/spellcheckcontext.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/app/uiitems.cxx | 47 | ||||
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/tabview.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/uiitems.hxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/spellcheckcontext.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/view/tabview.cxx | 11 |
10 files changed, 101 insertions, 25 deletions
diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx index 5d81ad5b4601..e3f3f74f0af8 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 42cbbb19294d..7454a7481992 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 d26337d221bb..ab83063d74e0 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 cbb774b85035..4288342524bd 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 cb94eb81b8d4..4964e6d685c1 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 d47528968915..a74a08d4ddd5 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 58308387de98..aa1aeea03884 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 6949b8f0dc8f..692fcece6a8c 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 d6cec232e889..66c218e679b5 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 2e9e61235c38..7feb1b7b11e8 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: */ |