diff --git a/vcl/inc/accessibility/textwindowaccessibility.hxx b/vcl/inc/accessibility/textwindowaccessibility.hxx index 09e527ff2780..a23a5f275d10 100644 --- a/vcl/inc/accessibility/textwindowaccessibility.hxx +++ b/vcl/inc/accessibility/textwindowaccessibility.hxx @@ -111,21 +111,19 @@ private: typedef std::vector< ParagraphInfo > Paragraphs; -typedef ::cppu::WeakComponentImplHelper< +typedef cppu::ImplInheritanceHelper< + comphelper::OAccessibleComponentHelper, css::accessibility::XAccessible, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleEditableText, css::accessibility::XAccessibleMultiLineText, - css::accessibility::XAccessibleTextAttributes, - css::accessibility::XAccessibleEventBroadcaster > ParagraphBase; + css::accessibility::XAccessibleTextAttributes> ParagraphBase; // The Paragraph's number is the absolute position within the text engine (from // 0 to N - 1), whereas the Paragraph's index is the position within the text // view/accessible parent (from 0 to M - 1). Paragraphs outside the currently // visible range have an index of -1. -class Paragraph final: - private cppu::BaseMutex, public ParagraphBase, private ::comphelper::OCommonAccessibleText +class Paragraph final + : public ParagraphBase, private ::comphelper::OCommonAccessibleText { public: Paragraph(::rtl::Reference< Document > xDocument, @@ -145,6 +143,9 @@ public: css::uno::Any const & rNewValue); private: + // OAccessibleComponentHelper + virtual css::awt::Rectangle implGetBounds() override; + // OCommonAccessibleText virtual void implGetParagraphBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, @@ -180,19 +181,9 @@ private: virtual css::lang::Locale SAL_CALL getLocale() override; - virtual sal_Bool SAL_CALL containsPoint(css::awt::Point const & rPoint) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(css::awt::Point const & rPoint) override; - virtual css::awt::Rectangle SAL_CALL getBounds() override; - - virtual css::awt::Point SAL_CALL getLocation() override; - - virtual css::awt::Point SAL_CALL getLocationOnScreen() override; - - virtual css::awt::Size SAL_CALL getSize() override; - virtual void SAL_CALL grabFocus() override; virtual sal_Int32 SAL_CALL getForeground() override; @@ -275,16 +266,6 @@ private: virtual ::sal_Int32 SAL_CALL getNumberOfLineWithCaret( ) override; - virtual void SAL_CALL addAccessibleEventListener( - css::uno::Reference< - css::accessibility::XAccessibleEventListener > const & rListener) override; - - virtual void SAL_CALL removeAccessibleEventListener( - css::uno::Reference< - css::accessibility::XAccessibleEventListener > const & rListener) override; - - virtual void SAL_CALL disposing() override; - virtual OUString implGetText() override; virtual css::lang::Locale implGetLocale() override; @@ -298,9 +279,6 @@ private: ::rtl::Reference< Document > m_xDocument; Paragraphs::size_type m_nNumber; - /// client id in the AccessibleEventNotifier queue - sal_uInt32 m_nClientId; - OUString m_aParagraphText; }; diff --git a/vcl/source/accessibility/textwindowaccessibility.cxx b/vcl/source/accessibility/textwindowaccessibility.cxx index 432142d99dff..f3b8a3d8db38 100644 --- a/vcl/source/accessibility/textwindowaccessibility.cxx +++ b/vcl/source/accessibility/textwindowaccessibility.cxx @@ -81,11 +81,10 @@ void WindowListenerGuard::endListening() } Paragraph::Paragraph(::rtl::Reference< Document > xDocument, - Paragraphs::size_type nNumber): - ParagraphBase(m_aMutex), + Paragraphs::size_type nNumber) + :ParagraphBase(), m_xDocument(std::move(xDocument)), - m_nNumber(nNumber), - m_nClientId(0) + m_nNumber(nNumber) { m_aParagraphText = m_xDocument->retrieveParagraphText(this); } @@ -116,10 +115,7 @@ void Paragraph::notifyEvent(::sal_Int16 nEventId, css::uno::Any const & rOldValue, css::uno::Any const & rNewValue) { - if (m_nClientId) - comphelper::AccessibleEventNotifier::addEvent( m_nClientId, css::accessibility::AccessibleEventObject( - getXWeak(), - nEventId, rNewValue, rOldValue, -1) ); + NotifyAccessibleEvent(nEventId, rOldValue, rNewValue); } // virtual @@ -209,16 +205,6 @@ css::lang::Locale SAL_CALL Paragraph::getLocale() return m_xDocument->retrieveLocale(); } -// virtual -sal_Bool SAL_CALL Paragraph::containsPoint(css::awt::Point const & rPoint) -{ - checkDisposed(); - css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this, - false)); - return rPoint.X >= 0 && rPoint.X < aRect.Width - && rPoint.Y >= 0 && rPoint.Y < aRect.Height; -} - // virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL Paragraph::getAccessibleAtPoint(css::awt::Point const &) @@ -227,40 +213,11 @@ Paragraph::getAccessibleAtPoint(css::awt::Point const &) return nullptr; } -// virtual -css::awt::Rectangle SAL_CALL Paragraph::getBounds() +css::awt::Rectangle Paragraph::implGetBounds() { - checkDisposed(); return m_xDocument->retrieveParagraphBounds(this, false); } -// virtual -css::awt::Point SAL_CALL Paragraph::getLocation() -{ - checkDisposed(); - css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this, - false)); - return css::awt::Point(aRect.X, aRect.Y); -} - -// virtual -css::awt::Point SAL_CALL Paragraph::getLocationOnScreen() -{ - checkDisposed(); - css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this, - true)); - return css::awt::Point(aRect.X, aRect.Y); -} - -// virtual -css::awt::Size SAL_CALL Paragraph::getSize() -{ - checkDisposed(); - css::awt::Rectangle aRect(m_xDocument->retrieveParagraphBounds(this, - false)); - return css::awt::Size(aRect.Width, aRect.Height); -} - // virtual void SAL_CALL Paragraph::grabFocus() { @@ -569,68 +526,6 @@ css::accessibility::TextSegment SAL_CALL Paragraph::getTextAtLineWithCaret( ) return m_xDocument->retrieveParagraphLineWithCursor(this); } - -// virtual -void SAL_CALL Paragraph::addAccessibleEventListener( - css::uno::Reference< - css::accessibility::XAccessibleEventListener > const & rListener) -{ - if (!rListener.is()) - return; - - ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - aGuard.clear(); - rListener->disposing(css::lang::EventObject( - getXWeak())); - } - else - { - if (!m_nClientId) - m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, rListener ); - } -} - -// virtual -void SAL_CALL Paragraph::removeAccessibleEventListener( - css::uno::Reference< - css::accessibility::XAccessibleEventListener > const & rListener) -{ - comphelper::AccessibleEventNotifier::TClientId nId = 0; - { - osl::MutexGuard aGuard(rBHelper.rMutex); - if (rListener.is() && m_nClientId != 0 - && comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, rListener ) == 0) - { - nId = m_nClientId; - m_nClientId = 0; - } - } - if (nId != 0) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient(nId); - } -} - -// virtual -void SAL_CALL Paragraph::disposing() -{ - comphelper::AccessibleEventNotifier::TClientId nId = 0; - { - osl::MutexGuard aGuard(rBHelper.rMutex); - nId = m_nClientId; - m_nClientId = 0; - } - if (nId != 0) - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(nId, *this); -} - // virtual OUString Paragraph::implGetText() {