accessibility/inc/extended/textwindowaccessibility.hxx | 13 ++++--- accessibility/inc/standard/vclxaccessiblebox.hxx | 6 +-- accessibility/source/extended/textwindowaccessibility.cxx | 17 +++------ accessibility/source/standard/vclxaccessiblebox.cxx | 24 +++++++------- 4 files changed, 29 insertions(+), 31 deletions(-)
New commits: commit 277c651875604a98032b70d6b0bd0f274cfe5d12 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 5 16:15:48 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 5 22:00:15 2023 +0200 use more concrete type in VCLXAccessibleBox and avoid some casting Change-Id: I755caf9ba5a333862d1a89a054359781544930f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156570 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/accessibility/inc/standard/vclxaccessiblebox.hxx b/accessibility/inc/standard/vclxaccessiblebox.hxx index 6c86491a5422..3825be0d4f22 100644 --- a/accessibility/inc/standard/vclxaccessiblebox.hxx +++ b/accessibility/inc/standard/vclxaccessiblebox.hxx @@ -26,6 +26,7 @@ #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <cppuhelper/implbase.hxx> +class VCLXAccessibleList; /** Base class for list- and combo boxes. This class manages the box' children. The classed derived from this one have only to implement the @@ -102,7 +103,7 @@ public: virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; protected: - virtual ~VCLXAccessibleBox() override = default; + virtual ~VCLXAccessibleBox() override; /** Returns true when the object is valid. */ @@ -129,8 +130,7 @@ private: m_xText; /// The child that contains the items of this box. - css::uno::Reference< css::accessibility::XAccessible> - m_xList; + rtl::Reference<VCLXAccessibleList> m_xList; /** This flag specifies whether an object has a text field as child regardless of whether that child being currently instantiated or diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx index 4f4972a04477..cbc68fb2d19a 100644 --- a/accessibility/source/standard/vclxaccessiblebox.cxx +++ b/accessibility/source/standard/vclxaccessiblebox.cxx @@ -52,6 +52,8 @@ VCLXAccessibleBox::VCLXAccessibleBox (VCLXWindow* pVCLWindow, BoxType aType, boo m_bHasTextChild = true; } +VCLXAccessibleBox::~VCLXAccessibleBox() {} + void VCLXAccessibleBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) { uno::Any aOldValue, aNewValue; @@ -106,11 +108,11 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven case VclEventId::ListboxSelect: { // Forward the call to the list child. - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if ( pList == nullptr ) { getAccessibleChild ( m_bHasTextChild ? 1 : 0 ); - pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + pList = m_xList.get(); } if ( pList != nullptr ) { @@ -126,11 +128,11 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven } case VclEventId::DropdownOpen: { - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if ( pList == nullptr ) { getAccessibleChild ( m_bHasTextChild ? 1 : 0 ); - pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + pList = m_xList.get(); } if ( pList != nullptr ) { @@ -141,11 +143,11 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven } case VclEventId::DropdownClose: { - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if ( pList == nullptr ) { getAccessibleChild ( m_bHasTextChild ? 1 : 0 ); - pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + pList = m_xList.get(); } if ( pList != nullptr ) { @@ -162,7 +164,7 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven } case VclEventId::ComboboxSelect: { - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if (pList != nullptr && m_xText.is()) { Reference<XAccessibleText> xText (m_xText->getAccessibleContext(), UNO_QUERY); @@ -191,11 +193,11 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven case VclEventId::ComboboxItemRemoved: { // Forward the call to the list child. - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if ( pList == nullptr ) { getAccessibleChild ( m_bHasTextChild ? 1 : 0 ); - pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + pList = m_xList.get(); } if ( pList != nullptr ) pList->ProcessWindowEvent (rVclWindowEvent); @@ -209,7 +211,7 @@ void VCLXAccessibleBox::ProcessWindowEvent (const VclWindowEvent& rVclWindowEven // the same VCL object as this box does. In case of the // combobox, however, we have to help by providing the list with // the text of the currently selected item. - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if (pList != nullptr && m_xText.is()) { Reference<XAccessibleText> xText (m_xText->getAccessibleContext(), UNO_QUERY); @@ -442,7 +444,7 @@ Any VCLXAccessibleBox::getCurrentValue( ) if (m_aBoxType == LISTBOX && m_bIsDropDownBox && m_xList.is() ) { - VCLXAccessibleList* pList = static_cast<VCLXAccessibleList*>(m_xList.get()); + VCLXAccessibleList* pList = m_xList.get(); if(pList->IsInDropDown()) { if(pList->getSelectedAccessibleChildCount()>0) commit 0c5deed0c5e1ca1e9a2a9315a38ab7b035d88bb9 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 5 16:08:54 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 5 22:00:05 2023 +0200 use more concrete type in ParagraphInfo and avoid some casting Change-Id: I22ff61a028c102b0b8b03b53ac9657af0fbe5acd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156569 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/accessibility/inc/extended/textwindowaccessibility.hxx b/accessibility/inc/extended/textwindowaccessibility.hxx index 47bb7be81a0c..db6e0f5423b0 100644 --- a/accessibility/inc/extended/textwindowaccessibility.hxx +++ b/accessibility/inc/extended/textwindowaccessibility.hxx @@ -39,6 +39,7 @@ #include <cppuhelper/compbase7.hxx> #include <comphelper/accessibletexthelper.hxx> #include <rtl/ref.hxx> +#include <unotools/weakref.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <queue> @@ -91,25 +92,25 @@ private: VclPtr<vcl::Window> m_pNotifier; }; +class Paragraph; + class ParagraphInfo { public: ParagraphInfo(::sal_Int32 nHeight): m_nHeight(nHeight) {} - css::uno::WeakReference< css::accessibility::XAccessible > const & + unotools::WeakReference< Paragraph > const & getParagraph() const { return m_xParagraph; } ::sal_Int32 getHeight() const { return m_nHeight; } - void setParagraph( - css::uno::Reference< css::accessibility::XAccessible > const & - rParagraph) { m_xParagraph = rParagraph; } + void setParagraph( rtl::Reference< Paragraph > const & rParagraph) + { m_xParagraph = rParagraph.get(); } void changeHeight(::sal_Int32 nHeight) { m_nHeight = nHeight; } private: - css::uno::WeakReference< css::accessibility::XAccessible > - m_xParagraph; + unotools::WeakReference< Paragraph > m_xParagraph; ::sal_Int32 m_nHeight; }; diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index 9a092d8fd6b8..19c8d139c6c6 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -1601,16 +1601,13 @@ void Document::init() ::rtl::Reference< Paragraph > Document::getParagraph(Paragraphs::iterator const & rIt) { - return static_cast< Paragraph * >( - css::uno::Reference< css::accessibility::XAccessible >( - rIt->getParagraph()).get()); + return rIt->getParagraph().get(); } css::uno::Reference< css::accessibility::XAccessible > Document::getAccessibleChild(Paragraphs::iterator const & rIt) { - css::uno::Reference< css::accessibility::XAccessible > xParagraph( - rIt->getParagraph()); + rtl::Reference< Paragraph > xParagraph(rIt->getParagraph()); if (!xParagraph.is()) { xParagraph = new Paragraph(this, rIt - m_xParagraphs->begin()); @@ -1841,8 +1838,7 @@ void Document::handleParagraphNotifications() xStrong; if (bWasVisible) xStrong = getAccessibleChild(aIt); - css::uno::WeakReference< - css::accessibility::XAccessible > xWeak( + unotools::WeakReference<Paragraph> xWeak( aIt->getParagraph()); aIt = m_xParagraphs->erase(aIt); @@ -1865,8 +1861,7 @@ void Document::handleParagraphNotifications() css::uno::Any(xStrong), css::uno::Any()); - css::uno::Reference< css::lang::XComponent > xComponent( - xWeak.get(), css::uno::UNO_QUERY); + rtl::Reference< Paragraph > xComponent( xWeak.get() ); if (xComponent.is()) xComponent->dispose(); @@ -2197,8 +2192,8 @@ void Document::disposeParagraphs() { for (auto const& paragraph : *m_xParagraphs) { - css::uno::Reference< css::lang::XComponent > xComponent( - paragraph.getParagraph().get(), css::uno::UNO_QUERY); + rtl::Reference< Paragraph > xComponent( + paragraph.getParagraph().get() ); if (xComponent.is()) xComponent->dispose(); }