From 547f4fec93a023ff244e3bf509baf4b8001effa0 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 30 Aug 2013 23:40:52 -0400 Subject: First step toward showing mis-spelled words without modifying cells. There are still tons of problems to fix. Change-Id: Icae6e3d2c9b8b2266724d8d068abbab8acae96da --- editeng/source/editeng/editeng.cxx | 10 ++++++++++ editeng/source/editeng/edtspell.cxx | 10 ++++++++++ editeng/source/editeng/edtspell.hxx | 3 +++ editeng/source/editeng/impedit.hxx | 8 ++++++++ editeng/source/editeng/impedit4.cxx | 34 ++++++++++++++++++++++++++++++++ editeng/source/editeng/misspellrange.cxx | 3 +++ 6 files changed, 68 insertions(+) (limited to 'editeng') diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 95a7ac28ae0f..4e3407145044 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& rRanges ) const +{ + pImpEditEngine->GetAllMisspellRanges(rRanges); +} + +void EditEngine::SetAllMisspellRanges( const std::vector& rRanges ) +{ + pImpEditEngine->SetAllMisspellRanges(rRanges); +} + void EditEngine::SetForbiddenCharsTable( rtl::Reference xForbiddenChars ) { DBG_CHKTHIS( EditEngine, 0 ); diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index 6d7bcd188aa6..6c2fdf741e09 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& WrongList::GetRanges() const +{ + return maRanges; +} + +void WrongList::SetRanges( const std::vector& 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 c79c2ac7dc87..8049b5f8509e 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& GetRanges() const; + void SetRanges( const std::vector& 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 f15f01a2ca4b..b62bc0277b97 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& rRanges ) const; + void SetAllMisspellRanges( const std::vector& 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 734a83c83ae9..99a9101610b8 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& rRanges ) const +{ + std::vector 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& rRanges ) +{ + EditDoc& rDoc = GetEditDoc(); + std::vector::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 0136705248d6..980a559be791 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& rRanges) : + mnParagraph(nParagraph), maRanges(rRanges) {} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit