Bugzilla – Attachment 191135 Details for
Bug 158454
Add Thai Autocorrect Support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to make Autocorrect match more than one rule
0002-SvxAutoCorrDoc-ChgAutoCorrWord-implementations-corre.patch (text/plain), 27.57 KB, created by
Theppitak Karoonboonyanan
on 2023-11-30 10:38:58 UTC
(
hide
)
Description:
Patch to make Autocorrect match more than one rule
Filename:
MIME Type:
Creator:
Theppitak Karoonboonyanan
Created:
2023-11-30 10:38:58 UTC
Size:
27.57 KB
patch
obsolete
>From 37af04462d13668892f8534f39866649894c22f3 Mon Sep 17 00:00:00 2001 >From: Theppitak Karoonboonyanan <theppitak@gmail.com> >Date: Thu, 30 Nov 2023 12:22:13 +0700 >Subject: [PATCH 2/2] SvxAutoCorrDoc::ChgAutoCorrWord() implementations: > correct multiple patterns > >* include/editeng/svxacorr.hxx, editeng/source/misc/svxacorr.cxx: > - Add classes SvxAutocorrWordList::{Iterator,WordSearchStatus}. > - Make SvxAutocorrWordList::SearchWordsInList() return WordSearchStatus > so the search can be continued with the added > SvxAutocorrWordList::SearchWordsNext() method. > - Make SvxAutoCorrect::SearchWordsInList(), and its lcl_SearchWordsInList() > companion, return WordSearchStatus propagated from > SvxAutocorrWordList::SearchWordsInList(). >* editeng/qa/unit/core-test.cxx: > - Modify TestAutoCorrDoc::ChgAutoCorrWord() to iterate through all patterns, > instead of finishing at the first one. >* editeng/source/editeng/edtspell.cxx: > - Ditto for EdtAutoCorrDoc::ChgAutoCorrWord(). >* sw/source/core/edit/acorrect.cxx: > - Ditto for SwAutoCorrDoc::ChgAutoCorrWord(). > >Change-Id: I771074c870935a9fa7bb1266ebf53a5c8987eec9 >--- > editeng/qa/unit/core-test.cxx | 29 +++-- > editeng/source/editeng/edtspell.cxx | 56 ++++++--- > editeng/source/misc/svxacorr.cxx | 146 +++++++++++++++++++--- > include/editeng/svxacorr.hxx | 63 +++++++++- > sw/source/core/edit/acorrect.cxx | 186 +++++++++++++++------------- > 5 files changed, 349 insertions(+), 131 deletions(-) > >diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx >index b5320f90e448..3ca88244e8de 100644 >--- a/editeng/qa/unit/core-test.cxx >+++ b/editeng/qa/unit/core-test.cxx >@@ -418,14 +418,29 @@ private: > return false; > > LanguageTag aLanguageTag( m_eLang); >- const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( >- m_rText, rSttPos, nEndPos, *this, aLanguageTag); >- if (pFnd && pFnd->IsTextOnly()) >+ sal_Int32 sttPos = rSttPos; >+ std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> pStatus >+ = rACorrect.SearchWordsInList(m_rText, sttPos, nEndPos, *this, >+ aLanguageTag); >+ if (pStatus) > { >- m_rText = m_rText.replaceAt(rSttPos, nEndPos, pFnd->GetLong()); >- if( pPara ) >- pPara->clear(); // =&pCurNode->GetString(); >- return true; >+ sal_Int32 minSttPos = sttPos; >+ do { >+ const SvxAutocorrWord* pFnd = pStatus->GetAutocorrWord(); >+ if (pFnd && pFnd->IsTextOnly()) >+ { >+ m_rText = m_rText.replaceAt(sttPos, nEndPos, pFnd->GetLong()); >+ nEndPos = sttPos + pFnd->GetLong().getLength(); >+ if( pPara ) >+ pPara->clear(); // =&pCurNode->GetString(); >+ return true; >+ } >+ if (sttPos < minSttPos) >+ minSttPos = sttPos; >+ sttPos = rSttPos; >+ } while (rACorrect.SearchWordsNext(m_rText, sttPos, nEndPos, >+ pStatus.get())); >+ rSttPos = minSttPos; > } > > return false; >diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx >index c07361bd196b..92a041cfac33 100644 >--- a/editeng/source/editeng/edtspell.cxx >+++ b/editeng/source/editeng/edtspell.cxx >@@ -655,27 +655,43 @@ bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, > return bRet; > > LanguageTag aLanguageTag( mpEditEngine->GetLanguage( EditPaM( pCurNode, rSttPos+1 ) ).nLang ); >- const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( >- pCurNode->GetString(), rSttPos, nEndPos, *this, aLanguageTag); >- if( pFnd && pFnd->IsTextOnly() ) >- { >+ sal_Int32 sttPos = rSttPos; >+ std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> pStatus >+ = rACorrect.SearchWordsInList(pCurNode->GetString(), sttPos, nEndPos, >+ *this, aLanguageTag); >+ if( !pStatus ) >+ return bRet; > >- // replace also last colon of keywords surrounded by colons (for example, ":name:") >- bool replaceLastChar = pFnd->GetShort()[0] == ':' && pFnd->GetShort().endsWith(":"); >- >- // then replace >- EditSelection aSel( EditPaM( pCurNode, rSttPos ), >- EditPaM( pCurNode, nEndPos + (replaceLastChar ? 1 : 0) )); >- aSel = mpEditEngine->DeleteSelection(aSel); >- SAL_WARN_IF(nCursor < nEndPos, "editeng", >- "Cursor in the heart of the action?!"); >- nCursor -= ( nEndPos-rSttPos ); >- mpEditEngine->InsertText(aSel, pFnd->GetLong()); >- nCursor = nCursor + pFnd->GetLong().getLength(); >- if( pPara ) >- *pPara = pCurNode->GetString(); >- bRet = true; >- } >+ sal_Int32 minSttPos = sttPos; >+ do { >+ const SvxAutocorrWord* pFnd = pStatus->GetAutocorrWord(); >+ if( pFnd && pFnd->IsTextOnly() ) >+ { >+ // replace also last colon of keywords surrounded by colons >+ // (for example, ":name:") >+ bool replaceLastChar = pFnd->GetShort()[0] == ':' >+ && pFnd->GetShort().endsWith(":"); >+ >+ // then replace >+ EditSelection aSel( EditPaM( pCurNode, sttPos ), >+ EditPaM( pCurNode, nEndPos + (replaceLastChar ? 1 : 0) )); >+ aSel = mpEditEngine->DeleteSelection(aSel); >+ SAL_WARN_IF(nCursor < nEndPos, "editeng", >+ "Cursor in the heart of the action?!"); >+ nCursor -= ( nEndPos-sttPos ); >+ mpEditEngine->InsertText(aSel, pFnd->GetLong()); >+ nCursor = nCursor + pFnd->GetLong().getLength(); >+ nEndPos = sttPos + pFnd->GetLong().getLength(); >+ if( pPara ) >+ *pPara = pCurNode->GetString(); >+ bRet = true; >+ if( sttPos < minSttPos ) >+ minSttPos = sttPos; >+ } >+ sttPos = rSttPos; >+ } while( rACorrect.SearchWordsNext(pCurNode->GetString(), sttPos, nEndPos, >+ pStatus.get()) ); >+ rSttPos = minSttPos; > > return bRet; > } >diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx >index 4c4b6883f247..7cfa755ee249 100644 >--- a/editeng/source/misc/svxacorr.cxx >+++ b/editeng/source/misc/svxacorr.cxx >@@ -1967,20 +1967,22 @@ static void GeneratePackageName ( std::u16string_view rShort, OUString& rPackage > rPackageName = aBuf.makeStringAndClear(); > } > >-static const SvxAutocorrWord* lcl_SearchWordsInList( >- SvxAutoCorrectLanguageLists* pList, std::u16string_view rTxt, >- sal_Int32& rStt, sal_Int32 nEndPos) >+static std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> >+lcl_SearchWordsInList( SvxAutoCorrectLanguageLists* pList, >+ std::u16string_view rTxt, >+ sal_Int32& rStt, sal_Int32 nEndPos ) > { > const SvxAutocorrWordList* pAutoCorrWordList = pList->GetAutocorrWordList(); > return pAutoCorrWordList->SearchWordsInList( rTxt, rStt, nEndPos ); > } > > // the search for the words in the substitution table >-const SvxAutocorrWord* SvxAutoCorrect::SearchWordsInList( >- std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos, >- SvxAutoCorrDoc&, LanguageTag& rLang ) >+std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> >+SvxAutoCorrect::SearchWordsInList( >+ std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos, >+ SvxAutoCorrDoc&, LanguageTag& rLang ) > { >- const SvxAutocorrWord* pRet = nullptr; >+ std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> pRet = nullptr; > LanguageTag aLanguageTag( rLang); > if( aLanguageTag.isSystemLocale() ) > aLanguageTag.reset( MsLangId::getConfiguredSystemLanguage()); >@@ -2038,6 +2040,14 @@ const SvxAutocorrWord* SvxAutoCorrect::SearchWordsInList( > return nullptr; > } > >+bool SvxAutoCorrect::SearchWordsNext( >+ std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos, >+ SvxAutocorrWordList::WordSearchStatus* pStatus ) >+{ >+ const SvxAutocorrWordList* pWordList = pStatus->GetAutocorrWordList(); >+ return pWordList->SearchWordsNext( rTxt, rStt, nEndPos, pStatus ); >+} >+ > bool SvxAutoCorrect::FindInWordStartExceptList( LanguageType eLang, > const OUString& sWord ) > { >@@ -2898,6 +2908,74 @@ void SvxAutocorrWordList::DeleteAndDestroyAll() > mpImpl->DeleteAndDestroyAll(); > } > >+struct SvxAutocorrWordList::Iterator::Impl { >+ typedef SvxAutocorrWordList::AutocorrWordSetType::const_iterator VecIterType; >+ typedef AutocorrWordHashType::const_iterator HashIterType; >+ >+ bool mIsSorted; >+ VecIterType mSortedVectorIter, mSortedVectorEnd; >+ HashIterType mHashIter, mHashEnd; >+ >+ Impl(const VecIterType& it, const VecIterType& end) >+ : mIsSorted(true), mSortedVectorIter(it), mSortedVectorEnd(end) {} >+ Impl(const HashIterType& it, const HashIterType& end) >+ : mIsSorted(false), mHashIter(it), mHashEnd(end) {} >+ Impl(const Impl& impl) >+ : mIsSorted(impl.mIsSorted) >+ { >+ if (mIsSorted) { >+ mSortedVectorIter = impl.mSortedVectorIter; >+ mSortedVectorEnd = impl.mSortedVectorEnd; >+ } else { >+ mHashIter = impl.mHashIter; >+ mHashEnd = impl.mHashEnd; >+ } >+ } >+ >+ bool Step() { >+ if (mIsSorted) { return ++mSortedVectorIter != mSortedVectorEnd; } >+ else { return ++mHashIter != mHashEnd; } >+ } >+ >+ const SvxAutocorrWord& operator*() { >+ return mIsSorted ? *mSortedVectorIter : mHashIter->second; >+ } >+ const SvxAutocorrWord* operator->() { >+ return mIsSorted ? &*mSortedVectorIter : &mHashIter->second; >+ } >+}; >+ >+SvxAutocorrWordList::Iterator::Iterator( >+ std::unique_ptr<SvxAutocorrWordList::Iterator::Impl> pImpl >+) : mpImpl(std::move(pImpl)) >+{ >+} >+ >+SvxAutocorrWordList::Iterator::Iterator( >+ const SvxAutocorrWordList::Iterator& it >+) : mpImpl(new Impl(*(it.mpImpl))) >+{ >+} >+ >+SvxAutocorrWordList::Iterator::~Iterator() >+{ >+} >+ >+bool SvxAutocorrWordList::Iterator::Step() >+{ >+ return mpImpl->Step(); >+} >+ >+const SvxAutocorrWord& SvxAutocorrWordList::Iterator::operator*() const >+{ >+ return **mpImpl; >+} >+ >+const SvxAutocorrWord* SvxAutocorrWordList::Iterator::operator->() const >+{ >+ return mpImpl->operator->(); >+} >+ > // returns true if inserted > const SvxAutocorrWord* SvxAutocorrWordList::Insert(SvxAutocorrWord aWord) const > { >@@ -3106,21 +3184,59 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p > return nullptr; > } > >-const SvxAutocorrWord* SvxAutocorrWordList::SearchWordsInList(std::u16string_view rTxt, sal_Int32& rStt, >- sal_Int32 nEndPos) const >+std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> >+SvxAutocorrWordList::SearchWordsInList(std::u16string_view rTxt, >+ sal_Int32& rStt, >+ sal_Int32 nEndPos) const > { >- for (auto const& elem : mpImpl->maHash) >+ for (auto it = mpImpl->maHash.begin(); it != mpImpl->maHash.end(); ++it) > { >- if( const SvxAutocorrWord *pTmp = WordMatches( &elem.second, rTxt, rStt, nEndPos ) ) >- return pTmp; >+ if( const SvxAutocorrWord *pTmp = WordMatches( &it->second, rTxt, rStt, >+ nEndPos ) ) >+ { >+ return std::make_unique<WordSearchStatus>( >+ pTmp, this, >+ Iterator(std::make_unique<Iterator::Impl>( >+ it, mpImpl->maHash.end() >+ )) >+ ); >+ } > } > >- for (auto const& elem : mpImpl->maSortedVector) >+ for (auto it = mpImpl->maSortedVector.begin(); >+ it != mpImpl->maSortedVector.end(); ++it) > { >- if( const SvxAutocorrWord *pTmp = WordMatches( &elem, rTxt, rStt, nEndPos ) ) >- return pTmp; >+ if( const SvxAutocorrWord *pTmp = WordMatches( &*it, rTxt, rStt, >+ nEndPos ) ) >+ { >+ return std::make_unique<WordSearchStatus>( >+ pTmp, this, >+ Iterator(std::make_unique<Iterator::Impl>( >+ it, mpImpl->maSortedVector.end() >+ )) >+ ); >+ } > } > return nullptr; > } > >+bool >+SvxAutocorrWordList::SearchWordsNext(std::u16string_view rTxt, >+ sal_Int32& rStt, >+ sal_Int32 nEndPos, >+ SvxAutocorrWordList::WordSearchStatus* pStatus) const >+{ >+ while( pStatus->StepIter() ) >+ { >+ if( const SvxAutocorrWord *pTmp = WordMatches( pStatus->GetWordAtIter(), >+ rTxt, rStt, nEndPos ) ) >+ { >+ pStatus->mpFnd = pTmp; >+ return true; >+ } >+ } >+ >+ return false; >+} >+ > /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx >index 6fe151449170..d56cb083506a 100644 >--- a/include/editeng/svxacorr.hxx >+++ b/include/editeng/svxacorr.hxx >@@ -167,6 +167,52 @@ class EDITENG_DLLPUBLIC SvxAutocorrWordList > sal_Int32 &rStt, > sal_Int32 nEndPos) const; > public: >+ class Iterator { >+ struct Impl; >+ std::unique_ptr<Impl> mpImpl; >+ >+ // For construction from containers in *SvxAutocorrWordList::mpImpl >+ friend class SvxAutocorrWordList; >+ Iterator(std::unique_ptr<Impl> pImpl); >+ >+ public: >+ Iterator(const Iterator& it); >+ ~Iterator(); >+ bool Step(); >+ const SvxAutocorrWord& operator*() const; >+ const SvxAutocorrWord* operator->() const; >+ }; >+ >+ class WordSearchStatus { >+ const SvxAutocorrWord* mpFnd; >+ >+ // For iteration >+ friend class SvxAutocorrWordList; >+ const SvxAutocorrWordList* mpAutocorrWordList; >+ SvxAutocorrWordList::Iterator mAutocorrWordListIter; >+ >+ public: >+ WordSearchStatus( >+ const SvxAutocorrWord* pFnd, >+ const SvxAutocorrWordList* pAutocorrWordList, >+ const SvxAutocorrWordList::Iterator& autocorrWordListIter >+ ) : mpFnd(pFnd), mpAutocorrWordList(pAutocorrWordList), >+ mAutocorrWordListIter(autocorrWordListIter) >+ {} >+ const SvxAutocorrWord* GetAutocorrWord() const { >+ return mpFnd; >+ } >+ const SvxAutocorrWordList* GetAutocorrWordList() const { >+ return mpAutocorrWordList; >+ } >+ const SvxAutocorrWord* GetWordAtIter() const { >+ return &*mAutocorrWordListIter; >+ } >+ bool StepIter() { >+ return mAutocorrWordListIter.Step(); >+ } >+ }; >+ > SvxAutocorrWordList(); > // free any objects still in the set > ~SvxAutocorrWordList(); >@@ -180,7 +226,10 @@ public: > typedef std::vector<SvxAutocorrWord> AutocorrWordSetType; > const AutocorrWordSetType & getSortedContent() const; > >- const SvxAutocorrWord* SearchWordsInList(std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos) const; >+ std::unique_ptr<WordSearchStatus> >+ SearchWordsInList(std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos) const; >+ bool >+ SearchWordsNext(std::u16string_view rTxt, sal_Int32& rStt, sal_Int32 nEndPos, WordSearchStatus* pStatus) const; > }; > > class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists >@@ -322,10 +371,14 @@ public: > // nEnd - to check position - as of this item forward > // rLang - Input: in which language is searched > // Output: in which "language list" was it found >- const SvxAutocorrWord* SearchWordsInList( std::u16string_view rTxt, >- sal_Int32& rStt, sal_Int32 nEndPos, >- SvxAutoCorrDoc& rDoc, >- LanguageTag& rLang ); >+ std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> >+ SearchWordsInList( std::u16string_view rTxt, >+ sal_Int32& rStt, sal_Int32 nEndPos, >+ SvxAutoCorrDoc& rDoc, >+ LanguageTag& rLang ); >+ bool SearchWordsNext( std::u16string_view rTxt, >+ sal_Int32& rStt, sal_Int32 nEndPos, >+ SvxAutocorrWordList::WordSearchStatus* pStatus ); > > // Query/Set the Character for the Quote substitution > sal_Unicode GetStartSingleQuote() const { return cStartSQuote; } >diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx >index 06ab1231ff40..d0baf7cf7e2a 100644 >--- a/sw/source/core/edit/acorrect.cxx >+++ b/sw/source/core/edit/acorrect.cxx >@@ -393,110 +393,128 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, > pTextNd->getLayoutFrame(m_rEditSh.GetLayout()))); > assert(pFrame); > >- const OUString sFrameText = pFrame->GetText(); >- const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( >- sFrameText, rSttPos, nEndPos, *this, aLanguageTag); >+ OUString sFrameText = pFrame->GetText(); >+ sal_Int32 sttPos = rSttPos; >+ std::unique_ptr<SvxAutocorrWordList::WordSearchStatus> pStatus >+ = rACorrect.SearchWordsInList(sFrameText, sttPos, nEndPos, *this, >+ aLanguageTag); > SwDoc* pDoc = m_rEditSh.GetDoc(); >- if( pFnd ) >+ if( pStatus ) > { >- // replace also last colon of keywords surrounded by colons (for example, ":name:") >- const bool replaceLastChar = sFrameText.getLength() > nEndPos && pFnd->GetShort()[0] == ':' >- && pFnd->GetShort().endsWith(":"); >- >- SwPosition aStartPos( pFrame->MapViewToModelPos(TextFrameIndex(rSttPos) )); >- SwPosition aEndPos( pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0))) ); >- SwPaM aPam(aStartPos, aEndPos); >- >- // don't replace, if a redline starts or ends within the original text >- if ( pDoc->getIDocumentRedlineAccess().HasRedline( aPam, RedlineType::Any, /*bStartOrEndInRange=*/true ) ) >- { >- return bRet; >- } >+ sal_Int32 minSttPos = sttPos; >+ do { >+ const SvxAutocorrWord* pFnd = pStatus->GetAutocorrWord(); >+ // replace also last colon of keywords surrounded by colons >+ // (for example, ":name:") >+ const bool replaceLastChar = sFrameText.getLength() > nEndPos >+ && pFnd->GetShort()[0] == ':' >+ && pFnd->GetShort().endsWith(":"); >+ >+ SwPosition aStartPos( pFrame->MapViewToModelPos(TextFrameIndex(sttPos)) ); >+ SwPosition aEndPos( pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0))) ); >+ SwPaM aPam(aStartPos, aEndPos); >+ >+ // don't replace, if a redline starts or ends within the original text >+ if ( pDoc->getIDocumentRedlineAccess().HasRedline( aPam, RedlineType::Any, /*bStartOrEndInRange=*/true ) ) >+ { >+ return bRet; >+ } > >- if( pFnd->IsTextOnly() ) >- { >- //JP 22.04.99: Bug 63883 - Special treatment for dots. >- const bool bLastCharIsPoint >- = nEndPos < sFrameText.getLength() && ('.' == sFrameText[nEndPos]); >- if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() || >- '.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] ) >+ if( pFnd->IsTextOnly() ) > { >- // replace the selection >- std::vector<std::shared_ptr<SwUnoCursor>> ranges; >- if (sw::GetRanges(ranges, *m_rEditSh.GetDoc(), aPam)) >- { >- pDoc->getIDocumentContentOperations().ReplaceRange(aPam, pFnd->GetLong(), false); >- bRet = true; >- } >- else if (!ranges.empty()) >+ //JP 22.04.99: Bug 63883 - Special treatment for dots. >+ const bool bLastCharIsPoint >+ = nEndPos < sFrameText.getLength() && ('.' == sFrameText[nEndPos]); >+ if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() || >+ '.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] ) > { >- assert(ranges.front()->GetPoint()->GetNode() == ranges.front()->GetMark()->GetNode()); >- pDoc->getIDocumentContentOperations().ReplaceRange( >- *ranges.front(), pFnd->GetLong(), false); >- for (auto it = ranges.begin() + 1; it != ranges.end(); ++it) >+ // replace the selection >+ std::vector<std::shared_ptr<SwUnoCursor>> ranges; >+ if (sw::GetRanges(ranges, *m_rEditSh.GetDoc(), aPam)) > { >- DeleteSelImpl(**it); >+ pDoc->getIDocumentContentOperations().ReplaceRange( >+ aPam, pFnd->GetLong(), false); >+ nEndPos = sttPos + pFnd->GetLong().getLength(); >+ bRet = true; >+ } >+ else if (!ranges.empty()) >+ { >+ assert(ranges.front()->GetPoint()->GetNode() == ranges.front()->GetMark()->GetNode()); >+ pDoc->getIDocumentContentOperations().ReplaceRange( >+ *ranges.front(), pFnd->GetLong(), false); >+ nEndPos = sttPos + pFnd->GetLong().getLength(); >+ for (auto it = ranges.begin() + 1; it != ranges.end(); ++it) >+ { >+ DeleteSelImpl(**it); >+ nEndPos -= pFnd->GetLong().getLength(); >+ } >+ bRet = true; > } >- bRet = true; >- } > >- // tdf#83260 After calling sw::DocumentContentOperationsManager::ReplaceRange >- // pTextNd may become invalid when change tracking is on and Edit -> Track Changes -> Show == OFF. >- // ReplaceRange shows changes, this moves deleted nodes from special section to document. >- // Then Show mode is disabled again. As a result pTextNd may be invalidated. >- pTextNd = m_rCursor.GetPointNode().GetTextNode(); >+ // tdf#83260 After calling sw::DocumentContentOperationsManager::ReplaceRange >+ // pTextNd may become invalid when change tracking is on and Edit -> Track Changes -> Show == OFF. >+ // ReplaceRange shows changes, this moves deleted nodes from special section to document. >+ // Then Show mode is disabled again. As a result pTextNd may be invalidated. >+ pTextNd = m_rCursor.GetPointNode().GetTextNode(); >+ } > } >- } >- else >- { >- SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, false, true )); >- sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() ); >- if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) ) >+ else > { >- DeleteSel( aPam ); >- pDoc->DontExpandFormat( *aPam.GetPoint() ); >- >- if( pPara ) >+ SwTextBlocks aTBlks( rACorrect.GetAutoCorrFileName( aLanguageTag, false, true )); >+ sal_uInt16 nPos = aTBlks.GetIndex( pFnd->GetShort() ); >+ if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) ) > { >- OSL_ENSURE( !m_oIndex, "who has not deleted his Index?" ); >- m_oIndex.emplace(m_rCursor.GetPoint()->GetNode()); >- sw::GotoPrevLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); >- } >+ DeleteSel( aPam ); >+ pDoc->DontExpandFormat( *aPam.GetPoint() ); > >- SwDoc* pAutoDoc = aTBlks.GetDoc(); >- SwNodeIndex aSttIdx( pAutoDoc->GetNodes().GetEndOfExtras(), 1 ); >- SwContentNode* pContentNd = pAutoDoc->GetNodes().GoNext( &aSttIdx ); >- SwPaM aCpyPam( aSttIdx ); >+ if( pPara ) >+ { >+ OSL_ENSURE( !m_oIndex, "who has not deleted his Index?" ); >+ m_oIndex.emplace(m_rCursor.GetPoint()->GetNode()); >+ sw::GotoPrevLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); >+ } > >- const SwTableNode* pTableNd = pContentNd->FindTableNode(); >- if( pTableNd ) >- { >- aCpyPam.GetPoint()->Assign( *pTableNd ); >- } >- aCpyPam.SetMark(); >+ SwDoc* pAutoDoc = aTBlks.GetDoc(); >+ SwNodeIndex aSttIdx( pAutoDoc->GetNodes().GetEndOfExtras(), 1 ); >+ SwContentNode* pContentNd = pAutoDoc->GetNodes().GoNext( &aSttIdx ); >+ SwPaM aCpyPam( aSttIdx ); > >- // then until the end of the Nodes Array >- aCpyPam.GetPoint()->Assign( pAutoDoc->GetNodes().GetEndOfContent(), SwNodeOffset(-1) ); >- pContentNd = aCpyPam.GetPointContentNode(); >- if (pContentNd) >- aCpyPam.GetPoint()->SetContent( pContentNd->Len() ); >+ const SwTableNode* pTableNd = pContentNd->FindTableNode(); >+ if( pTableNd ) >+ { >+ aCpyPam.GetPoint()->Assign( *pTableNd ); >+ } >+ aCpyPam.SetMark(); > >- SwDontExpandItem aExpItem; >- aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); >+ // then until the end of the Nodes Array >+ aCpyPam.GetPoint()->Assign( pAutoDoc->GetNodes().GetEndOfContent(), SwNodeOffset(-1) ); >+ pContentNd = aCpyPam.GetPointContentNode(); >+ if (pContentNd) >+ aCpyPam.GetPoint()->SetContent( pContentNd->Len() ); > >- pAutoDoc->getIDocumentContentOperations().CopyRange(aCpyPam, *aPam.GetPoint(), SwCopyFlags::CheckPosInFly); >+ SwDontExpandItem aExpItem; >+ aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); > >- aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); >+ pAutoDoc->getIDocumentContentOperations().CopyRange(aCpyPam, *aPam.GetPoint(), SwCopyFlags::CheckPosInFly); > >- if( pPara ) >- { >- sw::GotoNextLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); >- pTextNd = m_oIndex->GetNode().GetTextNode(); >+ aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); >+ >+ if( pPara ) >+ { >+ sw::GotoNextLayoutTextFrame(*m_oIndex, m_rEditSh.GetLayout()); >+ pTextNd = m_oIndex->GetNode().GetTextNode(); >+ } >+ bRet = true; > } >- bRet = true; >+ aTBlks.EndGetDoc(); > } >- aTBlks.EndGetDoc(); >- } >+ if( sttPos < minSttPos) >+ minSttPos = sttPos; >+ sttPos = rSttPos; >+ sFrameText = pFrame->GetText(); >+ } while( rACorrect.SearchWordsNext(sFrameText, rSttPos, nEndPos, >+ pStatus.get()) ); >+ rSttPos = minSttPos; > } > > if( bRet && pPara && pTextNd ) >-- >2.43.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 158454
:
191134
| 191135