IMPL_LINK( GrammarContact, TimerRepaint, Timer *, pTimer, void )
{
CheckBroadcaster(); if( pTimer )
{
pTimer->Stop(); if( m_pTextNode )
{ //Replace the old wrong list by the proxy list and repaint all frames
m_pTextNode->SetGrammarCheck( std::move(m_pProxyList) );
SwTextFrame::repaintTextFrames( *m_pTextNode );
}
}
}
/* I'm always a client of the current paragraph */ void GrammarContact::updateCursorPosition( const SwPosition& rNewPos )
{
CheckBroadcaster();
SwTextNode* pTextNode = rNewPos.GetNode().GetTextNode(); if( pTextNode == m_pTextNode ) // paragraph has been changed return;
m_aTimer.Stop(); if( m_pTextNode ) // My last paragraph has been left
{ if( m_pProxyList )
{ // replace old list by the proxy list and repaint
m_pTextNode->SetGrammarCheck( std::move(m_pProxyList) );
SwTextFrame::repaintTextFrames( *m_pTextNode );
}
EndListeningAll();
} if( pTextNode )
{
m_pTextNode = pTextNode;
EndListeningAll();
StartListening(pTextNode->GetNotifier()); // welcome new paragraph
}
}
/* deliver a grammar check list for the given text node */
SwGrammarMarkUp* GrammarContact::getGrammarCheck( SwTextNode& rTextNode, bool bCreate )
{
SwGrammarMarkUp *pRet = nullptr;
CheckBroadcaster(); if( m_pTextNode == &rTextNode ) // hey, that's my current paragraph!
{ // so you will get a proxy list... if( bCreate )
{ if( m_isFinished )
{
m_pProxyList.reset();
} if( !m_pProxyList )
{ if( rTextNode.GetGrammarCheck() )
m_pProxyList.reset( static_cast<SwGrammarMarkUp*>(rTextNode.GetGrammarCheck()->Clone()) ); else
{
m_pProxyList.reset( new SwGrammarMarkUp() );
m_pProxyList->SetInvalid( 0, COMPLETE_STRING );
}
}
m_isFinished = false;
}
pRet = m_pProxyList.get();
} else
{
pRet = rTextNode.GetGrammarCheck(); // do you have already a list? if( bCreate && !pRet ) // do you want to create a list?
{
pRet = new SwGrammarMarkUp();
pRet->SetInvalid( 0, COMPLETE_STRING );
rTextNode.SetGrammarCheck( std::unique_ptr<SwGrammarMarkUp>(pRet) );
rTextNode.SetGrammarCheckDirty( true );
}
} return pRet;
}
void GrammarContact::finishGrammarCheck( const SwTextNode& rTextNode )
{
CheckBroadcaster(); if( &rTextNode != m_pTextNode ) // not my paragraph
SwTextFrame::repaintTextFrames( rTextNode ); // can be repainted directly else
{ if( m_pProxyList )
{
m_isFinished = true;
m_aTimer.Start(); // will replace old list and repaint with delay
} elseif( m_pTextNode->GetGrammarCheck() )
{ // all grammar problems seems to be gone, no delay needed
m_pTextNode->ClearGrammarCheck();
SwTextFrame::repaintTextFrames( *m_pTextNode );
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.