LibreOffice Module linguistic (master) 1
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
GrammarCheckingIterator Class Reference

#include <gciterator.hxx>

Inheritance diagram for GrammarCheckingIterator:
[legend]
Collaboration diagram for GrammarCheckingIterator:
[legend]

Public Member Functions

void DequeueAndCheck ()
 
 GrammarCheckingIterator ()
 
virtual ~GrammarCheckingIterator () override
 
virtual void SAL_CALL startProofreading (const css::uno::Reference< css::uno::XInterface > &xDocument, const css::uno::Reference< css::text::XFlatParagraphIteratorProvider > &xIteratorProvider) override
 
virtual css::linguistic2::ProofreadingResult SAL_CALL checkSentenceAtPosition (const css::uno::Reference< css::uno::XInterface > &xDocument, const css::uno::Reference< css::text::XFlatParagraph > &xFlatParagraph, const OUString &aText, const css::lang::Locale &aLocale, ::sal_Int32 nStartOfSentencePosition, ::sal_Int32 nSuggestedBehindEndOfSentencePosition, ::sal_Int32 nErrorPositionInParagraph) override
 
virtual void SAL_CALL resetIgnoreRules () override
 
virtual sal_Bool SAL_CALL isProofreading (const css::uno::Reference< css::uno::XInterface > &xDocument) override
 
virtual void SAL_CALL processLinguServiceEvent (const css::linguistic2::LinguServiceEvent &aLngSvcEvent) override
 
virtual sal_Bool SAL_CALL addLinguServiceEventListener (const css::uno::Reference< css::linguistic2::XLinguServiceEventListener > &xLstnr) override
 
virtual sal_Bool SAL_CALL removeLinguServiceEventListener (const css::uno::Reference< css::linguistic2::XLinguServiceEventListener > &xLstnr) override
 
virtual void SAL_CALL dispose () override
 
virtual void SAL_CALL addEventListener (const css::uno::Reference< css::lang::XEventListener > &xListener) override
 
virtual void SAL_CALL removeEventListener (const css::uno::Reference< css::lang::XEventListener > &aListener) override
 
virtual void SAL_CALL disposing (const css::lang::EventObject &Source) override
 
virtual OUString SAL_CALL getImplementationName () override
 
virtual sal_Bool SAL_CALL supportsService (const OUString &ServiceName) override
 
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames () override
 
virtual void SetServiceList (const css::lang::Locale &rLocale, const css::uno::Sequence< OUString > &rSvcImplNames) override
 
virtual css::uno::Sequence< OUString > GetServiceList (const css::lang::Locale &rLocale) const override
 
virtual void SetServiceList (const css::lang::Locale &rLocale, const css::uno::Sequence< OUString > &rSvcImplNames)=0
 
virtual css::uno::Sequence< OUString > GetServiceList (const css::lang::Locale &rLocale) const =0
 

Private Types

typedef std::deque< FPEntryFPQueue_t
 
typedef std::map< XComponent *, OUString > DocMap_t
 
typedef std::map< OUString, OUString > GCImplNames_t
 
typedef std::map< OUString, css::uno::Reference< css::linguistic2::XProofreader > > GCReferences_t
 

Private Member Functions

void TerminateThread ()
 
sal_Int32 NextDocId ()
 
OUString GetOrCreateDocId (const css::uno::Reference< css::lang::XComponent > &xComp)
 
void AddEntry (const css::uno::Reference< css::text::XFlatParagraphIterator > &xFlatParaIterator, const css::uno::Reference< css::text::XFlatParagraph > &xFlatPara, const OUString &rDocId, sal_Int32 nStartIndex, bool bAutomatic)
 
void ProcessResult (const css::linguistic2::ProofreadingResult &rRes, const css::uno::Reference< css::text::XFlatParagraphIterator > &rxFlatParagraphIterator, bool bIsAutomaticChecking)
 
sal_Int32 GetSuggestedEndOfSentence (const OUString &rText, sal_Int32 nSentenceStartPos, const css::lang::Locale &rLocale)
 
void GetConfiguredGCSvcs_Impl ()
 
css::uno::Reference< css::linguistic2::XProofreader > GetGrammarChecker (css::lang::Locale &rLocale)
 
css::uno::Reference< css::util::XChangesBatch > const & GetUpdateAccess () const
 
 GrammarCheckingIterator (const GrammarCheckingIterator &)=delete
 
GrammarCheckingIteratoroperator= (const GrammarCheckingIterator &)=delete
 
std::pair< OUString, std::optional< OUString > > getServiceForLocale (const css::lang::Locale &rLocale) const
 

Static Private Member Functions

static osl::Mutex & MyMutex ()
 beware of initialization order! More...
 

Private Attributes

FPQueue_t m_aFPEntriesQueue
 
bool m_bEnd
 
DocMap_t m_aDocIdMap
 
GCImplNames_t m_aGCImplNamesByLang
 
GCReferences_t m_aGCReferencesByService
 
OUString m_aCurCheckedDocId
 
bool m_bGCServicesChecked
 
sal_Int32 m_nDocIdCounter
 
osl::Condition m_aWakeUpThread
 
oslThread m_thread
 
comphelper::OInterfaceContainerHelper3< css::lang::XEventListener > m_aEventListeners
 
comphelper::OInterfaceContainerHelper3< css::linguistic2::XLinguServiceEventListener > m_aNotifyListeners
 
css::uno::Reference< css::i18n::XBreakIterator > m_xBreakIterator
 
css::uno::Reference< css::util::XChangesBatch > m_xUpdateAccess
 

Additional Inherited Members

- Protected Member Functions inherited from LinguDispatcher
 ~LinguDispatcher ()
 

Detailed Description

Definition at line 74 of file gciterator.hxx.

Member Typedef Documentation

◆ DocMap_t

typedef std::map< XComponent *, OUString > GrammarCheckingIterator::DocMap_t
private

Definition at line 96 of file gciterator.hxx.

◆ FPQueue_t

typedef std::deque< FPEntry > GrammarCheckingIterator::FPQueue_t
private

Definition at line 87 of file gciterator.hxx.

◆ GCImplNames_t

typedef std::map< OUString, OUString > GrammarCheckingIterator::GCImplNames_t
private

Definition at line 101 of file gciterator.hxx.

◆ GCReferences_t

typedef std::map< OUString, css::uno::Reference< css::linguistic2::XProofreader > > GrammarCheckingIterator::GCReferences_t
private

Definition at line 105 of file gciterator.hxx.

Constructor & Destructor Documentation

◆ GrammarCheckingIterator() [1/2]

GrammarCheckingIterator::GrammarCheckingIterator ( const GrammarCheckingIterator )
privatedelete

◆ GrammarCheckingIterator() [2/2]

GrammarCheckingIterator::GrammarCheckingIterator ( )
explicit

Definition at line 281 of file gciterator.cxx.

◆ ~GrammarCheckingIterator()

GrammarCheckingIterator::~GrammarCheckingIterator ( )
overridevirtual

Definition at line 292 of file gciterator.cxx.

References TerminateThread().

Member Function Documentation

◆ AddEntry()

void GrammarCheckingIterator::AddEntry ( const css::uno::Reference< css::text::XFlatParagraphIterator > &  xFlatParaIterator,
const css::uno::Reference< css::text::XFlatParagraph > &  xFlatPara,
const OUString &  rDocId,
sal_Int32  nStartIndex,
bool  bAutomatic 
)
private

◆ addEventListener()

void SAL_CALL GrammarCheckingIterator::addEventListener ( const css::uno::Reference< css::lang::XEventListener > &  xListener)
overridevirtual

◆ addLinguServiceEventListener()

sal_Bool SAL_CALL GrammarCheckingIterator::addLinguServiceEventListener ( const css::uno::Reference< css::linguistic2::XLinguServiceEventListener > &  xLstnr)
overridevirtual

◆ checkSentenceAtPosition()

linguistic2::ProofreadingResult SAL_CALL GrammarCheckingIterator::checkSentenceAtPosition ( const css::uno::Reference< css::uno::XInterface > &  xDocument,
const css::uno::Reference< css::text::XFlatParagraph > &  xFlatParagraph,
const OUString &  aText,
const css::lang::Locale &  aLocale,
::sal_Int32  nStartOfSentencePosition,
::sal_Int32  nSuggestedBehindEndOfSentencePosition,
::sal_Int32  nErrorPositionInParagraph 
)
overridevirtual

! work-around to prevent looping if the grammar checker ! failed to properly identify the sentence end

Definition at line 763 of file gciterator.cxx.

References DBG_ASSERT, GetGrammarChecker(), GetOrCreateDocId(), GetSuggestedEndOfSentence(), lcl_BacktraceWhiteSpaces(), lcl_GetPrimaryLanguageOfSentence(), lcl_makeProperties(), lcl_SkipWhiteSpaces(), MyMutex(), PROOFINFO_GET_PROOFRESULT, and SAL_WARN.

◆ DequeueAndCheck()

void GrammarCheckingIterator::DequeueAndCheck ( )

◆ dispose()

void SAL_CALL GrammarCheckingIterator::dispose ( void  )
overridevirtual

◆ disposing()

void SAL_CALL GrammarCheckingIterator::disposing ( const css::lang::EventObject &  Source)
overridevirtual

! There is no need to remove entries from the queue that are from this document ! since the respectives xFlatParagraphs should become invalid (isModified() == true) ! and the call to xFlatParagraphIterator->getNextPara() will result in an empty reference. ! And if an entry is currently checked by a grammar checker upon return the results ! should be ignored. ! Also GetOrCreateDocId will not use that very same Id again... ! All of the above resulting in that we only have to get rid of the implementation pointer here.

Definition at line 1042 of file gciterator.cxx.

References m_aDocIdMap, and MyMutex().

◆ GetConfiguredGCSvcs_Impl()

void GrammarCheckingIterator::GetConfiguredGCSvcs_Impl ( )
private

◆ GetGrammarChecker()

uno::Reference< linguistic2::XProofreader > GrammarCheckingIterator::GetGrammarChecker ( css::lang::Locale &  rLocale)
private

◆ getImplementationName()

OUString SAL_CALL GrammarCheckingIterator::getImplementationName ( )
overridevirtual

Definition at line 1144 of file gciterator.cxx.

◆ GetOrCreateDocId()

OUString GrammarCheckingIterator::GetOrCreateDocId ( const css::uno::Reference< css::lang::XComponent > &  xComp)
private

Definition at line 322 of file gciterator.cxx.

References m_aDocIdMap, and NextDocId().

Referenced by checkSentenceAtPosition(), and startProofreading().

◆ getServiceForLocale()

std::pair< OUString, std::optional< OUString > > GrammarCheckingIterator::getServiceForLocale ( const css::lang::Locale &  rLocale) const
private

Definition at line 488 of file gciterator.cxx.

References LanguageTag::convertToBcp47(), and m_aGCImplNamesByLang.

Referenced by GetGrammarChecker(), and GetServiceList().

◆ GetServiceList()

uno::Sequence< OUString > GrammarCheckingIterator::GetServiceList ( const css::lang::Locale &  rLocale) const
overridevirtual

Implements LinguDispatcher.

Definition at line 1177 of file gciterator.cxx.

References getServiceForLocale(), and MyMutex().

◆ GetSuggestedEndOfSentence()

sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence ( const OUString &  rText,
sal_Int32  nSentenceStartPos,
const css::lang::Locale &  rLocale 
)
private

Definition at line 849 of file gciterator.cxx.

References m_xBreakIterator.

Referenced by checkSentenceAtPosition(), and DequeueAndCheck().

◆ getSupportedServiceNames()

uno::Sequence< OUString > SAL_CALL GrammarCheckingIterator::getSupportedServiceNames ( )
overridevirtual

Definition at line 1150 of file gciterator.cxx.

◆ GetUpdateAccess()

uno::Reference< util::XChangesBatch > const & GrammarCheckingIterator::GetUpdateAccess ( ) const
private

Definition at line 1063 of file gciterator.cxx.

References comphelper::getProcessComponentContext(), and m_xUpdateAccess.

Referenced by GetConfiguredGCSvcs_Impl().

◆ isProofreading()

sal_Bool SAL_CALL GrammarCheckingIterator::isProofreading ( const css::uno::Reference< css::uno::XInterface > &  xDocument)
overridevirtual

Definition at line 902 of file gciterator.cxx.

References i, m_aCurCheckedDocId, m_aDocIdMap, m_aFPEntriesQueue, and MyMutex().

◆ MyMutex()

osl::Mutex & GrammarCheckingIterator::MyMutex ( )
staticprivate

◆ NextDocId()

sal_Int32 GrammarCheckingIterator::NextDocId ( )
private

Definition at line 314 of file gciterator.cxx.

References m_nDocIdCounter, and MyMutex().

Referenced by GetOrCreateDocId().

◆ operator=()

GrammarCheckingIterator & GrammarCheckingIterator::operator= ( const GrammarCheckingIterator )
privatedelete

◆ processLinguServiceEvent()

void SAL_CALL GrammarCheckingIterator::processLinguServiceEvent ( const css::linguistic2::LinguServiceEvent &  aLngSvcEvent)
overridevirtual

◆ ProcessResult()

void GrammarCheckingIterator::ProcessResult ( const css::linguistic2::ProofreadingResult &  rRes,
const css::uno::Reference< css::text::XFlatParagraphIterator > &  rxFlatParagraphIterator,
bool  bIsAutomaticChecking 
)
private

Definition at line 377 of file gciterator.cxx.

References AddEntry(), DBG_ASSERT, and TOOLS_WARN_EXCEPTION.

Referenced by DequeueAndCheck().

◆ removeEventListener()

void SAL_CALL GrammarCheckingIterator::removeEventListener ( const css::uno::Reference< css::lang::XEventListener > &  aListener)
overridevirtual

◆ removeLinguServiceEventListener()

sal_Bool SAL_CALL GrammarCheckingIterator::removeLinguServiceEventListener ( const css::uno::Reference< css::linguistic2::XLinguServiceEventListener > &  xLstnr)
overridevirtual

◆ resetIgnoreRules()

void SAL_CALL GrammarCheckingIterator::resetIgnoreRules ( )
overridevirtual

Definition at line 891 of file gciterator.cxx.

References m_aGCReferencesByService.

◆ SetServiceList()

void GrammarCheckingIterator::SetServiceList ( const css::lang::Locale &  rLocale,
const css::uno::Sequence< OUString > &  rSvcImplNames 
)
overridevirtual

◆ startProofreading()

void SAL_CALL GrammarCheckingIterator::startProofreading ( const css::uno::Reference< css::uno::XInterface > &  xDocument,
const css::uno::Reference< css::text::XFlatParagraphIteratorProvider > &  xIteratorProvider 
)
overridevirtual

Definition at line 739 of file gciterator.cxx.

References AddEntry(), GetOrCreateDocId(), and MyMutex().

◆ supportsService()

sal_Bool SAL_CALL GrammarCheckingIterator::supportsService ( const OUString &  ServiceName)
overridevirtual

Definition at line 1137 of file gciterator.cxx.

References cppu::supportsService().

◆ TerminateThread()

void GrammarCheckingIterator::TerminateThread ( )
private

Definition at line 297 of file gciterator.cxx.

References m_aWakeUpThread, m_bEnd, m_thread, MyMutex(), and t.

Referenced by dispose(), and ~GrammarCheckingIterator().

Member Data Documentation

◆ m_aCurCheckedDocId

OUString GrammarCheckingIterator::m_aCurCheckedDocId
private

Definition at line 108 of file gciterator.hxx.

Referenced by DequeueAndCheck(), and isProofreading().

◆ m_aDocIdMap

DocMap_t GrammarCheckingIterator::m_aDocIdMap
private

Definition at line 97 of file gciterator.hxx.

Referenced by dispose(), disposing(), GetOrCreateDocId(), and isProofreading().

◆ m_aEventListeners

comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> GrammarCheckingIterator::m_aEventListeners
private

Definition at line 116 of file gciterator.hxx.

Referenced by addEventListener(), dispose(), and removeEventListener().

◆ m_aFPEntriesQueue

FPQueue_t GrammarCheckingIterator::m_aFPEntriesQueue
private

Definition at line 90 of file gciterator.hxx.

Referenced by AddEntry(), DequeueAndCheck(), dispose(), and isProofreading().

◆ m_aGCImplNamesByLang

GCImplNames_t GrammarCheckingIterator::m_aGCImplNamesByLang
private

Definition at line 102 of file gciterator.hxx.

Referenced by GetConfiguredGCSvcs_Impl(), getServiceForLocale(), and SetServiceList().

◆ m_aGCReferencesByService

GCReferences_t GrammarCheckingIterator::m_aGCReferencesByService
private

Definition at line 106 of file gciterator.hxx.

Referenced by dispose(), GetGrammarChecker(), and resetIgnoreRules().

◆ m_aNotifyListeners

comphelper::OInterfaceContainerHelper3<css::linguistic2::XLinguServiceEventListener> GrammarCheckingIterator::m_aNotifyListeners
private

◆ m_aWakeUpThread

osl::Condition GrammarCheckingIterator::m_aWakeUpThread
private

Definition at line 111 of file gciterator.hxx.

Referenced by AddEntry(), DequeueAndCheck(), and TerminateThread().

◆ m_bEnd

bool GrammarCheckingIterator::m_bEnd
private

Definition at line 93 of file gciterator.hxx.

Referenced by DequeueAndCheck(), and TerminateThread().

◆ m_bGCServicesChecked

bool GrammarCheckingIterator::m_bGCServicesChecked
private

Definition at line 109 of file gciterator.hxx.

Referenced by GetGrammarChecker().

◆ m_nDocIdCounter

sal_Int32 GrammarCheckingIterator::m_nDocIdCounter
private

Definition at line 110 of file gciterator.hxx.

Referenced by NextDocId().

◆ m_thread

oslThread GrammarCheckingIterator::m_thread
private

Definition at line 112 of file gciterator.hxx.

Referenced by AddEntry(), and TerminateThread().

◆ m_xBreakIterator

css::uno::Reference< css::i18n::XBreakIterator > GrammarCheckingIterator::m_xBreakIterator
private

Definition at line 119 of file gciterator.hxx.

Referenced by dispose(), and GetSuggestedEndOfSentence().

◆ m_xUpdateAccess

css::uno::Reference< css::util::XChangesBatch > GrammarCheckingIterator::m_xUpdateAccess
mutableprivate

Definition at line 120 of file gciterator.hxx.

Referenced by GetUpdateAccess().


The documentation for this class was generated from the following files: