diff options
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/crsr/crsrsh.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/SwGrammarContact.cxx | 73 | ||||
-rw-r--r-- | sw/source/core/unocore/unoflatpara.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotextmarkup.cxx | 4 |
6 files changed, 35 insertions, 64 deletions
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index d0a71e136d33..41a12ab26229 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1502,9 +1502,10 @@ void SwCursorShell::UpdateCursorPos() &aTmpState ); pShellCursor->DeleteMark(); } - IGrammarContact *pGrammarContact = GetDoc() ? GetDoc()->getGrammarContact() : nullptr; - if( pGrammarContact ) - pGrammarContact->updateCursorPosition( *m_pCurrentCursor->GetPoint() ); + auto* pDoc = GetDoc(); + if (pDoc) + pDoc->getGrammarContact()->updateCursorPosition(*m_pCurrentCursor->GetPoint()); + --mnStartAction; if( aOldSz != GetDocSize() ) SizeChgNotify(); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 798a279b930a..55bb56da9dc7 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -247,7 +247,7 @@ SwDoc::SwDoc() mpNumberFormatter( nullptr ), mpNumRuleTable( new SwNumRuleTable ), mpExtInputRing( nullptr ), - mpGrammarContact(createGrammarContact()), + mpGrammarContact(new sw::GrammarContact), mpCellStyles(new SwCellStyleTable), mReferenceCount(0), mbDtor(false), @@ -808,14 +808,19 @@ void SwDoc::WriteLayoutCache( SvStream& rStream ) SwLayoutCache::Write( rStream, *this ); } -IGrammarContact* getGrammarContact( const SwTextNode& rTextNode ) +namespace sw +{ + +sw::GrammarContact* getGrammarContact(const SwTextNode& rTextNode) { const SwDoc& rDoc = rTextNode.GetDoc(); if (rDoc.IsInDtor()) return nullptr; - return rDoc.getGrammarContact(); + return rDoc.getGrammarContact().get(); } +} // end sw + ::sfx2::IXmlIdRegistry& SwDoc::GetXmlIdRegistry() { diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index af3955a23e87..405d124c09e0 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1801,7 +1801,7 @@ static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode const& rNode, if ( !rFrame.IsFollow() ) { SwTextNode* pTextNode = const_cast<SwTextNode*>(&rNode); - IGrammarContact* pGrammarContact = getGrammarContact( *pTextNode ); + sw::GrammarContact* pGrammarContact = getGrammarContact(*pTextNode); SwGrammarMarkUp* pWrongGrammar = pGrammarContact ? pGrammarContact->getGrammarCheck( *pTextNode, false ) : pTextNode->GetGrammarCheck(); diff --git a/sw/source/core/txtnode/SwGrammarContact.cxx b/sw/source/core/txtnode/SwGrammarContact.cxx index e2c1049f42ec..aaddc1406cfb 100644 --- a/sw/source/core/txtnode/SwGrammarContact.cxx +++ b/sw/source/core/txtnode/SwGrammarContact.cxx @@ -17,64 +17,32 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <vcl/timer.hxx> #include <IGrammarContact.hxx> #include <pam.hxx> #include <ndtxt.hxx> -#include <SwGrammarMarkUp.hxx> #include <txtfrm.hxx> -#include <svl/listener.hxx> -namespace { - -/* - * This class is responsible for the delayed display of grammar checks when a paragraph is edited - * It's a client of the paragraph the cursor points to. - * If the cursor position changes, updateCursorPosition has to be called - * If the grammar checker wants to set a grammar marker at a paragraph, he has to request - * the grammar list from this class. If the requested paragraph is not edited, it returns - * the normal grammar list. But if the paragraph is the active one, a proxy list will be returned and - * all changes are set in this proxy list. If the cursor leaves the paragraph the proxy list - * will replace the old list. If the grammar checker has completed the paragraph ('setChecked') - * then a timer is setup which replaces the old list as well. - */ -class SwGrammarContact final : public IGrammarContact, public SvtListener +namespace sw { - Timer m_aTimer; - std::unique_ptr<SwGrammarMarkUp> m_pProxyList; - bool m_isFinished; - SwTextNode* m_pTextNode; - DECL_LINK( TimerRepaint, Timer *, void ); - -public: - SwGrammarContact(); - virtual ~SwGrammarContact() override { m_aTimer.Stop(); } - - // (pure) virtual functions of IGrammarContact - virtual void updateCursorPosition( const SwPosition& rNewPos ) override; - virtual SwGrammarMarkUp* getGrammarCheck( SwTextNode& rTextNode, bool bCreate ) override; - virtual void finishGrammarCheck( SwTextNode& rTextNode ) override; - void CheckBroadcaster() - { - if(HasBroadcaster()) - return; - m_pTextNode = nullptr; - m_pProxyList.reset(); - } -}; - -} -SwGrammarContact::SwGrammarContact() +GrammarContact::GrammarContact() : m_aTimer( "sw::SwGrammarContact TimerRepaint" ), m_isFinished( false ), m_pTextNode(nullptr) { m_aTimer.SetTimeout( 2000 ); // Repaint of grammar check after 'setChecked' - m_aTimer.SetInvokeHandler( LINK(this, SwGrammarContact, TimerRepaint) ); + m_aTimer.SetInvokeHandler( LINK(this, GrammarContact, TimerRepaint) ); } -IMPL_LINK( SwGrammarContact, TimerRepaint, Timer *, pTimer, void ) +void GrammarContact::CheckBroadcaster() +{ + if (HasBroadcaster()) + return; + m_pTextNode = nullptr; + m_pProxyList.reset(); +} + +IMPL_LINK( GrammarContact, TimerRepaint, Timer *, pTimer, void ) { CheckBroadcaster(); if( pTimer ) @@ -89,7 +57,7 @@ IMPL_LINK( SwGrammarContact, TimerRepaint, Timer *, pTimer, void ) } /* I'm always a client of the current paragraph */ -void SwGrammarContact::updateCursorPosition( const SwPosition& rNewPos ) +void GrammarContact::updateCursorPosition( const SwPosition& rNewPos ) { CheckBroadcaster(); SwTextNode* pTextNode = rNewPos.GetNode().GetTextNode(); @@ -115,7 +83,7 @@ void SwGrammarContact::updateCursorPosition( const SwPosition& rNewPos ) } /* deliver a grammar check list for the given text node */ -SwGrammarMarkUp* SwGrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool bCreate ) +SwGrammarMarkUp* GrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool bCreate ) { SwGrammarMarkUp *pRet = nullptr; CheckBroadcaster(); @@ -155,7 +123,7 @@ SwGrammarMarkUp* SwGrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool return pRet; } -void SwGrammarContact::finishGrammarCheck( SwTextNode& rTextNode ) +void GrammarContact::finishGrammarCheck( SwTextNode& rTextNode ) { CheckBroadcaster(); if( &rTextNode != m_pTextNode ) // not my paragraph @@ -175,16 +143,13 @@ void SwGrammarContact::finishGrammarCheck( SwTextNode& rTextNode ) } } -IGrammarContact* createGrammarContact() -{ - return new SwGrammarContact(); -} - void finishGrammarCheck( SwTextNode& rTextNode ) { - IGrammarContact* pGrammarContact = getGrammarContact( rTextNode ); - if( pGrammarContact ) + sw::GrammarContact* pGrammarContact = getGrammarContact( rTextNode ); + if (pGrammarContact) pGrammarContact->finishGrammarCheck( rTextNode ); } +} // end sw + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 6fa124a824fd..4f2c8e385620 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -190,7 +190,7 @@ void SAL_CALL SwXFlatParagraph::setChecked( ::sal_Int32 nType, sal_Bool bVal ) { GetTextNode()->SetGrammarCheckDirty( !bVal ); if( bVal ) - ::finishGrammarCheck( *GetTextNode() ); + sw::finishGrammarCheck( *GetTextNode() ); } } diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx index 8160da91a8ae..86add0f34c9c 100644 --- a/sw/source/core/unocore/unotextmarkup.cxx +++ b/sw/source/core/unocore/unotextmarkup.cxx @@ -157,7 +157,7 @@ void SAL_CALL SwXTextMarkup::commitStringMarkup( } else if ( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE ) { - IGrammarContact *pGrammarContact = getGrammarContact(*m_pImpl->m_pTextNode); + sw::GrammarContact* pGrammarContact = getGrammarContact(*m_pImpl->m_pTextNode); if( pGrammarContact ) { pWList = pGrammarContact->getGrammarCheck(*m_pImpl->m_pTextNode, true); @@ -411,7 +411,7 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup( // get appropriate list to use... SwGrammarMarkUp* pWList = nullptr; bool bRepaint = false; - IGrammarContact *pGrammarContact = getGrammarContact(*m_pImpl->m_pTextNode); + sw::GrammarContact* pGrammarContact = getGrammarContact(*m_pImpl->m_pTextNode); if( pGrammarContact ) { pWList = pGrammarContact->getGrammarCheck(*m_pImpl->m_pTextNode, true); |